version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_SCVF_TO_SCV_BCTYPES_HH
13#define DUMUX_SCVF_TO_SCV_BCTYPES_HH
14
15#include <vector>
16#include <dune/common/exceptions.hh>
18
19namespace Dumux {
20
25template<class BoundaryTypes, class DiscretizationMethod>
27{
28public:
30
31 template<class Problem>
32 void computeBoundaryTypes(const Problem& problem)
33 {
34 // only do something for box
35 if (DiscretizationMethod{} == DiscretizationMethods::box)
36 {
37 const auto& gridGeometry = problem.gridGeometry();
38 scvBoundaryTypes.resize(gridGeometry.vertexMapper().size());
39 // set all equations to Neumann by default
40 for (std::size_t vIdx = 0; vIdx < scvBoundaryTypes.size(); vIdx++)
41 scvBoundaryTypes[vIdx].setAllNeumann();
42
43 auto fvGeometry = localView(gridGeometry);
44 for (const auto& element : elements(gridGeometry.gridView()))
45 {
46 // iterate over the scvfs
47 fvGeometry.bindElement(element);
48
49 for (const auto& scvf : scvfs(fvGeometry))
50 {
51 if (!scvf.boundary())
52 continue;
53
54 const auto bcTypes = problem.boundaryTypes(element, scvf);
55 if (!bcTypes.hasDirichlet())
56 continue;
57
58 // get the inside scv belonging to this scvf and set possible Dirichlet boundary conditions
59 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
60 for (int pvIdx = 0; pvIdx < bcTypes.size(); ++pvIdx)
61 if (bcTypes.isDirichlet(pvIdx))
62 scvBoundaryTypes[scv.dofIndex()].setDirichlet(pvIdx);
63 }
64 }
65 }
66 }
67
69 template<class SubControlVolume>
70 const BoundaryTypes& boundaryTypes(const SubControlVolume& scv) const
71 {
72 if (DiscretizationMethod{} == DiscretizationMethods::box)
73 return scvBoundaryTypes[scv.dofIndex()];
74 else
75 DUNE_THROW(Dune::InvalidStateException, "Only use this for the box discretization!");
76 }
77
78private:
79 std::vector<BoundaryTypes> scvBoundaryTypes;
80};
81
82} // end namespace Dumux
83
84#endif
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:26
Convert intersection boundary types to vertex boundary types.
Definition: scvftoscvboundarytypes.hh:27
void computeBoundaryTypes(const Problem &problem)
Definition: scvftoscvboundarytypes.hh:32
const BoundaryTypes & boundaryTypes(const SubControlVolume &scv) const
get the boundary types of the scv
Definition: scvftoscvboundarytypes.hh:70
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
The available discretization methods in Dumux.
constexpr Box box
Definition: method.hh:147
Definition: adapt.hh:17