Read a mesh by meshio

Hi everyone!
I am working with a colleague who uses Fluent to solve Navier-Stokes and Hexpress to generate the mesh. And I need to be able to take the mesh and its solution to analyze with FEniCS.
The first problem we are having is that we can open the mesh. The program gives us two formats, .msh and .cgns.
I tried to open the .msh file with meshio.
I have two problems. If I read the original file, I get this error.

ValueError: could not convert string to float: '0.00783466630154))'

This is the last point of the mesh. If I chage this, by moving the two parentheses one space or changing lines, the command never ends.

This is a short mesh, in case it helps…

(1 "HEXPRESS 10.1")

(0 "Dimensionality :")
(2 3)

(0 "Total numbers of cells, faces, nodes :")
(12 (0 1 38 0 0))
(13 (0 1 b4 0 0))
(10 (0 1 4f 0 3))

(0 "Block: cubo")

(0 "Cells :")
(12 (1 1 38 1 4))

(0 "Nodes :")
(10 (2 1 4f 1 3)(
-0.000915954457192 -0.000527569364281 0.00472478482088
-3.59221014159e-12 -0.000562777812788 0.00470707629674
-4.69990659312e-21 -0.000623214592678 0.005
-0.000969460982795 -0.000556063892768 0.00499999999891
-5.79173661059e-12 9.08792715035e-12 0.00467281686198
-0.000970816157777 9.65876772251e-12 0.00470806897482
-0.00107720964193 7.99437222428e-12 0.00499999999824
4.78141938394e-20 8.09223300414e-12 0.005
3.59221016729e-12 -0.000562777812788 0.00529292370326
-0.000915954450918 -0.00052756936575 0.00527521517686
-0.000970816148649 7.70637134061e-12 0.00529193102167
5.79173660904e-12 9.08792716966e-12 0.00532718313802
-6.62787807525e-12 0.0005627778294 0.00470707629465
-0.000915954459771 0.000527569382292 0.00472478481803
-0.00096946098292 0.000556063907936 0.00499999999796
4.30404324329e-20 0.000623214607524 0.005
-0.000915954448595 0.000527569380546 0.00527521517778
6.62787817151e-12 0.0005627778294 0.00529292370535
0.000915954450918 -0.00052756936575 0.00472478482314
0.000969460982795 -0.000556063892768 0.00500000000109
0.000970816148649 7.70637137879e-12 0.00470806897833
0.00107720964193 7.99437227152e-12 0.00500000000176
0.000915954457192 -0.000527569364281 0.00527521517912
0.000970816157777 9.65876776069e-12 0.00529193102518
0.000915954448595 0.000527569380546 0.00472478482222
0.00096946098292 0.000556063907936 0.00500000000204
0.000915954459771 0.000527569382292 0.00527521518197
-0.00193025819715 -0.00109960826452 0.00444028540948
-3.58628800643e-12 -0.00132879861897 0.00432996688856
1.32691848414e-19 -0.0017972388346 0.005
-0.00218656589841 -0.00121908853579 0.00499999999897
-0.00219277730636 2.08018074456e-11 0.0043366776715
-2.89701914321e-11 2.09779912581e-11 0.00400502010201
-0.00294598261519 5.87988592885e-12 0.00499999999777
3.58628796764e-12 -0.00132879861897 0.00567003311144
-0.00193025819152 -0.00109960826616 0.00555971458844
2.89701914386e-11 2.0977991219e-11 0.00599497989799
-0.00219277729836 5.66573410723e-12 0.00566332231651
-2.83238066502e-11 0.00132879863111 0.00432996687764
-0.00193025820169 0.00109960828099 0.00444028539389
-0.00218656589857 0.00121908854648 0.00499999999779
9.80897484485e-20 0.0017972388442 0.005
-0.00193025818891 0.00109960827677 0.00555971458947
2.83238066641e-11 0.00132879863111 0.00567003312236
0.00193025819152 -0.00109960826616 0.00444028541156
0.00218656589841 -0.00121908853579 0.00500000000103
0.00219277729836 5.66573412629e-12 0.00433667768349
0.00294598261519 5.87988602175e-12 0.00500000000223
0.00193025819715 -0.00109960826452 0.00555971459052
0.00219277730636 2.080180756e-11 0.0056633223285
0.00193025818891 0.00109960827677 0.00444028541053
0.00218656589857 0.00121908854648 0.00500000000221
0.00193025820169 0.00109960828099 0.00555971460611
-0.00614874549586 -0.00232313228356 0.0038481820816
0 -0.00538889232211 0.00356770761269
-8.67361737988e-19 -0.00538889232211 0.005
-0.00614874549586 -0.00250730107519 0.005
-0.00614874549586 0 0.00360017698178
0 0 0
-0.00614874549586 0 0.005
0 -0.00538889232211 0.00643229238731
-0.00614874549586 -0.00232313228356 0.0061518179184
0 -8.67361737988e-19 0.01
-0.00614874549586 0 0.00639982301822
8.67361737988e-19 0.00538889232211 0.00356770761269
-0.00614874549586 0.00232313228356 0.0038481820816
-0.00614874549586 0.00250730107519 0.005
8.67361737988e-19 0.00538889232211 0.005
-0.00614874549586 0.00232313228356 0.0061518179184
0 0.00538889232211 0.00643229238731
0.00614874549586 -0.00232313228356 0.0038481820816
0.00614874549586 -0.00250730107519 0.005
0.00614874549586 0 0.00360017698178
0.00614874549586 0 0.005
0.00614874549586 -0.00232313228356 0.0061518179184
0.00614874549586 0 0.00639982301822
0.00614874549586 0.00232313228356 0.0038481820816
0.00614874549586 0.00250730107519 0.005
0.00614874549586 0.00232313228356 0.0061518179184))

