23#ifndef DUMUX_UPWINDING_METHODS_HH
24#define DUMUX_UPWINDING_METHODS_HH
51template<
class Scalar,
int upwindSchemeOrder>
57 upwindWeight_ = getParamFromGroup<Scalar>(paramGroup,
"Flux.UpwindWeight");
59 if (upwindSchemeOrder > 1)
62 tvdApproach_ =
tvdApproachFromString(getParamFromGroup<std::string>(paramGroup,
"Flux.TvdApproach",
"Uniform"));
66 switch (differencingScheme_)
76 DUNE_THROW(
ParameterException,
"\nDifferencing scheme (Van Albada) is not implemented for the Tvd approach (Hou).");
93 limiter_ = this->
umist;
103 limiter_ = this->
wahyd;
109 " is not implemented.\n");
116 std::cout <<
"No TvdApproach specified. Defaulting to the Uniform method." <<
"\n";
117 std::cout <<
"Other available TVD approaches for uniform (and nonuniform) grids are as follows: \n"
121 std::cout <<
"Each approach can be specified as written above in the Flux group under the title TvdApproach in your input file. \n";
126 std::cout <<
"No DifferencingScheme specified. Defaulting to the Minmod scheme." <<
"\n";
127 std::cout <<
"Other available Differencing Schemes are as follows: \n"
135 std::cout <<
"Each scheme can be specified as written above in the Flux group under the variable DifferencingScheme in your input file. \n";
159 <<
"The available TVD approaches for uniform (and nonuniform) grids are as follows: \n"
175 default:
return "Invalid";
193 <<
"The available differencing schemes are as follows: \n"
217 default:
return "Invalid";
224 Scalar
upwind(
const Scalar downstreamMomentum,
225 const Scalar upstreamMomentum)
const
227 return (upwindWeight_ * upstreamMomentum + (1.0 - upwindWeight_) * downstreamMomentum);
234 Scalar
tvd(
const std::array<Scalar,3>& momenta,
235 const std::array<Scalar,3>& distances,
236 const bool selfIsUpstream,
239 Scalar momentum = 0.0;
244 momentum +=
tvdUniform(momenta, distances, selfIsUpstream);
249 momentum +=
tvdLi(momenta, distances, selfIsUpstream);
254 momentum +=
tvdHou(momenta, distances, selfIsUpstream);
272 const std::array<Scalar,3>& distances,
273 const bool selfIsUpstream)
const
276 const Scalar downstreamMomentum = momenta[0];
277 const Scalar upstreamMomentum = momenta[1];
278 const Scalar upUpstreamMomentum = momenta[2];
279 const Scalar ratio = (upstreamMomentum - upUpstreamMomentum) / (downstreamMomentum - upstreamMomentum);
282 if(ratio > 0.0 && isfinite(ratio))
284 const Scalar secondOrderTerm = 0.5 * limiter_(ratio, 2.0) * (downstreamMomentum - upstreamMomentum);
285 return (upstreamMomentum + secondOrderTerm);
288 return upstreamMomentum;
298 Scalar
tvdLi(
const std::array<Scalar,3>& momenta,
299 const std::array<Scalar,3>& distances,
300 const bool selfIsUpstream)
const
303 const Scalar downstreamMomentum = momenta[0];
304 const Scalar upstreamMomentum = momenta[1];
305 const Scalar upUpstreamMomentum = momenta[2];
306 const Scalar upstreamToDownstreamDistance = distances[0];
307 const Scalar upUpstreamToUpstreamDistance = distances[1];
310 const Scalar upUpstreamGradient = (upstreamMomentum - upUpstreamMomentum) / upUpstreamToUpstreamDistance * selfIsUpstream;
313 const Scalar correctionDistance = upUpstreamToUpstreamDistance - upstreamToDownstreamDistance;
314 const Scalar reconstrutedUpUpstreamVelocity = upUpstreamMomentum + upUpstreamGradient * correctionDistance;
315 const Scalar ratio = (upstreamMomentum - reconstrutedUpUpstreamVelocity) / (downstreamMomentum - upstreamMomentum);
318 if(ratio > 0.0 && isfinite(ratio))
320 const Scalar secondOrderTerm = 0.5 * limiter_(ratio, 2.0) * (downstreamMomentum - upstreamMomentum);
321 return (upstreamMomentum + secondOrderTerm);
324 return upstreamMomentum;
333 Scalar
tvdHou(
const std::array<Scalar,3>& momenta,
334 const std::array<Scalar,3>& distances,
335 const bool selfIsUpstream)
const
338 const Scalar downstreamMomentum = momenta[0];
339 const Scalar upstreamMomentum = momenta[1];
340 const Scalar upUpstreamMomentum = momenta[2];
341 const Scalar upstreamToDownstreamDistance = distances[0];
342 const Scalar upUpstreamToUpstreamDistance = distances[1];
343 const Scalar downstreamStaggeredCellSize = distances[2];
344 const Scalar ratio = (upstreamMomentum - upUpstreamMomentum) / (downstreamMomentum - upstreamMomentum)
345 * upstreamToDownstreamDistance / upUpstreamToUpstreamDistance;
348 if(ratio > 0.0 && isfinite(ratio))
350 const Scalar upstreamStaggeredCellSize = 0.5 * (upstreamToDownstreamDistance + upUpstreamToUpstreamDistance);
351 const Scalar R = (upstreamStaggeredCellSize + downstreamStaggeredCellSize) / upstreamStaggeredCellSize;
352 const Scalar secondOrderTerm = limiter_(ratio, R) / R * (downstreamMomentum - upstreamMomentum);
353 return (upstreamMomentum + secondOrderTerm);
356 return upstreamMomentum;
364 static Scalar
vanleer(
const Scalar r,
const Scalar R)
366 return R * r / (R - 1.0 + r);
374 return r * (r + 1.0) / (1.0 + r * r);
380 static Scalar
minmod(
const Scalar r,
const Scalar R)
391 static Scalar
superbee(
const Scalar r,
const Scalar R)
395 return max(min(R * r, 1.0), min(r, R));
401 static Scalar
umist(
const Scalar r,
const Scalar R)
404 return min({R * r, (r * (5.0 - R) + R - 1.0) / 4.0, (r * (R - 1.0) + 5.0 - R) / 4.0, R});
413 return min({R * r, (r + 1.0) / 2.0, R});
419 static Scalar
wahyd(
const Scalar r,
const Scalar R)
422 return r > 1 ? min((r + R * r * r) / (R + r * r), R)
435 return differencingScheme_;
441 Scalar upwindWeight_;
443 std::function<Scalar(
const Scalar,
const Scalar)> limiter_;
Some exceptions thrown in DuMux
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
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:454
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
TvdApproach
Available Tvd approaches.
Definition: staggeredupwindmethods.hh:38
DifferencingScheme
Available differencing schemes.
Definition: staggeredupwindmethods.hh:44
Exception thrown if a run-time parameter is not specified correctly.
Definition: exceptions.hh:60
This file contains different higher order methods for approximating the velocity.
Definition: staggeredupwindmethods.hh:53
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:153
static Scalar vanalbada(const Scalar r, const Scalar R)
Van Albada flux limiter function [Van Albada et al. 1982].
Definition: staggeredupwindmethods.hh:372
StaggeredUpwindMethods(const std::string ¶mGroup="")
Definition: staggeredupwindmethods.hh:55
Scalar upwind(const Scalar downstreamMomentum, const Scalar upstreamMomentum) const
Upwind Method.
Definition: staggeredupwindmethods.hh:224
const DifferencingScheme & differencingScheme() const
Returns the differencing scheme.
Definition: staggeredupwindmethods.hh:433
std::string tvdApproachToString(TvdApproach tvd)
return the name of the TVD approach
Definition: staggeredupwindmethods.hh:168
static Scalar umist(const Scalar r, const Scalar R)
UMIST flux limiter function [Lien and Leschziner 1993].
Definition: staggeredupwindmethods.hh:401
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:271
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:298
static Scalar mclimiter(const Scalar r, const Scalar R)
Definition: staggeredupwindmethods.hh:410
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:183
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:234
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:333
static Scalar vanleer(const Scalar r, const Scalar R)
Van Leer flux limiter function [Van Leer 1974].
Definition: staggeredupwindmethods.hh:364
const TvdApproach & tvdApproach() const
Returns the Tvd approach.
Definition: staggeredupwindmethods.hh:427
std::string differencingSchemeToString(DifferencingScheme differencingScheme)
return the name of the Discretization Method
Definition: staggeredupwindmethods.hh:206
static Scalar superbee(const Scalar r, const Scalar R)
SUPERBEE flux limiter function [Roe 1985].
Definition: staggeredupwindmethods.hh:391
static Scalar minmod(const Scalar r, const Scalar R)
MinMod flux limiter function [Roe 1985].
Definition: staggeredupwindmethods.hh:380
static Scalar wahyd(const Scalar r, const Scalar R)
WAHYD Scheme [Hou, Simons, Hinkelmann 2007];.
Definition: staggeredupwindmethods.hh:419