Skip to content

Commit b743753

Browse files
authored
Merge pull request #76 from fdzgallen/extend_to_line_meshes_in_2D_spaces
Extension to 1D meshes in the 2D space
2 parents 9989338 + dd8487e commit b743753

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/GmshDiscreteModels.jl

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
const D2=2
23
const D3=3
34
const POINT=15
45
const UNSET = 0
@@ -74,7 +75,7 @@ end
7475

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

77-
if Dp == 3 && Dc == 2
78+
if ( Dp == 3 && Dc == 2 ) || ( Dp == 2 && Dc == 1 )
7879
orient_if_simplex = false
7980
else
8081
orient_if_simplex = true
@@ -85,7 +86,7 @@ function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)
8586
cell_to_entity = _setup_cell_to_entity(
8687
gmsh,Dc,length(cell_to_nodes),nminD)
8788

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

113114
end
114115

116+
function _unit_outward_normal(v::MultiValue{Tuple{1,2}})
117+
n1 = v[1,2]
118+
n2 = -v[1,1]
119+
n = VectorValue(n1,n2)
120+
n/norm(n)
121+
end
122+
115123
function _unit_outward_normal(v::MultiValue{Tuple{2,3}})
116124
n1 = v[1,2]*v[2,3] - v[1,3]*v[2,2]
117125
n2 = v[1,3]*v[2,1] - v[1,1]*v[2,3]
@@ -199,14 +207,20 @@ function _setup_point_dim(gmsh,Dc)
199207
return Dc
200208
end
201209
nodeTags, coord, parametricCoord = gmsh.model.mesh.getNodes()
202-
for node in nodeTags
203-
j = D3
204-
k = (node-1)*D3 + j
205-
xj = coord[k]
206-
if !(xj + 1 1)
210+
for node in nodeTags # Search a non-zero z-coordinate
211+
k = (node-1)*D3 + D3
212+
xk = coord[k]
213+
if !(xk + 1 1)
207214
return D3
208215
end
209216
end
217+
for node in nodeTags # Search a non-zero y-coordinate
218+
j = (node-1)*D3 + D2
219+
xj = coord[j]
220+
if !(xj + 1 1)
221+
return D2
222+
end
223+
end
210224
Dc
211225
end
212226

0 commit comments

Comments
 (0)