24#ifndef DUMUX_DISCRETIZATION_UPWINDSCHEME_HH
25#define DUMUX_DISCRETIZATION_UPWINDSCHEME_HH
33template<
class Gr
idGeometry,
class DiscretizationMethod>
41template<
class Gr
idGeometry>
47template<
class ElemVolVars,
class SubControlVolumeFace,
class UpwindTermFunction,
class Scalar>
49 const SubControlVolumeFace& scvf,
50 const UpwindTermFunction& upwindTerm,
51 Scalar flux,
int phaseIdx)
54 static const Scalar upwindWeight = getParamFromGroup<Scalar>(elemVolVars.gridVolVars().problem().paramGroup(),
"Flux.UpwindWeight");
56 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
57 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
61 return (upwindWeight*upwindTerm(outsideVolVars)
62 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
64 return (upwindWeight*upwindTerm(insideVolVars)
65 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
71template<
class Gr
idGeometry,
class DM>
76 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar>
77 static Scalar
apply(
const FluxVariables& fluxVars,
78 const UpwindTermFunction& upwindTerm,
79 Scalar flux,
int phaseIdx)
81 return apply(fluxVars.elemVolVars(), fluxVars.scvFace(), upwindTerm, flux, phaseIdx);
85 template<
class ElemVolVars,
class SubControlVolumeFace,
class UpwindTermFunction,
class Scalar>
86 static Scalar
apply(
const ElemVolVars& elemVolVars,
87 const SubControlVolumeFace& scvf,
88 const UpwindTermFunction& upwindTerm,
89 Scalar flux,
int phaseIdx)
91 return flux*multiplier(elemVolVars, scvf, upwindTerm, flux, phaseIdx);
95 template<
class ElemVolVars,
class SubControlVolumeFace,
class UpwindTermFunction,
class Scalar>
97 const SubControlVolumeFace& scvf,
98 const UpwindTermFunction& upwindTerm,
99 Scalar flux,
int phaseIdx)
106template<
class Gr
idGeometry>
109 using GridView =
typename GridGeometry::GridView;
110 static constexpr int dim = GridView::dimension;
111 static constexpr int dimWorld = GridView::dimensionworld;
115 template<
class ElemVolVars,
class SubControlVolumeFace,
class UpwindTermFunction,
class Scalar>
117 const SubControlVolumeFace& scvf,
118 const UpwindTermFunction& upwindTerm,
119 Scalar flux,
int phaseIdx)
121 static_assert(dim == dimWorld,
"Multiplier cannot be computed on surface grids using cell-centered scheme!");
126 template<
class ElemVolVars,
class SubControlVolumeFace,
class UpwindTermFunction,
class Scalar>
127 static Scalar
apply(
const ElemVolVars& elemVolVars,
128 const SubControlVolumeFace& scvf,
129 const UpwindTermFunction& upwindTerm,
130 Scalar flux,
int phaseIdx)
132 static_assert(dim == dimWorld,
"This upwind scheme cannot be used on surface grids using cell-centered schemes!");
133 return flux*multiplier(elemVolVars, scvf, upwindTerm, flux, phaseIdx);
137 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar>
138 static Scalar
apply(
const FluxVariables& fluxVars,
139 const UpwindTermFunction& upwindTerm,
140 Scalar flux,
int phaseIdx)
142 const auto& scvf = fluxVars.scvFace();
143 const auto& elemVolVars = fluxVars.elemVolVars();
146 if constexpr (dim == dimWorld)
147 return apply(elemVolVars, scvf, upwindTerm, flux, phaseIdx);
150 if (scvf.numOutsideScvs() == 1)
155 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
157 Scalar branchingPointUpwindTerm = 0.0;
158 Scalar sumUpwindFluxes = 0.0;
163 return upwindTerm(insideVolVars)*flux;
165 sumUpwindFluxes += flux;
167 for (
unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
170 const auto& fvGeometry = fluxVars.fvGeometry();
171 const auto outsideScvIdx = scvf.outsideScvIdx(i);
172 const auto outsideElement = fvGeometry.gridGeometry().element(outsideScvIdx);
173 const auto& flippedScvf = fvGeometry.flipScvf(scvf.index(), i);
175 using AdvectionType =
typename FluxVariables::AdvectionType;
176 const auto outsideFlux = AdvectionType::flux(fluxVars.problem(),
182 fluxVars.elemFluxVarsCache());
184 if (!signbit(outsideFlux))
185 branchingPointUpwindTerm += upwindTerm(elemVolVars[outsideScvIdx])*outsideFlux;
187 sumUpwindFluxes += outsideFlux;
191 if (sumUpwindFluxes != 0.0)
192 branchingPointUpwindTerm /= -sumUpwindFluxes;
194 branchingPointUpwindTerm = 0.0;
200 return flux*branchingPointUpwindTerm;
202 return flux*upwindTerm(insideVolVars);
207template<
class Gr
idGeometry>
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Scalar upwindSchemeMultiplier(const ElemVolVars &elemVolVars, const SubControlVolumeFace &scvf, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
returns the upwind factor which is multiplied to the advective flux across the given scvf
Definition: flux/upwindscheme.hh:48
Forward declaration of the upwind scheme implementation.
Definition: flux/upwindscheme.hh:34
static Scalar multiplier(const ElemVolVars &elemVolVars, const SubControlVolumeFace &scvf, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
returns the upwind factor which is multiplied to the advective flux across the given scvf
Definition: flux/upwindscheme.hh:96
static Scalar apply(const ElemVolVars &elemVolVars, const SubControlVolumeFace &scvf, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
applies a simple upwind scheme to the precalculated advective flux across the given scvf
Definition: flux/upwindscheme.hh:86
static Scalar apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
applies a simple upwind scheme to the precalculated advective flux
Definition: flux/upwindscheme.hh:77
static Scalar apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: flux/upwindscheme.hh:138
static Scalar apply(const ElemVolVars &elemVolVars, const SubControlVolumeFace &scvf, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
applies a simple upwind scheme to the precalculated advective flux across the given scvf
Definition: flux/upwindscheme.hh:127
static Scalar multiplier(const ElemVolVars &elemVolVars, const SubControlVolumeFace &scvf, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
returns the upwind factor which is multiplied to the advective flux across the given scvf
Definition: flux/upwindscheme.hh:116