Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesh_from_gmsh fails when .msh has quadrilateral reference elements #60

Closed
jfdev001 opened this issue Feb 20, 2024 · 4 comments
Closed

Comments

@jfdev001
Copy link
Collaborator

jfdev001 commented Feb 20, 2024

In prepping for the periodic boundary condition handling algorithm that is necessary to ensure consistent global ids, I wanted to generate some coarser meshes for ease of visualization with paraview. Commit 2b32a73 contains the quad.msh, which was generated by opening quad.geo in gmsh, then all mesh options > Set 2D Algorithm to "Frontal Delauny for Quads (Experimental)" > Checking "Recombine all triangular meshes" > Set "Element size factor" to 2. Attempting to load this mesh fails, the cause of which is the assertion at src/geometry.jl:1970. This is low priority right now, but thought I'd submit anyways and I or you could come back to it later. An image of the mesh that throws the assertion error is attached along with the error producing code.

import GalerkinToolkit as gk
mesh = gk.mesh_from_gmsh("assets/quad.msh")

ERROR: AssertionError: ldface2 != INVALID_ID
Stacktrace:
[1] generate_face_boundary(Dface_to_vertices::PartitionedArrays.JaggedArray{…}, vertex_to_D
faces::PartitionedArrays.JaggedArray{…}, dface_to_vertices::PartitionedArrays.JaggedArray{…},
vertex_to_dfaces::PartitionedArrays.JaggedArray{…}, Dface_to_refid::Vector{…}, Drefid_to_ldf
ace_to_lvertices::Tuple{…})
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:1970
[2] complexify_mesh(mesh::GalerkinToolkit.GenericFEMesh{…})
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:1676
[3] complexify(mesh::GalerkinToolkit.GenericFEMesh{Vector{…}, Vector{…}, Vector{…}, Tuple{…
}, Pair{…}, Vector{…}, Nothing})
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:1633
[4] mesh_from_gmsh_module(; complexify::Bool)
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:707
[5] mesh_from_gmsh_module
@ ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:525 [inlined]
[6] (::GalerkinToolkit.var"#63#64"{Bool, Bool, String})()
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:521
[7] with_gmsh(f::GalerkinToolkit.var"#63#64"{Bool, Bool, String}; options::Vector{Pair{Stri
ng, Int64}})
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:507
[8] with_gmsh
@ ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:501 [inlined]
[9] mesh_from_gmsh(file::String; complexify::Bool, renumber::Bool, kwargs::@kwargs{})
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:517
[10] mesh_from_gmsh(file::String)
@ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:515
[11] top-level scope
@ REPL[24]:1
Some type information was truncated. Use show(err) to see complete types.

image

@jfdev001 jfdev001 changed the title mesh_from_gmsh fails when .msh has quadrilateral reference elements Two level mesh with fine meshes that have periodic bcs: mesh_from_gmsh fails when .msh has quadrilateral reference elements Feb 21, 2024
@jfdev001
Copy link
Collaborator Author

The gk.cartesian_mesh function doesn't appear to support imposing periodic boundary conditions. So for developing the periodic bc handling algorithm in the context of a two level mesh, would the coarse mesh be a Cartesian mesh and the fine mesh a periodic mesh created from gmsh? See e.g., below for visualization. If this is the case, then either (a) a fix for mesh to gmsh quad reference elements is necessary or (b) the cartesian mesh needs to support periodic bcs on arbitrary sides. I will look into (a) unless otherwise notified.

image

@fverdugo
Copy link
Collaborator

Regarding the first error:

have you added a physical group that covers all cells in the mesh? If not, gmsh does not store connectivity information in the .msh file for the cells. (gmsh only stores connectivity for objects appearing in physical groups)

@fverdugo
Copy link
Collaborator

Regarding the periodic BCs:

  • Note that you also need periodic BCs in the vertical direction, in addition to the horizontal one.
  • gk.cartesian_mesh needs to be extended to support periodic bcs. This is important in many scenarios. For the moment, use a unit cell mesh generated with gmsh.

@jfdev001
Copy link
Collaborator Author

jfdev001 commented Feb 21, 2024

Regarding the first error:

have you added a physical group that covers all cells in the mesh? If not, gmsh does not store connectivity information in the .msh file for the cells. (gmsh only stores connectivity for objects appearing in physical groups)

Commit 8021398 adds physical groups to the simple quad geometry and then meshes using two strategies: (1) recombining triangles to give quadrilateral reference elements, and (2) just using triangular reference elements. Recombining triangles still throws the assertion error despite physical groups now being named.

julia> import GalerkinToolkit as gk
julia> gk.mesh_from_gmsh("assets/quad_recombine_triangles.msh")
Info    : Reading 'assets/quad_recombine_triangles.msh'...
Info    : 9 entities
Info    : 25 nodes
Info    : 36 elements
Info    : Done reading 'assets/quad_recombine_triangles.msh'
ERROR: AssertionError: ldface2 != INVALID_ID
Stacktrace:
  [1] generate_face_boundary(Dface_to_vertices::PartitionedArrays.JaggedArray{…}, vertex_to_Dfaces::PartitionedArrays.JaggedArray{…}, dface_to_vertices::PartitionedArrays.JaggedArray{…}, vertex_to_dfaces::PartitionedArrays.JaggedArray{…}, Dface_to_refid::Vector{…}, Drefid_to_ldface_to_lvertices::Tuple{…})
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:1970
  [2] complexify_mesh(mesh::GalerkinToolkit.GenericFEMesh{…})
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:1676
  [3] complexify(mesh::GalerkinToolkit.GenericFEMesh{Vector{…}, Vector{…}, Vector{…}, Tuple{…}, Pair{…}, Vector{…}, Nothing})
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:1633
  [4] mesh_from_gmsh_module(; complexify::Bool)
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:707
  [5] mesh_from_gmsh_module
    @ ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:525 [inlined]
  [6] (::GalerkinToolkit.var"#63#64"{Bool, Bool, String})()
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:521
  [7] with_gmsh(f::GalerkinToolkit.var"#63#64"{Bool, Bool, String}; options::Vector{Pair{String, Int64}})
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:507
  [8] with_gmsh
    @ ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:501 [inlined]
  [9] mesh_from_gmsh(file::String; complexify::Bool, renumber::Bool, kwargs::@Kwargs{})
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:517
 [10] mesh_from_gmsh(file::String)
    @ GalerkinToolkit ~/.julia/dev/GalerkinToolkit.jl/src/geometry.jl:515
 [11] top-level scope
    @ REPL[48]:1
Some type information was truncated. Use `show(err)` to see complete types.

and

julia> gk.mesh_from_gmsh("assets/quad_triangles.msh")
Info    : Reading 'assets/quad_triangles.msh'...
Info    : 9 entities
Info    : 25 nodes
Info    : 52 elements
Info    : Done reading 'assets/quad_triangles.msh'
GalerkinToolkit.GenericFEMesh()

@fverdugo fverdugo changed the title Two level mesh with fine meshes that have periodic bcs: mesh_from_gmsh fails when .msh has quadrilateral reference elements mesh_from_gmsh fails when .msh has quadrilateral reference elements Feb 21, 2024
fverdugo added a commit that referenced this issue Feb 21, 2024
fverdugo added a commit that referenced this issue Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants