24#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_CVFE_FLUXVARIABLES_HH
25#define DUMUX_NAVIERSTOKES_MOMENTUM_CVFE_FLUXVARIABLES_HH
27#include <dune/common/fmatrix.hh>
46template<
class Problem,
47 class FVElementGeometry,
48 class ElementVolumeVariables,
49 class ElementFluxVariablesCache>
52 using Element =
typename FVElementGeometry::Element;
53 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
62 const SubControlVolumeFace& scvf
75 {
return fvGeometry_.element(); }
77 const SubControlVolumeFace&
scvFace()
const
81 {
return fvGeometry_; }
84 {
return elemVolVars_; }
87 {
return elemFluxVarsCache_; }
90 const Problem& problem_;
91 const FVElementGeometry& fvGeometry_;
92 const ElementVolumeVariables& elemVolVars_;
93 const ElementFluxVariablesCache& elemFluxVarsCache_;
94 const SubControlVolumeFace& scvf_;
101template<
class Gr
idGeometry,
class NumEqVector>
104 using GridView =
typename GridGeometry::GridView;
105 using Element =
typename GridView::template Codim<0>::Entity;
106 using Scalar =
typename NumEqVector::value_type;
110 static constexpr int dim = GridView::dimension;
111 static constexpr int dimWorld = GridView::dimensionworld;
113 using Tensor = Dune::FieldMatrix<Scalar, dim, dimWorld>;
114 static_assert(NumEqVector::dimension == dimWorld,
"Wrong dimension of velocity vector");
120 template<
class Context>
123 if (!context.problem().enableInertiaTerms())
126 const auto& fvGeometry = context.fvGeometry();
127 const auto& elemVolVars = context.elemVolVars();
128 const auto& scvf = context.scvFace();
129 const auto& fluxVarCache = context.elemFluxVarsCache()[scvf];
130 const auto& shapeValues = fluxVarCache.shapeValues();
134 for (
const auto& scv : scvs(fvGeometry))
135 v.axpy(shapeValues[scv.indexInElement()][0], elemVolVars[scv].velocity());
138 const Scalar
density = context.problem().density(context.element(), context.fvGeometry(), scvf);
140 const auto vn = v*scvf.unitOuterNormal();
141 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
142 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
143 const auto upwindVelocity = vn > 0 ? insideVolVars.velocity() : outsideVolVars.velocity();
144 const auto downwindVelocity = vn > 0 ? outsideVolVars.velocity() : insideVolVars.velocity();
145 static const auto upwindWeight = getParamFromGroup<Scalar>(context.problem().paramGroup(),
"Flux.UpwindWeight");
146 const auto advectiveTermIntegrand =
density*vn * (upwindWeight * upwindVelocity + (1.0-upwindWeight)*downwindVelocity);
148 return advectiveTermIntegrand * Extrusion::area(fvGeometry, scvf) * insideVolVars.extrusionFactor();
154 template<
class Context>
157 const auto& element = context.element();
158 const auto& fvGeometry = context.fvGeometry();
159 const auto& elemVolVars = context.elemVolVars();
160 const auto& scvf = context.scvFace();
161 const auto& fluxVarCache = context.elemFluxVarsCache()[scvf];
165 for (
const auto& scv : scvs(fvGeometry))
167 const auto& volVars = elemVolVars[scv];
168 for (
int dir = 0; dir < dim; ++dir)
169 gradV[dir].axpy(volVars.velocity(dir), fluxVarCache.gradN(scv.indexInElement()));
173 const auto mu = context.problem().effectiveViscosity(element, fvGeometry, scvf);
175 static const bool enableUnsymmetrizedVelocityGradient
176 = getParamFromGroup<bool>(context.problem().paramGroup(),
"FreeFlow.EnableUnsymmetrizedVelocityGradient",
false);
179 NumEqVector diffusiveFlux = enableUnsymmetrizedVelocityGradient ?
180 mv(gradV, scvf.unitOuterNormal())
183 diffusiveFlux *= -mu;
185 static const bool enableDilatationTerm = getParamFromGroup<bool>(context.problem().paramGroup(),
"FreeFlow.EnableDilatationTerm",
false);
186 if (enableDilatationTerm)
187 diffusiveFlux += 2.0/3.0 * mu *
trace(gradV) * scvf.unitOuterNormal();
189 diffusiveFlux *= Extrusion::area(fvGeometry, scvf) * elemVolVars[scvf.insideScvIdx()].extrusionFactor();
190 return diffusiveFlux;
193 template<
class Context>
196 const auto& element = context.element();
197 const auto& fvGeometry = context.fvGeometry();
198 const auto& elemVolVars = context.elemVolVars();
199 const auto& scvf = context.scvFace();
202 const auto pressure = context.problem().pressure(element, fvGeometry, scvf);
208 const auto referencePressure = context.problem().referencePressure();
211 pn *= (
pressure-referencePressure)*Extrusion::area(fvGeometry, scvf)*elemVolVars[scvf.insideScvIdx()].extrusionFactor();
Some exceptions thrown in DuMux
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Define some often used mathematical functions.
Helper classes to compute the integration elements.
Dune::DenseVector< V >::derived_type mv(const Dune::DenseMatrix< MAT > &M, const Dune::DenseVector< V > &v)
Returns the result of the projection of a vector v with a Matrix M.
Definition: math.hh:812
Dune::DenseMatrix< MatrixType >::field_type trace(const Dune::DenseMatrix< MatrixType > &M)
Trace of a dense matrix.
Definition: math.hh:783
Dune::FieldMatrix< Scalar, n, m > getTransposed(const Dune::FieldMatrix< Scalar, m, n > &M)
Transpose a FieldMatrix.
Definition: math.hh:695
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:46
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Context for computing fluxes.
Definition: flux.hh:51
const Element & element() const
Definition: flux.hh:74
const FVElementGeometry & fvGeometry() const
Definition: flux.hh:80
NavierStokesMomentumFluxContext(const Problem &problem, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf)
Initialize the flux variables storing some temporary pointers.
Definition: flux.hh:57
const SubControlVolumeFace & scvFace() const
Definition: flux.hh:77
const ElementVolumeVariables & elemVolVars() const
Definition: flux.hh:83
const ElementFluxVariablesCache & elemFluxVarsCache() const
Definition: flux.hh:86
const Problem & problem() const
Definition: flux.hh:71
The flux variables class for the Navier-Stokes model using control-volume finite element schemes.
Definition: flux.hh:103
NumEqVector advectiveMomentumFlux(const Context &context) const
Returns the diffusive momentum flux due to viscous forces.
Definition: flux.hh:121
NumEqVector diffusiveMomentumFlux(const Context &context) const
Returns the diffusive momentum flux due to viscous forces.
Definition: flux.hh:155
NumEqVector pressureContribution(const Context &context) const
Definition: flux.hh:194