Commit 99efc3f6 authored by Lukas Riedel's avatar Lukas Riedel

Update unit tests to boundary segmentation input scheme

* Update 'test-grid-creation': Check for correct boundary segmentation
* Add boundary segmentation datasets
* Add boundary segments to GMSH mesh files
* Update .mini files with new keys
parent b935e645
......@@ -12,8 +12,16 @@ gridType = rectangular
extensions = 1 1, 1 1 1 | expand dim
cells = 20 20, 10 10 10 | expand dim
initialLevel = 1
mappingFile = None
globalIndex = 0
[grid.mapping]
file = None
volume = 0
boundaryLeft = 2
boundaryRight = 2
boundaryFront = 2
boundaryBack = 2
boundaryLower = 2
boundaryUpper = 2
[misc]
debugMode = false
......@@ -12,6 +12,7 @@
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/dorie/common/grid_creator.hh>
#include <dune/dorie/common/logging.hh>
/// Create the grid and check if the mapping is as expected
template<typename Grid>
......@@ -24,7 +25,24 @@ void create_grid_and_test_mapping (const Dune::ParameterTree& config,
// get grid and data
auto grid = gc.grid();
auto element_map = gc.get_element_index_map();
const auto element_map = gc.get_element_index_map();
const auto boundary_map = gc.get_boundary_index_map();
// report maps
auto log = Dune::Dorie::get_logger(Dune::Dorie::log_base);
log->debug("Read element map: {}",Dune::Dorie::to_string(element_map));
log->debug("Read boundary map: {}", Dune::Dorie::to_string(boundary_map));
// check overall contents of boundary map
if ((std::is_same_v<Grid, Dune::UGGrid<2>>
or std::is_same_v<Grid, Dune::UGGrid<3>>)
and helper.size() > 1) {
// nothing
}
else {
assert(std::none_of(begin(boundary_map), end(boundary_map),
[](const auto index){ return index == 0; }));
}
// check mapping
auto gv = grid->levelGridView(0);
......@@ -45,6 +63,23 @@ void create_grid_and_test_mapping (const Dune::ParameterTree& config,
else {
assert(element_map.at(index) == 0);
}
if (cell.hasBoundaryIntersections()) {
for (auto&& is : intersections(gv, cell)) {
if (not is.boundary()) {
continue;
}
const auto pos = is.geometry().center();
const auto index = is.boundarySegmentIndex();
if (pos[Grid::dimension-1] > 1.0) {
assert(boundary_map.at(index) == 3);
}
else {
assert(boundary_map.at(index) == 2);
}
}
}
}
}
......
......@@ -13,8 +13,16 @@ gridFile = {_asset_path}/meshes/square-layered.msh, {_asset_path}/meshes/cube-la
extensions = 2 2, 2 2 2 | expand dim
cells = 20 20, 10 10 10 | expand dim
initialLevel = 1
mappingFile = {_asset_path}/maps/cell_ids.h5
mappingFileDataset = grid_test_2d, grid_test_3d | expand dim
[grid.mapping]
file = {_asset_path}/maps/cell_ids.h5
volume = grid_test_2d/volume, grid_test_3d/volume | expand dim
boundaryLeft = grid_test_2d/boundary_left, grid_test_3d/boundary_left | expand dim
boundaryRight = grid_test_2d/boundary_right, grid_test_3d/boundary_right | expand dim
boundaryFront = grid_test_2d/boundary_front, grid_test_3d/boundary_front | expand dim
boundaryBack = grid_test_2d/boundary_back, grid_test_3d/boundary_back | expand dim
boundaryLower = 2
boundaryUpper = 3
[misc]
debugMode = false
......@@ -5,9 +5,16 @@ _asset_path = "${PROJECT_SOURCE_DIR}/test"
adaptivity.useAdaptivity = false
grid.initialLevel = 1
grid.gridType = rectangular
grid.cells = 50 50
grid.extensions = 1 1
grid.mappingFile = "{_asset_path}/maps/cell_ids.h5"
grid.mappingFileDataset = ut/param_test
[grid]
initialLevel = 1
gridType = rectangular
cells = 50 50
extensions = 1 1
[grid.mapping]
file = "{_asset_path}/maps/cell_ids.h5"
volume = ut/param_test
boundaryLeft = 0
boundaryRight = 0
boundaryLower = 0
boundaryUpper = 0
......@@ -3,14 +3,21 @@ include ${CMAKE_BINARY_DIR}/doc/default_files/config.ini
__name = param
_asset_path = "${PROJECT_SOURCE_DIR}/test"
grid.dimensions = 2
grid.initialLevel = 1
grid.gridType = rectangular
grid.cells = 50 50
grid.FEorder = 1
grid.extensions = 1 1
grid.mappingFile = "{_asset_path}/maps/cell_ids.h5"
grid.mappingFileDataset = ut/param_test
[grid]
dimensions = 2
initialLevel = 1
gridType = rectangular
cells = 50 50
FEorder = 1
extensions = 1 1
[grid.mapping]
file = "{_asset_path}/maps/cell_ids.h5"
volume = ut/param_test
boundaryLeft = 0
boundaryRight = 0
boundaryLower = 0
boundaryUpper = 0
[richards]
......
......@@ -7,8 +7,21 @@ def create_and_write_datasets(args):
grid_test_2d = np.zeros((20, 20), dtype=np.int_)
grid_test_2d[10:, :] = 1
grid_test_2d_bc_left = np.full((20), 2, dtype=np.int_)
grid_test_2d_bc_left[10:] = 3
grid_test_2d_bc_right = np.full((20), 2, dtype=np.int_)
grid_test_2d_bc_right[10:] = 3
grid_test_3d = np.zeros((10, 10, 10), dtype=np.int_)
grid_test_3d[5:, :, :] = 1
grid_test_3d_bc_left = np.full((10, 10), 2, dtype=np.int_)
grid_test_3d_bc_left[5:, ...] = 3
grid_test_3d_bc_right = np.full((10, 10), 2, dtype=np.int_)
grid_test_3d_bc_right[5:, ...] = 3
grid_test_3d_bc_front = np.full((10, 10), 2, dtype=np.int_)
grid_test_3d_bc_front[5:, ...] = 3
grid_test_3d_bc_back = np.full((10, 10), 2, dtype=np.int_)
grid_test_3d_bc_back[5:, ...] = 3
ode_layered_160 = np.zeros((160, 1), dtype=np.int_)
ode_layered_160[80:, ...] = 1
......@@ -29,8 +42,15 @@ def create_and_write_datasets(args):
[1, 0]]], np.ones((5, 5, 5), dtype=np.int_))
f = h5py.File(args.path, 'w')
f.create_dataset("grid_test_2d", data=grid_test_2d)
f.create_dataset("grid_test_3d", data=grid_test_3d)
f.create_dataset("grid_test_2d/volume", data=grid_test_2d)
f.create_dataset("grid_test_2d/boundary_left", data=grid_test_2d_bc_left)
f.create_dataset("grid_test_2d/boundary_right", data=grid_test_2d_bc_right)
f.create_dataset("grid_test_3d/volume", data=grid_test_3d)
f.create_dataset("grid_test_3d/boundary_left", data=grid_test_3d_bc_left)
f.create_dataset("grid_test_3d/boundary_right", data=grid_test_3d_bc_right)
f.create_dataset("grid_test_3d/boundary_front", data=grid_test_3d_bc_front)
f.create_dataset("grid_test_3d/boundary_back", data=grid_test_3d_bc_back)
f.create_dataset("ode_layered_160", data=ode_layered_160)
f.create_dataset("ode_layered_40", data=ode_layered_40)
f.create_dataset("ode_layered_20", data=ode_layered_20)
......@@ -48,4 +68,4 @@ def parse_cli():
if __name__ == "__main__":
args = parse_cli()
create_and_write_datasets(args)
\ No newline at end of file
create_and_write_datasets(args)
......@@ -77,54 +77,54 @@ $Elements
14 2 2 2 1 15 25 27
15 2 2 2 1 29 26 16
16 2 2 2 1 25 26 29
17 2 2 2 3 21 39 9
18 2 2 2 3 39 24 9
19 2 2 2 3 38 21 10
20 2 2 2 3 22 38 10
21 2 2 2 3 37 22 11
22 2 2 2 3 23 37 11
23 2 2 2 3 36 23 12
24 2 2 2 3 24 36 12
25 2 2 2 3 38 35 21
26 2 2 2 3 35 39 21
27 2 2 2 3 37 35 22
28 2 2 2 3 35 38 22
29 2 2 2 3 36 35 23
30 2 2 2 3 35 37 23
31 2 2 2 3 36 24 39
32 2 2 2 3 36 39 35
33 2 2 2 4 5 9 41
34 2 2 2 4 5 41 17
35 2 2 2 4 6 40 10
36 2 2 2 4 6 17 40
37 2 2 2 4 9 21 41
38 2 2 2 4 10 40 21
39 2 2 2 4 17 41 40
40 2 2 2 4 21 40 41
41 2 2 2 5 9 42 5
42 2 2 2 5 42 20 5
43 2 2 2 5 43 12 8
44 2 2 2 5 20 43 8
45 2 2 2 5 24 42 9
46 2 2 2 5 43 24 12
47 2 2 2 5 43 20 42
48 2 2 2 5 43 42 24
49 2 2 2 6 45 7 11
50 2 2 2 6 19 7 45
51 2 2 2 6 12 8 44
52 2 2 2 6 44 8 19
53 2 2 2 6 45 11 23
54 2 2 2 6 23 12 44
55 2 2 2 6 45 44 19
56 2 2 2 6 45 23 44
57 2 2 2 7 6 47 10
58 2 2 2 7 6 18 47
59 2 2 2 7 7 11 46
60 2 2 2 7 7 46 18
61 2 2 2 7 10 47 22
62 2 2 2 7 11 22 46
63 2 2 2 7 18 46 47
64 2 2 2 7 22 47 46
17 2 2 3 3 21 39 9
18 2 2 3 3 39 24 9
19 2 2 3 3 38 21 10
20 2 2 3 3 22 38 10
21 2 2 3 3 37 22 11
22 2 2 3 3 23 37 11
23 2 2 3 3 36 23 12
24 2 2 3 3 24 36 12
25 2 2 3 3 38 35 21
26 2 2 3 3 35 39 21
27 2 2 3 3 37 35 22
28 2 2 3 3 35 38 22
29 2 2 3 3 36 35 23
30 2 2 3 3 35 37 23
31 2 2 3 3 36 24 39
32 2 2 3 3 36 39 35
33 2 2 3 4 5 9 41
34 2 2 3 4 5 41 17
35 2 2 3 4 6 40 10
36 2 2 3 4 6 17 40
37 2 2 3 4 9 21 41
38 2 2 3 4 10 40 21
39 2 2 3 4 17 41 40
40 2 2 3 4 21 40 41
41 2 2 3 5 9 42 5
42 2 2 3 5 42 20 5
43 2 2 3 5 43 12 8
44 2 2 3 5 20 43 8
45 2 2 3 5 24 42 9
46 2 2 3 5 43 24 12
47 2 2 3 5 43 20 42
48 2 2 3 5 43 42 24
49 2 2 3 6 45 7 11
50 2 2 3 6 19 7 45
51 2 2 3 6 12 8 44
52 2 2 3 6 44 8 19
53 2 2 3 6 45 11 23
54 2 2 3 6 23 12 44
55 2 2 3 6 45 44 19
56 2 2 3 6 45 23 44
57 2 2 3 7 6 47 10
58 2 2 3 7 6 18 47
59 2 2 3 7 7 11 46
60 2 2 3 7 7 46 18
61 2 2 3 7 10 47 22
62 2 2 3 7 11 22 46
63 2 2 3 7 18 46 47
64 2 2 3 7 22 47 46
65 2 2 2 8 2 49 6
66 2 2 2 8 2 14 49
67 2 2 2 8 3 7 48
......@@ -159,49 +159,49 @@ $Elements
96 2 2 2 11 17 55 54
97 4 2 0 1 30 28 48 33
98 4 2 0 1 28 48 33 49
99 4 2 0 1 30 28 33 54
100 4 2 0 1 27 30 48 32
101 4 2 0 1 19 30 27 32
102 4 2 0 1 19 27 51 32
99 4 2 0 1 28 30 54 33
100 4 2 0 1 32 25 50 27
101 4 2 0 1 25 32 48 27
102 4 2 0 1 50 32 27 51
103 4 2 0 1 28 30 48 25
104 4 2 0 1 30 25 28 54
105 4 2 0 1 30 31 27 25
106 4 2 0 1 50 25 27 31
107 4 2 0 1 27 30 25 48
108 4 2 0 1 48 18 30 33
109 4 2 0 1 14 48 25 28
110 4 2 0 1 25 13 28 54
111 4 2 0 1 48 18 33 49
112 4 2 0 1 14 48 28 49
113 4 2 0 1 17 30 33 54
114 4 2 0 1 48 27 14 25
115 4 2 0 1 32 48 18 30
116 4 2 0 1 27 31 19 50
117 4 2 0 1 30 19 27 31
118 4 2 0 1 27 50 51 15
119 4 2 0 1 19 27 50 51
120 4 2 0 1 25 15 50 27
121 4 2 0 1 29 26 31 25
122 4 2 0 1 53 29 31 52
123 4 2 0 1 29 53 31 26
124 4 2 0 1 52 29 31 34
125 4 2 0 1 30 29 31 25
126 4 2 0 1 29 30 31 34
127 4 2 0 1 50 25 31 26
128 4 2 0 1 55 13 30 54
129 4 2 0 1 13 55 30 25
130 4 2 0 1 17 55 30 54
131 4 2 0 1 30 13 25 54
132 4 2 0 1 55 29 30 25
133 4 2 0 1 55 29 34 30
134 4 2 0 1 52 31 20 34
135 4 2 0 1 52 29 16 53
136 4 2 0 1 29 16 53 26
137 4 2 0 1 53 52 31 20
105 4 2 0 1 32 25 30 50
106 4 2 0 1 32 25 48 30
107 4 2 0 1 48 18 30 33
108 4 2 0 1 14 48 25 28
109 4 2 0 1 25 13 28 54
110 4 2 0 1 48 18 33 49
111 4 2 0 1 14 48 28 49
112 4 2 0 1 30 17 54 33
113 4 2 0 1 48 27 14 25
114 4 2 0 1 32 48 18 30
115 4 2 0 1 32 50 19 51
116 4 2 0 1 15 50 27 51
117 4 2 0 1 25 15 50 27
118 4 2 0 1 30 19 32 50
119 4 2 0 1 53 29 31 52
120 4 2 0 1 29 53 31 26
121 4 2 0 1 52 29 31 34
122 4 2 0 1 29 26 31 25
123 4 2 0 1 30 50 25 31
124 4 2 0 1 30 29 31 25
125 4 2 0 1 29 30 31 34
126 4 2 0 1 50 25 31 26
127 4 2 0 1 55 13 30 54
128 4 2 0 1 13 55 30 25
129 4 2 0 1 17 55 30 54
130 4 2 0 1 30 13 25 54
131 4 2 0 1 55 29 30 25
132 4 2 0 1 55 29 34 30
133 4 2 0 1 29 52 53 16
134 4 2 0 1 20 52 31 34
135 4 2 0 1 52 53 20 31
136 4 2 0 1 29 53 26 16
137 4 2 0 1 30 19 50 31
138 4 2 0 1 15 25 50 26
139 4 2 0 1 55 13 29 25
140 4 2 0 1 55 34 17 30
141 4 2 0 1 28 33 54 49
139 4 2 0 1 13 29 55 25
140 4 2 0 1 17 55 34 30
141 4 2 0 1 54 28 33 49
142 4 2 0 1 32 48 27 51
143 4 2 0 1 6 17 33 54
144 4 2 0 1 13 28 54 2
......@@ -209,104 +209,104 @@ $Elements
146 4 2 0 1 7 18 32 48
147 4 2 0 1 14 28 2 49
148 4 2 0 1 33 18 6 49
149 4 2 0 1 19 32 51 7
150 4 2 0 1 3 27 51 15
151 4 2 0 1 1 52 29 16
149 4 2 0 1 7 32 19 51
150 4 2 0 1 3 15 27 51
151 4 2 0 1 29 1 52 16
152 4 2 0 1 8 19 31 50
153 4 2 0 1 4 50 26 15
154 4 2 0 1 5 20 34 52
155 4 2 0 1 50 53 26 31
156 4 2 0 1 52 55 29 34
157 4 2 0 1 48 3 51 7
158 4 2 0 1 54 6 2 49
159 4 2 0 1 50 4 53 8
160 4 2 0 1 55 52 1 5
161 4 2 0 1 55 13 1 29
162 4 2 0 1 55 34 5 17
163 4 2 0 1 16 4 53 26
164 4 2 0 1 8 53 31 20
153 4 2 0 1 5 20 34 52
154 4 2 0 1 26 4 50 15
155 4 2 0 1 53 26 50 31
156 4 2 0 1 29 52 55 34
157 4 2 0 1 54 6 2 49
158 4 2 0 1 3 48 7 51
159 4 2 0 1 4 53 50 8
160 4 2 0 1 52 1 55 5
161 4 2 0 1 1 13 29 55
162 4 2 0 1 55 17 34 5
163 4 2 0 1 53 4 26 16
164 4 2 0 1 53 8 20 31
165 4 2 0 1 54 33 6 49
166 4 2 0 1 28 54 2 49
167 4 2 0 1 32 48 51 7
167 4 2 0 1 48 32 7 51
168 4 2 0 1 48 3 27 51
169 4 2 0 1 52 55 1 29
169 4 2 0 1 1 29 52 55
170 4 2 0 1 52 55 34 5
171 4 2 0 1 4 50 53 26
171 4 2 0 1 4 53 26 50
172 4 2 0 1 53 50 8 31
173 4 2 1 2 38 30 46 33
174 4 2 1 2 38 40 30 33
175 4 2 1 2 47 38 46 33
176 4 2 1 2 44 32 37 35
177 4 2 1 2 32 35 46 37
178 4 2 1 2 32 44 37 45
176 4 2 1 2 37 30 32 46
177 4 2 1 2 30 19 37 32
178 4 2 1 2 19 37 32 45
179 4 2 1 2 30 38 46 35
180 4 2 1 2 38 40 35 30
181 4 2 1 2 32 44 30 35
182 4 2 1 2 35 32 46 30
183 4 2 1 2 38 22 47 46
184 4 2 1 2 40 21 38 35
185 4 2 1 2 22 38 35 46
186 4 2 1 2 47 46 18 33
187 4 2 1 2 18 46 30 33
188 4 2 1 2 40 17 30 33
189 4 2 1 2 35 22 46 37
190 4 2 1 2 46 32 18 30
191 4 2 1 2 44 45 23 37
192 4 2 1 2 32 44 19 30
193 4 2 1 2 32 44 45 19
194 4 2 1 2 23 35 44 37
195 4 2 1 2 34 31 39 35
196 4 2 1 2 31 36 43 42
197 4 2 1 2 31 36 39 35
198 4 2 1 2 30 44 31 35
199 4 2 1 2 34 31 42 39
200 4 2 1 2 34 31 35 30
201 4 2 1 2 31 36 42 39
202 4 2 1 2 44 35 36 31
203 4 2 1 2 21 41 35 30
204 4 2 1 2 41 21 40 30
205 4 2 1 2 17 41 40 30
206 4 2 1 2 40 21 35 30
207 4 2 1 2 35 34 41 39
208 4 2 1 2 34 35 41 30
209 4 2 1 2 36 42 24 43
210 4 2 1 2 31 20 34 42
211 4 2 1 2 20 31 43 42
212 4 2 1 2 42 36 24 39
213 4 2 1 2 30 44 19 31
181 4 2 1 2 31 30 37 35
182 4 2 1 2 44 35 31 37
183 4 2 1 2 37 30 46 35
184 4 2 1 2 22 47 38 46
185 4 2 1 2 40 21 38 35
186 4 2 1 2 22 38 35 46
187 4 2 1 2 47 46 18 33
188 4 2 1 2 18 46 30 33
189 4 2 1 2 40 17 30 33
190 4 2 1 2 35 22 46 37
191 4 2 1 2 46 32 18 30
192 4 2 1 2 31 37 19 44
193 4 2 1 2 19 30 37 31
194 4 2 1 2 19 37 45 44
195 4 2 1 2 23 44 45 37
196 4 2 1 2 23 35 44 37
197 4 2 1 2 43 39 31 36
198 4 2 1 2 39 43 31 42
199 4 2 1 2 31 36 39 35
200 4 2 1 2 39 31 34 42
201 4 2 1 2 34 31 35 30
202 4 2 1 2 31 39 34 35
203 4 2 1 2 44 35 36 31
204 4 2 1 2 21 41 35 30
205 4 2 1 2 41 21 40 30
206 4 2 1 2 17 41 40 30
207 4 2 1 2 40 21 35 30
208 4 2 1 2 35 34 41 39
209 4 2 1 2 34 35 41 30
210 4 2 1 2 24 43 39 42
211 4 2 1 2 43 20 31 42
212 4 2 1 2 31 20 34 42
213 4 2 1 2 24 43 36 39
214 4 2 1 2 35 23 44 36
215 4 2 1 2 21 41 39 35
216 4 2 1 2 34 41 17 30
217 4 2 1 2 40 38 47 33
215 4 2 1 2 41 39 21 35
216 4 2 1 2 41 17 34 30
217 4 2 1 2 47 40 38 33
218 4 2 1 2 45 46 37 32
219 4 2 1 2 6 17 40 33
220 4 2 1 2 21 40 38 10
220 4 2 1 2 21 10 40 38
221 4 2 1 2 7 18 46 32
222 4 2 1 2 22 46 37 11
223 4 2 1 2 18 47 33 6
224 4 2 1 2 38 22 10 47
225 4 2 1 2 19 45 32 7
226 4 2 1 2 45 23 37 11
227 4 2 1 2 12 36 44 23
228 4 2 1 2 24 9 42 39
229 4 2 1 2 8 19 44 31
230 4 2 1 2 5 20 42 34
231 4 2 1 2 36 31 43 44
232 4 2 1 2 41 34 42 39
233 4 2 1 2 46 45 11 7
234 4 2 1 2 10 40 47 6
235 4 2 1 2 8 12 43 44
222 4 2 1 2 22 11 46 37
223 4 2 1 2 47 10 22 38
224 4 2 1 2 18 47 33 6
225 4 2 1 2 23 45 11 37
226 4 2 1 2 32 45 7 19
227 4 2 1 2 5 20 42 34
228 4 2 1 2 8 19 44 31
229 4 2 1 2 24 39 9 42
230 4 2 1 2 44 12 36 23
231 4 2 1 2 41 39 34 42
232 4 2 1 2 44 43 31 36
233 4 2 1 2 47 10 40 6
234 4 2 1 2 45 11 46 7
235 4 2 1 2 8 44 12 43
236 4 2 1 2 9 41 5 42
237 4 2 1 2 9 21 41 39
238 4 2 1 2 34 41 5 17
239 4 2 1 2 31 8 20 43
240 4 2 1 2 12 36 24 43
241 4 2 1 2 40 38 10 47
237 4 2 1 2 17 41 34 5
238 4 2 1 2 39 9 41 21
239 4 2 1 2 8 43 20 31
240 4 2 1 2 12 24 43 36
241 4 2 1 2 10 47 40 38
242 4 2 1 2 47 40 33 6
243 4 2 1 2 45 46 32 7
244 4 2 1 2 46 45 37 11
244 4 2 1 2 11 45 46 37
245 4 2 1 2 41 34 5 42
246 4 2 1 2 9 41 42 39
247 4 2 1 2 12 36 43 44
248 4 2 1 2 31 8 43 44
246 4 2 1 2 9 39 41 42
247 4 2 1 2 8 44 43 31
248 4 2 1 2 44 12 43 36
$EndElements
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment