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

Extension to 1D meshes in the 2D space #76

Merged
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
28 changes: 21 additions & 7 deletions src/GmshDiscreteModels.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

const D2=2
const D3=3
const POINT=15
const UNSET = 0
Expand Down Expand Up @@ -74,7 +75,7 @@ end

function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)

if Dp == 3 && Dc == 2
if ( Dp == 3 && Dc == 2 ) || ( Dp == 2 && Dc == 1 )
orient_if_simplex = false
else
orient_if_simplex = true
Expand All @@ -85,7 +86,7 @@ function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)
cell_to_entity = _setup_cell_to_entity(
gmsh,Dc,length(cell_to_nodes),nminD)

if Dp == 3 && Dc == 2
if ( Dp == 3 && Dc == 2 ) || ( Dp == 2 && Dc == 1 )
cell_coords = lazy_map(Broadcasting(Reindex(node_to_coords)),cell_to_nodes)
ctype_shapefuns = map(get_shapefuns,reffes)
cell_shapefuns = expand_cell_data(ctype_shapefuns,cell_to_type)
Expand All @@ -112,6 +113,13 @@ function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)

end

function _unit_outward_normal(v::MultiValue{Tuple{1,2}})
n1 = v[1,2]
n2 = -v[1,1]
n = VectorValue(n1,n2)
n/norm(n)
end

function _unit_outward_normal(v::MultiValue{Tuple{2,3}})
n1 = v[1,2]*v[2,3] - v[1,3]*v[2,2]
n2 = v[1,3]*v[2,1] - v[1,1]*v[2,3]
Expand Down Expand Up @@ -199,14 +207,20 @@ function _setup_point_dim(gmsh,Dc)
return Dc
end
nodeTags, coord, parametricCoord = gmsh.model.mesh.getNodes()
for node in nodeTags
j = D3
k = (node-1)*D3 + j
xj = coord[k]
if !(xj + 1 ≈ 1)
for node in nodeTags # Search a non-zero z-coordinate
k = (node-1)*D3 + D3
xk = coord[k]
if !(xk + 1 ≈ 1)
return D3
end
end
for node in nodeTags # Search a non-zero y-coordinate
j = (node-1)*D3 + D2
xj = coord[j]
if !(xj + 1 ≈ 1)
return D2
end
end
Dc
end

Expand Down
Loading