(0 "Faces :")

(13 (4 1 9c 2 4)(
 1 2 3 4 9 1
 5 6 7 8 3 1
 2 1 6 5 a 1
 4 3 8 7 2 1
 3 2 5 8 5 1
 1 4 7 6 b 1
 4 3 9 a c 2
 8 7 b c 4 2
 a 9 c b d 2
 9 3 8 c 6 2
 4 a b 7 e 2
 d e f 10 f 3
 5 6 e d 10 3
 7 8 10 f 4 3
 8 5 d 10 7 3
 6 7 f e 11 3
 10 f 11 12 12 4
 b c 12 11 13 4
 c 8 10 12 8 4
 7 b 11 f 14 4
 2 13 14 3 15 5
 15 5 8 16 7 5
 13 2 5 15 16 5
 3 14 16 8 6 5
 14 13 15 16 17 5
 3 14 17 9 18 6
 16 8 c 18 8 6
 9 17 18 c 19 6
 17 14 16 18 1a 6
 19 d 10 1a 1b 7
 15 5 d 19 1c 7
 8 16 1a 10 8 7
 16 15 19 1a 1d 7
 1a 10 12 1b 1e 8
 c 18 1b 12 1f 8
 18 16 1a 1b 20 8
 1c 1d 1e 1f 21 9
 1c 1d 2 1 9 a
 1f 1e 3 4 c 9
 1d 1e 3 2 9 15
 1c 1f 4 1 b 9
 1d 1c 20 21 22 a
 20 21 5 6 a 10
 1c 20 6 1 a b
 1d 21 5 2 16 a
 1c 1f 22 20 23 b
 20 22 7 6 11 b
 1f 22 7 4 b e
 1f 1e 23 24 24 c
 24 23 9 a d c
 1e 23 9 3 c 18
 1f 24 a 4 e c
 24 23 25 26 25 d
 26 25 c b 13 d
 23 25 c 9 d 19
 24 26 b a e d
 1f 24 26 22 26 e
 22 26 b 7 14 e
 27 28 29 2a 27 f
 28 27 d e 10 f
 29 2a 10 f f 12
 28 29 f e f 11
 27 2a 10 d 1b f
 21 20 28 27 28 10
 20 28 e 6 10 11
 21 27 d 5 1c 10
 20 22 29 28 29 11
 22 29 f 7 11 14
 2a 29 2b 2c 2a 12
 2b 2c 12 11 12 13
 29 2b 11 f 12 14
 2a 2c 12 10 1e 12
 26 25 2c 2b 2b 13
 25 2c 12 c 13 1f
 26 2b 11 b 14 13
 22 26 2b 29 2c 14
 1d 2d 2e 1e 2d 15
 1d 2d 13 2 15 16
 1e 2e 14 3 18 15
 2d 2e 14 13 15 17
 2d 1d 21 2f 2e 16
 21 2f 15 5 16 1c
 2d 2f 15 13 17 16
 2e 2d 2f 30 2f 17
 2f 30 16 15 17 1d
 2e 30 16 14 1a 17
 1e 2e 31 23 30 18
 23 31 17 9 19 18
 2e 31 17 14 18 1a
 23 31 32 25 31 19
 25 32 18 c 1f 19
 31 32 18 17 19 1a
 31 2e 30 32 32 1a
 30 32 18 16 1a 20
 33 27 2a 34 33 1b
 27 33 19 d 1c 1b
 2a 34 1a 10 1b 1e
 33 34 1a 19 1d 1b
 2f 21 27 33 34 1c
 2f 33 19 15 1d 1c
 30 2f 33 34 35 1d
 30 34 1a 16 20 1d
 34 2a 2c 35 36 1e
 2c 35 1b 12 1e 1f
 34 35 1b 1a 20 1e
 25 32 35 2c 37 1f
 32 35 1b 18 1f 20
 32 30 34 35 38 20
 36 37 1d 1c 21 22
 39 38 1e 1f 24 21
 37 38 1e 1d 21 2d
 36 39 1f 1c 23 21
 3a 3b 21 20 22 28
 36 3a 20 1c 22 23
 37 3b 21 1d 2e 22
 3a 3c 22 20 29 23
 39 3c 22 1f 23 26
 3e 3d 23 24 25 24
 38 3d 23 1e 24 30
 39 3e 24 1f 26 24
 40 3f 25 26 2b 25
 3d 3f 25 23 25 31
 3e 40 26 24 26 25
 3c 40 26 22 2c 26
 42 41 27 28 28 27
 43 44 2a 29 27 2a
 42 43 29 28 27 29
 41 44 2a 27 33 27
 3a 42 28 20 28 29
 3b 41 27 21 34 28
 3c 43 29 22 29 2c
 45 46 2c 2b 2a 2b
 43 45 2b 29 2a 2c
 44 46 2c 2a 36 2a
 3f 46 2c 25 2b 37
 40 45 2b 26 2c 2b
 37 47 2d 1d 2d 2e
 38 48 2e 1e 30 2d
 47 48 2e 2d 2d 2f
 3b 49 2f 21 2e 34
 47 49 2f 2d 2f 2e
 49 4a 30 2f 2f 35
 48 4a 30 2e 32 2f
 3d 4b 31 23 31 30
 48 4b 31 2e 30 32
 3f 4c 32 25 37 31
 4b 4c 32 31 31 32
 4a 4c 32 30 32 38
 41 4d 33 27 34 33
 44 4e 34 2a 33 36
 4d 4e 34 33 35 33
 49 4d 33 2f 35 34
 4a 4e 34 30 38 35
 46 4f 35 2c 36 37
 4e 4f 35 34 38 36
 4c 4f 35 32 37 38))

