From 4ef50774326964c11c35a073107b1db0e42410b8 Mon Sep 17 00:00:00 2001 From: James Edgeley Date: Tue, 16 Apr 2024 11:31:52 +0100 Subject: [PATCH] Update README.md Guide for simple Nektar++ meshes --- README.md | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/README.md b/README.md index 92d8ab9b..d48c9239 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,143 @@ To debug for memory leaks, compile with the options cmake . -B -DENABLE_SANITIZER_ADDRESS=on -DENABLE_SANITIZER_LEAK=on ``` +## Generating meshes + +One pipeline for creating simple Nektar++ meshes is through Gmsh and NekMesh. + .geo -> .msh in Gmsh + .msh -> .xml with NekMesh + +A .geo file can be created using the Gmsh UI (each command adds a new line to the .geo file. For simple meshes it may be easier to produce the .geo file in a text editor. .geo files can also be loaded into the UI to edit. +
+ Expand + mesh.geo + + ```cpp +//Create construction points for the corners of the mesh +//Point(i) = (x, y, z, scale) +Point(1) = {0, 0, 0, 1.0}; +Point(2) = {0, 1, 0, 1.0}; +Point(3) = {1, 1, 0, 1.0}; +Point(4) = {1, 0, 0, 1.0}; + +//Create construction lines for the edges of the mesh +//Line(i) = (Start_i, End_i) +Line(1) = {1, 2}; +Line(2) = {2, 3}; +Line(3) = {3, 4}; +Line(4) = {4, 1}; + +//Add physical lines from the construction lines +Physical Line(5) = {1}; +Physical Line(6) = {2}; +Physical Line(7) = {3}; +Physical Line(8) = {4}; + +//Close the lines with a curve loop +Curve Loop(1) = {1,2,3,4}; +//Create a construction surface out of the curve loop +Plane Surface(1) = {1}; +//Create a physical surface out of the construction surface +Physical Surface(1) = {1}; + +//A transfinite line means that 65 points are created along lines +// 1 and 3, which will form the corners of 64 mesh elements. +//Progression 1 means they are uniformly spaced +Transfinite Line {1, 3} = 65 Using Progression 1; +Transfinite Line {2, 4} = 2 Using Progression 1; +//Set the surface +Transfinite Surface {1}; + +//The default is tris, this line is necessary to produce quads +Recombine Surface "*"; +``` + +
+ +Selecting 2D mesh in Gmsh and saving will produce a .msh file. The mesh should be visible in the UI to check before saving. Alternatively for simple meshes one can jump straight to this step by writing the .msh file in a text editor. +
+ Expand + mesh.msh + + ``` +$MeshFormat +4.1 0 8 +$EndMeshFormat +$Entities +4 4 1 0 +. +. +. +$EndEntities +$Nodes +9 130 1 130 +0 1 0 1 +. +. +. +$EndNodes +$Elements +5 194 1 194 +1 1 1 64 +. +. +. +$EndElements +``` +
+ +Next call NekMesh on the .msh file to convert it to .xml format + +``` +./NekMesh path/to/src/mesh.msh path/to/dst/mesh.xml +``` +This will produce a .xml file like the following: +
+ Expand + mesh.xml + +``` + + + eJx912dsjWEYxvFjz9qUmq3aW+1Zu0VttalVWlup7TwSMT4UH3wQiZFIDoKQVFqCKEWt2tUqpWZRW+1RrqfJfee9Ivrljvz7u5/Tc95z3sPl+v9PPse/3nXlnp96YDDmJvm9AvT7a0/k/v3ZKL3gP/1O6YXI5xyH3yG9MPnrszD3SC9CPugS/G7pRcm3s+cfkl6M/KIj8AelFye/bgzmYeklyFdPgY+VXpJ8mn38R6R7kZ94BT5eeinyvgbzuPTS5D1J8MeklyHfwf79CdLLkvdLgD8pvRz5sCGYp6WXJ18kHf6U9Ark19vn74z0iuS33YRPlF6J/MEpmOeke5NvmQx/Vnpl8in2+T8vvQr5pHPwSdJ9yP+IxrwovSr5sfb5uyC9Gnl/g3lZenXy74/CX5Jeg/yA9ZhXpNckvyYWPll6LfJ51/816b7kvQ/AX5XuRz45BPO69NrkQ+3rp/v9yeddPzek1yHvew1e99clnxOKeVN6PfLZl+F1f33ya+31d0t6A/JxF+B1f0PyPmGYKdIbkTf2+tH9jckfsNfvbelNyPdLhNf9Tcl3j8BMld6MfCV7/en+5uRT7fWfJr0F+Uz7+av7W5KPnI95R3oA+X32+tX9rcj/su+fdOmtyS+Mg9f9bchvXIZ5V3pb8oH2+tf97cj7G8x70tuTL3oIXvd3IB+/GjNDekfyKfvhdX8n8n3t+/e+9M7kt++F1/1dyD+IwXwgn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BG+g28ibcwVvogDuEwxkm/jSN4B+Ol38V7eB8TpD/AURzDROnj+BAnMEn6I3yMTzBZ+lN8hpOYIv05vsCXmCp9Cl/ha0yT/gbf4jtMlz6N73EGM6R/wFmcw0zpH3EeP2GW9M/4Bb9itvRvuIDfMUf6D1zEn5gr/Rf+xiXMk/4Hl/Ev5ktfwX+4imuOL2ei + + + Q[0-63] + E[3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192] + E[191] + E[190,187,184,181,178,175,172,169,166,163,160,157,154,151,148,145,142,139,136,133,130,127,124,121,118,115,112,109,106,103,100,97,94,91,88,85,82,79,76,73,70,67,64,61,58,55,52,49,46,43,40,37,34,31,28,25,22,19,16,13,10,7,4,1] + E[0] + + + C[1] + + + + + refs/heads/master + X + X + 5.5.0 + T + + path/to/src/mesh.msh path/to/dst/mesh.xml + + + + + +``` +
+ +Note the edge composites run in opposite directions. To align them to the same direction use the NekMesh module peralign as follows: + +``` +./NekMesh -m peralign:surf1=5:surf2=7:dir=x path/to/src/mesh.xml path/to/dst/mesh_aligned.xml +``` + ## Licence This is licenced under MIT.