ibaned / gmodel

Gmsh model generation library
Other
13 stars 6 forks source link

spline for an airfoil #7

Closed cwsmith closed 6 years ago

cwsmith commented 6 years ago

I'm trying to create an airfoil geometric model using gmodel. I first create a loop, add a spline from the points defining the airfoil to the loop, create a square, then remove the loop from the square.

The source code and input set of airfoil points are here: https://gist.github.com/cwsmith/99c95f1ec78389375ce3d32b3e234661

Running it as:

airfoil e625.dat e625

produces the .geo and .dmg as expected. When the .geo is loaded into Gmsh and 2D meshing is executed the following error appears:

Info    : -------------------------------------------------------
Info    : Gmsh version   : 3.0.7-git-56f5689e
Info    : Build OS       : Linux64
Info    : Build options  : 64Bit Ann Bamg Bfgs Blas(Generic) Blossom DIntegration Dlopen Fltk Gmm Hxt Jpeg(Fltk) Kbipack Lapack(Generic) LinuxJoystick MathEx Med Mesh Metis Mmg3d Mpeg Netgen ONELAB ONELABMetamodel OpenCASCADE OpenGL OptHom PETSc Parser Plugins Png(Fltk) Post SLEPc Solver TetGen/BR Voro++ Zlib
Info    : Build date     : 20180414
Info    : Build host     : gmsh.info
Info    : Packager       : gitlab-runner
Info    : Executable     : /home/cwsmith/Downloads/onelab-Linux64/gmsh
Info    : Home directory : /home/cwsmith/
Info    : Launch date    : Mon May  7 20:33:13 2018
Info    : Command line   : /home/cwsmith/Downloads/onelab-Linux64/gmsh e625.geo
Info    : -------------------------------------------------------
Info    : Reading 'e625.geo'...
Info    : Done reading 'e625.geo'
Info    : Reading 'e625.geo'...
Info    : Done reading 'e625.geo'
Info    : Meshing 1D...
Info    : Meshing curve 100 (Nurb)
Info    : Meshing curve 103 (Line)
Info    : Meshing curve 105 (Line)
Info    : Meshing curve 107 (Line)
Info    : Meshing curve 109 (Line)
Info    : Done meshing 1D (0.040419 s)
Info    : Meshing 2D...
Info    : Meshing surface 110 (Plane, Delaunay)
Error   : The 1D mesh seems not to be forming a closed loop (2 boundary points are considered once)
Warning : Surface 110 consists of no elements
Info    : Done meshing 2D (7e-05 s)
Info    : 179 vertices 184 elements
Error   : ------------------------------
Error   : Mesh generation error summary
Error   :     1 warning
Error   :     1 error
Error   : Check the full log for details
Error   : ------------------------------
Info    : Writing '/home/cwsmith/develop/build-gmodel/tests/gmsh.log'...

If I manually edit the e625.geo file and add point 0 to the spline as follows:

$ diff e625.geo e625_gold.geo 
104c104
< Spline(100) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98};
---
> Spline(100) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,0};
123a124,125
> //+
> Characteristic Length {0, 98, 1, 2, 97, 3, 96, 4, 95, 5, 6, 94, 7, 8, 93, 9, 10, 92, 11, 12, 13, 91, 14, 15, 90, 16, 89, 17, 88, 18, 87, 19, 86, 20, 85, 21, 84, 83, 22, 82, 23, 24, 81, 25, 26, 80, 27, 28, 79, 29, 78, 30, 77, 31, 76, 32, 75, 33, 74, 73, 34, 72, 35, 71, 36, 70, 37, 38, 69, 39, 40, 68, 41, 42, 67, 43, 44, 45, 46, 47, 66, 48, 49, 65, 50, 51, 52, 53, 64, 54, 55, 56, 63, 57, 62, 58, 61, 60, 59} = 0.01;

2D meshing executes successfully (screenshot attached). gmsh_e625

Is there a quick fix for this? It seems like I'm somehow not closing the spline, in a way gmsh likes, in gmodel.

Thank-you, Cameron

ibaned commented 6 years ago

