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 = getParam<Scalar>(
"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];
65 if (std::signbit(flux))
66 return flux*(upwindWeight*upwindTerm(outsideVolVars)
67 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
69 return flux*(upwindWeight*upwindTerm(insideVolVars)
70 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
75template<
class Gr
idGeometry>
78 using GridView =
typename GridGeometry::GridView;
79 static constexpr int dim = GridView::dimension;
80 static constexpr int dimWorld = GridView::dimensionworld;
84 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar,
int d = dim,
int dw = dimWorld>
85 static typename std::enable_if<(d < dw), Scalar>::type
86 apply(
const FluxVariables& fluxVars,
87 const UpwindTermFunction& upwindTerm,
88 Scalar flux,
int phaseIdx)
90 static const Scalar upwindWeight = getParam<Scalar>(
"Flux.UpwindWeight");
93 const auto& scvf = fluxVars.scvFace();
94 const auto& elemVolVars = fluxVars.elemVolVars();
95 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
98 if (scvf.numOutsideScvs() > 1)
102 Scalar branchingPointUpwindTerm = 0.0;
103 Scalar sumUpwindFluxes = 0.0;
106 if (!std::signbit(flux))
107 return upwindTerm(insideVolVars)*flux;
109 sumUpwindFluxes += flux;
111 for (
unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
114 const auto& fvGeometry = fluxVars.fvGeometry();
115 const auto outsideScvIdx = scvf.outsideScvIdx(i);
116 const auto outsideElement = fvGeometry.gridGeometry().element(outsideScvIdx);
117 const auto& flippedScvf = fvGeometry.flipScvf(scvf.index(), i);
119 using AdvectionType =
typename FluxVariables::AdvectionType;
120 const auto outsideFlux = AdvectionType::flux(fluxVars.problem(),
126 fluxVars.elemFluxVarsCache());
128 if (!std::signbit(outsideFlux))
129 branchingPointUpwindTerm += upwindTerm(elemVolVars[outsideScvIdx])*outsideFlux;
131 sumUpwindFluxes += outsideFlux;
135 if (sumUpwindFluxes != 0.0)
136 branchingPointUpwindTerm /= -sumUpwindFluxes;
138 branchingPointUpwindTerm = 0.0;
143 if (std::signbit(flux))
144 return flux*branchingPointUpwindTerm;
146 return flux*upwindTerm(insideVolVars);
152 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
153 if (std::signbit(flux))
154 return flux*(upwindWeight*upwindTerm(outsideVolVars)
155 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
157 return flux*(upwindWeight*upwindTerm(insideVolVars)
158 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
163 template<
class FluxVariables,
class UpwindTermFunction,
class Scalar,
int d = dim,
int dw = dimWorld>
164 static typename std::enable_if<(d == dw), Scalar>::type
165 apply(
const FluxVariables& fluxVars,
166 const UpwindTermFunction& upwindTerm,
167 Scalar flux,
int phaseIdx)
169 static const Scalar upwindWeight = getParam<Scalar>(
"Flux.UpwindWeight");
171 const auto& scvf = fluxVars.scvFace();
172 const auto& elemVolVars = fluxVars.elemVolVars();
173 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
174 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
176 if (std::signbit(flux))
177 return flux*(upwindWeight*upwindTerm(outsideVolVars)
178 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
180 return flux*(upwindWeight*upwindTerm(insideVolVars)
181 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
186template<
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
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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:86
static std::enable_if<(d==dw), Scalar >::type apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: flux/upwindscheme.hh:165