3.5-git
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
34
35namespace Dumux {
36
42template<class TypeTag>
44{
49 using FVElementGeometry = typename GridGeometry::LocalView;
50 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
51 using Extrusion = Extrusion_t<GridGeometry>;
52 using GridView = typename GridGeometry::GridView;
53 using Element = typename GridView::template Codim<0>::Entity;
55 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
56 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
58
59public:
61 using ParentType::ParentType;
62
65 const Problem& problem,
66 const Element& element,
67 const FVElementGeometry& fvGeometry,
68 const ElementVolumeVariables& elemVolVars,
69 const ElementBoundaryTypes& elemBcTypes,
70 const ElementFluxVariablesCache& elemFluxVarsCache,
71 const SubControlVolumeFace& scvf) const
72 {
73 const auto flux = evalFlux(problem, element, fvGeometry, elemVolVars, elemBcTypes, elemFluxVarsCache, scvf);
74
75 // inner faces
76 if (!scvf.boundary() && !scvf.interiorBoundary())
77 {
78 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
79 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
80 residual[insideScv.localDofIndex()] += flux;
81 residual[outsideScv.localDofIndex()] -= flux;
82 }
83
84 // interior/domain boundary faces
85 else
86 {
87 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
88 residual[insideScv.localDofIndex()] += flux;
89 }
90 }
91
93 NumEqVector evalFlux(const Problem& problem,
94 const Element& element,
95 const FVElementGeometry& fvGeometry,
96 const ElementVolumeVariables& elemVolVars,
97 const ElementBoundaryTypes& elemBcTypes,
98 const ElementFluxVariablesCache& elemFluxVarsCache,
99 const SubControlVolumeFace& scvf) const
100 {
101 NumEqVector flux(0.0);
102
103 // inner or interior boundary faces
104 if (!scvf.boundary() || scvf.interiorBoundary())
105 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
106
107 // boundary faces
108 else
109 {
110 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
111 const auto& bcTypes = elemBcTypes[scv.localDofIndex()];
112
113 // Neumann and Robin ("solution dependent Neumann") boundary conditions
114 if (bcTypes.hasNeumann())
115 {
116 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
117
118 // multiply neumann fluxes with the area and the extrusion factor
119 neumannFluxes *= Extrusion::area(scvf)*elemVolVars[scv].extrusionFactor();
120
121 // only add fluxes to equations for which Neumann is set
122 for (int eqIdx = 0; eqIdx < NumEqVector::dimension; ++eqIdx)
123 if (bcTypes.isNeumann(eqIdx))
124 flux[eqIdx] += neumannFluxes[eqIdx];
125 }
126 }
127
128 return flux;
129 }
130};
131
132} // end namespace Dumux
133
134#endif
The element-wise residual for finite volume schemes.
A helper to deduce a vector with the same size as numbers of equations.
Helper classes to compute the integration elements.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:46
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
Definition: propertysystem.hh:150
The element-wise residual for finite volume schemes.
Definition: fvlocalresidual.hh:47
Implementation & asImp()
Definition: fvlocalresidual.hh:501
const Problem & problem() const
the problem
Definition: fvlocalresidual.hh:486
ReservedBlockVector< NumEqVector, FVElementGeometry::maxNumElementScvs > ElementResidualVector
the container storing all element residuals
Definition: fvlocalresidual.hh:69
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:44
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:93
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:64
Declares all properties used in Dumux.