24#ifndef DUMUX_EVALCFLFLUX_DEFAULT_HH
25#define DUMUX_EVALCFLFLUX_DEFAULT_HH
41template<
class TypeTag>
53 wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx
58 vt = Indices::velocityTotal
61 using Element =
typename GridView::Traits::template Codim<0>::Entity;
62 using Intersection =
typename GridView::Intersection;
71 void addFlux(Scalar& lambdaW, Scalar& lambdaNw, Scalar& viscosityW, Scalar& viscosityNw, Scalar flux,
72 const Element& element,
int phaseIdx = -1)
74 addFlux(lambdaW, lambdaNw, viscosityW, viscosityNw, flux, phaseIdx);
82 void addFlux(Scalar& lambdaW, Scalar& lambdaNw, Scalar& viscosityW, Scalar& viscosityNw, Scalar flux,
83 const Intersection& intersection,
int phaseIdx = -1)
85 addFlux(lambdaW, lambdaNw, viscosityW, viscosityNw, flux, phaseIdx);
100 Scalar
getDt(
const Element& element)
103 Scalar
porosity = max(problem_.spatialParams().porosity(element), porosityThreshold_);
112 fluxNonwettingOut_ = 0;
125 porosityThreshold_ = getParam<Scalar>(
"Impet.PorosityThreshold");
131 void addFlux(Scalar& lambdaW, Scalar& lambdaNw, Scalar& viscosityW, Scalar& viscosityNw, Scalar flux,
int phaseIdx = -1)
134 Scalar krSum = lambdaW * viscosityW + lambdaNw * viscosityNw;
135 Scalar viscosityRatio = 1 - abs(0.5 - viscosityNw / (viscosityW + viscosityNw));
145 fluxWettingOut_ += flux / (krSum * viscosityRatio);
149 fluxIn_ -= flux / (krSum * viscosityRatio);
160 fluxNonwettingOut_ += flux / (krSum * viscosityRatio);
164 fluxIn_ -= flux / (krSum * viscosityRatio);
173 fluxOut_ += flux / (krSum * viscosityRatio);
177 fluxIn_ -= flux / (krSum * viscosityRatio);
186 Scalar getCFLFluxIn(
int phaseIdx = 0)
190 if (isnan(fluxIn_) || isinf(fluxIn_))
199 Scalar getCFLFluxOut(
int phaseIdx = 0)
203 if (isnan(fluxWettingOut_) || isinf(fluxWettingOut_))
205 fluxWettingOut_ = 1e-100;
208 if (isnan(fluxNonwettingOut_) || isinf(fluxNonwettingOut_))
210 fluxNonwettingOut_ = 1e-100;
212 if (isnan(fluxOut_) || isinf(fluxOut_))
217 if (phaseIdx == wPhaseIdx)
218 return fluxWettingOut_;
219 else if (phaseIdx == nPhaseIdx)
220 return fluxNonwettingOut_;
226 Scalar fluxWettingOut_;
227 Scalar fluxNonwettingOut_;
230 Scalar porosityThreshold_;
231 static const int velocityType_ = getPropValue<TypeTag, Properties::VelocityFormulation>();
232 static const int saturationType_ = getPropValue<TypeTag, Properties::SaturationFormulation>();
236template<
class TypeTag>
242 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem_.spatialParams(), element);
244 const Scalar residualSatW = fluidMatrixInteraction.pcSwCurve().effToAbsParams().swr();
245 const Scalar residualSatNw = fluidMatrixInteraction.pcSwCurve().effToAbsParams().snr();
248 const Scalar volumeCorrectionFactor = 1 - residualSatW - residualSatNw;
249 Scalar volumeCorrectionFactorOutW = 0;
250 Scalar volumeCorrectionFactorOutNw = 0;
252 Scalar satW = problem_.variables().cellData(problem_.variables().index(element)).saturation(wPhaseIdx);
254 volumeCorrectionFactorOutW = max((satW - residualSatW), 1e-2);
255 volumeCorrectionFactorOutNw = max((1 - satW - residualSatNw), 1e-2);
258 if (volumeCorrectionFactorOutW <= 0)
260 volumeCorrectionFactorOutW = 1e100;
262 if (volumeCorrectionFactorOutNw <= 0)
264 volumeCorrectionFactorOutNw = 1e100;
268 Scalar cFLFluxIn = volumeCorrectionFactor / getCFLFluxIn();
269 Scalar cFLFluxOut = 0;
272 if (velocityType_ == vt)
274 cFLFluxOut = volumeCorrectionFactor / getCFLFluxOut(-1);
278 cFLFluxOut = min(volumeCorrectionFactorOutW / getCFLFluxOut(wPhaseIdx),
279 volumeCorrectionFactorOutNw / getCFLFluxOut(nPhaseIdx));
283 const Scalar cFLFluxFunction = min(cFLFluxIn, cFLFluxOut);
285 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:43
EvalCflFluxDefault(Problem &problem)
Constructs an EvalCflFluxDefault object.
Definition: evalcflfluxdefault.hh:122
Scalar getCflFluxFunction(const Element &element)
Returns the CFL flux-function.
Definition: evalcflfluxdefault.hh:237
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:71
void reset()
resets the accumulated CFL-fluxes to zero
Definition: evalcflfluxdefault.hh:109
Scalar getDt(const Element &element)
Returns the CFL time-step.
Definition: evalcflfluxdefault.hh:100
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:82