Skip to content

Commit

Permalink
Merge pull request #25 from jesusbonilla/reorder_local_numbering_for_…
Browse files Browse the repository at this point in the history
…quad_and_hex

Reorder local numbering for quad and hex
  • Loading branch information
fverdugo authored Sep 25, 2020
2 parents 4245e1c + e249ec0 commit cc43be0
Show file tree
Hide file tree
Showing 4 changed files with 316 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/GmshDiscreteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ function _fill_connectivity!(
i_lnode_to_node = nodeTags[j]
if (nlnodes == d+1)
_orient_simplex_connectivities!(nlnodes,i_lnode_to_node)
elseif (nlnodes == 4)
_sort_quad_connectivites!(nlnodes,i_lnode_to_node)
elseif (nlnodes == 8)
_sort_hex_connectivites!(nlnodes,i_lnode_to_node)
end
for (i,cell) in enumerate(i_to_cell)
a = cell_to_nodes_prts[cell-o]-1
Expand All @@ -197,6 +201,26 @@ function _orient_simplex_connectivities!(nlnodes,i_lnode_to_node)
end
end

function _sort_quad_connectivites!(nlnodes,i_lnode_to_node)
aux = zero(eltype(i_lnode_to_node))
offset = nlnodes-1
for i in 1:nlnodes:length(i_lnode_to_node)
aux = i_lnode_to_node[i+offset-1]
i_lnode_to_node[i+offset-1] = i_lnode_to_node[i+offset]
i_lnode_to_node[i+offset] = aux
end
end

function _sort_hex_connectivites!(nlnodes,i_lnode_to_node)
perm = [1, 2, 4, 3, 5, 6, 8, 7]
aux = zeros(eltype(i_lnode_to_node),nlnodes)
offset = nlnodes-1
for i in 1:nlnodes:length(i_lnode_to_node)
aux = i_lnode_to_node[i:i+offset]
i_lnode_to_node[i:i+offset] = aux[perm]
end
end

function _setup_reffes(gmsh,d)

elemTypes, elemTags, nodeTags = gmsh.model.mesh.getElements(d)
Expand Down
8 changes: 8 additions & 0 deletions test/GmshDiscreteModelsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ mshfile = joinpath(@__DIR__,"..","demo","demo.msh")
model = GmshDiscreteModel(mshfile)
test_discrete_model(model)

mshfile = joinpath(@__DIR__,"square.msh")
model = GmshDiscreteModel(mshfile)
test_discrete_model(model)

mshfile = joinpath(@__DIR__,"cube.msh")
model = GmshDiscreteModel(mshfile)
test_discrete_model(model)

end # module
211 changes: 211 additions & 0 deletions test/cube.msh
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
$MeshFormat
4.1 0 8
$EndMeshFormat
$Entities
8 12 6 1
1 0 0 1 0
2 0 0 0 0
3 0 1 1 0
4 0 1 0 0
5 1 0 1 0
6 1 0 0 0
7 1 1 1 0
8 1 1 0 0
1 -1e-07 -1e-07 -9.999999994736442e-08 1e-07 1e-07 1.0000001 0 2 2 -1
2 -1e-07 -9.999999994736442e-08 0.9999999000000001 1e-07 1.0000001 1.0000001 0 2 1 -3
3 -1e-07 0.9999999000000001 -9.999999994736442e-08 1e-07 1.0000001 1.0000001 0 2 4 -3
4 -1e-07 -9.999999994736442e-08 -1e-07 1e-07 1.0000001 1e-07 0 2 2 -4
5 0.9999999000000001 -1e-07 -9.999999994736442e-08 1.0000001 1e-07 1.0000001 0 2 6 -5
6 0.9999999000000001 -9.999999994736442e-08 0.9999999000000001 1.0000001 1.0000001 1.0000001 0 2 5 -7
7 0.9999999000000001 0.9999999000000001 -9.999999994736442e-08 1.0000001 1.0000001 1.0000001 0 2 8 -7
8 0.9999999000000001 -9.999999994736442e-08 -1e-07 1.0000001 1.0000001 1e-07 0 2 6 -8
9 -9.999999994736442e-08 -1e-07 -1e-07 1.0000001 1e-07 1e-07 0 2 2 -6
10 -9.999999994736442e-08 -1e-07 0.9999999000000001 1.0000001 1e-07 1.0000001 0 2 1 -5
11 -9.999999994736442e-08 0.9999999000000001 -1e-07 1.0000001 1.0000001 1e-07 0 2 4 -8
12 -9.999999994736442e-08 0.9999999000000001 0.9999999000000001 1.0000001 1.0000001 1.0000001 0 2 3 -7
1 -1e-07 -9.999999994736442e-08 -9.999999994736442e-08 1e-07 1.0000001 1.0000001 0 4 1 2 -3 -4
2 0.9999999000000001 -9.999999994736442e-08 -9.999999994736442e-08 1.0000001 1.0000001 1.0000001 0 4 5 6 -7 -8
3 -9.999999994736442e-08 -1e-07 -9.999999994736442e-08 1.0000001 1e-07 1.0000001 0 4 9 5 -10 -1
4 -9.999999994736442e-08 0.9999999000000001 -9.999999994736442e-08 1.0000001 1.0000001 1.0000001 0 4 11 7 -12 -3
5 -9.999999994736442e-08 -9.999999994736442e-08 -1e-07 1.0000001 1.0000001 1e-07 0 4 4 11 -8 -9
6 -9.999999994736442e-08 -9.999999994736442e-08 0.9999999000000001 1.0000001 1.0000001 1.0000001 0 4 2 12 -6 -10
1 -9.999999994736442e-08 -9.999999994736442e-08 -9.999999994736442e-08 1.0000001 1.0000001 1.0000001 0 6 1 2 3 4 5 6
$EndEntities
$Nodes
27 27 1 27
0 1 0 1
1
0 0 1
0 2 0 1
2
0 0 0
0 3 0 1
3
0 1 1
0 4 0 1
4
0 1 0
0 5 0 1
5
1 0 1
0 6 0 1
6
1 0 0
0 7 0 1
7
1 1 1
0 8 0 1
8
1 1 0
1 1 0 1
9
0 0 0.5
1 2 0 1
10
0 0.5 1
1 3 0 1
11
0 1 0.5
1 4 0 1
12
0 0.5 0
1 5 0 1
13
1 0 0.5
1 6 0 1
14
1 0.5 1
1 7 0 1
15
1 1 0.5
1 8 0 1
16
1 0.5 0
1 9 0 1
17
0.5 0 0
1 10 0 1
18
0.5 0 1
1 11 0 1
19
0.5 1 0
1 12 0 1
20
0.5 1 1
2 1 0 1
21
0 0.5 0.5
2 2 0 1
22
1 0.5 0.5
2 3 0 1
23
0.5 0 0.5
2 4 0 1
24
0.5 1 0.5
2 5 0 1
25
0.5 0.5 0
2 6 0 1
26
0.5 0.5 1
3 1 0 1
27
0.5 0.5 0.5
$EndNodes
$Elements
27 64 1 64
0 1 15 1
1 1
0 2 15 1
2 2
0 3 15 1
3 3
0 4 15 1
4 4
0 5 15 1
5 5
0 6 15 1
6 6
0 7 15 1
7 7
0 8 15 1
8 8
1 1 1 2
9 2 9
10 9 1
1 2 1 2
11 1 10
12 10 3
1 3 1 2
13 4 11
14 11 3
1 4 1 2
15 2 12
16 12 4
1 5 1 2
17 6 13
18 13 5
1 6 1 2
19 5 14
20 14 7
1 7 1 2
21 8 15
22 15 7
1 8 1 2
23 6 16
24 16 8
1 9 1 2
25 2 17
26 17 6
1 10 1 2
27 1 18
28 18 5
1 11 1 2
29 4 19
30 19 8
1 12 1 2
31 3 20
32 20 7
2 1 3 4
33 2 9 21 12
34 12 21 11 4
35 9 1 10 21
36 21 10 3 11
2 2 3 4
37 6 16 22 13
38 16 8 15 22
39 13 22 14 5
40 22 15 7 14
2 3 3 4
41 2 17 23 9
42 9 23 18 1
43 17 6 13 23
44 23 13 5 18
2 4 3 4
45 4 11 24 19
46 11 3 20 24
47 19 24 15 8
48 24 20 7 15
2 5 3 4
49 2 12 25 17
50 17 25 16 6
51 12 4 19 25
52 25 19 8 16
2 6 3 4
53 1 18 26 10
54 18 5 14 26
55 10 26 20 3
56 26 14 7 20
3 1 5 8
57 25 12 2 17 27 21 9 23
58 27 21 9 23 26 10 1 18
59 16 25 17 6 22 27 23 13
60 22 27 23 13 14 26 18 5
61 19 4 12 25 24 11 21 27
62 24 11 21 27 20 3 10 26
63 8 19 25 16 15 24 27 22
64 15 24 27 22 7 20 26 14
$EndElements
73 changes: 73 additions & 0 deletions test/square.msh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
$MeshFormat
4.1 0 8
$EndMeshFormat
$Entities
4 4 1 0
1 0 0 0 0
2 1 0 0 0
3 1 1 0 0
4 0 1 0 0
1 -9.999999994736442e-08 0.9999999000000001 -1e-07 1.0000001 1.0000001 1e-07 0 2 4 -3
2 0.9999999000000001 -9.999999994736442e-08 -1e-07 1.0000001 1.0000001 1e-07 0 2 3 -2
3 -9.999999994736442e-08 -1e-07 -1e-07 1.0000001 1e-07 1e-07 0 2 2 -1
4 -1e-07 -9.999999994736442e-08 -1e-07 1e-07 1.0000001 1e-07 0 2 1 -4
1 -0.2140513462247553 -0.2140513462247554 -1e-07 1.214051346224751 1.214051346224774 1e-07 0 4 1 2 3 4
$EndEntities
$Nodes
9 9 1 9
0 1 0 1
1
0 0 0
0 2 0 1
2
1 0 0
0 3 0 1
3
1 1 0
0 4 0 1
4
0 1 0
1 1 0 1
5
0.5 1 0
1 2 0 1
6
1 0.5 0
1 3 0 1
7
0.5 0 0
1 4 0 1
8
0 0.5 0
2 1 0 1
9
0.5000000000000073 0.4999999999999898 0
$EndNodes
$Elements
9 16 1 16
0 1 15 1
1 1
0 2 15 1
2 2
0 3 15 1
3 3
0 4 15 1
4 4
1 1 1 2
5 4 5
6 5 3
1 2 1 2
7 3 6
8 6 2
1 3 1 2
9 2 7
10 7 1
1 4 1 2
11 1 8
12 8 4
2 1 3 4
13 4 5 9 8
14 8 9 7 1
15 5 3 6 9
16 9 6 2 7
$EndElements

0 comments on commit cc43be0

Please sign in to comment.