24#ifndef DUMUX_MATERIAL_FLUIDMATRIX_TWOP_SPLINE_MATERIAL_LAW_HH
25#define DUMUX_MATERIAL_FLUIDMATRIX_TWOP_SPLINE_MATERIAL_LAW_HH
46template<
class TwoPMaterialLaw,
bool approximatePcSwInverse = false>
49,
public Adapter<SplineTwoPMaterialLaw<TwoPMaterialLaw, approximatePcSwInverse>, PcKrSw>
84 const std::array<Scalar, 2> defaultInterval{{ 0.01, 1.0 }};
85 const auto sweInterval = getParamFromGroup<std::array<Scalar, 2>>(paramGroup,
"SplineSweInterval", defaultInterval);
86 swInterval_ = {{ TwoPMaterialLaw::EffToAbs::sweToSw(sweInterval[0], this->
effToAbsParams()),
87 TwoPMaterialLaw::EffToAbs::sweToSw(sweInterval[1], this->
effToAbsParams()) }};
90 numSwSamples_ = getParamFromGroup<std::size_t>(paramGroup,
"SplineNumSwSamples", 30);
92 pcSpline_ = makeSweSpline_(
94 approximatePcSwInverse
97 krwSpline_ = makeSweSpline_(
101 krnSpline_ = makeSweSpline_(
111 std::size_t numSwSamples,
114 , numSwSamples_(numSwSamples)
116 swInterval_ = {{ TwoPMaterialLaw::EffToAbs::sweToSw(sweInterval[0], this->
effToAbsParams()),
117 TwoPMaterialLaw::EffToAbs::sweToSw(sweInterval[1], this->
effToAbsParams()) }};
127 if (
sw > swInterval_[0] &&
sw < swInterval_[1])
129 if constexpr (approximatePcSwInverse)
130 return pcSpline_->evalInverse(
sw);
132 return pcSpline_->eval(
sw);
143 if (
sw > swInterval_[0] &&
sw < swInterval_[1])
145 if constexpr (approximatePcSwInverse)
146 return 1.0/pcSpline_->evalDerivative(pcSpline_->evalInverse(
sw));
148 return pcSpline_->evalDerivative(
sw);
159 if (
pc > swIntervalPc_[0] &&
pc < swIntervalPc_[1])
161 if constexpr (approximatePcSwInverse)
162 return pcSpline_->eval(
pc);
164 return pcSpline_->evalInverse(
pc);
175 if (
pc > swIntervalPc_[0] &&
pc < swIntervalPc_[1])
177 if constexpr (approximatePcSwInverse)
178 return pcSpline_->evalDerivative(
pc);
180 return 1.0/pcSpline_->evalDerivative(pcSpline_->evalInverse(
pc));
191 if (
sw > swInterval_[0] &&
sw < swInterval_[1])
192 return krwSpline_->eval(
sw);
202 if (
sw > swInterval_[0] &&
sw < swInterval_[1])
203 return krwSpline_->evalDerivative(
sw);
213 if (
sw > swInterval_[0] &&
sw < swInterval_[1])
214 return krnSpline_->eval(
sw);
224 if (
sw > swInterval_[0] &&
sw < swInterval_[1])
225 return krnSpline_->evalDerivative(
sw);
231 template<
class Function>
232 std::unique_ptr<MonotoneCubicSpline<Scalar>>
233 makeSweSpline_(
const Function& f,
bool invert =
false)
const
235 const auto sw =
linspace(swInterval_[0], swInterval_[1], numSwSamples_);
238 std::transform(
sw.begin(),
sw.end(), values.begin(), f);
241 return std::make_unique<MonotoneCubicSpline<Scalar>>(values,
sw);
243 return std::make_unique<MonotoneCubicSpline<Scalar>>(
sw, values);
246 std::unique_ptr<MonotoneCubicSpline<Scalar>> pcSpline_;
247 std::unique_ptr<MonotoneCubicSpline<Scalar>> krwSpline_;
248 std::unique_ptr<MonotoneCubicSpline<Scalar>> krnSpline_;
250 std::array<Scalar, 2> swInterval_;
251 std::array<Scalar, 2> swIntervalPc_;
252 std::size_t numSwSamples_;
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Implementation helper for capillary pressure and relative permeability <-> saturation relations for t...
Wrapper type to combine an arbitrary number of different laws for fluid-matrix interaction (e....
std::vector< Scalar > linspace(const Scalar begin, const Scalar end, std::size_t samples, bool endPoint=true)
Generates linearly spaced vectors.
Definition: math.hh:594
Definition: brookscorey.hh:35
Wrapper class to implement regularized material laws (pc-sw, kr-sw) with a conversion policy between ...
Definition: materiallaw.hh:57
Scalar dsw_dpc(const Scalar pc) const
The partial derivative of the saturation to the capillary pressure.
Definition: materiallaw.hh:174
Scalar dkrn_dsw(const Scalar sw) const
The derivative of the relative permeability for the non-wetting phase w.r.t. saturation.
Definition: materiallaw.hh:241
ScalarType Scalar
Definition: materiallaw.hh:60
Scalar krn(const Scalar sw) const
The relative permeability for the non-wetting phase.
Definition: materiallaw.hh:224
Scalar dkrw_dsw(const Scalar sw) const
The derivative of the relative permeability for the wetting phase w.r.t. saturation.
Definition: materiallaw.hh:207
typename Regularization::template Params< Scalar > RegularizationParams
Definition: materiallaw.hh:64
const EffToAbsParams & effToAbsParams() const
Return the parameters of the EffToAbs policy.
Definition: materiallaw.hh:291
Scalar dpc_dsw(const Scalar sw) const
The partial derivative of the capillary pressure w.r.t. the saturation.
Definition: materiallaw.hh:133
Scalar sw(const Scalar pc) const
The saturation-capillary pressure curve.
Definition: materiallaw.hh:158
typename EffToAbsPolicy::template Params< Scalar > EffToAbsParams
Definition: materiallaw.hh:63
typename BaseLaw::template Params< Scalar > BasicParams
Definition: materiallaw.hh:62
Scalar pc(const Scalar sw) const
The capillary pressure-saturation curve.
Definition: materiallaw.hh:116
Scalar krw(const Scalar sw) const
The relative permeability for the wetting phase.
Definition: materiallaw.hh:190
A spline approximation wrapper for 2p material laws.
Definition: splinemateriallaw.hh:50
static constexpr bool isRegularized()
We are always regularized in the sense that we replace the orginal curve by a cubic spline.
Definition: splinemateriallaw.hh:68
Scalar dkrn_dsw(const Scalar sw) const
The derivative of the relative permeability for the non-wetting phase w.r.t. saturation.
Definition: splinemateriallaw.hh:222
Scalar pc(const Scalar sw) const
The capillary pressure-saturation curve.
Definition: splinemateriallaw.hh:125
static constexpr int numFluidPhases()
Return the number of fluid phases.
Definition: splinemateriallaw.hh:61
typename TwoPMaterialLaw::Scalar Scalar
Definition: splinemateriallaw.hh:52
SplineTwoPMaterialLaw(const std::string ¶mGroup)
Construct from a subgroup from the global parameter tree.
Definition: splinemateriallaw.hh:81
SplineTwoPMaterialLaw(const std::array< Scalar, 2 > &sweInterval, std::size_t numSwSamples, TwoPMaterialLaw &&twoP)
Construct from parameter structs.
Definition: splinemateriallaw.hh:110
Scalar dsw_dpc(const Scalar pc) const
The partial derivative of the saturation to the capillary pressure.
Definition: splinemateriallaw.hh:173
Scalar krn(const Scalar sw) const
The relative permeability for the non-wetting phase.
Definition: splinemateriallaw.hh:211
Scalar krw(const Scalar sw) const
The relative permeability for the wetting phase.
Definition: splinemateriallaw.hh:189
Scalar dkrw_dsw(const Scalar sw) const
The derivative of the relative permeability for the wetting phase w.r.t. saturation.
Definition: splinemateriallaw.hh:200
SplineTwoPMaterialLaw()=delete
Deleted default constructor (so we are never in an undefined state)
Scalar dpc_dsw(const Scalar sw) const
The partial derivative of the capillary pressure w.r.t. the saturation.
Definition: splinemateriallaw.hh:141
Scalar sw(const Scalar pc) const
The saturation-capillary pressure curve.
Definition: splinemateriallaw.hh:157
Adapter to inherit from, allowing the inheriting class to be wrapped by the makeFluidMatrixInteractio...
Definition: fluidmatrixinteraction.hh:67