(13 (5 9d a0 3 4)(
 4a 49 47 48 2f 0
 4c 4a 48 4b 32 0
 4e 4d 49 4a 35 0
 4f 4e 4a 4c 38 0))

(13 (6 a1 a4 3 4)(
 44 43 42 41 27 0
 46 45 43 44 2a 0
 4e 44 41 4d 33 0
 4f 46 44 4e 36 0))

(13 (7 a5 a8 3 4)(
 3a 3c 39 36 23 0
 3c 40 3e 39 26 0
 42 43 3c 3a 29 0
 43 45 40 3c 2c 0))

(13 (8 a9 ac 3 4)(
 39 38 37 36 21 0
 3e 3d 38 39 24 0
 38 48 47 37 2d 0
 3d 4b 48 38 30 0))

(13 (9 ad b0 3 4)(
 40 3f 3d 3e 25 0
 45 46 3f 40 2b 0
 3f 4c 4b 3d 31 0
 46 4f 4c 3f 37 0))

(13 (a b1 b4 3 4)(
 3b 3a 36 37 22 0
 41 42 3a 3b 28 0
 49 3b 37 47 2e 0
 4d 41 3b 49 34 0))

(0 "Face tree :")

(0 "Other :")

(39 (3 parent parent) ())
(39 (4 interior interior) ())
(39 (5 wall cubo_group_0) ())
(39 (6 wall cubo_group_1) ())
(39 (7 wall cubo_group_2) ())
(39 (8 wall cubo_group_3) ())
(39 (9 wall cubo_group_4) ())
(39 (10 wall cubo_group_5) ())


