24#ifndef DUMUX_DISCRETIZATION_UPWINDSCHEME_HH
25#define DUMUX_DISCRETIZATION_UPWINDSCHEME_HH
33template<
class Gr
idGeometry, DiscretizationMethod discMethod>
41template<
class Gr
idGeometry>
45template<
class Gr
idGeometry>
50 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar>
51 static Scalar
apply(
const FluxVariables& fluxVars,
52 const UpwindTermFunction& upwindTerm,
53 Scalar flux,
int phaseIdx)
56 static const Scalar upwindWeight = getParamFromGroup<Scalar>(fluxVars.problem().paramGroup(),
"Flux.UpwindWeight");
58 const auto& elemVolVars = fluxVars.elemVolVars();
59 const auto& scvf = fluxVars.scvFace();
60 const auto& insideScv = fluxVars.fvGeometry().scv(scvf.insideScvIdx());
61 const auto& outsideScv = fluxVars.fvGeometry().scv(scvf.outsideScvIdx());
62 const auto& insideVolVars = elemVolVars[insideScv];
63 const auto& outsideVolVars = elemVolVars[outsideScv];
67 return flux*(upwindWeight*upwindTerm(outsideVolVars)
68 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
70 return flux*(upwindWeight*upwindTerm(insideVolVars)
71 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
76template<
class Gr
idGeometry>
79 using GridView =
typename GridGeometry::GridView;
80 static constexpr int dim = GridView::dimension;
81 static constexpr int dimWorld = GridView::dimensionworld;
85 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar,
int d = dim,
int dw = dimWorld>
86 static typename std::enable_if<(d < dw), Scalar>::type
87 apply(
const FluxVariables& fluxVars,
88 const UpwindTermFunction& upwindTerm,
89 Scalar flux,
int phaseIdx)
92 static const Scalar upwindWeight = getParam<Scalar>(
"Flux.UpwindWeight");
95 const auto& scvf = fluxVars.scvFace();
96 const auto& elemVolVars = fluxVars.elemVolVars();
97 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
100 if (scvf.numOutsideScvs() > 1)
104 Scalar branchingPointUpwindTerm = 0.0;
105 Scalar sumUpwindFluxes = 0.0;
109 return upwindTerm(insideVolVars)*flux;
111 sumUpwindFluxes += flux;
113 for (
unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
116 const auto& fvGeometry = fluxVars.fvGeometry();
117 const auto outsideScvIdx = scvf.outsideScvIdx(i);
118 const auto outsideElement = fvGeometry.gridGeometry().element(outsideScvIdx);
119 const auto& flippedScvf = fvGeometry.flipScvf(scvf.index(), i);
121 using AdvectionType =
typename FluxVariables::AdvectionType;
122 const auto outsideFlux = AdvectionType::flux(fluxVars.problem(),
128 fluxVars.elemFluxVarsCache());
130 if (!signbit(outsideFlux))
131 branchingPointUpwindTerm += upwindTerm(elemVolVars[outsideScvIdx])*outsideFlux;
133 sumUpwindFluxes += outsideFlux;
137 if (sumUpwindFluxes != 0.0)
138 branchingPointUpwindTerm /= -sumUpwindFluxes;
140 branchingPointUpwindTerm = 0.0;
146 return flux*branchingPointUpwindTerm;
148 return flux*upwindTerm(insideVolVars);
154 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
156 return flux*(upwindWeight*upwindTerm(outsideVolVars)
157 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
159 return flux*(upwindWeight*upwindTerm(insideVolVars)
160 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
165 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar,
int d = dim,
int dw = dimWorld>
166 static typename std::enable_if<(d == dw), Scalar>::type
167 apply(
const FluxVariables& fluxVars,
168 const UpwindTermFunction& upwindTerm,
169 Scalar flux,
int phaseIdx)
171 static const Scalar upwindWeight = getParam<Scalar>(
"Flux.UpwindWeight");
173 const auto& scvf = fluxVars.scvFace();
174 const auto& elemVolVars = fluxVars.elemVolVars();
175 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
176 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
180 return flux*(upwindWeight*upwindTerm(outsideVolVars)
181 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
183 return flux*(upwindWeight*upwindTerm(insideVolVars)
184 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
189template<
class Gr
idGeometry>
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
Forward declaration of the upwind scheme implementation.
Definition: flux/upwindscheme.hh:34
static Scalar apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: flux/upwindscheme.hh:51
static std::enable_if<(d< dw), Scalar >::type apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: flux/upwindscheme.hh:87
static std::enable_if<(d==dw), Scalar >::type apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: flux/upwindscheme.hh:167