3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
cclocalresidual.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_CC_LOCAL_RESIDUAL_HH
26#define DUMUX_CC_LOCAL_RESIDUAL_HH
27
32
33namespace Dumux {
34
40template<class TypeTag>
41class CCLocalResidual : public FVLocalResidual<TypeTag>
42{
45 using Element = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView::template Codim<0>::Entity;
48 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
49 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
51 using FVElementGeometry = typename GridGeometry::LocalView;
52 using Extrusion = Extrusion_t<GridGeometry>;
53 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
54
55public:
57 using ParentType::ParentType;
58
61 const Problem& problem,
62 const Element& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const ElementBoundaryTypes& elemBcTypes,
66 const ElementFluxVariablesCache& elemFluxVarsCache,
67 const SubControlVolumeFace& scvf) const
68 {
69 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
70 const auto localScvIdx = scv.localDofIndex();
71 residual[localScvIdx] += this->asImp().evalFlux(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
72 }
73
75 NumEqVector evalFlux(const Problem& problem,
76 const Element& element,
77 const FVElementGeometry& fvGeometry,
78 const ElementVolumeVariables& elemVolVars,
79 const ElementFluxVariablesCache& elemFluxVarsCache,
80 const SubControlVolumeFace& scvf) const
81 {
82 NumEqVector flux(0.0);
83
84 // inner faces
85 if (!scvf.boundary())
86 {
87 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
88 }
89
90 // boundary faces
91 else
92 {
93 const auto& bcTypes = problem.boundaryTypes(element, scvf);
94
95 // Dirichlet boundaries
96 if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann())
97 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
98
99 // Neumann and Robin ("solution dependent Neumann") boundary conditions
100 else if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet())
101 {
102 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
103
104 // multiply neumann fluxes with the area and the extrusion factor
105 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
106 neumannFluxes *= Extrusion::area(scvf)*elemVolVars[scv].extrusionFactor();
107
108 flux += neumannFluxes;
109 }
110
111 else
112 DUNE_THROW(Dune::NotImplemented, "Mixed boundary conditions. Use pure boundary conditions by converting Dirichlet BCs to Robin BCs");
113 }
114
115 return flux;
116 }
117};
118
119} // end namespace Dumux
120
121#endif
The element-wise residual for finite volume schemes.
A arithmetic block vector type based on DUNE's reserved vector.
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
Calculates the element-wise residual for the cell-centered discretization schemes.
Definition: cclocalresidual.hh:42
NumEqVector evalFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
evaluate the flux residual for a sub control volume face
Definition: cclocalresidual.hh:75
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 the flux residual for a sub control volume face and add to residual
Definition: cclocalresidual.hh:60
typename ParentType::ElementResidualVector ElementResidualVector
Definition: cclocalresidual.hh:56
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
Declares all properties used in Dumux.