I have the files, but I cant post here. I can send if anyone need.
These are other formats Hexprees export
MicrosoftTeams-image

Does anyone know how to solve?
Thank you so much!

I would strongly suggest also making an issue on the meshio issue tracker, as this has to do with meshio’s support of file formats

Meshio has a list of formats it supports at GitHub - nschloe/meshio: input/output for many mesh formats
(so it seems to me you could try with NASTRAN)

Thank you Dokken. I converted the mesh from Nastran format to xdmf format with the command:

meshio convert small_cube_nastran.bdf small_cube.xdmf

I have read the new mesh with:

from fenics import *
from mshr import *
import numpy as np
from dolfin import *

mesh_file= XDMFFile("Mesh/small_cube.xdmf")
mesh = Mesh()
mesh_file.read(mesh)

and I get a error

*** 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 order hexahedron cell.
*** Reason:  Cell is not orderable.
*** Where:   This error was encountered inside HexahedronCell.cpp.
*** Process: 0
*** 
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset:  ubuntu

Legacy dolfin does not support hexahedral elements. Consider dolfinx for this:

Thank you for the suggestion.
I’m new to Fenicsx and I don’t know much about it. I tried to open the file

from dolfinx.io import XDMFFile
mesh_file= XDMFFile(MPI.COMM_WORLD,"Mesh/small_cube.xdmf",'r')
mesh = Mesh()
mesh_file.read(mesh)

And the error is

RuntimeError: Failed to load xml document from file.

I don’t know if it is an error in the previous conversion or if I am not doing it correctly.

I would suggest reading the tutorial:
https://jsdokken.com/dolfinx-tutorial/
in particular:
https://jsdokken.com/dolfinx-tutorial/chapter3/subdomains.html?highlight=xdmffile#convert-msh-files-to-xdmf-using-meshio

Thanks Dokken!

I am trying the tutorial with the file I have, and I get the following error.

import dolfinx
import meshio
def create_mesh(mesh, cell_type, prune_z=False):
    cells = mesh.get_cells_type(cell_type)
    cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
    points = mesh.points[:,:2] if prune_z else mesh.points
    out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
    return out_mesh

msh = meshio.read("small_cube_nastran.bdf")

triangle_mesh = create_mesh(msh, "hexahedron", prune_z=True)
line_mesh = create_mesh(msh, "line", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)
meshio.write("mt.xdmf", line_mesh)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-31-a7b7dcffb804> in <module>
      3 
      4 # Create and save one file for the mesh, and one file for the facets
----> 5 triangle_mesh = create_mesh(msh, "hexahedron", prune_z=True)
      6 line_mesh = create_mesh(msh, "line", prune_z=True)
      7 meshio.write("mesh.xdmf", triangle_mesh)

<ipython-input-30-9d86930359bf> in create_mesh(mesh, cell_type, prune_z)
      3 def create_mesh(mesh, cell_type, prune_z=False):
      4     cells = mesh.get_cells_type(cell_type)
----> 5     cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
      6     points = mesh.points[:,:2] if prune_z else mesh.points
      7     out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})

~/.local/lib/python3.8/site-packages/meshio/_mesh.py in get_cell_data(self, name, cell_type)
    248     def get_cell_data(self, name: str, cell_type: str):
    249         return np.concatenate(
--> 250             [d for c, d in zip(self.cells, self.cell_data[name]) if c.type == cell_type]
    251         )
    252 

KeyError: 'gmsh:physical'

I don’t know if the error comes from the mesh file or from somewhere else.

This is the mesh file:

