1
votes

I have a geo file for gmsh and mesh it. Then I would like to extract the normal vectors at the nodes of a selected surface. How is this possible?

Below is my gmsh geo file.

//Construct a cube in GMSH

//Build a line
Point(1) = {0, 0, 0, 1.0};
Point(2) = {0, 0, 10, 1.0};
Line(1) = {1, 2};

//Extrude line to create a surface (square)
Extrude {10, 0, 0} {
  Line{1};
}

//Extrude surface to create a volume (cube)
Extrude {0, 10, 0} {
  Surface{5};
}

//Six surfaces of the cube
Physical Surface(28) = {18};
Physical Surface(29) = {26};
Physical Surface(30) = {22}; 
Physical Surface(31) = {14};
Physical Surface(32) = {27};
Physical Surface(33) = {5};

//Volume of the cube
Physical Volume(34) = {1};
1
How do you define a normal at the node? In general, the nodes belong to several surfaces; thus, the direction of the normal has to be defined in some fashion. You can find the normal of a surface element (if it is curved – at a point belonging to the surface element).Anton Menshov
Hi Anton, thanks for your message! As you say, for example, I would like to have a normal to the Physical Surface(28) = {18} at a given position (x,y,z) that lies within that surface. How can this be found within gmsh?Marc Frei

1 Answers

0
votes

Hmm, I don't know how to do it via a GEO file scripting (though, I would not be surprised if it exists).

However, it certainly can be done via GMSH API using getNormal() function.

getNormal()

Get the normal to the surface with tag tag at the parametric coordinates parametricCoord. parametricCoord are given by pairs of u and v coordinates, concatenated: [p1u, p1v, p2u, ...]. normals are returned as triplets of x, y, z components, concatenated: [n1x, n1y, n1z, n2x, ...].

Input: tag, parametricCoord

Output: normals

GMSH API is available via Python, C/C++, and Julia. For details on the usage, I would suggest looking directly into how API is defined in GMSH repository.