3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/navierstokes/staggered/problem.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_NAVIERSTOKES_STAGGERED_PROBLEM_HH
25#define DUMUX_NAVIERSTOKES_STAGGERED_PROBLEM_HH
26
27#include <dune/common/exceptions.hh>
28#include <dune/common/typetraits.hh>
33
34namespace Dumux {
35
43template<class TypeTag>
45{
47 using Implementation = GetPropType<TypeTag, Properties::Problem>;
48
50 using GridView = typename GridGeometry::GridView;
51 using Element = typename GridView::template Codim<0>::Entity;
52
54 using GridFaceVariables = typename GridVariables::GridFaceVariables;
55 using ElementFaceVariables = typename GridFaceVariables::LocalView;
56 using FaceVariables = typename GridFaceVariables::FaceVariables;
57 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
58 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
60
61 using FVElementGeometry = typename GridGeometry::LocalView;
62 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
63 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
66
67 enum {
68 dim = GridView::dimension,
69 dimWorld = GridView::dimensionworld
70 };
71
72 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
73 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
74 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
75
76public:
82 NavierStokesStaggeredProblem(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
84 , gravity_(0.0)
85 {
86 if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
87 gravity_[dim-1] = -9.81;
88
89 enableInertiaTerms_ = getParamFromGroup<bool>(paramGroup, "Problem.EnableInertiaTerms");
90 }
91
92
99 const GravityVector& gravity() const
100 { return gravity_; }
101
106 { return enableInertiaTerms_; }
107
109 template <class SolutionVector, class G = GridGeometry>
110 typename std::enable_if<G::discMethod == DiscretizationMethods::staggered, void>::type
111 applyInitialFaceSolution(SolutionVector& sol,
112 const SubControlVolumeFace& scvf,
113 const PrimaryVariables& initSol) const
114 {
115 sol[GridGeometry::faceIdx()][scvf.dofIndex()][0] = initSol[Indices::velocity(scvf.directionIndex())];
116 }
117
131 Scalar pseudo3DWallFriction(const Scalar velocity,
132 const Scalar viscosity,
133 const Scalar height,
134 const Scalar factor = 8.0) const
135 {
136 static_assert(dim == 2, "Pseudo 3D wall friction may only be used in 2D");
137 return -factor * velocity * viscosity / (height*height);
138 }
139
141 template <class ElementVolumeVariables, class ElementFaceVariables, class G = GridGeometry>
142 typename std::enable_if<G::discMethod == DiscretizationMethods::staggered, Scalar>::type
143 pseudo3DWallFriction(const SubControlVolumeFace& scvf,
144 const ElementVolumeVariables& elemVolVars,
145 const ElementFaceVariables& elemFaceVars,
146 const Scalar height,
147 const Scalar factor = 8.0) const
148 {
149 const Scalar velocity = elemFaceVars[scvf].velocitySelf();
150 const Scalar viscosity = elemVolVars[scvf.insideScvIdx()].effectiveViscosity();
151 return pseudo3DWallFriction(velocity, viscosity, height, factor);
152 }
153
159 Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const
160 {
161 DUNE_THROW(Dune::NotImplemented,
162 "When using the Beavers-Joseph-Saffman boundary condition, "
163 "the permeability must be returned in the actual problem"
164 );
165 }
166
172 Scalar alphaBJ(const SubControlVolumeFace& scvf) const
173 {
174 DUNE_THROW(Dune::NotImplemented,
175 "When using the Beavers-Joseph-Saffman boundary condition, "
176 "the alpha value must be returned in the actual problem"
177 );
178 }
179
183 Scalar betaBJ(const Element& element, const SubControlVolumeFace& scvf, const GlobalPosition& tangentialVector) const
184 {
185 const Scalar interfacePermeability = interfacePermeability_(element, scvf, tangentialVector);
186 using std::sqrt;
187 return asImp_().alphaBJ(scvf) / sqrt(interfacePermeability);
188 }
189
193 VelocityVector porousMediumVelocity(const Element& element, const SubControlVolumeFace& scvf) const
194 {
195 return VelocityVector(0.0);
196 }
197
201 const Scalar beaversJosephVelocity(const Element& element,
202 const SubControlVolume& scv,
203 const SubControlVolumeFace& ownScvf,
204 const SubControlVolumeFace& faceOnPorousBoundary,
205 const Scalar velocitySelf,
206 const Scalar tangentialVelocityGradient) const
207 {
208 // create a unit normal vector oriented in positive coordinate direction
209 GlobalPosition orientation = ownScvf.unitOuterNormal();
210 orientation[ownScvf.directionIndex()] = 1.0;
211
212 // du/dy + dv/dx = alpha/sqrt(K) * (u_boundary-uPM)
213 // beta = alpha/sqrt(K)
214 const Scalar betaBJ = asImp_().betaBJ(element, faceOnPorousBoundary, orientation);
215 const Scalar distanceNormalToBoundary = (faceOnPorousBoundary.center() - scv.center()).two_norm();
216
217 return (tangentialVelocityGradient*distanceNormalToBoundary
218 + asImp_().porousMediumVelocity(element, faceOnPorousBoundary) * orientation * betaBJ * distanceNormalToBoundary
219 + velocitySelf) / (betaBJ*distanceNormalToBoundary + 1.0);
220 }
221
222private:
224 Scalar interfacePermeability_(const Element& element, const SubControlVolumeFace& scvf, const GlobalPosition& tangentialVector) const
225 {
226 const auto& K = asImp_().permeability(element, scvf);
227
228 // use t*K*t for permeability tensors
229 if constexpr (Dune::IsNumber<std::decay_t<decltype(K)>>::value)
230 return K;
231 else
232 return vtmv(tangentialVector, K, tangentialVector);
233 }
234
236 Implementation &asImp_()
237 { return *static_cast<Implementation *>(this); }
238
240 const Implementation &asImp_() const
241 { return *static_cast<const Implementation *>(this); }
242
243 GravityVector gravity_;
244 bool enableInertiaTerms_;
245};
246
247} // end namespace Dumux
248
249#endif
Base class for all staggered fv problems.
The available discretization methods in Dumux.
Dune::DenseMatrix< MAT >::value_type vtmv(const Dune::DenseVector< V1 > &v1, const Dune::DenseMatrix< MAT > &M, const Dune::DenseVector< V2 > &v2)
Evaluates the scalar product of a vector v2, projected by a matrix M, with a vector v1.
Definition: math.hh:863
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:55
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:544
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:540
Base class for all staggered finite-volume problems.
Definition: staggeredfvproblem.hh:48
Navier-Stokes staggered problem base class.
Definition: freeflow/navierstokes/staggered/problem.hh:45
const GravityVector & gravity() const
Returns the acceleration due to gravity.
Definition: freeflow/navierstokes/staggered/problem.hh:99
const Scalar beaversJosephVelocity(const Element &element, const SubControlVolume &scv, const SubControlVolumeFace &ownScvf, const SubControlVolumeFace &faceOnPorousBoundary, const Scalar velocitySelf, const Scalar tangentialVelocityGradient) const
Returns the slip velocity at a porous boundary based on the Beavers-Joseph(-Saffman) condition.
Definition: freeflow/navierstokes/staggered/problem.hh:201
std::enable_if< G::discMethod==DiscretizationMethods::staggered, Scalar >::type pseudo3DWallFriction(const SubControlVolumeFace &scvf, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const Scalar height, const Scalar factor=8.0) const
Convenience function for staggered grid implementation.
Definition: freeflow/navierstokes/staggered/problem.hh:143
NavierStokesStaggeredProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/staggered/problem.hh:82
bool enableInertiaTerms() const
Returns whether interia terms should be considered.
Definition: freeflow/navierstokes/staggered/problem.hh:105
Scalar permeability(const Element &element, const SubControlVolumeFace &scvf) const
Returns the intrinsic permeability of required as input parameter for the Beavers-Joseph-Saffman boun...
Definition: freeflow/navierstokes/staggered/problem.hh:159
Scalar pseudo3DWallFriction(const Scalar velocity, const Scalar viscosity, const Scalar height, const Scalar factor=8.0) const
An additional drag term can be included as source term for the momentum balance to mimic 3D flow beha...
Definition: freeflow/navierstokes/staggered/problem.hh:131
Scalar alphaBJ(const SubControlVolumeFace &scvf) const
Returns the alpha value required as input parameter for the Beavers-Joseph-Saffman boundary condition...
Definition: freeflow/navierstokes/staggered/problem.hh:172
VelocityVector porousMediumVelocity(const Element &element, const SubControlVolumeFace &scvf) const
Returns the velocity in the porous medium (which is 0 by default according to Saffmann).
Definition: freeflow/navierstokes/staggered/problem.hh:193
Scalar betaBJ(const Element &element, const SubControlVolumeFace &scvf, const GlobalPosition &tangentialVector) const
Returns the beta value which is the alpha value divided by the square root of the (scalar-valued) int...
Definition: freeflow/navierstokes/staggered/problem.hh:183
std::enable_if< G::discMethod==DiscretizationMethods::staggered, void >::type applyInitialFaceSolution(SolutionVector &sol, const SubControlVolumeFace &scvf, const PrimaryVariables &initSol) const
Applies the initial face solution (velocities on the faces). Specialization for staggered grid discre...
Definition: freeflow/navierstokes/staggered/problem.hh:111
Declares all properties used in Dumux.