Hi all,
I want to import a second order mesh generated by GMSH into FEnics. I am using meshio to import the mesh. The gmsh .msh file* is in format of MeshFormat 2.2 0 8 . Since I want to use tetrahedron elements with 10 Nodes and triangle with 6 nodes, I try to write the code below.
I would be very thankful for any support
Cheers
Ovel
*PS msh file below
msh = meshio.read(mesh_file) #select the mesh file
cell_element_order = "tetra10"
facet_element_order = "triangle6"
degree_FE = 1 # Finite Element degree
meshio.write("./Temp/mesh.xdmf",
meshio.Mesh(points=msh.points,
cells={cell_element_order: msh.cells[cell_element_order]},
cell_data={cell_element_order:
{"name_to_read": msh.cell_data[cell_element_order]["gmsh:physical"]}}))
meshio.write("./Temp/mesh_boundary.xdmf",
meshio.Mesh(points=msh.points,
cells={facet_element_order: msh.cells[facet_element_order]},
cell_data={facet_element_order:
{"name_to_read": msh.cell_data[facet_element_order]["gmsh:physical"]}}))
mesh = Mesh()
with XDMFFile("./Temp/mesh.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, DIM)
with XDMFFile("./Temp/mesh_boundary.xdmf") as infile:
infile.read(mvc, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
Unfortunately I got an error. Does anyone have any experience importing second order meshes?
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-14-5828977a4a77> in <module>
19
20 with XDMFFile("./Temp/mesh.xdmf") as infile:
---> 21 infile.read(mesh)
22 mvc = MeshValueCollection("size_t", mesh, DIM)
23
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to recognise cell type.
*** Reason: Unknown value "tetrahedron_10".
*** Where: This error was encountered inside XDMFFile.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 76bf12b24408e3ce2364eb22e62c802a92c90ff2
*** -------------------------------------------------------------------------
*Mesh file
$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
5
2 2 "ROOF_BACK_2D"
2 3 "FRONT_2D"
2 4 "LOUDSPEAKER_2D"
2 5 "VOLUMENK_RPER_1_1_2D"
3 1 "car_body_ansys_simplified_5cm_lo"
$EndPhysicalNames
$Nodes
90580
1 4.262164115905762 1.389446139335632 2.520000050645899e-012
2 4.227527141571045 1.391816854476929 0.1622721999883652
3 4.234670639038086 1.391465783119202 0.1213999465107918
4 4.243685722351074 1.39084804058075 0.08089913427829742
5 4.253204822540283 1.390129327774048 0.0405135490000248
6 4.194525241851807 1.372372269630432 0.5614960789680481
7 4.209649562835693 1.383093476295471 0.520927369594574
8 4.214374542236328 1.388261437416077 0.4765497148036957
9 4.215836048126221 1.389703273773193 0.431630551815033
10 4.215663433074951 1.390226721763611 0.3866600096225739
11 4.216094017028809 1.390782833099365 0.3416904211044312
12 4.21720552444458 1.391260027885437 0.29673171043396
....... * I cut some lines, because the file is quite long *
90578 2.592917442321777 0.6017194390296936 0.6876446008682251
90579 2.586379766464233 0.5731936693191528 0.6859179139137268
90580 2.834211587905884 0.6411230564117432 0.6843199133872986
$EndNodes
$Elements
71703
1 9 2 2 2 61 62 95 324 330 325
2 9 2 2 2 96 92 102 421 423 442
3 9 2 2 2 94 118 122 433 494 434
4 9 2 2 2 103 91 123 417 420 472
5 9 2 2 2 105 92 109 424 425 476
...
18062 9 2 5 5 2690 6278 4127 12824 19258 12823
18063 9 2 5 5 4127 6278 6803 19258 28293 19260
18064 9 2 5 5 4127 6803 4161 19260 19391 19257
18065 11 2 1 1 3324 10643 5843 40556 15558 26728 15555 43022 51032 90435
18066 11 2 1 1 3324 10122 10643 40556 43021 64400 15558 43022 90435 64398
18067 11 2 1 1 7895 10643 10641 10122 31028 36130 31027 56442 64399 64400
18068 11 2 1 1 4765 6939 37209 6948 21735 53935 48000 21736 53967 29485
18069 11 2 1 1 4187 37094 40718 8325 45676 73606 45680 19474 57834 57830
18070 11 2 1 1 4187 4188 40718 40665 19472 45683 45680 45679 90481 45682
...
71700 11 2 1 1 4772 6956 40895 40697 21770 54001 48029 48028 90489 54000
71701 11 2 1 1 4667 6898 38639 38592 21333 53843 47735 47734 83018 53841
71702 11 2 1 1 3844 36155 6660 6657 44644 53194 18033 18031 29030 53188
71703 11 2 1 1 39533 39581 39864 39943 88171 88404 88174 88175 89605 88405
$EndElements