version 3.10-dev
multidomain/facet/box/upwindscheme.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_MULTIDOMAIN_FACET_BOX_UPWINDSCHEME_HH
14#define DUMUX_MULTIDOMAIN_FACET_BOX_UPWINDSCHEME_HH
15
18
19namespace Dumux {
20
27template<class GridGeometry>
29{
30public:
31 // applies a simple upwind scheme to the precalculated advective flux
32 template<class FluxVariables, class UpwindTermFunction, class Scalar>
33 static Scalar apply(const FluxVariables& fluxVars,
34 const UpwindTermFunction& upwindTerm,
35 Scalar flux, int phaseIdx)
36 {
37 // TODO: pass this from outside?
38 static const Scalar upwindWeight = getParam<Scalar>("Flux.UpwindWeight");
39
40 const auto& elemVolVars = fluxVars.elemVolVars();
41 const auto& scvf = fluxVars.scvFace();
42 const auto& insideScv = fluxVars.fvGeometry().scv(scvf.insideScvIdx());
43 const auto& insideVolVars = elemVolVars[insideScv];
44
45 // check if this is an interior boundary
46 if (scvf.interiorBoundary())
47 {
48 const auto& cm = fluxVars.problem().couplingManager();
49 const auto& outsideVolVars = cm.getLowDimVolVars(fluxVars.element(), scvf);
50 if (std::signbit(flux)) // if sign of flux is negative
51 return flux*(upwindWeight*upwindTerm(outsideVolVars)
52 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
53 else
54 return flux*(upwindWeight*upwindTerm(insideVolVars)
55 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
56 }
57 else
58 {
59 const auto& outsideScv = fluxVars.fvGeometry().scv(scvf.outsideScvIdx());
60 const auto& outsideVolVars = elemVolVars[outsideScv];
61 if (std::signbit(flux)) // if sign of flux is negative
62 return flux*(upwindWeight*upwindTerm(outsideVolVars)
63 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
64 else
65 return flux*(upwindWeight*upwindTerm(insideVolVars)
66 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
67 }
68 }
69};
70
71} // end namespace Dumux
72
73#endif
The upwind scheme used for the advective fluxes. This is a modified scheme for models involving coupl...
Definition: multidomain/facet/box/upwindscheme.hh:29
static Scalar apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: multidomain/facet/box/upwindscheme.hh:33
The available discretization methods in Dumux.
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.