3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/facet/box/localresidual.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_FACETCOUPLING_BOX_LOCAL_RESIDUAL_HH
26#define DUMUX_FACETCOUPLING_BOX_LOCAL_RESIDUAL_HH
27
28#include <dune/geometry/type.hh>
29
33
34namespace Dumux {
35
41template<class TypeTag>
43{
48 using FVElementGeometry = typename GridGeometry::LocalView;
49 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
50 using Extrusion = Extrusion_t<GridGeometry>;
51 using GridView = typename GridGeometry::GridView;
52 using Element = typename GridView::template Codim<0>::Entity;
54 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
55 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
57
58public:
60 using ParentType::ParentType;
61
64 const Problem& problem,
65 const Element& element,
66 const FVElementGeometry& fvGeometry,
67 const ElementVolumeVariables& elemVolVars,
68 const ElementBoundaryTypes& elemBcTypes,
69 const ElementFluxVariablesCache& elemFluxVarsCache,
70 const SubControlVolumeFace& scvf) const
71 {
72 const auto flux = evalFlux(problem, element, fvGeometry, elemVolVars, elemBcTypes, elemFluxVarsCache, scvf);
73
74 // inner faces
75 if (!scvf.boundary() && !scvf.interiorBoundary())
76 {
77 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
78 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
79 residual[insideScv.localDofIndex()] += flux;
80 residual[outsideScv.localDofIndex()] -= flux;
81 }
82
83 // interior/domain boundary faces
84 else
85 {
86 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
87 residual[insideScv.localDofIndex()] += flux;
88 }
89 }
90
92 NumEqVector evalFlux(const Problem& problem,
93 const Element& element,
94 const FVElementGeometry& fvGeometry,
95 const ElementVolumeVariables& elemVolVars,
96 const ElementBoundaryTypes& elemBcTypes,
97 const ElementFluxVariablesCache& elemFluxVarsCache,
98 const SubControlVolumeFace& scvf) const
99 {
100 NumEqVector flux(0.0);
101
102 // inner or interior boundary faces
103 if (!scvf.boundary() || scvf.interiorBoundary())
104 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
105
106 // boundary faces
107 else
108 {
109 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
110 const auto& bcTypes = elemBcTypes[scv.localDofIndex()];
111
112 // Neumann and Robin ("solution dependent Neumann") boundary conditions
113 if (bcTypes.hasNeumann())
114 {
115 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
116
117 // multiply neumann fluxes with the area and the extrusion factor
118 neumannFluxes *= Extrusion::area(scvf)*elemVolVars[scv].extrusionFactor();
119
120 // only add fluxes to equations for which Neumann is set
121 for (int eqIdx = 0; eqIdx < NumEqVector::dimension; ++eqIdx)
122 if (bcTypes.isNeumann(eqIdx))
123 flux[eqIdx] += neumannFluxes[eqIdx];
124 }
125 }
126
127 return flux;
128 }
129};
130
131} // end namespace Dumux
132
133#endif
The element-wise residual for finite volume schemes.
Helper classes to compute the integration elements.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
The element-wise residual for finite volume schemes.
Definition: fvlocalresidual.hh:46
Implementation & asImp()
Definition: fvlocalresidual.hh:503
const Problem & problem() const
the problem
Definition: fvlocalresidual.hh:488
ReservedBlockVector< NumEqVector, FVElementGeometry::maxNumElementScvs > ElementResidualVector
the container storing all element residuals
Definition: fvlocalresidual.hh:68
A arithmetic block vector type based on DUNE's reserved vector.
Definition: reservedblockvector.hh:38
The element-wise residual for the box scheme.
Definition: multidomain/facet/box/localresidual.hh:43
NumEqVector evalFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementBoundaryTypes &elemBcTypes, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
evaluate flux residuals for one sub control volume face
Definition: multidomain/facet/box/localresidual.hh:92
void evalFlux(ElementResidualVector &residual, const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementBoundaryTypes &elemBcTypes, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
evaluate flux residuals for one sub control volume face and add to residual
Definition: multidomain/facet/box/localresidual.hh:63
Declares all properties used in Dumux.