Yea, the first and last points need to be the exact same object in order for it to be topologically closed (otherwise its endpoints just happen to be at the same location, but its not topologically closed). Just add some logic to your loop so that the last point you add to the spline is the same object as the first point. Probably just store the first point in a variable for later use. Also I think you will get a different spline shape if you repeat the last point, so you may want to ignore the last point in your data file (or just assert that its the same as the first but don't create an object from it).

cwsmith commented 6 years ago

Success! Thank you. https://gist.github.com/cwsmith/99c95f1ec78389375ce3d32b3e234661/revisions

The next step is extruding. Adding the following call:

  auto r = gmod::extrude_face(sq, gmod::Vector{0,0,.3}).middle;

produces extruded

Attempting to generate a 2D mesh results in the following mesh without triangles on the airfoil surface:

airfoil_not_meshed

and the following error:

Info    : Meshing 2D...
Info    : Meshing surface 110 (Plane, Delaunay)
Info    : Meshing surface 221 (Ruled surface, MeshAdapt)
Error   : Unable to recover the edge 84492 (21/21) on GEdge 100 (on GFace 221)
Warning : Surface 221 consists of no elements
Info    : Meshing surface 224 (Plane, Delaunay)
Info    : Meshing surface 227 (Plane, Delaunay)
Info    : Meshing surface 230 (Plane, Delaunay)
Info    : Meshing surface 233 (Plane, Delaunay)
Info    : Meshing surface 234 (Plane, Delaunay)
Info    : Done meshing 2D (0.035129 s)
Info    : 991 vertices 1927 elements
Error   : ------------------------------
Error   : Mesh generation error summary
Error   :     1 warning
Error   :     1 error
Error   : Check the full log for details
Error   : ------------------------------
Info    : Writing '/home/cwsmith/develop/build-gmodel/tests/gmsh2d.log'...

The only way I've found to extrude the surface with the airfoil cut out and mesh the resulting volume is by using the Geometry->Elementary entities->Extrude->Translate tool in Gmsh as follows:

airfoil_manual_extrude

Which creates the following model:

airfoil_manual_extrude2

Note, the .geo files produced this way relies on the extrude command(?) where it appears gmodel forms the volume by copying the source surface and connecting the two copies. I assume this is an important difference.

Below is the 3D mesh produced of the manually extruded model; it is simply an extrusion of the 2D surface mesh:

airfoil_manual_extruded_mesh

When the manual Gmsh extrusion is created without the 'extrude mesh' box selected, and the 2D mesher is executed, it produces what appears to be an identical error as seen with the gmodel:

Info    : Meshing 2D...
Info    : Meshing surface 110 (Plane, Delaunay)
Info    : Meshing surface 120 (Ruled surface, MeshAdapt)
Info    : Meshing surface 124 (Ruled surface, MeshAdapt)
Info    : Meshing surface 128 (Ruled surface, MeshAdapt)
Info    : Meshing surface 132 (Ruled surface, MeshAdapt)
Info    : Meshing surface 136 (Ruled surface, MeshAdapt)
Error   : Unable to recover the edge 39001 (1/21) on GEdge 100 (on GFace 136)
Warning : Surface 136 consists of no elements
Info    : Meshing surface 137 (Plane, Delaunay)
Info    : Done meshing 2D (0.181625 s)
Info    : 1524 vertices 3016 elements
Error   : ------------------------------
Error   : Mesh generation error summary
Error   :     1 warning
Error   :     1 error
Error   : Check the full log for details
Error   : ------------------------------
Info    : Writing '/home/cwsmith/develop/build-gmodel/tests/gmsh2d.log'...

Do you know if Gmsh supports generating a fully unstructured mesh of this model?

ibaned commented 6 years ago

It should. Possibilities are: the edge is in the "wrong" direction, or Gmsh doesn't support loops with just one edge. I think the latter is more likely. If you can separate the spline into two that might help. You can also open Gmsh issues here and get feedback from their developers:

https://gitlab.onelab.info/gmsh/gmsh/issues

cwsmith commented 6 years ago

I was wondering about splitting the spline. I'll give that a shot.

Thanks for the pointer to gmsh support.

cwsmith commented 6 years ago

Success!

model: airfoil

3D unstructured tet mesh: 3dunstruturedairfoil

The code is here: https://github.com/cwsmith/gmodel/commits/airfoil

Should I create a PR to add this example, and the input data file?

ibaned commented 6 years ago

Sure, thank you!

cwsmith commented 6 years ago

merged #8