3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
gmshboundaryflagtest.hh
Go to the documentation of this file.
1/*****************************************************************************
2 * See the file COPYING for full copying permissions. *
3 * *
4 * This program is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 3 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16 *****************************************************************************/
26#ifndef DUMUX_TEST_IO_GMSHBOUNDARYFLAG_TEST_HH
27#define DUMUX_TEST_IO_GMSHBOUNDARYFLAG_TEST_HH
28
31
32#include <iostream>
33
34namespace Dumux {
35
36template<class Grid>
38{
39 using GridView = typename Grid::LeafGridView;
40 using Scalar = double;
41 static const int dim = Grid::dimension;
42 using GridManager = typename Dumux::GridManager<Grid>;
43 using ReferenceElements = typename Dune::ReferenceElements<Scalar, dim>;
44
45public:
46
47 template<class GridGeometry>
48 static void testGmshBoundaryFlag(const GridView& leafGridView,
49 std::shared_ptr<const GridGeometry> gridGeometry,
50 std::shared_ptr<const GridData<Grid>> gridData)
51 {
52
53 for(const auto& element : elements(leafGridView))
54 {
55 auto fvGeometry = localView(*gridGeometry);
56 fvGeometry.bind(element);
57
58 for (auto&& scvf : scvfs(fvGeometry))
59 {
60 if (scvf.boundary())
61 {
62 const auto boundaryMarkerId = gridData->getBoundaryDomainMarker(scvf.boundaryFlag());
63 const auto& pos = scvf.center();
64 std::cout << "z-coordinate: " << pos[dim-1] << ", actual ID = " << boundaryMarkerId << ", ";
65
66 /* According to unitcube.geo:
67 * top = 1, bottom = 2, side = 3
68 *
69 * According to unitcube.msh:
70 * top = 1, bottom = 0, side = 2
71 */
72 const int topId = 1;
73 const int bottomId = 0;
74 const int sideId = 2;
75
76 const bool isTop = pos[dim-1] > 1.0 - eps_;
77 const bool isBottom = pos[dim-1] < eps_;
78 const bool isSide = !isTop && !isBottom;
79
80 if (isTop)
81 {
82 std::cout << "correct ID = " << topId << " (is top surface)" << std::endl;
83 if (boundaryMarkerId != topId)
84 DUNE_THROW(Dune::Exception, "BoundaryMarkerId for top is wrong!");
85 }
86 else if (isBottom)
87 {
88 std::cout << "correct ID = " << bottomId << " (is bottom surface)" << std::endl;
89 if (boundaryMarkerId != bottomId)
90 DUNE_THROW(Dune::Exception, "BoundaryMarkerId for bottom is wrong!");
91 }
92 else if (isSide)
93 {
94 std::cout << "correct ID = " << sideId << " (is side surface)" << std::endl;
95 if (boundaryMarkerId != sideId)
96 DUNE_THROW(Dune::Exception, "BoundaryMarkerId for side is wrong!");
97 }
98 } // end if boundary
99 } // end scvf loop
100 } // end element loop
101 } // end testGmshBoundaryFlag
102
103private:
104 static constexpr Scalar eps_ = 1e-4;
105
106};
107
108
109} // end namespace Dumux
110
111
112#endif /* DUMUX_TEST_IO_GMSHBOUNDARYFLAG_TEST_HH */
The available discretization methods in Dumux.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Class for grid data attached to dgf or gmsh grid files.
Definition: griddata.hh:66
The grid manager (this is the class used by the user) for all supported grid managers that constructs...
Definition: gridmanager_base.hh:312
Definition: gmshboundaryflagtest.hh:38
static void testGmshBoundaryFlag(const GridView &leafGridView, std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< const GridData< Grid > > gridData)
Definition: gmshboundaryflagtest.hh:48
Convience header that includes all grid manager specializations.