13#ifndef DUMUX_UPWINDING_METHODS_HH
14#define DUMUX_UPWINDING_METHODS_HH
48template<
class Scalar,
int upwindSchemeOrder>
54 upwindWeight_ = getParamFromGroup<Scalar>(paramGroup,
"Flux.UpwindWeight");
56 if (upwindSchemeOrder > 1)
59 tvdApproach_ =
tvdApproachFromString(getParamFromGroup<std::string>(paramGroup,
"Flux.TvdApproach",
"Uniform"));
63 switch (differencingScheme_)
73 DUNE_THROW(
ParameterException,
"\nDifferencing scheme (Van Albada) is not implemented for the Tvd approach (Hou).");
90 limiter_ = this->
umist;
100 limiter_ = this->
wahyd;
106 " is not implemented.\n");
113 std::cout <<
"No TvdApproach specified. Defaulting to the Uniform method." <<
"\n";
114 std::cout <<
"Other available TVD approaches for uniform (and nonuniform) grids are as follows: \n"
118 std::cout <<
"Each approach can be specified as written above in the Flux group under the title TvdApproach in your input file. \n";
123 std::cout <<
"No DifferencingScheme specified. Defaulting to the Minmod scheme." <<
"\n";
124 std::cout <<
"Other available Differencing Schemes are as follows: \n"
132 std::cout <<
"Each scheme can be specified as written above in the Flux group under the variable DifferencingScheme in your input file. \n";
156 <<
"The available TVD approaches for uniform (and nonuniform) grids are as follows: \n"
172 default:
return "Invalid";
190 <<
"The available differencing schemes are as follows: \n"
214 default:
return "Invalid";
221 Scalar
upwind(
const Scalar downstreamMomentum,
222 const Scalar upstreamMomentum)
const
224 return (upwindWeight_ * upstreamMomentum + (1.0 - upwindWeight_) * downstreamMomentum);
231 Scalar
tvd(
const std::array<Scalar,3>& momenta,
232 const std::array<Scalar,3>& distances,
233 const bool selfIsUpstream,
236 Scalar momentum = 0.0;
241 momentum +=
tvdUniform(momenta, distances, selfIsUpstream);
246 momentum +=
tvdLi(momenta, distances, selfIsUpstream);
251 momentum +=
tvdHou(momenta, distances, selfIsUpstream);
269 const std::array<Scalar,3>& distances,
270 const bool selfIsUpstream)
const
273 const Scalar downstreamMomentum = momenta[0];
274 const Scalar upstreamMomentum = momenta[1];
275 const Scalar upUpstreamMomentum = momenta[2];
276 const Scalar ratio = (upstreamMomentum - upUpstreamMomentum) / (downstreamMomentum - upstreamMomentum);
279 if(ratio > 0.0 && isfinite(ratio))
281 const Scalar secondOrderTerm = 0.5 * limiter_(ratio, 2.0) * (downstreamMomentum - upstreamMomentum);
282 return (upstreamMomentum + secondOrderTerm);
285 return upstreamMomentum;
295 Scalar
tvdLi(
const std::array<Scalar,3>& momenta,
296 const std::array<Scalar,3>& distances,
297 const bool selfIsUpstream)
const
300 const Scalar downstreamMomentum = momenta[0];
301 const Scalar upstreamMomentum = momenta[1];
302 const Scalar upUpstreamMomentum = momenta[2];
303 const Scalar upstreamToDownstreamDistance = distances[0];
304 const Scalar upUpstreamToUpstreamDistance = distances[1];
307 const Scalar upUpstreamGradient = (upstreamMomentum - upUpstreamMomentum) / upUpstreamToUpstreamDistance * selfIsUpstream;
310 const Scalar correctionDistance = upUpstreamToUpstreamDistance - upstreamToDownstreamDistance;
311 const Scalar reconstrutedUpUpstreamVelocity = upUpstreamMomentum + upUpstreamGradient * correctionDistance;
312 const Scalar ratio = (upstreamMomentum - reconstrutedUpUpstreamVelocity) / (downstreamMomentum - upstreamMomentum);
315 if(ratio > 0.0 && isfinite(ratio))
317 const Scalar secondOrderTerm = 0.5 * limiter_(ratio, 2.0) * (downstreamMomentum - upstreamMomentum);
318 return (upstreamMomentum + secondOrderTerm);
321 return upstreamMomentum;
330 Scalar
tvdHou(
const std::array<Scalar,3>& momenta,
331 const std::array<Scalar,3>& distances,
332 const bool selfIsUpstream)
const
335 const Scalar downstreamMomentum = momenta[0];
336 const Scalar upstreamMomentum = momenta[1];
337 const Scalar upUpstreamMomentum = momenta[2];
338 const Scalar upstreamToDownstreamDistance = distances[0];
339 const Scalar upUpstreamToUpstreamDistance = distances[1];
340 const Scalar downstreamStaggeredCellSize = distances[2];
341 const Scalar ratio = (upstreamMomentum - upUpstreamMomentum) / (downstreamMomentum - upstreamMomentum)
342 * upstreamToDownstreamDistance / upUpstreamToUpstreamDistance;
345 if(ratio > 0.0 && isfinite(ratio))
347 const Scalar upstreamStaggeredCellSize = 0.5 * (upstreamToDownstreamDistance + upUpstreamToUpstreamDistance);
348 const Scalar R = (upstreamStaggeredCellSize + downstreamStaggeredCellSize) / upstreamStaggeredCellSize;
349 const Scalar secondOrderTerm = limiter_(ratio, R) / R * (downstreamMomentum - upstreamMomentum);
350 return (upstreamMomentum + secondOrderTerm);
353 return upstreamMomentum;
361 static Scalar
vanleer(
const Scalar r,
const Scalar R)
363 return R * r / (R - 1.0 + r);
371 return r * (r + 1.0) / (1.0 + r * r);
377 static Scalar
minmod(
const Scalar r,
const Scalar R)
388 static Scalar
superbee(
const Scalar r,
const Scalar R)
392 return max(min(R * r, 1.0), min(r, R));
398 static Scalar
umist(
const Scalar r,
const Scalar R)
401 return min({R * r, (r * (5.0 - R) + R - 1.0) / 4.0, (r * (R - 1.0) + 5.0 - R) / 4.0, R});
410 return min({R * r, (r + 1.0) / 2.0, R});
416 static Scalar
wahyd(
const Scalar r,
const Scalar R)
419 return r > 1 ? min((r + R * r * r) / (R + r * r), R)
432 return differencingScheme_;
438 Scalar upwindWeight_;
440 std::function<Scalar(
const Scalar,
const Scalar)> limiter_;
Exception thrown if a run-time parameter is not specified correctly.
Definition: exceptions.hh:48
This file contains different higher order methods for approximating the velocity.
Definition: staggeredupwindmethods.hh:50
TvdApproach tvdApproachFromString(const std::string &tvd)
Convenience function to convert user input given as std::string to the corresponding enum class used ...
Definition: staggeredupwindmethods.hh:150
static Scalar vanalbada(const Scalar r, const Scalar R)
Van Albada flux limiter function [Van Albada et al. 1982].
Definition: staggeredupwindmethods.hh:369
StaggeredUpwindMethods(const std::string ¶mGroup="")
Definition: staggeredupwindmethods.hh:52
Scalar upwind(const Scalar downstreamMomentum, const Scalar upstreamMomentum) const
Upwind Method.
Definition: staggeredupwindmethods.hh:221
const DifferencingScheme & differencingScheme() const
Returns the differencing scheme.
Definition: staggeredupwindmethods.hh:430
std::string tvdApproachToString(TvdApproach tvd)
return the name of the TVD approach
Definition: staggeredupwindmethods.hh:165
static Scalar umist(const Scalar r, const Scalar R)
UMIST flux limiter function [Lien and Leschziner 1993].
Definition: staggeredupwindmethods.hh:398
Scalar tvdUniform(const std::array< Scalar, 3 > &momenta, const std::array< Scalar, 3 > &distances, const bool selfIsUpstream) const
Tvd Scheme: Total Variation Diminishing.
Definition: staggeredupwindmethods.hh:268
Scalar tvdLi(const std::array< Scalar, 3 > &momenta, const std::array< Scalar, 3 > &distances, const bool selfIsUpstream) const
Tvd Scheme: Total Variation Diminishing.
Definition: staggeredupwindmethods.hh:295
static Scalar mclimiter(const Scalar r, const Scalar R)
Definition: staggeredupwindmethods.hh:407
DifferencingScheme differencingSchemeFromString(const std::string &differencingScheme)
Convenience function to convert user input given as std::string to the corresponding enum class used ...
Definition: staggeredupwindmethods.hh:180
Scalar tvd(const std::array< Scalar, 3 > &momenta, const std::array< Scalar, 3 > &distances, const bool selfIsUpstream, const TvdApproach tvdApproach) const
Tvd Scheme: Total Variation Diminishing.
Definition: staggeredupwindmethods.hh:231
Scalar tvdHou(const std::array< Scalar, 3 > &momenta, const std::array< Scalar, 3 > &distances, const bool selfIsUpstream) const
Tvd Scheme: Total Variation Diminishing.
Definition: staggeredupwindmethods.hh:330
static Scalar vanleer(const Scalar r, const Scalar R)
Van Leer flux limiter function [Van Leer 1974].
Definition: staggeredupwindmethods.hh:361
const TvdApproach & tvdApproach() const
Returns the Tvd approach.
Definition: staggeredupwindmethods.hh:424
std::string differencingSchemeToString(DifferencingScheme differencingScheme)
return the name of the Discretization Method
Definition: staggeredupwindmethods.hh:203
static Scalar superbee(const Scalar r, const Scalar R)
SUPERBEE flux limiter function [Roe 1985].
Definition: staggeredupwindmethods.hh:388
static Scalar minmod(const Scalar r, const Scalar R)
MinMod flux limiter function [Roe 1985].
Definition: staggeredupwindmethods.hh:377
static Scalar wahyd(const Scalar r, const Scalar R)
WAHYD Scheme [Hou, Simons, Hinkelmann 2007];.
Definition: staggeredupwindmethods.hh:416
Some exceptions thrown in DuMux
TvdApproach
Available Tvd approaches.
Definition: staggeredupwindmethods.hh:31
DifferencingScheme
Available differencing schemes.
Definition: staggeredupwindmethods.hh:40
bool hasParamInGroup(const std::string ¶mGroup, const std::string ¶m)
Check whether a key exists in the parameter tree with a model group prefix.
Definition: parameters.hh:165
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.