BEGIN BULK
$------------------------------------------------------------------------------$
$             Grid DATA                                                        $
$------------------------------------------------------------------------------$
GRID*   1                               -.0061487454958 -.0023231322835 *GRID000
*GRID000.00384818208159 
GRID*   2                               0.0000000000000 -.0053888923221 *GRID000
*GRID000.00356770761268 
GRID*   3                               -8.67361737E-19 -.0053888923221 *GRID000
*GRID000.00500000000000 
GRID*   4                               -.0061487454958 -.0025073010751 *GRID000
*GRID000.00500000000000 
GRID*   5                               0.0000000000000 0.0000000000000 *GRID000
*GRID0000.0000000000000 
GRID*   6                               -.0061487454958 0.0000000000000 *GRID000
*GRID000.00360017698178 
GRID*   7                               -.0061487454958 0.0000000000000 *GRID000
*GRID000.00500000000000 
GRID*   8                               4.781419383E-20 8.092233004E-12 *GRID000
*GRID000.00500000000000 
GRID*   9                               0.0000000000000 -.0053888923221 *GRID000
*GRID000.00643229238731 
GRID*   10                              -.0061487454958 -.0023231322835 *GRID000
*GRID000.00615181791840 
GRID*   11                              -.0061487454958 0.0000000000000 *GRID000
*GRID000.00639982301821 
GRID*   12                              0.0000000000000 -8.67361737E-19 *GRID000
*GRID000.01000000000000 
GRID*   13                              8.673617379E-19 .00538889232211 *GRID000
*GRID000.00356770761268 
GRID*   14                              -.0061487454958 .00232313228355 *GRID000
*GRID000.00384818208159 
GRID*   15                              -.0061487454958 .00250730107519 *GRID000
*GRID000.00500000000000 
GRID*   16                              8.673617379E-19 .00538889232211 *GRID000
*GRID000.00500000000000 
GRID*   17                              -.0061487454958 .00232313228355 *GRID000
*GRID000.00615181791840 
GRID*   18                              0.0000000000000 .00538889232211 *GRID000
*GRID000.00643229238731 
GRID*   19                              .00614874549585 -.0023231322835 *GRID000
*GRID000.00384818208159 
GRID*   20                              .00614874549585 -.0025073010751 *GRID000
*GRID000.00500000000000 
GRID*   21                              .00614874549585 0.0000000000000 *GRID000
*GRID000.00360017698178 
GRID*   22                              .00614874549585 0.0000000000000 *GRID000
*GRID000.00500000000000 
GRID*   23                              .00614874549585 -.0023231322835 *GRID000
*GRID000.00615181791840 
GRID*   24                              .00614874549585 0.0000000000000 *GRID000
*GRID000.00639982301821 
GRID*   25                              .00614874549585 .00232313228355 *GRID000
*GRID000.00384818208159 
GRID*   26                              .00614874549585 .00250730107519 *GRID000
*GRID000.00500000000000 
GRID*   27                              .00614874549585 .00232313228355 *GRID000
*GRID000.00615181791840 
GRID*   28                              -.0009159544571 -.0005275693642 *GRID000
*GRID000.00472478482088 
GRID*   29                              -3.59221014E-12 -.0005627778127 *GRID000
*GRID000.00470707629674 
GRID*   30                              -4.69990659E-21 -.0006232145926 *GRID000
*GRID000.00500000000000 
GRID*   31                              -.0009694609827 -.0005560638927 *GRID000
*GRID000.00499999999890 
GRID*   32                              -.0009708161577 9.658767722E-12 *GRID000
*GRID000.00470806897481 
GRID*   33                              -5.79173661E-12 9.087927150E-12 *GRID000
*GRID000.00467281686197 
GRID*   34                              -.0010772096419 7.994372224E-12 *GRID000
*GRID000.00499999999824 
GRID*   35                              3.592210167E-12 -.0005627778127 *GRID000
*GRID000.00529292370325 
GRID*   36                              -.0009159544509 -.0005275693657 *GRID000
*GRID000.00527521517685 
GRID*   37                              5.791736609E-12 9.087927169E-12 *GRID000
*GRID000.00532718313802 
GRID*   38                              -.0009708161486 7.706371340E-12 *GRID000
*GRID000.00529193102167 
GRID*   39                              -.0009159544597 .00052756938229 *GRID000
*GRID000.00472478481803 
GRID*   40                              -6.62787807E-12 .00056277782940 *GRID000
*GRID000.00470707629464 
GRID*   41                              -.0009694609829 .00055606390793 *GRID000
*GRID000.00499999999795 
GRID*   42                              4.304043243E-20 .00062321460752 *GRID000
*GRID000.00500000000000 
GRID*   43                              -.0009159544485 .00052756938054 *GRID000
*GRID000.00527521517777 
GRID*   44                              6.627878171E-12 .00056277782940 *GRID000
*GRID000.00529292370535 
GRID*   45                              .00091595445091 -.0005275693657 *GRID000
*GRID000.00472478482314 
GRID*   46                              .00096946098279 -.0005560638927 *GRID000
*GRID000.00500000000109 
GRID*   47                              .00097081614864 7.706371378E-12 *GRID000
*GRID000.00470806897832 
GRID*   48                              .00107720964192 7.994372271E-12 *GRID000
*GRID000.00500000000175 
GRID*   49                              .00091595445719 -.0005275693642 *GRID000
*GRID000.00527521517911 
GRID*   50                              .00097081615777 9.658767760E-12 *GRID000
*GRID000.00529193102518 
GRID*   51                              .00091595444859 .00052756938054 *GRID000
*GRID000.00472478482222 
GRID*   52                              .00096946098292 .00055606390793 *GRID000
*GRID000.00500000000204 
GRID*   53                              .00091595445977 .00052756938229 *GRID000
*GRID000.00527521518196 
GRID*   54                              -.0019302581971 -.0010996082645 *GRID000
*GRID000.00444028540947 
GRID*   55                              -3.58628800E-12 -.0013287986189 *GRID000
*GRID000.00432996688856 
GRID*   56                              1.326918484E-19 -.0017972388345 *GRID000
*GRID000.00500000000000 
GRID*   57                              -.0021865658984 -.0012190885357 *GRID000
*GRID000.00499999999896 
GRID*   58                              -.0021927773063 2.080180744E-11 *GRID000
*GRID000.00433667767149 
GRID*   59                              -2.89701914E-11 2.097799125E-11 *GRID000
*GRID000.00400502010200 
GRID*   60                              -.0029459826151 5.879885928E-12 *GRID000
*GRID000.00499999999776 
GRID*   61                              3.586287967E-12 -.0013287986189 *GRID000
*GRID000.00567003311143 
GRID*   62                              -.0019302581915 -.0010996082661 *GRID000
*GRID000.00555971458844 
GRID*   63                              2.897019143E-11 2.097799121E-11 *GRID000
*GRID000.00599497989799 
GRID*   64                              -.0021927772983 5.665734107E-12 *GRID000
*GRID000.00566332231651 
GRID*   65                              -.0019302582016 .00109960828099 *GRID000
*GRID000.00444028539388 
GRID*   66                              -2.83238066E-11 .00132879863111 *GRID000
*GRID000.00432996687763 
GRID*   67                              -.0021865658985 .00121908854648 *GRID000
*GRID000.00499999999779 
GRID*   68                              9.808974844E-20 .00179723884420 *GRID000
*GRID000.00500000000000 
GRID*   69                              -.0019302581889 .00109960827676 *GRID000
*GRID000.00555971458947 
GRID*   70                              2.832380666E-11 .00132879863111 *GRID000
*GRID000.00567003312236 
GRID*   71                              .00193025819152 -.0010996082661 *GRID000
*GRID000.00444028541155 
GRID*   72                              .00218656589841 -.0012190885357 *GRID000
*GRID000.00500000000103 
GRID*   73                              .00219277729835 5.665734126E-12 *GRID000
*GRID000.00433667768348 
GRID*   74                              .00294598261519 5.879886021E-12 *GRID000
*GRID000.00500000000223 
GRID*   75                              .00193025819715 -.0010996082645 *GRID000
*GRID000.00555971459052 
GRID*   76                              .00219277730635 2.080180755E-11 *GRID000
*GRID000.00566332232850 
GRID*   77                              .00193025818891 .00109960827676 *GRID000
*GRID000.00444028541052 
GRID*   78                              .00218656589856 .00121908854648 *GRID000
*GRID000.00500000000220 
GRID*   79                              .00193025820168 .00109960828099 *GRID000
*GRID000.00555971460611 
$------------------------------------------------------------------------------$
$             Element Definitions                                              $
$------------------------------------------------------------------------------$
$
$  CHEXA Elements: First Order
$
CHEXA   1       1       28      31      34      32      29      30              
        8       33      
