12#ifndef DUMUX_MATERIAL_FLUIDMATRIX_DISPERSIONTENSORS_SCHEIDEGGER_HH
13#define DUMUX_MATERIAL_FLUIDMATRIX_DISPERSIONTENSORS_SCHEIDEGGER_HH
17#include <dune/common/math.hh>
18#include <dune/common/std/type_traits.hh>
19#include <dune/common/fmatrix.hh>
29template <
class Problem,
class SubControlVolumeFace>
32template<
class Problem,
class SubControlVolumeFace>
34{
return Dune::Std::is_detected<HasVelocityInSpatialParams, Problem, SubControlVolumeFace>::value; }
41template<
class TypeTag>
46 using FVElementGeometry =
typename GridGeometry::LocalView;
47 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
52 static const int dimWorld = GridView::dimensionworld;
53 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
60 template <
class ElementFluxVariablesCache>
62 const SubControlVolumeFace& scvf,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const ElementFluxVariablesCache& elemFluxVarsCache,
69 DimWorldMatrix dispersionTensor(0.0);
72 auto velocity = dispersionVelocity_(problem, scvf, fvGeometry, elemVolVars, elemFluxVarsCache);
75 std::array<Scalar,2> dispersivity = problem.spatialParams().dispersionAlphas(scvf.center(), phaseIdx, compIdx);
77 return scheideggerTensor_(dispersivity, velocity);
80 template <
class ElementFluxVariablesCache>
82 const SubControlVolumeFace& scvf,
83 const FVElementGeometry& fvGeometry,
84 const ElementVolumeVariables& elemVolVars,
85 const ElementFluxVariablesCache& elemFluxVarsCache,
88 DimWorldMatrix dispersionTensor(0.0);
91 auto velocity = dispersionVelocity_(problem, scvf, fvGeometry, elemVolVars, elemFluxVarsCache);
94 std::array<Scalar,2> dispersivity = problem.spatialParams().dispersionAlphas(scvf.center(), phaseIdx);
96 return scheideggerTensor_(dispersivity, velocity);
101 template <
class ElementFluxVariablesCache>
102 static Dune::FieldVector<Scalar, dimWorld> dispersionVelocity_(
const Problem& problem,
103 const SubControlVolumeFace& scvf,
104 [[maybe_unused]]
const FVElementGeometry& fvGeometry,
105 [[maybe_unused]]
const ElementVolumeVariables& elemVolVars,
106 [[maybe_unused]]
const ElementFluxVariablesCache& elemFluxVarsCache)
109 Dune::FieldVector<Scalar, dimWorld> velocity(0.0);
110 if constexpr (stationaryVelocityField)
112 if constexpr (!Detail::hasVelocityInSpatialParams<Problem,SubControlVolumeFace>() )
113 DUNE_THROW(Dune::NotImplemented,
"\n Please provide the stationary velocity field in the spatialparams via a velocity function.");
115 velocity = problem.spatialParams().velocity(scvf);
121 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
122 const auto& shapeValues = fluxVarsCache.shapeValues();
125 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
126 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
128 outsideVolVars.permeability(),
129 scvf.unitOuterNormal());
132 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
134 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(),
"Problem.EnableGravity");
135 for (
auto&& scv : scvs(fvGeometry))
137 const auto& volVars = elemVolVars[scv];
140 rho += volVars.density(0)*shapeValues[scv.indexInElement()][0];
142 gradP.axpy(volVars.pressure(0), fluxVarsCache.gradN(scv.indexInElement()));
146 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
151 velocity /= -0.5 * (insideVolVars.viscosity() + outsideVolVars.viscosity());
154 DUNE_THROW(Dune::NotImplemented,
"\n Scheidegger Dispersion for compositional models without given constant velocity field is only implemented using the Box method.");
160 static DimWorldMatrix scheideggerTensor_(
const std::array<Scalar,2>& dispersivity,
161 const Dune::FieldVector<Scalar, dimWorld>& velocity)
163 DimWorldMatrix scheideggerTensor(0.0);
166 for (
int i=0; i < dimWorld; i++)
167 for (
int j = 0; j < dimWorld; j++)
168 scheideggerTensor[i][j] = velocity[i]*velocity[j];
171 Scalar vNorm = velocity.two_norm();
173 scheideggerTensor /= vNorm;
175 scheideggerTensor = 0;
178 scheideggerTensor *= (dispersivity[0] - dispersivity[1]);
181 for (
int i = 0; i < dimWorld; i++)
182 scheideggerTensor[i][i] += vNorm*dispersivity[1];
184 return scheideggerTensor;
Scheidegger's dispersion tensor.
Definition: scheidegger.hh:43
static DimWorldMatrix compositionalDispersionTensor(const Problem &problem, const SubControlVolumeFace &scvf, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const int phaseIdx, const int compIdx)
Definition: scheidegger.hh:61
static DimWorldMatrix thermalDispersionTensor(const Problem &problem, const SubControlVolumeFace &scvf, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const int phaseIdx)
Definition: scheidegger.hh:81
Defines all properties used in Dumux.
A free function to average a Tensor at an interface.
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
decltype(std::declval< Problem >().spatialParams().velocity(std::declval< SubControlVolumeFace >())) HasVelocityInSpatialParams
Definition: scheidegger.hh:30
static constexpr bool hasVelocityInSpatialParams()
Definition: scheidegger.hh:33
constexpr Box box
Definition: method.hh:147
Scalar faceTensorAverage(const Scalar T1, const Scalar T2, const Dune::FieldVector< Scalar, dim > &normal)
Average of a discontinuous scalar field at discontinuity interface (for compatibility reasons with th...
Definition: facetensoraverage.hh:29
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Traits of a flux variables type.
Definition: flux/traits.hh:32
static constexpr bool hasStationaryVelocityField()
Definition: flux/traits.hh:33