I am working on a solver that loops on an unstructured mesh, and I've got a couple of coordinates for a given point (x, y) (2 dimensions). I need to find the position corresponding to this given x-value on one given boundary.
I was wondering if there is any function or routines allowing the user to find all the nodes ore element that belong to a given boundary ?
Just a suggestion: if your mesh file is in the Elmer format (mesh.header, mesh.nodes, mesh.boundary, mesh.elements) just take a look at the mesh.boundary files and to the reference in the ElmerSolver Manual appendix A. If you are familiar with any programming language, you will find easy to write your own routine to extract the nodes or the coordinates.
MinDist = HUGE(MinDist)
DO i=1,Model % NumberOfNodes
x = Mesh % Nodes % x(i)
y = Mesh % Nodes % y(i)
Dist = (x-Point(1))**2 + (y-Point(2))**2
IF(Dist < MinDist) THEN
MinDist = Dist
NodeIndex = i
END IF
END DO
If you need to go through just some elements you could use the MakePermUsingMask subroutine to create a permutation vector for the candidate nodes and then loop only over them.
If you you need to map a large number of nodes then there are better algorithms. For example the InterpolateMeshToMesh uses some octtree data structures to find the target element for each node.
I finally combined a loop on each boundary element and the code given by Peter. I will probably spend more time on the MakePermUsingMask subroutine, but first I am looking in the source files to see how this subroutine is used...