version 3.11-dev
freeflow/navierstokes/mass/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// 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_NAVIERSTOKES_MASS_PROBLEM_HH
13#define DUMUX_NAVIERSTOKES_MASS_PROBLEM_HH
14
15#include <dune/common/exceptions.hh>
16#include <dune/common/typetraits.hh>
19#include <dumux/common/boundarytypes_.hh>
23
24namespace Dumux {
25
26// default implementation
27template<class TypeTag, class DiscretizationMethod>
29{
31 using Implementation = GetPropType<TypeTag, Properties::Problem>;
32
34 using GridView = typename GridGeometry::GridView;
35 using FVElementGeometry = typename GridGeometry::LocalView;
36 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
37 using Element = typename GridView::template Codim<0>::Entity;
38 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
39 using VelocityVector = GlobalPosition;
43
44 static constexpr bool isCoupled_ = !std::is_empty_v<CouplingManager>;
45
46public:
47
52 using InitialValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
53 using Sources = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
54 using DirichletValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
55 using BoundaryFluxes = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
56
58 using BoundaryTypes = Dumux::BoundaryTypes<ModelTraits::numEq()>;
59
61 static constexpr bool isMomentumProblem() { return false; }
62
69 NavierStokesMassProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
70 std::shared_ptr<CouplingManager> couplingManager,
71 const std::string& paramGroup = "")
73 , couplingManager_(couplingManager)
74 {}
75
81 NavierStokesMassProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
82 const std::string& paramGroup = "")
84 {}
85
89 VelocityVector faceVelocity(const Element& element,
90 const FVElementGeometry& fvGeometry,
91 const SubControlVolumeFace& scvf) const
92 {
93 if constexpr (isCoupled_)
94 return couplingManager_->faceVelocity(element, scvf);
95 else
96 return asImp_().velocityAtPos(scvf.ipGlobal());
97 }
98
102 template<class IpData>
103 VelocityVector velocity(const FVElementGeometry& fvGeometry, const IpData& ipData) const
104 {
105 if constexpr (isCoupled_)
106 return couplingManager_->velocity(fvGeometry, ipData);
107 else
108 return asImp_().velocityAtPos(ipData.global());
109 }
110
114 VelocityVector elementVelocity(const FVElementGeometry& fvGeometry) const
115 {
116 if constexpr (isCoupled_)
117 return couplingManager_->elementVelocity(fvGeometry);
118 else
119 return asImp_().velocityAtPos(fvGeometry.element().geometry().center());
120 }
121
125 VelocityVector velocityAtPos(const GlobalPosition&) const
126 {
127 DUNE_THROW(Dune::NotImplemented, "velocityAtPos not implemented");
128 }
129
130 const CouplingManager& couplingManager() const
131 {
132 if constexpr (isCoupled_)
133 return *couplingManager_;
134 else
135 DUNE_THROW(Dune::InvalidStateException,
136 "Accessing coupling manager of an uncoupled problem is not possible."
137 );
138 }
139
140private:
142 Implementation &asImp_()
143 { return *static_cast<Implementation *>(this); }
144
146 const Implementation &asImp_() const
147 { return *static_cast<const Implementation *>(this); }
148
149 std::shared_ptr<CouplingManager> couplingManager_;
150};
151
152template<class TypeTag>
154{
156 using Implementation = GetPropType<TypeTag, Properties::Problem>;
157
159 using GridView = typename GridGeometry::GridView;
160 using FVElementGeometry = typename GridGeometry::LocalView;
161 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
162 using Element = typename GridView::template Codim<0>::Entity;
163 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
164 using VelocityVector = GlobalPosition;
168
169 static constexpr bool isCoupled_ = !std::is_empty_v<CouplingManager>;
170
171public:
172
177 using InitialValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
178 using Sources = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
179 using DirichletValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
180 using BoundaryFluxes = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
181
183 using BoundaryTypes = Dumux::Experimental::BoundaryTypes<ModelTraits::numEq()>;
184
186 static constexpr bool isMomentumProblem() { return false; }
187 static constexpr bool providesIntegralInterface() { return true; }
188
195 CVFENavierStokesMassProblem(std::shared_ptr<const GridGeometry> gridGeometry,
196 std::shared_ptr<CouplingManager> couplingManager,
197 const std::string& paramGroup = "")
199 , couplingManager_(couplingManager)
200 {}
201
207 CVFENavierStokesMassProblem(std::shared_ptr<const GridGeometry> gridGeometry,
208 const std::string& paramGroup = "")
210 {}
211
212 using ParentType::source;
228 template<class ElementVariables, class IpData>
229 Sources source(const FVElementGeometry& fvGeometry,
230 const ElementVariables& elemVars,
231 const IpData& ipData) const
232 {
233 return asImp_().sourceAtPos(ipData.global());
234 }
235
243 BoundaryTypes boundaryTypes(const FVElementGeometry& fvGeometry,
244 const FVElementGeometry::BoundaryFace& boundaryFace) const
245 {
246 // forward it to the method which only takes the global coordinate
247 return asImp_().boundaryTypesAtPos(boundaryFace.center());
248 }
249
258 template<class FaceIpData>
259 DirichletValues dirichlet(const FVElementGeometry& fvGeometry,
260 const FaceIpData& faceIpData) const
261 {
262 // forward it to the method which only takes the global coordinate
263 return asImp_().dirichletAtPos(faceIpData.global());
264 }
265
274 template<class ElementVariables, class ElementFluxVariablesCache>
275 [[deprecated("This function is deprecated and will be removed after release 3.11. "
276 "Use boundaryFluxIntegral(fvGeometry, elemVars, scvf) instead.")]]
277 BoundaryFluxes boundaryFluxIntegral(const FVElementGeometry& fvGeometry,
278 const ElementVariables& elemVars,
279 const ElementFluxVariablesCache& elemFluxVarsCache,
280 const SubControlVolumeFace& scvf) const
281 {
282 BoundaryFluxes flux(0.0);
283 for (const auto& qpData : CVFE::quadratureRule(fvGeometry, scvf))
284 flux += qpData.weight() * asImp_().boundaryFlux(fvGeometry, elemVars, elemFluxVarsCache, qpData.ipData());
285
286 return flux * elemVars[fvGeometry.scv(scvf.insideScvIdx())].extrusionFactor();
287 }
288
296 template<class ElementVariables>
297 BoundaryFluxes boundaryFluxIntegral(const FVElementGeometry& fvGeometry,
298 const ElementVariables& elemVars,
299 const SubControlVolumeFace& scvf) const
300 {
301 BoundaryFluxes flux(0.0);
302 for (const auto& qpData : CVFE::quadratureRule(fvGeometry, scvf))
303 flux += qpData.weight() * asImp_().boundaryFlux(fvGeometry, elemVars, qpData.ipData());
304
305 return flux * elemVars[fvGeometry.scv(scvf.insideScvIdx())].extrusionFactor();
306 }
307
316 template<class ElementVariables, class ElementFluxVariablesCache, class FaceIpData>
317 [[deprecated("This function is deprecated and will be removed after release 3.11. "
318 "Use boundaryFlux(fvGeometry, elemVars, scvf) instead.")]]
319 BoundaryFluxes boundaryFlux(const FVElementGeometry& fvGeometry,
320 const ElementVariables& elemVars,
321 const ElementFluxVariablesCache& elemFluxVarsCache,
322 const FaceIpData& faceIpData) const
323 {
324 return asImp_().boundaryFlux(fvGeometry, elemVars, faceIpData);
325 }
326
334 template<class ElementVariables, class FaceIpData>
335 BoundaryFluxes boundaryFlux(const FVElementGeometry& fvGeometry,
336 const ElementVariables& elemVars,
337 const FaceIpData& faceIpData) const
338 {
339 return asImp_().boundaryFluxAtPos(faceIpData.global());
340 }
341
345 BoundaryFluxes boundaryFluxAtPos(const GlobalPosition& globalPos) const
346 { return BoundaryFluxes(0.0); }
347
351 VelocityVector faceVelocity(const Element& element,
352 const FVElementGeometry& fvGeometry,
353 const SubControlVolumeFace& scvf) const
354 {
355 if constexpr (isCoupled_)
356 return couplingManager_->faceVelocity(element, scvf);
357 else
358 return asImp_().velocityAtPos(scvf.ipGlobal());
359 }
360
364 template<class IpData>
365 VelocityVector velocity(const FVElementGeometry& fvGeometry, const IpData& ipData) const
366 {
367 if constexpr (isCoupled_)
368 return couplingManager_->velocity(fvGeometry, ipData);
369 else
370 return asImp_().velocityAtPos(ipData.global());
371 }
372
376 VelocityVector elementVelocity(const FVElementGeometry& fvGeometry) const
377 {
378 if constexpr (isCoupled_)
379 return couplingManager_->elementVelocity(fvGeometry);
380 else
381 return asImp_().velocityAtPos(fvGeometry.element().geometry().center());
382 }
383
387 VelocityVector velocityAtPos(const GlobalPosition&) const
388 {
389 DUNE_THROW(Dune::NotImplemented, "velocityAtPos not implemented");
390 }
391
392 const CouplingManager& couplingManager() const
393 {
394 if constexpr (isCoupled_)
395 return *couplingManager_;
396 else
397 DUNE_THROW(Dune::InvalidStateException,
398 "Accessing coupling manager of an uncoupled problem is not possible."
399 );
400 }
401
402private:
404 Implementation &asImp_()
405 { return *static_cast<Implementation *>(this); }
406
408 const Implementation &asImp_() const
409 { return *static_cast<const Implementation *>(this); }
410
411 std::shared_ptr<CouplingManager> couplingManager_;
412};
413
420template<class TypeTag>
423>;
424
425} // end namespace Dumux
426
427#endif
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:26
Definition: freeflow/navierstokes/mass/problem.hh:154
BoundaryFluxes boundaryFluxIntegral(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolumeFace &scvf) const
Evaluates the boundary flux integral for a scvf.
Definition: freeflow/navierstokes/mass/problem.hh:297
CVFENavierStokesMassProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor for usage without a coupling manager.
Definition: freeflow/navierstokes/mass/problem.hh:207
BoundaryTypes boundaryTypes(const FVElementGeometry &fvGeometry, const FVElementGeometry::BoundaryFace &boundaryFace) const
Specifies which kind of boundary condition should be used for which equation on a given boundary face...
Definition: freeflow/navierstokes/mass/problem.hh:243
BoundaryFluxes boundaryFluxIntegral(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary flux integral for a scvf.
Definition: freeflow/navierstokes/mass/problem.hh:277
CVFENavierStokesMassProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/mass/problem.hh:195
Dune::FieldVector< Scalar, ModelTraits::numEq()> DirichletValues
Definition: freeflow/navierstokes/mass/problem.hh:179
VelocityVector faceVelocity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
A default, i.e. if the user's does not overload any boundaryFlux method.
Definition: freeflow/navierstokes/mass/problem.hh:351
Dune::FieldVector< Scalar, ModelTraits::numEq()> Sources
Definition: freeflow/navierstokes/mass/problem.hh:178
Dune::FieldVector< Scalar, ModelTraits::numEq()> BoundaryFluxes
Definition: freeflow/navierstokes/mass/problem.hh:180
static constexpr bool isMomentumProblem()
this problem is used for the mass balance model
Definition: freeflow/navierstokes/mass/problem.hh:186
VelocityVector velocity(const FVElementGeometry &fvGeometry, const IpData &ipData) const
Returns the velocity at a given interpolation point.
Definition: freeflow/navierstokes/mass/problem.hh:365
BoundaryFluxes boundaryFlux(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const FaceIpData &faceIpData) const
Evaluates the boundary flux related to a localDof at a given interpolation point.
Definition: freeflow/navierstokes/mass/problem.hh:335
BoundaryFluxes boundaryFlux(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const ElementFluxVariablesCache &elemFluxVarsCache, const FaceIpData &faceIpData) const
Evaluates the boundary flux related to a localDof at a given interpolation point.
Definition: freeflow/navierstokes/mass/problem.hh:319
DirichletValues dirichlet(const FVElementGeometry &fvGeometry, const FaceIpData &faceIpData) const
Evaluate the boundary conditions for a Dirichlet control volume.
Definition: freeflow/navierstokes/mass/problem.hh:259
Sources source(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const IpData &ipData) const
Evaluate the source term at a given interpolation point, related to the residual of a local dof.
Definition: freeflow/navierstokes/mass/problem.hh:229
static constexpr bool providesIntegralInterface()
Definition: freeflow/navierstokes/mass/problem.hh:187
Dune::FieldVector< Scalar, ModelTraits::numEq()> InitialValues
Definition: freeflow/navierstokes/mass/problem.hh:177
BoundaryFluxes boundaryFluxAtPos(const GlobalPosition &globalPos) const
Returns the boundary flux at a given position.
Definition: freeflow/navierstokes/mass/problem.hh:345
VelocityVector velocityAtPos(const GlobalPosition &) const
Returns the velocity at a given position.
Definition: freeflow/navierstokes/mass/problem.hh:387
const CouplingManager & couplingManager() const
Definition: freeflow/navierstokes/mass/problem.hh:392
VelocityVector elementVelocity(const FVElementGeometry &fvGeometry) const
Returns the velocity at the element center.
Definition: freeflow/navierstokes/mass/problem.hh:376
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:43
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:524
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition: common/fvproblem.hh:178
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:520
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:307
Base class for all finite-volume problems using spatial parameters.
Definition: fvproblemwithspatialparams.hh:29
Definition: freeflow/navierstokes/mass/problem.hh:29
VelocityVector elementVelocity(const FVElementGeometry &fvGeometry) const
Returns the velocity at the element center.
Definition: freeflow/navierstokes/mass/problem.hh:114
Dune::FieldVector< Scalar, ModelTraits::numEq()> BoundaryFluxes
Definition: freeflow/navierstokes/mass/problem.hh:55
const CouplingManager & couplingManager() const
Definition: freeflow/navierstokes/mass/problem.hh:130
VelocityVector faceVelocity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the normal velocity at a given sub control volume face.
Definition: freeflow/navierstokes/mass/problem.hh:89
VelocityVector velocity(const FVElementGeometry &fvGeometry, const IpData &ipData) const
Returns the velocity at a given interpolation point.
Definition: freeflow/navierstokes/mass/problem.hh:103
Dune::FieldVector< Scalar, ModelTraits::numEq()> DirichletValues
Definition: freeflow/navierstokes/mass/problem.hh:54
NavierStokesMassProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor for usage without a coupling manager.
Definition: freeflow/navierstokes/mass/problem.hh:81
Dune::FieldVector< Scalar, ModelTraits::numEq()> Sources
Definition: freeflow/navierstokes/mass/problem.hh:53
NavierStokesMassProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/mass/problem.hh:69
VelocityVector velocityAtPos(const GlobalPosition &) const
Returns the velocity at a given position.
Definition: freeflow/navierstokes/mass/problem.hh:125
Dune::FieldVector< Scalar, ModelTraits::numEq()> InitialValues
Definition: freeflow/navierstokes/mass/problem.hh:52
static constexpr bool isMomentumProblem()
this problem is used for the mass balance model
Definition: freeflow/navierstokes/mass/problem.hh:61
Defines all properties used in Dumux.
Base class for all finite volume problems that are parameterized.
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition: quadraturerules.hh:159
Definition: adapt.hh:17
A helper to deduce a vector with the same size as numbers of equations.
Quadrature rules over sub-control volumes and sub-control volume faces.