Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
3 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
4 | // | ||
5 | /*! | ||
6 | * \file | ||
7 | * | ||
8 | * \brief Test whether GmshBoundaryFlag works as expected | ||
9 | * \note GmshBoundaryFlag only exists for ALUGrid | ||
10 | * | ||
11 | * This tests whether the boundary marker IDs accessed using boundary flags are | ||
12 | * correct when using ALUGrid, a Gmsh mesh file, and the class GmshBoundaryFlag. | ||
13 | */ | ||
14 | #ifndef DUMUX_TEST_IO_GMSHBOUNDARYFLAG_TEST_HH | ||
15 | #define DUMUX_TEST_IO_GMSHBOUNDARYFLAG_TEST_HH | ||
16 | |||
17 | #include <dumux/io/grid/gridmanager_base.hh> | ||
18 | #include <dumux/discretization/method.hh> | ||
19 | |||
20 | #include <iostream> | ||
21 | |||
22 | namespace Dumux { | ||
23 | |||
24 | template<class Grid> | ||
25 | class GmshBoundaryFlagTest | ||
26 | { | ||
27 | using GridView = typename Grid::LeafGridView; | ||
28 | using Scalar = double; | ||
29 | static const int dim = Grid::dimension; | ||
30 | using GridManager = typename Dumux::GridManager<Grid>; | ||
31 | |||
32 | public: | ||
33 | |||
34 | template<class GridGeometry> | ||
35 | 8 | static void testGmshBoundaryFlag(const GridView& leafGridView, | |
36 | std::shared_ptr<const GridGeometry> gridGeometry, | ||
37 | std::shared_ptr<const GridData<Grid>> gridData) | ||
38 | { | ||
39 |
2/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
16 | auto fvGeometry = localView(*gridGeometry); |
40 |
10/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3036 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 3036 times.
✓ Branch 12 taken 4 times.
✓ Branch 14 taken 3036 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 3036 times.
✗ Branch 18 not taken.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
|
6088 | for(const auto& element : elements(leafGridView)) |
41 | { | ||
42 |
1/2✓ Branch 1 taken 3036 times.
✗ Branch 2 not taken.
|
6072 | fvGeometry.bind(element); |
43 |
6/6✓ Branch 0 taken 17628 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 17628 times.
✓ Branch 3 taken 3036 times.
✓ Branch 4 taken 408 times.
✓ Branch 5 taken 2628 times.
|
47400 | for (auto&& scvf : scvfs(fvGeometry)) |
44 | { | ||
45 |
2/2✓ Branch 0 taken 3264 times.
✓ Branch 1 taken 14364 times.
|
35256 | if (scvf.boundary()) |
46 | { | ||
47 |
3/6✓ Branch 1 taken 3264 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3264 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3264 times.
✗ Branch 8 not taken.
|
19584 | const auto boundaryMarkerId = gridData->getBoundaryDomainMarker(scvf.boundaryFlag()); |
48 | 6528 | const auto& pos = scvf.center(); | |
49 |
4/8✓ Branch 2 taken 3264 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3264 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 3264 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 3264 times.
✗ Branch 13 not taken.
|
26112 | std::cout << "z-coordinate: " << pos[dim-1] << ", actual ID = " << boundaryMarkerId << ", "; |
50 | |||
51 | /* According to unitcube.geo: | ||
52 | * top = 1, bottom = 2, side = 3 | ||
53 | * | ||
54 | * According to unitcube.msh: | ||
55 | * top = 1, bottom = 0, side = 2 | ||
56 | */ | ||
57 | 6528 | const int topId = 1; | |
58 | 6528 | const int bottomId = 0; | |
59 | 6528 | const int sideId = 2; | |
60 | |||
61 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 2720 times.
|
6528 | const bool isTop = pos[dim-1] > 1.0 - eps_; |
62 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 2720 times.
|
6528 | const bool isBottom = pos[dim-1] < eps_; |
63 | 6528 | const bool isSide = !isTop && !isBottom; | |
64 | |||
65 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 2720 times.
|
6528 | if (isTop) |
66 | { | ||
67 |
2/4✓ Branch 2 taken 544 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 544 times.
✗ Branch 7 not taken.
|
3264 | std::cout << "correct ID = " << topId << " (is top surface)" << std::endl; |
68 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 544 times.
|
1088 | if (boundaryMarkerId != topId) |
69 | ✗ | DUNE_THROW(Dune::Exception, "BoundaryMarkerId for top is wrong!"); | |
70 | } | ||
71 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 2176 times.
|
5440 | else if (isBottom) |
72 | { | ||
73 |
2/4✓ Branch 2 taken 544 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 544 times.
✗ Branch 7 not taken.
|
3264 | std::cout << "correct ID = " << bottomId << " (is bottom surface)" << std::endl; |
74 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 544 times.
|
1088 | if (boundaryMarkerId != bottomId) |
75 | ✗ | DUNE_THROW(Dune::Exception, "BoundaryMarkerId for bottom is wrong!"); | |
76 | } | ||
77 |
1/2✓ Branch 0 taken 2176 times.
✗ Branch 1 not taken.
|
4352 | else if (isSide) |
78 | { | ||
79 |
2/4✓ Branch 2 taken 2176 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 2176 times.
✗ Branch 7 not taken.
|
13056 | std::cout << "correct ID = " << sideId << " (is side surface)" << std::endl; |
80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2176 times.
|
4352 | if (boundaryMarkerId != sideId) |
81 | ✗ | DUNE_THROW(Dune::Exception, "BoundaryMarkerId for side is wrong!"); | |
82 | } | ||
83 | } // end if boundary | ||
84 | } // end scvf loop | ||
85 | } // end element loop | ||
86 | 8 | } // end testGmshBoundaryFlag | |
87 | |||
88 | private: | ||
89 | static constexpr Scalar eps_ = 1e-4; | ||
90 | |||
91 | }; | ||
92 | |||
93 | |||
94 | } // end namespace Dumux | ||
95 | |||
96 | |||
97 | #endif | ||
98 |