GridapGmsh.jl icon indicating copy to clipboard operation
GridapGmsh.jl copied to clipboard

Check local numeration of quads and hexs

Open fverdugo opened this issue 6 years ago • 18 comments
trafficstars

To be fixed if one wants to import meshes of quads / hexs

fverdugo avatar Aug 01 '19 12:08 fverdugo

Here is a simple med file with 16 linear hexahedrons exported from Salome Platform. It seems to open fine in gmsh, but import fails

model = GmshDiscreteModel("Mesh_SimpleHex.med")
Info    : Reading '/home/andi/projects/juliaModules/gridapTest/bugreport/Mesh_SimpleHex.med'...
Info    : Reading MED file V4.0.0 using MED library V4.0.0
Info    : Reading 3-D unstructured mesh 'Mesh_1'
Info    : Done reading '/home/andi/projects/juliaModules/gridapTest/bugreport/Mesh_SimpleHex.med'
ERROR: LoadError: BoundsError: attempt to access 114-element Array{Int64,1} at index [0]
Stacktrace:
 [1] setindex! at ./array.jl:847 [inlined]
 [2] _apply_offset_for_faces!(::Array{Int64,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Int64) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:464
 [3] _fill_dim_to_face_to_label!(::Array{Array{Int64,1},1}, ::Gridap.Geometry.UnstructuredGridTopology{3,3,Float64,false}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Int64,1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:436
 [4] _setup_face_labels(::Gridap.Geometry.UnstructuredGridTopology{3,3,Float64,false}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Int64,1}, ::Array{Array{Array{Int64,1},1},1}, ::Array{Array{String,1},1}, ::Array{Int64,1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:394
 [5] _setup_labeling(::Module, ::Gridap.Geometry.UnstructuredGrid{3,3,Float64,false}, ::Gridap.Geometry.UnstructuredGridTopology{3,3,Float64,false}, ::Array{Int64,1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:284
 [6] GmshDiscreteModel(::String) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:18
 [7] top-level scope at /home/andi/projects/juliaModules/gridapTest/main.jl:9
 [8] include(::String) at ./client.jl:457
 [9] top-level scope at REPL[1]:1
in expression starting at /home/andi/projects/juliaModules/gridapTest/main.jl:9

EDIT: Simpler .msh Mesh containing 2 Hexahedra: twoHexa.msh.txt

Mesh_SimpleHex.zip

AndiMD avatar Aug 11 '20 18:08 AndiMD

We have always used msh format instead of med. Are they equivalent?

fverdugo avatar Aug 11 '20 18:08 fverdugo

No, the med format is a HDF5 based format used by Salome Platform (for Code_Aster). Gmsh converts it to msh. Opening tetrahedra-based med files in GridapGmsh works just fine, so I assume the format is not the issue here.

AndiMD avatar Aug 11 '20 19:08 AndiMD

OK. Thanks for reporting!

fverdugo avatar Aug 12 '20 15:08 fverdugo

@jesusbonilla if your fork fixes this issue for general quad and hex meshes, we definitively want to merge it. Does it fix the MWE of @AndiMD ?

fverdugo avatar Sep 21 '20 15:09 fverdugo

Yes. I have just tried, and I am able to create the model using file Mesh_SimpleHex.med than @AndiMD attached.

jesusbonilla avatar Sep 21 '20 16:09 jesusbonilla

@fverdugo @jesusbonilla I experimented with a few different meshes:

  • Strangely, it looks like first saving the .med file with gmsh to .msh before using in GridapGmsh fixes some cases where import works, but the .vtu export looks visually wrong (see https://github.com/gridap/GridapGmsh.jl/pull/25#issuecomment-696231149).
  • The option renumber=true is usually required. With renumber=false, the mesh might open but again, the .vtu export may show something is wrong.
  • Some big hex meshes (>500k cells) created by Salome Platform seem to work flawlessly with this technique
  • Something is wrong with Mesh_SimpleHex.med/msh: It imports only with renumber=false, but the mesh export is visually wrong (https://github.com/gridap/GridapGmsh.jl/pull/25#issuecomment-696231149).

Here is an additional mesh that has 1d,2d,3d entities and could make a nice test: Cylinder5Hex.msh.txt

AndiMD avatar Sep 21 '20 18:09 AndiMD

@AndiMD I have been trying the examples that you sent and if I use the .med file I can reproduce the error you show in your comment. However, if I use the .msh files with renumber=true then it works (the vtu looks good).

jesusbonilla avatar Sep 22 '20 12:09 jesusbonilla

@AndiMD @jesusbonilla Do you think we want renumber=true by default?

fverdugo avatar Sep 22 '20 13:09 fverdugo

I would suggest so.

jesusbonilla avatar Sep 22 '20 13:09 jesusbonilla

It is the better default, but possibly breaks backwards compatibility in some corner cases.

AndiMD avatar Sep 22 '20 18:09 AndiMD

@jesusbonilla All other hex meshes open fine for me too, just this one does not (see below). My gmsh version is gmsh-4.6.0-Linux64-sdk from the website. I am willing to blame this on my setup, and merge your branch.

The med variant:

julia> a = GridapGmsh.GmshDiscreteModel("Mesh_SimpleHex.med",renumber=true)
Info    : No current model available: creating one
Info    : Reading 'Mesh_SimpleHex.med'...
Info    : Reading MED file V4.0.0 using MED library V4.0.0
Info    : Reading 3-D unstructured mesh 'Mesh_1'
Info    : Done reading 'Mesh_SimpleHex.med'
ERROR: Only consecutive elem tags allowed.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] _check_cell_tags(::Array{Array{UInt64,1},1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:136
 [3] _setup_connectivity(::Module, ::Int64) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:105
 [4] _setup_grid(::Module) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:34
 [5] GmshDiscreteModel(::String; renumber::Bool) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:19
 [6] top-level scope at REPL[13]:1

The msh variant:

julia> a = GridapGmsh.GmshDiscreteModel("Mesh_SimpleHex.msh",renumber=true)
Info    : No current model available: creating one
Info    : Reading 'Mesh_SimpleHex.msh'...
Info    : 13 entities
Info    : 44 nodes
Info    : 34 elements
Info    : Done reading 'Mesh_SimpleHex.msh'
ERROR: BoundsError: attempt to access 54-element Array{Int64,1} at index [0]
Stacktrace:
 [1] setindex! at ./array.jl:847 [inlined]
 [2] _apply_offset_for_faces!(::Array{Int64,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Int64) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:491
 [3] _fill_dim_to_face_to_label!(::Array{Array{Int64,1},1}, ::Gridap.Geometry.UnstructuredGridTopology{3,3,Float64,false}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Int64,1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:463
 [4] _setup_face_labels(::Gridap.Geometry.UnstructuredGridTopology{3,3,Float64,false}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Int64,1}, ::Array{Array{Array{Int64,1},1},1}, ::Array{Array{String,1},1}, ::Array{Int64,1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:421
 [5] _setup_labeling(::Module, ::Gridap.Geometry.UnstructuredGrid{3,3,Float64,false}, ::Gridap.Geometry.UnstructuredGridTopology{3,3,Float64,false}, ::Array{Int64,1}) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:311
 [6] GmshDiscreteModel(::String; renumber::Bool) at /home/andi/.julia/dev/GridapGmsh/src/GmshDiscreteModels.jl:21
 [7] top-level scope at REPL[14]:1

AndiMD avatar Sep 22 '20 19:09 AndiMD

Indeed when looking at both meshes in Gmsh, the converted .msh file (right) is missing something: image

EDIT: Adding the ungrouped hexahedra into a volume group fixes this issue.

AndiMD avatar Sep 22 '20 19:09 AndiMD

@AndiMD I use the same version of Gmsh that you have. Can you try if this (cube.zip) med mesh works? It works properly in my case. Or can you send an even simpler mesh that does not work (just with a couple of elements)?

jesusbonilla avatar Sep 23 '20 15:09 jesusbonilla

@jesusbonilla Your cube.med mesh works fine.

Here is a simpler mesh that reproduces the issue: Mesh_SimpleHex2.zip

This seems to be an issue with how gmsh deals with the .med format. gmsh seems to omit entities that are not found in a group when saving the .med file as .msh:

image When I export the same mesh from Salome to the .unv mesh format, it works flawlessly. (unfortuately, .unv is not a very good replacement in general)

julia> model = GridapGmsh.GmshDiscreteModel("Mesh_SimpleHex2.med",renumber=true)
...
ERROR: Only consecutive elem tags allowed.

AndiMD avatar Sep 23 '20 19:09 AndiMD

Thanks to Max Orok's kind reference to the manual at onelab.info, this issue seems to be completely solved for me. See my PR #27

@jesusbonilla Could you please confirm that the (non-default) option Mesh.SaveAll = 1; explains the difference between our systems? Thank you.

AndiMD avatar Sep 27 '20 17:09 AndiMD

@AndiMD yes that option explains the different behaviors in my system too. I think that PR #27 fixes this issue :)

jesusbonilla avatar Sep 30 '20 14:09 jesusbonilla