CHEXA   2       1       31      36      38      34      30      35              
        37      8       
CHEXA   3       1       32      34      41      39      33      8               
        42      40      
CHEXA   4       1       34      38      43      41      8       37              
        44      42      
CHEXA   5       1       29      30      8       33      45      46              
        48      47      
CHEXA   6       1       30      35      37      8       46      49              
        50      48      
CHEXA   7       1       33      8       42      40      47      48              
        52      51      
CHEXA   8       1       8       37      44      42      48      50              
        53      52      
CHEXA   9       1       54      57      31      28      55      56              
        30      29      
CHEXA   10      1       55      59      33      29      54      58              
        32      28      
CHEXA   11      1       54      58      32      28      57      60              
        34      31      
CHEXA   12      1       57      62      36      31      56      61              
        35      30      
CHEXA   13      1       62      64      38      36      61      63              
        37      35      
CHEXA   14      1       57      60      34      31      62      64              
        38      36      
CHEXA   15      1       66      68      42      40      65      67              
        41      39      
CHEXA   16      1       59      66      40      33      58      65              
        39      32      
CHEXA   17      1       58      65      39      32      60      67              
        41      34      
CHEXA   18      1       68      70      44      42      67      69              
        43      41      
CHEXA   19      1       64      69      43      38      63      70              
        44      37      
