version 3.11-dev
Loading...
Searching...
No Matches
cvfe/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_CVFE_ELEMENT_BOUNDARY_TYPES_HH
13#define DUMUX_CVFE_ELEMENT_BOUNDARY_TYPES_HH
14
15#include <cassert>
16#include <vector>
17
20
21namespace Dumux {
22
27template<class BTypes>
29{
30public:
31 using BoundaryTypes = BTypes;
32
41 template<class Problem, class FVElementGeometry>
42 void update(const Problem& problem,
43 const typename FVElementGeometry::Element& element,
44 const FVElementGeometry& fvGeometry)
45 {
46 bcTypes_.resize(fvGeometry.numScv());
47
48 hasDirichlet_ = false;
49 hasNeumann_ = false;
50
51 const auto& gridDiscretization = Deprecated::gridGeometry(fvGeometry);
52
53 for (const auto& scv : scvs(fvGeometry))
54 {
55 const auto scvIdxLocal = scv.localDofIndex();
56 bcTypes_[scvIdxLocal].reset();
57
58 if (gridDiscretization.dofOnBoundary(scv.dofIndex()))
59 {
60 bcTypes_[scvIdxLocal] = problem.boundaryTypes(element, scv);
61 hasDirichlet_ = hasDirichlet_ || bcTypes_[scvIdxLocal].hasDirichlet();
62 hasNeumann_ = hasNeumann_ || bcTypes_[scvIdxLocal].hasNeumann();
63 }
64 }
65 }
66
71 bool hasDirichlet() const
72 { return hasDirichlet_; }
73
78 bool hasNeumann() const
79 { return hasNeumann_; }
80
81 /*
82 * \brief Access operator
83 * \return BoundaryTypes
84 * \note yields undefined behaviour of the scv is not on the boundary
85 */
86 template<class FVElementGeometry>
87 const BoundaryTypes& get(const FVElementGeometry& fvGeometry, const typename FVElementGeometry::SubControlVolumeFace& scvf) const
88 {
89 assert(scvf.boundary());
90 const auto localDofIdx = fvGeometry.scv(scvf.insideScvIdx()).localDofIndex();
91 assert(localDofIdx < bcTypes_.size());
92 return bcTypes_[localDofIdx];
93 }
94
95 /*
96 * \brief Access operator
97 * \return BoundaryTypes
98 * \note yields undefined behaviour of the scv is not on the boundary
99 */
100 template<class FVElementGeometry>
101 const BoundaryTypes& get(const FVElementGeometry&, const typename FVElementGeometry::SubControlVolume& scv) const
102 {
103 const auto localDofIdx = scv.localDofIndex();
104 assert(localDofIdx < bcTypes_.size());
105 return bcTypes_[localDofIdx];
106 }
107
108private:
109 std::vector<BoundaryTypes> bcTypes_;
110 bool hasDirichlet_ = false;
111 bool hasNeumann_ = false;
112};
113
114} // namespace Dumux
115
116#endif
This class stores an array of BoundaryTypes objects.
Definition cvfe/elementboundarytypes.hh:29
BTypes BoundaryTypes
Definition cvfe/elementboundarytypes.hh:31
bool hasDirichlet() const
Returns whether the element has a vertex which contains a Dirichlet value.
Definition cvfe/elementboundarytypes.hh:71
const BoundaryTypes & get(const FVElementGeometry &, const typename FVElementGeometry::SubControlVolume &scv) const
Definition cvfe/elementboundarytypes.hh:101
bool hasNeumann() const
Returns whether the element potentially features a Neumann boundary segment.
Definition cvfe/elementboundarytypes.hh:78
const BoundaryTypes & get(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolumeFace &scvf) const
Definition cvfe/elementboundarytypes.hh:87
void update(const Problem &problem, const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry)
Update the boundary types for all vertices of an element.
Definition cvfe/elementboundarytypes.hh:42
Helpers for deprecation.
The available discretization methods in Dumux.
Definition adapt.hh:17
std::ranges::range auto scvs(const FVElementGeometry &fvGeometry, const LocalDof &localDof)
Definition localdof.hh:82