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 hasDirichlet_ = false;
53 hasNeumann_ = false;
54
55 for (const auto& intersection : intersections(fvGeometry.gridGeometry().gridView(), element))
56 {
57 const auto localIdx = intersection.indexInInside();
58 bcTypes_[localIdx].reset();
59
60 if (intersection.boundary() && !intersection.neighbor())
61 {
62 bcTypes_[localIdx] = problem.boundaryTypes(fvGeometry, intersection);
63 hasDirichlet_ = hasDirichlet_ || bcTypes_[localIdx].hasDirichlet();
64 hasNeumann_ = hasNeumann_ || bcTypes_[localIdx].hasNeumann();
65 }
66 }
67 }
68
73 bool hasDirichlet() const
74 { return hasDirichlet_; }
75
80 bool hasNeumann() const
81 { return hasNeumann_; }
82
83 /*
84 * \brief Access operator
85 * \return BoundaryTypes
86 * \note yields undefined behaviour if the scvf is not on the boundary
87 */
88 template<class FVElementGeometry>
89 const BoundaryTypes& get(const FVElementGeometry& fvGeometry, const typename FVElementGeometry::SubControlVolumeFace& scvf) const
90 {
91 assert(scvf.boundary());
92 const auto localIdx = fvGeometry.intersectionIndex(scvf);
93 assert(localIdx < bcTypes_.size());
94 return bcTypes_[localIdx];
95 }
96
97 /*
98 * \brief Access operator
99 * \return BoundaryTypes
100 * \note yields undefined behaviour if the intersection is not on the boundary
101 */
102 template<class FVElementGeometry>
103 const BoundaryTypes& get(const FVElementGeometry&, const typename FVElementGeometry::GridGeometry::GridView::Intersection& intersection) const
104 {
105 assert(intersection.boundary());
106 const auto localIdx = intersection.indexInInside();
107 assert(localIdx < bcTypes_.size());
108 return bcTypes_[localIdx];
109 }
110
111private:
112 std::vector<BoundaryTypes> bcTypes_;
113 bool hasDirichlet_ = false;
114 bool hasNeumann_ = false;
115};
116
117
118} // namespace Dumux
119
120#endif
This class stores an array of BoundaryTypes objects. This class is not dependent on the used discreti...
Definition: elementboundarytypes.hh:30
bool hasNeumann() const
Returns whether the element potentially features a Neumann boundary segment.
Definition: elementboundarytypes.hh:80
const BoundaryTypes & get(const FVElementGeometry &, const typename FVElementGeometry::GridGeometry::GridView::Intersection &intersection) const
Definition: elementboundarytypes.hh:103
BTypes BoundaryTypes
Definition: elementboundarytypes.hh:32
const BoundaryTypes & get(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolumeFace &scvf) const
Definition: elementboundarytypes.hh:89
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
bool hasDirichlet() const
Returns whether the element has an intersection with Dirichlet conditions.
Definition: elementboundarytypes.hh:73
Definition: adapt.hh:17