3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_MULTIDOMAIN_FACET_BOX_UPWINDSCHEME_HH
26#define DUMUX_MULTIDOMAIN_FACET_BOX_UPWINDSCHEME_HH
27
30
31namespace Dumux {
32
39template<class GridGeometry>
41{
42public:
43 // applies a simple upwind scheme to the precalculated advective flux
44 template<class FluxVariables, class UpwindTermFunction, class Scalar>
45 static Scalar apply(const FluxVariables& fluxVars,
46 const UpwindTermFunction& upwindTerm,
47 Scalar flux, int phaseIdx)
48 {
49 // TODO: pass this from outside?
50 static const Scalar upwindWeight = getParam<Scalar>("Flux.UpwindWeight");
51
52 const auto& elemVolVars = fluxVars.elemVolVars();
53 const auto& scvf = fluxVars.scvFace();
54 const auto& insideScv = fluxVars.fvGeometry().scv(scvf.insideScvIdx());
55 const auto& insideVolVars = elemVolVars[insideScv];
56
57 // check if this is an interior boundary
58 if (scvf.interiorBoundary())
59 {
60 const auto& cm = fluxVars.problem().couplingManager();
61 const auto& outsideVolVars = cm.getLowDimVolVars(fluxVars.element(), scvf);
62 if (std::signbit(flux)) // if sign of flux is negative
63 return flux*(upwindWeight*upwindTerm(outsideVolVars)
64 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
65 else
66 return flux*(upwindWeight*upwindTerm(insideVolVars)
67 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
68 }
69 else
70 {
71 const auto& outsideScv = fluxVars.fvGeometry().scv(scvf.outsideScvIdx());
72 const auto& outsideVolVars = elemVolVars[outsideScv];
73 if (std::signbit(flux)) // if sign of flux is negative
74 return flux*(upwindWeight*upwindTerm(outsideVolVars)
75 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
76 else
77 return flux*(upwindWeight*upwindTerm(insideVolVars)
78 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
79 }
80 }
81};
82
83} // end namespace Dumux
84
85#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
The upwind scheme used for the advective fluxes. This is a modified scheme for models involving coupl...
Definition: multidomain/facet/box/upwindscheme.hh:41
static Scalar apply(const FluxVariables &fluxVars, const UpwindTermFunction &upwindTerm, Scalar flux, int phaseIdx)
Definition: multidomain/facet/box/upwindscheme.hh:45