3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
scvftoscvboundarytypes.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_SCVF_TO_SCV_BCTYPES_HH
25#define DUMUX_SCVF_TO_SCV_BCTYPES_HH
26
27#include <vector>
28#include <dune/common/exceptions.hh>
30
31namespace Dumux {
32
37template<class BoundaryTypes, class DiscretizationMethod>
39{
40public:
42
43 template<class Problem>
44 void computeBoundaryTypes(const Problem& problem)
45 {
46 // only do something for box
47 if (DiscretizationMethod{} == DiscretizationMethods::box)
48 {
49 const auto& gridGeometry = problem.gridGeometry();
50 scvBoundaryTypes.resize(gridGeometry.vertexMapper().size());
51 // set all equations to Neumann by default
52 for (std::size_t vIdx = 0; vIdx < scvBoundaryTypes.size(); vIdx++)
53 scvBoundaryTypes[vIdx].setAllNeumann();
54
55 auto fvGeometry = localView(gridGeometry);
56 for (const auto& element : elements(gridGeometry.gridView()))
57 {
58 // iterate over the scvfs
59 fvGeometry.bindElement(element);
60
61 for (const auto& scvf : scvfs(fvGeometry))
62 {
63 if (!scvf.boundary())
64 continue;
65
66 const auto bcTypes = problem.boundaryTypes(element, scvf);
67 if (!bcTypes.hasDirichlet())
68 continue;
69
70 // get the inside scv belonging to this scvf and set possible Dirichlet boundary conditions
71 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
72 for (int pvIdx = 0; pvIdx < bcTypes.size(); ++pvIdx)
73 if (bcTypes.isDirichlet(pvIdx))
74 scvBoundaryTypes[scv.dofIndex()].setDirichlet(pvIdx);
75 }
76 }
77 }
78 }
79
81 template<class SubControlVolume>
82 const BoundaryTypes& boundaryTypes(const SubControlVolume& scv) const
83 {
84 if (DiscretizationMethod{} == DiscretizationMethods::box)
85 return scvBoundaryTypes[scv.dofIndex()];
86 else
87 DUNE_THROW(Dune::InvalidStateException, "Only use this for the box discretization!");
88 }
89
90private:
91 std::vector<BoundaryTypes> scvBoundaryTypes;
92};
93
94} // end namespace Dumux
95
96#endif
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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
constexpr Box box
Definition: method.hh:136
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:38
Convert intersection boundary types to vertex boundary types.
Definition: scvftoscvboundarytypes.hh:39
void computeBoundaryTypes(const Problem &problem)
Definition: scvftoscvboundarytypes.hh:44
const BoundaryTypes & boundaryTypes(const SubControlVolume &scv) const
get the boundary types of the scv
Definition: scvftoscvboundarytypes.hh:82