How to get H20 and H27?

Numerical methods and mathematical models of Elmer
drmike
Posts: 38
Joined: 17 Mar 2024, 18:52
Antispam: Yes

How to get H20 and H27?

Post by drmike »

I can get gmsh to create a 2nd order mesh of hexahedra, but ElmerGrid does not seem to notice. Here's what gmsh outputs:

Code: Select all

....
Info    : [ 90%] Meshing surface 62 order 2
Info    : [ 90%] Meshing surface 70 order 2
Info    : [100%] Meshing surface 75 order 2
Info    : [100%] Meshing volume 1 order 2
Info    : [100%] Meshing volume 2 order 2
Info    : [100%] Meshing volume 3 order 2
Info    : Done meshing order 2 (Wall 0.0659926s, CPU 0.169568s)
Info    : Done refining mesh (Wall 0.0692012s, CPU 0.17285s)
Info    : 23828 nodes 28082 elements
Info    : Writing 'mymesh_test.msh'...
Info    : Done writing 'mymesh_test.msh'
And this is what ElmerGrid outputs:

Code: Select all

....
Mapping mesh tag 1 to physical tag 5 in 3DIM
Mapping mesh tag 2 to physical tag 5 in 3DIM
Mapping mesh tag 3 to physical tag 5 in 3DIM
Moving bulk elements to boundary elements
Assuming that boundaries names are already Ok!
Leading bulk elementtype is 808
Trailing bulk elementtype is 101
Checking that different dimensions have unique boundary tags!
Tag interval for boundaries: [1 162]
No overlap, no offsets needed!
There are 7562 (out of 28082) lower dimensional elements.
....
What command or method do I use to get 2nd order mesh from ElmerGrid? And how do I tell it to try H20 or H27?
kevinarden
Posts: 2319
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: How to get H20 and H27?

Post by kevinarden »

Appendix D has Elmer element types
https://www.nic.funet.fi/pub/sci/physic ... Manual.pdf

I see an H20 not an H27.
However you can also use p-elements to get higher orders, Appendix E.

Elmergrid can also increase the order of a mesh, if you write out a linear hex
ElmerGrid 14 2 mymesh.msh -increase -autoclean

typing ElmerGrid with no parameters shows all of the options.
drmike
Posts: 38
Joined: 17 Mar 2024, 18:52
Antispam: Yes

Re: How to get H20 and H27?

Post by drmike »

Thanks! I get a bunch of errors

Code: Select all

...
GetElementDimension: unknown elementtype 0
GetElementDimension: unknown elementtype 0
GetElementDimension: unknown elementtype 0
...
But the final result seems to be form 820 which loads fine. The 827 is in elements.def, that's why I was curious how to get that one. Looking at the p-elements probably makes more sense overall though, so I will dig into that.
kevinarden
Posts: 2319
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: How to get H20 and H27?

Post by kevinarden »

drmike
Posts: 38
Joined: 17 Mar 2024, 18:52
Antispam: Yes

Re: How to get H20 and H27?

Post by drmike »

I saw that at some point and it didn't make much sense. Now that I read it multiple times, I'm starting to understand a bit.

The files are different now (9 years later), but I can find the places that require changing. I think this will be a lot of fun to play with, thanks!
Edit: I am definitely confused. Looks like 827 is in place for all the code, and I can not create "second order complete" with Gmsh. It should be automatic because Mesh.SecondOrderIncomplete is 0. I assume I'm breaking some kind of rule in the generation process and the routine falls back to the incomplete form. It's not critical, but it would be nice to understand how to get there from here.
kevinarden
Posts: 2319
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: How to get H20 and H27?

Post by kevinarden »

I did a study with hexa for both salome and gmsh. Salome supports H27 elements but I do not know how to mesh them in salome.
the hexa8 and hexa20 translated to Elmer no issue, both GUI and ElmerGrid.

In gmsh I can extrude geometry to hexa linear, hexa8, then select 2 order elements, which convert to H27, I do not know how to get H20 out of gmsh.

The heax8 gmsh works, the H27 will convert with ElmerGrid and can be used in ElmerSolver but ElemerGUI still fails reading in to the mesh because of the boundary 409 element
this error persists
findSurfaceElementNormals: error: unable to change element orientation

https://github.com/mrkearden/hexa_convert/tree/main
drmike
Posts: 38
Joined: 17 Mar 2024, 18:52
Antispam: Yes

Re: How to get H20 and H27?

Post by drmike »

I'm using a C program to create the mesh. Maybe the order I call things has something to do with it. Sounds like you first create the Hexa8 (808) mesh, then tell gmsh to go 2nd order. I'm telling it to start with 2nd order at the beginning.

There is a bit Mesh.SecondOrderIncomplete which is default 0 and is supposed to create 2nd order complete mesh. When set to 1 it does the 820. Does not seem to make any difference in my program - I always get 820.

I'm trying to find a way to ask questions on the gmsh forum/issues page, but having trouble getting allowed in. With luck I'll get to ask soon.

Edit: Changing the order of request actually did work:

Code: Select all

Leading bulk elementtype is 827
ElmerGrid found the right thing from the .msh file, but only when I changed to 2nd order after doing the extrusion. I guess that makes sense if you first need to know where all the corners are before you can create the nodes in between. But nice! I now have 2nd order complete mesh.
kevinarden
Posts: 2319
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: How to get H20 and H27?

Post by kevinarden »

Mesh.SecondOrderIncomplete=1

did create 820 from gmsh which loaded fine into Elmer.

gmsh, salome can support H8, H20, H27 all will work with ElmerSolver

H27 will not load into ElmerGUI with the boundary element 409. If there are no boundary elements then the solid elements will.
kevinarden
Posts: 2319
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: How to get H20 and H27?

Post by kevinarden »

With the H27, changing the boundary element from 409 to 408, allows the mesh to load into ElmerGUI.
kevinarden
Posts: 2319
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: How to get H20 and H27?

Post by kevinarden »

A change to the ElmerGUI code allows ElmerGUI to load the H27 with the 409 boundary
the change was in meshutils.cpp starting at line 1717
There was surface information for orientation of the 408 element but nothing for the 409 element
adding the 409 resolved the issue, which I believe was only a display issue

} else if(surface->getCode() == 408) {
int tmp = surface->getNodeIndex(1);
surface->setNodeIndex(1, surface->getNodeIndex(3));
surface->setNodeIndex(3, tmp);
tmp = surface->getNodeIndex(4);
surface->setNodeIndex(4, surface->getNodeIndex(7));
surface->setNodeIndex(7, tmp);
tmp = surface->getNodeIndex(5);
surface->setNodeIndex(5, surface->getNodeIndex(6));
surface->setNodeIndex(6, tmp);

} else if(surface->getCode() == 409) {
int tmp = surface->getNodeIndex(1);
surface->setNodeIndex(1, surface->getNodeIndex(3));
surface->setNodeIndex(3, tmp);
tmp = surface->getNodeIndex(4);
surface->setNodeIndex(4, surface->getNodeIndex(7));
surface->setNodeIndex(7, tmp);
tmp = surface->getNodeIndex(5);
surface->setNodeIndex(5, surface->getNodeIndex(6));
surface->setNodeIndex(6, tmp);

} else {
cout << "findSurfaceElementNormals: error: unable to change element orientation" << endl;
cout.flush();
exit(0);
Post Reply