24#ifndef DUMUX_EVALCFLFLUX_DEFAULT_HH
25#define DUMUX_EVALCFLFLUX_DEFAULT_HH
39template<
class TypeTag>
51 wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx
56 vt = Indices::velocityTotal
59 using Element =
typename GridView::Traits::template Codim<0>::Entity;
60 using Intersection =
typename GridView::Intersection;
69 void addFlux(Scalar& lambdaW, Scalar& lambdaNw, Scalar& viscosityW, Scalar& viscosityNw, Scalar flux,
70 const Element& element,
int phaseIdx = -1)
72 addFlux(lambdaW, lambdaNw, viscosityW, viscosityNw, flux, phaseIdx);
80 void addFlux(Scalar& lambdaW, Scalar& lambdaNw, Scalar& viscosityW, Scalar& viscosityNw, Scalar flux,
81 const Intersection& intersection,
int phaseIdx = -1)
83 addFlux(lambdaW, lambdaNw, viscosityW, viscosityNw, flux, phaseIdx);
98 Scalar
getDt(
const Element& element)
101 Scalar
porosity = max(problem_.spatialParams().porosity(element), porosityThreshold_);
110 fluxNonwettingOut_ = 0;
123 porosityThreshold_ = getParam<Scalar>(
"Impet.PorosityThreshold");
129 void addFlux(Scalar& lambdaW, Scalar& lambdaNw, Scalar& viscosityW, Scalar& viscosityNw, Scalar flux,
int phaseIdx = -1)
132 Scalar krSum = lambdaW * viscosityW + lambdaNw * viscosityNw;
133 Scalar viscosityRatio = 1 - abs(0.5 - viscosityNw / (viscosityW + viscosityNw));
143 fluxWettingOut_ += flux / (krSum * viscosityRatio);
147 fluxIn_ -= flux / (krSum * viscosityRatio);
158 fluxNonwettingOut_ += flux / (krSum * viscosityRatio);
162 fluxIn_ -= flux / (krSum * viscosityRatio);
171 fluxOut_ += flux / (krSum * viscosityRatio);
175 fluxIn_ -= flux / (krSum * viscosityRatio);
184 Scalar getCFLFluxIn(
int phaseIdx = 0)
188 if (isnan(fluxIn_) || isinf(fluxIn_))
197 Scalar getCFLFluxOut(
int phaseIdx = 0)
201 if (isnan(fluxWettingOut_) || isinf(fluxWettingOut_))
203 fluxWettingOut_ = 1e-100;
206 if (isnan(fluxNonwettingOut_) || isinf(fluxNonwettingOut_))
208 fluxNonwettingOut_ = 1e-100;
210 if (isnan(fluxOut_) || isinf(fluxOut_))
215 if (phaseIdx == wPhaseIdx)
216 return fluxWettingOut_;
217 else if (phaseIdx == nPhaseIdx)
218 return fluxNonwettingOut_;
224 Scalar fluxWettingOut_;
225 Scalar fluxNonwettingOut_;
228 Scalar porosityThreshold_;
229 static const int velocityType_ = getPropValue<TypeTag, Properties::VelocityFormulation>();
230 static const int saturationType_ = getPropValue<TypeTag, Properties::SaturationFormulation>();
234template<
class TypeTag>
237 Scalar residualSatW = problem_.spatialParams().materialLawParams(element).swr();
238 Scalar residualSatNw = problem_.spatialParams().materialLawParams(element).snr();
241 Scalar volumeCorrectionFactor = 1 - residualSatW - residualSatNw;
242 Scalar volumeCorrectionFactorOutW = 0;
243 Scalar volumeCorrectionFactorOutNw = 0;
245 Scalar satW = problem_.variables().cellData(problem_.variables().index(element)).saturation(wPhaseIdx);
247 volumeCorrectionFactorOutW = max((satW - residualSatW), 1e-2);
248 volumeCorrectionFactorOutNw = max((1 - satW - residualSatNw), 1e-2);
251 if (volumeCorrectionFactorOutW <= 0)
253 volumeCorrectionFactorOutW = 1e100;
255 if (volumeCorrectionFactorOutNw <= 0)
257 volumeCorrectionFactorOutNw = 1e100;
261 Scalar cFLFluxIn = volumeCorrectionFactor / getCFLFluxIn();
262 Scalar cFLFluxOut = 0;
265 if (velocityType_ == vt)
267 cFLFluxOut = volumeCorrectionFactor / getCFLFluxOut(-1);
271 cFLFluxOut = min(volumeCorrectionFactorOutW / getCFLFluxOut(wPhaseIdx),
272 volumeCorrectionFactorOutNw / getCFLFluxOut(nPhaseIdx));
276 Scalar cFLFluxFunction = min(cFLFluxIn, cFLFluxOut);
278 return cFLFluxFunction;
Base class for implementations of different kinds of fluxes to evaluate a CFL-Condition.
Base file for properties related to sequential IMPET algorithms.
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
std::string porosity() noexcept
I/O name of porosity.
Definition: name.hh:139
Base class for implementations of different kinds of fluxes to evaluate a CFL-Condition.
Definition: evalcflflux.hh:52
Default implementation of cfl-fluxes to evaluate a CFL-Condition.
Definition: evalcflfluxdefault.hh:41
EvalCflFluxDefault(Problem &problem)
Constructs an EvalCflFluxDefault object.
Definition: evalcflfluxdefault.hh:120
Scalar getCflFluxFunction(const Element &element)
Returns the CFL flux-function.
Definition: evalcflfluxdefault.hh:235
void addFlux(Scalar &lambdaW, Scalar &lambdaNw, Scalar &viscosityW, Scalar &viscosityNw, Scalar flux, const Element &element, int phaseIdx=-1)
adds a flux to the cfl-criterion evaluation
Definition: evalcflfluxdefault.hh:69
void reset()
resets the accumulated CFL-fluxes to zero
Definition: evalcflfluxdefault.hh:107
Scalar getDt(const Element &element)
Returns the CFL time-step.
Definition: evalcflfluxdefault.hh:98
void addFlux(Scalar &lambdaW, Scalar &lambdaNw, Scalar &viscosityW, Scalar &viscosityNw, Scalar flux, const Intersection &intersection, int phaseIdx=-1)
adds a flux to the cfl-criterion evaluation
Definition: evalcflfluxdefault.hh:80