version 3.10-dev
facevariables.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_DISCRETIZATION_STAGGERED_FREEFLOW_FACEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_STAGGERED_FREEFLOW_FACEVARIABLES_HH
14
15#include <array>
16#include <vector>
17#include <type_traits>
18
19namespace Dumux {
20
21namespace Detail {
22
23template<class Scalar, int upwindSchemeOrder>
25{
26 Scalar self = 0.0;
27 Scalar opposite = 0.0;
28 std::array<Scalar, upwindSchemeOrder-1> forward{};
29 std::array<Scalar, upwindSchemeOrder-1> backward{};
30};
31
32template<class Scalar>
33struct InAxisVelocities<Scalar, 1>
34{
35 Scalar self = 0.0;
36 Scalar opposite = 0.0;
37};
38
39} // end namespace Detail
40
49template<class FacePrimaryVariables, int dim, int upwindSchemeOrder>
51{
52 static constexpr int numPairs = (dim == 2) ? 2 : 4;
53 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
54
55 using Scalar = typename FacePrimaryVariables::block_type;
57
58public:
59
65 void updateOwnFaceOnly(const FacePrimaryVariables& priVars)
66 {
67 inAxisVelocities_.self = priVars[0];
68 }
69
80 template<class FaceSolution, class Problem, class Element,
81 class FVElementGeometry, class SubControlVolumeFace>
82 void update(const FaceSolution& faceSol,
83 const Problem& problem,
84 const Element& element,
85 const FVElementGeometry& fvGeometry,
86 const SubControlVolumeFace& scvf)
87 {
88 static_assert(std::decay_t<decltype(faceSol[0])>::dimension == 1,
89 "\n\n\nVelocity primary variable must be a scalar value. \n\n Make sure to use\n\n ffSol = partial(sol, ffFaceIdx, ffCellCenterIdx);\n\n");
90
91 inAxisVelocities_.self = faceSol[scvf.dofIndex()];
92 inAxisVelocities_.opposite = faceSol[scvf.dofIndexOpposingFace()];
93
94 addHigherOrderInAxisVelocities_(faceSol, scvf, std::integral_constant<bool, useHigherOrder>{});
95
96 // handle all sub faces
97 for (int i = 0; i < velocityParallel_.size(); ++i)
98 velocityParallel_[i].fill(0.0);
99
100 for (int i = 0; i < scvf.pairData().size(); ++i)
101 {
102 const auto& subFaceData = scvf.pairData(i);
103
104 // treat the velocities normal to the face
105 velocityLateralInside_[i] = faceSol[subFaceData.lateralPair.first];
106
107 if (scvf.hasOuterLateral(i))
108 velocityLateralOutside_[i] = faceSol[subFaceData.lateralPair.second];
109
110 // treat the velocities parallel to the self face
111 for (int j = 0; j < upwindSchemeOrder; j++)
112 {
113 if (scvf.hasParallelNeighbor(i,j))
114 velocityParallel_[i][j] = faceSol[subFaceData.parallelDofs[j]];
115 }
116 }
117 }
118
122 Scalar velocitySelf() const
123 {
124 return inAxisVelocities_.self;
125 }
126
130 Scalar velocityOpposite() const
131 {
132 return inAxisVelocities_.opposite;
133 }
134
140 template<bool enable = useHigherOrder, std::enable_if_t<enable, int> = 0>
141 Scalar velocityBackward(const int backwardIdx) const
142 {
143 return inAxisVelocities_.backward[backwardIdx];
144 }
145
151 template<bool enable = useHigherOrder, std::enable_if_t<enable, int> = 0>
152 Scalar velocityForward(const int forwardIdx) const
153 {
154 return inAxisVelocities_.forward[forwardIdx];
155 }
156
163 Scalar velocityParallel(const int localSubFaceIdx, const int parallelDegreeIdx = 0) const
164 {
165 return velocityParallel_[localSubFaceIdx][parallelDegreeIdx];
166 }
167
173 Scalar velocityLateralInside(const int localSubFaceIdx) const
174 {
175 return velocityLateralInside_[localSubFaceIdx];
176 }
177
183 Scalar velocityLateralOutside(const int localSubFaceIdx) const
184 {
185 return velocityLateralOutside_[localSubFaceIdx];
186 }
187
188private:
189
190 template<class SolVector, class SubControlVolumeFace>
191 void addHigherOrderInAxisVelocities_(const SolVector& faceSol, const SubControlVolumeFace& scvf, std::false_type) {}
192
193 template<class SolVector, class SubControlVolumeFace>
194 void addHigherOrderInAxisVelocities_(const SolVector& faceSol, const SubControlVolumeFace& scvf, std::true_type)
195 {
196
197 // treat the velocity forward of the self face i.e. the face that is
198 // forward wrt the self face by degree i
199 for (int i = 0; i < scvf.axisData().inAxisForwardDofs.size(); i++)
200 {
201 if (scvf.hasForwardNeighbor(i))
202 inAxisVelocities_.forward[i]= faceSol[scvf.axisData().inAxisForwardDofs[i]];
203 }
204
205 // treat the velocity at the first backward face i.e. the face that is
206 // behind the opposite face by degree i
207 for (int i = 0; i < scvf.axisData().inAxisBackwardDofs.size(); i++)
208 {
209 if (scvf.hasBackwardNeighbor(i))
210 inAxisVelocities_.backward[i] = faceSol[scvf.axisData().inAxisBackwardDofs[i]];
211 }
212 }
213
214 InAxisVelocities inAxisVelocities_;
215 std::array<std::array<Scalar, upwindSchemeOrder>, numPairs> velocityParallel_;
216 std::array<Scalar, numPairs> velocityLateralInside_;
217 std::array<Scalar, numPairs> velocityLateralOutside_;
218
219};
220
221} // end namespace Dumux
222
223#endif
The face variables class for free flow staggered grid models. Contains all relevant velocities for th...
Definition: facevariables.hh:51
Scalar velocityForward(const int forwardIdx) const
Returns the velocity at a forward face.
Definition: facevariables.hh:152
void update(const FaceSolution &faceSol, const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf)
Complete update of the face variables (i.e. velocities for free flow) for a given face.
Definition: facevariables.hh:82
Scalar velocityOpposite() const
Returns the velocity at the opposing face.
Definition: facevariables.hh:130
Scalar velocityParallel(const int localSubFaceIdx, const int parallelDegreeIdx=0) const
Returns the velocity at a parallel face.
Definition: facevariables.hh:163
void updateOwnFaceOnly(const FacePrimaryVariables &priVars)
Partial update of the face variables. Only the face itself is considered.
Definition: facevariables.hh:65
Scalar velocitySelf() const
Returns the velocity at the face itself.
Definition: facevariables.hh:122
Scalar velocityLateralInside(const int localSubFaceIdx) const
Returns the velocity at the inner normal face.
Definition: facevariables.hh:173
Scalar velocityLateralOutside(const int localSubFaceIdx) const
Returns the velocity at the outer normal face.
Definition: facevariables.hh:183
Scalar velocityBackward(const int backwardIdx) const
Returns the velocity at a backward face.
Definition: facevariables.hh:141
Definition: adapt.hh:17
Definition: facevariables.hh:25
std::array< Scalar, upwindSchemeOrder-1 > forward
Definition: facevariables.hh:28
Scalar opposite
Definition: facevariables.hh:27
std::array< Scalar, upwindSchemeOrder-1 > backward
Definition: facevariables.hh:29
Scalar self
Definition: facevariables.hh:26