3.1-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
33
34namespace Dumux {
35
41template<class TypeTag>
43{
48 using Element = typename GridView::template Codim<0>::Entity;
50 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
51 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
52 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
53 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
55
56public:
58 using ParentType::ParentType;
59
62 const Problem& problem,
63 const Element& element,
64 const FVElementGeometry& fvGeometry,
65 const ElementVolumeVariables& elemVolVars,
66 const ElementBoundaryTypes& elemBcTypes,
67 const ElementFluxVariablesCache& elemFluxVarsCache,
68 const SubControlVolumeFace& scvf) const
69 {
70 const auto flux = evalFlux(problem, element, fvGeometry, elemVolVars, elemBcTypes, elemFluxVarsCache, scvf);
71
72 // inner faces
73 if (!scvf.boundary() && !scvf.interiorBoundary())
74 {
75 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
76 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
77 residual[insideScv.localDofIndex()] += flux;
78 residual[outsideScv.localDofIndex()] -= flux;
79 }
80
81 // interior/domain boundary faces
82 else
83 {
84 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
85 residual[insideScv.localDofIndex()] += flux;
86 }
87 }
88
90 NumEqVector evalFlux(const Problem& problem,
91 const Element& element,
92 const FVElementGeometry& fvGeometry,
93 const ElementVolumeVariables& elemVolVars,
94 const ElementBoundaryTypes& elemBcTypes,
95 const ElementFluxVariablesCache& elemFluxVarsCache,
96 const SubControlVolumeFace& scvf) const
97 {
98 NumEqVector flux(0.0);
99
100 // inner or interior boundary faces
101 if (!scvf.boundary() || scvf.interiorBoundary())
102 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
103
104 // boundary faces
105 else
106 {
107 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
108 const auto& bcTypes = elemBcTypes[scv.localDofIndex()];
109
110 // Neumann and Robin ("solution dependent Neumann") boundary conditions
111 if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet())
112 {
113 auto neumannFluxes = Deprecated::neumann(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
114
115 // multiply neumann fluxes with the area and the extrusion factor
116 neumannFluxes *= scvf.area()*elemVolVars[scv].extrusionFactor();
117
118 flux += neumannFluxes;
119 }
120
121 // for Dirichlet there is no addition to the residual here but they
122 // are enforced strongly by replacing the residual entry afterwards
123 else if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann())
124 return flux;
125 else
126 DUNE_THROW(Dune::NotImplemented, "Mixed boundary conditions. Use pure boundary conditions by converting Dirichlet BCs to Robin BCs");
127 }
128
129 return flux;
130 }
131};
132
133} // end namespace Dumux
134
135#endif
The element-wise residual for finite volume schemes.
Helpers for deprecation.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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:45
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:66
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:90
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:61
Declares all properties used in Dumux.