CHEXA   20      1       60      67      41      34      64      69              
        43      38      
CHEXA   21      1       55      56      30      29      71      72              
        46      45      
CHEXA   22      1       71      73      47      45      55      59              
        33      29      
CHEXA   23      1       72      74      48      46      71      73              
        47      45      
CHEXA   24      1       56      61      35      30      72      75              
        49      46      
CHEXA   25      1       61      63      37      35      75      76              
        50      49      
CHEXA   26      1       75      76      50      49      72      74              
        48      46      
CHEXA   27      1       77      78      52      51      66      68              
        42      40      
CHEXA   28      1       73      77      51      47      59      66              
        40      33      
CHEXA   29      1       74      78      52      48      73      77              
        51      47      
CHEXA   30      1       78      79      53      52      68      70              
        44      42      
CHEXA   31      1       63      70      44      37      76      79              
        53      50      
CHEXA   32      1       76      79      53      50      74      78              
        52      48      
CHEXA   33      1       1       4       57      54      2       3               
        56      55      
CHEXA   34      1       2       5       59      55      1       6               
        58      54      
CHEXA   35      1       1       6       58      54      4       7               
        60      57      
CHEXA   36      1       4       10      62      57      3       9               
        61      56      
CHEXA   37      1       10      11      64      62      9       12              
        63      61      
CHEXA   38      1       4       7       60      57      10      11              
        64      62      
CHEXA   39      1       13      16      68      66      14      15              
        67      65      
CHEXA   40      1       5       13      66      59      6       14              
        65      58      
CHEXA   41      1       6       14      65      58      7       15              
        67      60      
CHEXA   42      1       16      18      70      68      15      17              
        69      67      
CHEXA   43      1       11      17      69      64      12      18              
        70      63      
CHEXA   44      1       7       15      67      60      11      17              
        69      64      
CHEXA   45      1       2       3       56      55      19      20              
        72      71      
CHEXA   46      1       19      21      73      71      2       5               
        59      55      
CHEXA   47      1       20      22      74      72      19      21              
        73      71      
CHEXA   48      1       3       9       61      56      20      23              
        75      72      
CHEXA   49      1       9       12      63      61      23      24              
        76      75      
CHEXA   50      1       23      24      76      75      20      22              
        74      72      
CHEXA   51      1       25      26      78      77      13      16              
        68      66      
CHEXA   52      1       21      25      77      73      5       13              
        66      59      
CHEXA   53      1       22      26      78      74      21      25              
        77      73      
CHEXA   54      1       26      27      79      78      16      18              
        70      68      
CHEXA   55      1       12      18      70      63      24      27              
        79      76      
CHEXA   56      1       24      27      79      76      22      26              
        78      74      
ENDDATA         

You already made xdmf files in the previous post,

So you should try using that mesh as input to dolfinx.

I tried that command

import dolfinx
import meshio
from dolfinx.io import XDMFFile
from mpi4py import MPI
mesh = XDMFFile(MPI.COMM_WORLD,"Mesh/small_cube.xdmf",'r')

and the error

RuntimeError: Failed to load xml document from file.

You would have to supply the xdmf file ("small_cube.xdmf") for anyone to help you with this.

This is the link where the mesh files are located. The original one, small_cube_nastran.bdf, and the ones generated with the command

meshio convert small_cube_nastran.bdf small_cube.xdmf

I have no issues reading in your mesh with:

import dolfinx
from mpi4py import MPI

with dolfinx.io.XDMFFile(MPI.COMM_WORLD, "Mesh/small_cube.xdmf", "r") as xdmf:
    mesh = xdmf.read_mesh(name="Grid")
1 Like

This works!! Thank you very much for your patience @dokken!!