version 3.11-dev
elementboundarytypes.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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_ELEMENT_BOUNDARY_TYPES_HH
13#define DUMUX_ELEMENT_BOUNDARY_TYPES_HH
14
15#include <cassert>
16#include <vector>
17
18#include <dune/geometry/referenceelements.hh>
19
20namespace Dumux {
21
28template<class BTypes>
30{
31public:
32 using BoundaryTypes = BTypes;
33
42 template<class Problem, class FVElementGeometry>
43 void update(const Problem& problem,
44 const typename FVElementGeometry::Element& element,
45 const FVElementGeometry& fvGeometry)
46 {
47 static constexpr int dim = FVElementGeometry::GridGeometry::GridView::dimension;
48 using Scalar = typename FVElementGeometry::GridGeometry::GlobalCoordinate::value_type;
49 // Resize according to the number of faces (intersections)
50 bcTypes_.resize(Dune::referenceElement<Scalar, dim>(element.type()).size(dim-1));
51
52 hasFluxBoundary_ = false;
53
54 for (const auto& boundaryFace : boundaryFaces(fvGeometry))
55 {
56 const auto localIdx = boundaryFace.intersectionIndex();
57 bcTypes_[localIdx].reset();
58
59 bcTypes_[localIdx] = problem.boundaryTypes(fvGeometry, boundaryFace);
60 hasFluxBoundary_ = hasFluxBoundary_ || bcTypes_[localIdx].hasFluxBoundary();
61 }
62 }
63
68 bool hasFluxBoundary() const
69 { return hasFluxBoundary_; }
70
71 /*
72 * \brief Access operator
73 * \return BoundaryTypes
74 * \note yields undefined behaviour if the scvf is not on the boundary
75 */
76 template<class FVElementGeometry>
77 const BoundaryTypes& get(const FVElementGeometry& fvGeometry, const typename FVElementGeometry::SubControlVolumeFace& scvf) const
78 {
79 assert(scvf.boundary());
80 const auto localIdx = fvGeometry.intersectionIndex(scvf);
81 assert(localIdx < bcTypes_.size());
82 return bcTypes_[localIdx];
83 }
84
85 /*
86 * \brief Access operator
87 * \return BoundaryTypes
88 */
89 template<class FVElementGeometry>
90 const BoundaryTypes& get(const FVElementGeometry&, const typename FVElementGeometry::BoundaryFace& boundaryFace) const
91 {
92 const auto localIdx = boundaryFace.intersectionIndex();
93 assert(localIdx < bcTypes_.size());
94 return bcTypes_[localIdx];
95 }
96
97private:
98 std::vector<BoundaryTypes> bcTypes_;
99 bool hasFluxBoundary_ = false;
100};
101
102
103} // namespace Dumux
104
105#endif
This class stores an array of BoundaryTypes objects. This class is not dependent on the used discreti...
Definition: elementboundarytypes.hh:30
bool hasFluxBoundary() const
Returns whether the element potentially features a flux boundary segment.
Definition: elementboundarytypes.hh:68
const BoundaryTypes & get(const FVElementGeometry &, const typename FVElementGeometry::BoundaryFace &boundaryFace) const
Definition: elementboundarytypes.hh:90
BTypes BoundaryTypes
Definition: elementboundarytypes.hh:32
const BoundaryTypes & get(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolumeFace &scvf) const
Definition: elementboundarytypes.hh:77
void update(const Problem &problem, const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry)
Update the boundary types for all element intersections.
Definition: elementboundarytypes.hh:43
Definition: adapt.hh:17