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

added keyword for positive=true from simplexify() for GMSH mesh #82

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/GmshDiscreteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const UNSET = 0
# some cartesian-like grids can also have affine maps. You can force the creation of
# affine maps by setting has_affine_map=true.

function GmshDiscreteModel(mshfile; renumber=true, has_affine_map=nothing)
function GmshDiscreteModel(mshfile; renumber=true, has_affine_map=nothing, orient_if_simplex=nothing)
@check_if_loaded
if !isfile(mshfile)
error("Msh file not found: $mshfile")
Expand All @@ -22,18 +22,18 @@ function GmshDiscreteModel(mshfile; renumber=true, has_affine_map=nothing)
gmsh.open(mshfile)
renumber && gmsh.model.mesh.renumberNodes()
renumber && gmsh.model.mesh.renumberElements()
model = GmshDiscreteModel(gmsh;has_affine_map)
model = GmshDiscreteModel(gmsh;has_affine_map,orient_if_simplex)
gmsh.finalize()
model
end

function GmshDiscreteModel(gmsh::Module; has_affine_map=nothing)
function GmshDiscreteModel(gmsh::Module; has_affine_map=nothing, orient_if_simplex=nothing)
Dc = _setup_cell_dim(gmsh)
Dp = _setup_point_dim(gmsh,Dc)
node_to_coords = _setup_node_coords(gmsh,Dp)
nnodes = length(node_to_coords)
vertex_to_node, node_to_vertex = _setup_nodes_and_vertices(gmsh,node_to_coords)
grid, cell_to_entity = _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex;has_affine_map)
grid, cell_to_entity = _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex;has_affine_map,orient_if_simplex)
cell_to_vertices, vertex_to_node, node_to_vertex = _setup_cell_to_vertices(grid,vertex_to_node,node_to_vertex)
grid_topology = UnstructuredGridTopology(grid,cell_to_vertices,vertex_to_node)
labeling = _setup_labeling(gmsh,grid,grid_topology,cell_to_entity,vertex_to_node,node_to_vertex)
Expand Down Expand Up @@ -78,12 +78,13 @@ function _setup_nodes_and_vertices_periodic(gmsh,dimTags,nnodes)
vertex_to_node, node_to_vertex
end

function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex;has_affine_map=nothing)
function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex;has_affine_map=nothing,orient_if_simplex=nothing)

if ( Dp == 3 && Dc == 2 ) || ( Dp == 2 && Dc == 1 )
@assert isnothing(orient_if_simplex)
orient_if_simplex = false
else
orient_if_simplex = true
orient_if_simplex = isnothing(orient_if_simplex) || orient_if_simplex
end

cell_to_nodes, nminD = _setup_connectivity(gmsh,Dc,node_to_vertex,orient_if_simplex)
Expand Down
Loading