Loading [MathJax]/extensions/tex2jax.js
3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
freeflow/navierstokes/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_PROBLEM_HH
25#define DUMUX_NAVIERSTOKES_PROBLEM_HH
26
27#include <dune/common/deprecated.hh>
28#include <dune/common/exceptions.hh>
32
33namespace Dumux {
34
36template<class TypeTag, DiscretizationMethod discMethod> struct NavierStokesParentProblemImpl;
37
38template<class TypeTag>
40{
42};
43
45template<class TypeTag>
47 typename NavierStokesParentProblemImpl<TypeTag,
49
58template<class TypeTag>
60{
61 using ParentType = NavierStokesParentProblem<TypeTag>;
62 using Implementation = GetPropType<TypeTag, Properties::Problem>;
63
65 using GridView = typename GridGeometry::GridView;
66 using Element = typename GridView::template Codim<0>::Entity;
67
69 using GridFaceVariables = typename GridVariables::GridFaceVariables;
70 using ElementFaceVariables = typename GridFaceVariables::LocalView;
71 using FaceVariables = typename GridFaceVariables::FaceVariables;
72 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
73 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
75
76 using FVElementGeometry = typename GridGeometry::LocalView;
77 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
78 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
81
82 enum {
83 dim = GridView::dimension,
84 dimWorld = GridView::dimensionworld
85 };
86
87 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
88 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
89 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
90
91public:
97 NavierStokesProblem(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
98 : ParentType(gridGeometry, paramGroup)
99 , gravity_(0.0)
100 {
101 if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
102 gravity_[dim-1] = -9.81;
103
104 enableInertiaTerms_ = getParamFromGroup<bool>(paramGroup, "Problem.EnableInertiaTerms");
105 }
106
115 Scalar temperatureAtPos(const GlobalPosition &globalPos) const
116 { return asImp_().temperature(); }
117
123 Scalar temperature() const
124 { DUNE_THROW(Dune::NotImplemented, "temperature() method not implemented by the actual problem"); }
125
132 const GravityVector& gravity() const
133 { return gravity_; }
134
139 { return enableInertiaTerms_; }
140
142 template <class SolutionVector, class G = GridGeometry>
143 typename std::enable_if<G::discMethod == DiscretizationMethod::staggered, void>::type
144 applyInitialFaceSolution(SolutionVector& sol,
145 const SubControlVolumeFace& scvf,
146 const PrimaryVariables& initSol) const
147 {
148 sol[GridGeometry::faceIdx()][scvf.dofIndex()][0] = initSol[Indices::velocity(scvf.directionIndex())];
149 }
150
164 Scalar pseudo3DWallFriction(const Scalar velocity,
165 const Scalar viscosity,
166 const Scalar height,
167 const Scalar factor = 8.0) const
168 {
169 static_assert(dim == 2, "Pseudo 3D wall friction may only be used in 2D");
170 return -factor * velocity * viscosity / (height*height);
171 }
172
174 template <class ElementVolumeVariables, class ElementFaceVariables, class G = GridGeometry>
175 typename std::enable_if<G::discMethod == DiscretizationMethod::staggered, Scalar>::type
176 pseudo3DWallFriction(const SubControlVolumeFace& scvf,
177 const ElementVolumeVariables& elemVolVars,
178 const ElementFaceVariables& elemFaceVars,
179 const Scalar height,
180 const Scalar factor = 8.0) const
181 {
182 const Scalar velocity = elemFaceVars[scvf].velocitySelf();
183 const Scalar viscosity = elemVolVars[scvf.insideScvIdx()].effectiveViscosity();
184 return pseudo3DWallFriction(velocity, viscosity, height, factor);
185 }
186
192 Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const
193 {
194 DUNE_THROW(Dune::NotImplemented, "When using the Beavers-Joseph-Saffman boundary condition, the permeability must be returned in the acutal problem");
195 }
196
202 Scalar alphaBJ(const SubControlVolumeFace& scvf) const
203 {
204 DUNE_THROW(Dune::NotImplemented, "When using the Beavers-Joseph-Saffman boundary condition, the alpha value must be returned in the acutal problem");
205 }
206
210 Scalar betaBJ(const Element& element, const SubControlVolumeFace& scvf) const
211 {
212 using std::sqrt;
213 return asImp_().alphaBJ(scvf) / sqrt(asImp_().permeability(element, scvf));
214 }
215
219 [[deprecated("\nvelocityPorousMedium(element, scvf) is deprecated. Use porousMediumVelocity(element, scvf) instead, returning a velocity vector. Will be removed after 3.2")]]
220 Scalar velocityPorousMedium(const Element& element, const SubControlVolumeFace& scvf) const
221 { return 0.0; }
222
226 VelocityVector porousMediumVelocity(const Element& element, const SubControlVolumeFace& scvf) const
227 {
228 // TODO: return VelocityVector(0.0) after 3.2!
229 return VelocityVector(getVelPM_(element, scvf));
230 }
231
233 [[deprecated("Use beaversJosephVelocity(element, scv, ownScvf, faceOnPorousBoundary, velocitySelf, tangentialVelocityGradient) instead. Will be removed after 3.2")]]
234 const Scalar beaversJosephVelocity(const Element& element,
235 const SubControlVolume& scv,
236 const SubControlVolumeFace& faceOnPorousBoundary,
237 const Scalar velocitySelf,
238 const Scalar tangentialVelocityGradient) const
239 {
240 // du/dy + dv/dx = alpha/sqrt(K) * (u_boundary-uPM)
241 // beta = alpha/sqrt(K)
242 const Scalar betaBJ = asImp_().betaBJ(element, faceOnPorousBoundary);
243 const Scalar distance = (faceOnPorousBoundary.center() - scv.center()).two_norm();
244 return (tangentialVelocityGradient*distance + asImp_().velocityPorousMedium(element,faceOnPorousBoundary)*betaBJ*distance + velocitySelf) / (betaBJ*distance + 1.0);
245 }
246
248 const Scalar beaversJosephVelocity(const Element& element,
249 const SubControlVolume& scv,
250 const SubControlVolumeFace& ownScvf,
251 const SubControlVolumeFace& faceOnPorousBoundary,
252 const Scalar velocitySelf,
253 const Scalar tangentialVelocityGradient) const
254 {
255 // du/dy + dv/dx = alpha/sqrt(K) * (u_boundary-uPM)
256 // beta = alpha/sqrt(K)
257 const Scalar betaBJ = asImp_().betaBJ(element, faceOnPorousBoundary);
258 const Scalar distanceNormalToBoundary = (faceOnPorousBoundary.center() - scv.center()).two_norm();
259
260 // create a unit normal vector oriented in positive coordinate direction
261 GlobalPosition orientation = ownScvf.unitOuterNormal();
262 orientation[ownScvf.directionIndex()] = 1.0;
263
264 return (tangentialVelocityGradient*distanceNormalToBoundary
265 + asImp_().porousMediumVelocity(element, faceOnPorousBoundary) * orientation * betaBJ * distanceNormalToBoundary
266 + velocitySelf) / (betaBJ*distanceNormalToBoundary + 1.0);
267 }
268
269private:
270
271 // Auxiliary method handling deprecation warnings. TODO: Remove after 3.2!
272 Scalar getVelPM_(const Element& element, const SubControlVolumeFace& scvf) const
273 {
274 // Check if the user problem implements the deprecated velocityPorousMedium method
275 DUNE_NO_DEPRECATED_BEGIN
276 static constexpr bool implHasVelocityPorousMedium = !std::is_same<decltype(&Implementation::velocityPorousMedium), decltype(&NavierStokesProblem::velocityPorousMedium)>::value;
277 // This check would always trigger a spurious deprecation warning if the base class' (NavierStokesProblem) velocityPorousMedium method was equipped with a deprecation warning.
278 DUNE_NO_DEPRECATED_END
279
280 // Forward either to user impl (thereby raising a deprecation warning) or return 0.0 by default
281 return deprecationHelper_(element, scvf, std::integral_constant<bool, implHasVelocityPorousMedium>{});
282 }
283
284 [[deprecated("\nvelocityPorousMedium(element, scvf) is deprecated. Use porousMediumVelocity(element, scvf) instead, returning a velocity vector. Will be removed after 3.2")]]
285 Scalar deprecationHelper_(const Element& element, const SubControlVolumeFace& scvf, std::true_type) const
286 { return asImp_().velocityPorousMedium(element, scvf); }
287
288 // Return 0.0 by default. TODO: Remove this after 3.2
289 Scalar deprecationHelper_(const Element& element, const SubControlVolumeFace& scvf, std::false_type) const
290 { return 0.0; }
291
293 Implementation &asImp_()
294 { return *static_cast<Implementation *>(this); }
295
297 const Implementation &asImp_() const
298 { return *static_cast<const Implementation *>(this); }
299
300 GravityVector gravity_;
301 bool enableInertiaTerms_;
302};
303
304} // end namespace Dumux
305
306#endif
Base class for all staggered fv problems.
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
Definition: adapt.hh:29
typename NavierStokesParentProblemImpl< TypeTag, GetPropType< TypeTag, Properties::GridGeometry >::discMethod >::type NavierStokesParentProblem
The actual NavierStokesParentProblem.
Definition: freeflow/navierstokes/problem.hh:48
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
Base class for all staggered finite-volume problems.
Definition: staggeredfvproblem.hh:47
The implementation is specialized for the different discretizations.
Definition: freeflow/navierstokes/problem.hh:36
Navier-Stokes problem base class.
Definition: freeflow/navierstokes/problem.hh:60
Scalar temperature() const
Returns the temperature within the domain.
Definition: freeflow/navierstokes/problem.hh:123
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/problem.hh:164
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/problem.hh:192
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/problem.hh:226
std::enable_if< G::discMethod==DiscretizationMethod::staggered, void >::type applyInitialFaceSolution(SolutionVector &sol, const SubControlVolumeFace &scvf, const PrimaryVariables &initSol) const
Applys the initial face solution (velocities on the faces). Specialization for staggered grid discret...
Definition: freeflow/navierstokes/problem.hh:144
Scalar alphaBJ(const SubControlVolumeFace &scvf) const
Returns the alpha value required as input parameter for the Beavers-Joseph-Saffman boundary condition...
Definition: freeflow/navierstokes/problem.hh:202
const GravityVector & gravity() const
Returns the acceleration due to gravity.
Definition: freeflow/navierstokes/problem.hh:132
Scalar velocityPorousMedium(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/problem.hh:220
std::enable_if< G::discMethod==DiscretizationMethod::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/problem.hh:176
const Scalar beaversJosephVelocity(const Element &element, const SubControlVolume &scv, const SubControlVolumeFace &ownScvf, const SubControlVolumeFace &faceOnPorousBoundary, const Scalar velocitySelf, const Scalar tangentialVelocityGradient) const
helper function to evaluate the slip velocity on the boundary when the Beavers-Joseph condition is us...
Definition: freeflow/navierstokes/problem.hh:248
Scalar betaBJ(const Element &element, const SubControlVolumeFace &scvf) const
Returns the beta value, or the alpha value divided by the square root of the intrinsic permeability.
Definition: freeflow/navierstokes/problem.hh:210
const Scalar beaversJosephVelocity(const Element &element, const SubControlVolume &scv, const SubControlVolumeFace &faceOnPorousBoundary, const Scalar velocitySelf, const Scalar tangentialVelocityGradient) const
helper function to evaluate the slip velocity on the boundary when the Beavers-Joseph condition is us...
Definition: freeflow/navierstokes/problem.hh:234
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Returns the temperature at a given global position.
Definition: freeflow/navierstokes/problem.hh:115
bool enableInertiaTerms() const
Returns whether interia terms should be considered.
Definition: freeflow/navierstokes/problem.hh:138
NavierStokesProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/problem.hh:97
Declares all properties used in Dumux.