version 3.11-dev
constraintinfo.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_CONSTRAINT_INFO_HH
13#define DUMUX_CONSTRAINT_INFO_HH
14
15#include <algorithm>
16#include <array>
17
18namespace Dumux {
19
24template <int numEq>
26{
27public:
29 { reset(); }
30
32 static constexpr int size()
33 { return numEq; }
34
38 void reset()
39 {
40 for (int eqIdx=0; eqIdx < numEq; ++eqIdx)
41 resetEq(eqIdx);
42 }
43
47 void resetEq(int eqIdx)
48 { isConstraint_[eqIdx] = false; }
49
53 void setAll()
54 {
55 for (int eqIdx = 0; eqIdx < numEq; ++ eqIdx)
56 set(eqIdx);
57 }
58
64 void set(int eqIdx)
65 { isConstraint_[eqIdx] = true; }
66
73 bool isConstraintEquation(int eqIdx) const
74 { return isConstraint_[eqIdx]; }
75
76protected:
77 std::array<bool, numEq> isConstraint_;
78};
79
84template <int numEq>
86{
88public:
90 { reset(); }
91
95 void reset()
96 {
97 for (int eqIdx=0; eqIdx < numEq; ++eqIdx)
98 resetEq(eqIdx);
99 }
100
104 void resetEq(int eqIdx)
105 {
106 ParentType::resetEq(eqIdx);
107 eq2pvIdx_[eqIdx] = eqIdx;
108 pv2eqIdx_[eqIdx] = eqIdx;
109 }
110
114 void setAll()
115 {
116 for (int eqIdx = 0; eqIdx < numEq; ++ eqIdx)
117 set(eqIdx);
118 }
119
129 void set(int pvIdx, int eqIdx)
130 {
131 ParentType::set(eqIdx);
132
133 // update the equation <-> primary variable mapping
134 eq2pvIdx_[eqIdx] = pvIdx;
135 pv2eqIdx_[pvIdx] = eqIdx;
136 }
137
145 void set(int pvIdx)
146 { set(pvIdx, pvIdx); }
147
156 int priVarToEqIndex(int pvIdx) const
157 { return pv2eqIdx_[pvIdx]; }
158
167 int eqToPriVarIndex(int eqIdx) const
168 { return eq2pvIdx_[eqIdx]; }
169
170private:
171 std::array<int, numEq> eq2pvIdx_, pv2eqIdx_;
172};
173
174} // end namespace Dumux
175
176#endif
Class to specify information related to constraints.
Definition: constraintinfo.hh:26
void set(int eqIdx)
Set a constraint condition for a single equation.
Definition: constraintinfo.hh:64
static constexpr int size()
we might have a constraint for each equation
Definition: constraintinfo.hh:32
ConstraintInfo()
Definition: constraintinfo.hh:28
void reset()
Reset for all equations.
Definition: constraintinfo.hh:38
bool isConstraintEquation(int eqIdx) const
Returns true if an equation is used to specify a constraint condition.
Definition: constraintinfo.hh:73
void setAll()
Set all as constraints.
Definition: constraintinfo.hh:53
void resetEq(int eqIdx)
Reset for one equation.
Definition: constraintinfo.hh:47
std::array< bool, numEq > isConstraint_
Definition: constraintinfo.hh:77
Class to specify information related to Dirichlet constraints.
Definition: constraintinfo.hh:86
void setAll()
Set all as constraints.
Definition: constraintinfo.hh:114
int priVarToEqIndex(int pvIdx) const
Returns the index of the equation which should be used for the constraint condition of the pvIdx's pr...
Definition: constraintinfo.hh:156
void set(int pvIdx)
Set a constraint condition for a single primary variable.
Definition: constraintinfo.hh:145
DirichletConstraintInfo()
Definition: constraintinfo.hh:89
void set(int pvIdx, int eqIdx)
Set a constraint condition for a single primary variable.
Definition: constraintinfo.hh:129
void resetEq(int eqIdx)
Reset for one equation.
Definition: constraintinfo.hh:104
void reset()
Reset for all equations.
Definition: constraintinfo.hh:95
int eqToPriVarIndex(int eqIdx) const
Returns the index of the primary variable which should be used for the constraint condition given an ...
Definition: constraintinfo.hh:167
Definition: adapt.hh:17