24#ifndef DUMUX_MATERIAL_FLUIDMATRIX_DISPERSIONTENSORS_SCHEIDEGGER_HH
25#define DUMUX_MATERIAL_FLUIDMATRIX_DISPERSIONTENSORS_SCHEIDEGGER_HH
29#include <dune/common/math.hh>
30#include <dune/common/std/type_traits.hh>
31#include <dune/common/fmatrix.hh>
41template <
class Problem,
class SubControlVolumeFace>
44template<
class Problem,
class SubControlVolumeFace>
46{
return Dune::Std::is_detected<HasVelocityInSpatialParams, Problem, SubControlVolumeFace>::value; }
49template<
class TypeTag>
54 using FVElementGeometry =
typename GridGeometry::LocalView;
55 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
60 static const int dimWorld = GridView::dimensionworld;
61 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
68 template <
class ElementFluxVariablesCache>
70 const SubControlVolumeFace& scvf,
71 const FVElementGeometry& fvGeometry,
72 const ElementVolumeVariables& elemVolVars,
73 const ElementFluxVariablesCache& elemFluxVarsCache,
77 DimWorldMatrix dispersionTensor(0.0);
80 auto velocity = dispersionVelocity_(problem, scvf, fvGeometry, elemVolVars, elemFluxVarsCache);
83 std::array<Scalar,2> dispersivity = problem.spatialParams().dispersionAlphas(scvf.center(), phaseIdx, compIdx);
85 return scheideggerTensor_(dispersivity, velocity);
88 template <
class ElementFluxVariablesCache>
90 const SubControlVolumeFace& scvf,
91 const FVElementGeometry& fvGeometry,
92 const ElementVolumeVariables& elemVolVars,
93 const ElementFluxVariablesCache& elemFluxVarsCache,
96 DimWorldMatrix dispersionTensor(0.0);
99 auto velocity = dispersionVelocity_(problem, scvf, fvGeometry, elemVolVars, elemFluxVarsCache);
102 std::array<Scalar,2> dispersivity = problem.spatialParams().dispersionAlphas(scvf.center(), phaseIdx);
104 return scheideggerTensor_(dispersivity, velocity);
109 template <
class ElementFluxVariablesCache>
110 static Dune::FieldVector<Scalar, dimWorld> dispersionVelocity_(
const Problem& problem,
111 const SubControlVolumeFace& scvf,
112 [[maybe_unused]]
const FVElementGeometry& fvGeometry,
113 [[maybe_unused]]
const ElementVolumeVariables& elemVolVars,
114 [[maybe_unused]]
const ElementFluxVariablesCache& elemFluxVarsCache)
117 Dune::FieldVector<Scalar, dimWorld> velocity(0.0);
118 if constexpr (stationaryVelocityField)
120 if constexpr (!Detail::hasVelocityInSpatialParams<Problem,SubControlVolumeFace>() )
121 DUNE_THROW(Dune::NotImplemented,
"\n Please provide the stationary velocity field in the spatialparams via a velocity function.");
123 velocity = problem.spatialParams().velocity(scvf);
129 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
130 const auto& shapeValues = fluxVarsCache.shapeValues();
133 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
134 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
136 outsideVolVars.permeability(),
137 scvf.unitOuterNormal());
140 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
142 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(),
"Problem.EnableGravity");
143 for (
auto&& scv : scvs(fvGeometry))
145 const auto& volVars = elemVolVars[scv];
148 rho += volVars.density(0)*shapeValues[scv.indexInElement()][0];
150 gradP.axpy(volVars.pressure(0), fluxVarsCache.gradN(scv.indexInElement()));
154 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
159 velocity /= -0.5 * (insideVolVars.viscosity() + outsideVolVars.viscosity());
162 DUNE_THROW(Dune::NotImplemented,
"\n Scheidegger Dispersion for compositional models without given constant velocity field is only implemented using the Box method.");
168 static DimWorldMatrix scheideggerTensor_(
const std::array<Scalar,2>& dispersivity,
169 const Dune::FieldVector<Scalar, dimWorld>& velocity)
171 DimWorldMatrix scheideggerTensor(0.0);
174 for (
int i=0; i < dimWorld; i++)
175 for (
int j = 0; j < dimWorld; j++)
176 scheideggerTensor[i][j] = velocity[i]*velocity[j];
179 Scalar vNorm = velocity.two_norm();
181 scheideggerTensor /= vNorm;
183 scheideggerTensor = 0;
186 scheideggerTensor *= (dispersivity[0] - dispersivity[1]);
189 for (
int i = 0; i < dimWorld; i++)
190 scheideggerTensor[i][i] += vNorm*dispersivity[1];
192 return scheideggerTensor;
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
A free function to average a Tensor at an interface.
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:41
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
decltype(std::declval< Problem >().spatialParams().velocity(std::declval< SubControlVolumeFace >())) HasVelocityInSpatialParams
Definition: scheidegger.hh:42
static constexpr bool hasVelocityInSpatialParams()
Definition: scheidegger.hh:45
constexpr Box box
Definition: method.hh:139
Traits of a flux variables type.
Definition: flux/traits.hh:44
static constexpr bool hasStationaryVelocityField()
Definition: flux/traits.hh:45
Definition: scheidegger.hh:51
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:69
static DimWorldMatrix thermalDispersionTensor(const Problem &problem, const SubControlVolumeFace &scvf, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const int phaseIdx)
Definition: scheidegger.hh:89
Declares all properties used in Dumux.