version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_CC_LOCAL_RESIDUAL_HH
14#define DUMUX_CC_LOCAL_RESIDUAL_HH
15
21
22namespace Dumux {
23
29template<class TypeTag>
30class CCLocalResidual : public FVLocalResidual<TypeTag>
31{
34 using Element = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView::template Codim<0>::Entity;
37 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
38 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
40 using FVElementGeometry = typename GridGeometry::LocalView;
41 using Extrusion = Extrusion_t<GridGeometry>;
42 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
43
44public:
46 using ParentType::ParentType;
47
50 const Problem& problem,
51 const Element& element,
52 const FVElementGeometry& fvGeometry,
53 const ElementVolumeVariables& elemVolVars,
54 const ElementBoundaryTypes& elemBcTypes,
55 const ElementFluxVariablesCache& elemFluxVarsCache,
56 const SubControlVolumeFace& scvf) const
57 {
58 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
59 const auto localScvIdx = scv.localDofIndex();
60 residual[localScvIdx] += this->asImp().evalFlux(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
61 }
62
64 NumEqVector evalFlux(const Problem& problem,
65 const Element& element,
66 const FVElementGeometry& fvGeometry,
67 const ElementVolumeVariables& elemVolVars,
68 const ElementFluxVariablesCache& elemFluxVarsCache,
69 const SubControlVolumeFace& scvf) const
70 {
71 NumEqVector flux(0.0);
72
73 // inner faces
74 if (!scvf.boundary())
75 {
76 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
77 }
78
79 // boundary faces
80 else
81 {
82 const auto& bcTypes = problem.boundaryTypes(element, scvf);
83
84 // Dirichlet boundaries
85 if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann())
86 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
87
88 // Neumann and Robin ("solution dependent Neumann") boundary conditions
89 else if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet())
90 {
91 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
92
93 // multiply neumann fluxes with the area and the extrusion factor
94 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
95 neumannFluxes *= Extrusion::area(fvGeometry, scvf)*elemVolVars[scv].extrusionFactor();
96
97 flux += neumannFluxes;
98 }
99
100 else
101 DUNE_THROW(Dune::NotImplemented, "Mixed boundary conditions. Use pure boundary conditions by converting Dirichlet BCs to Robin BCs");
102 }
103
104 return flux;
105 }
106};
107
108} // end namespace Dumux
109
110#endif
Calculates the element-wise residual for the cell-centered discretization schemes.
Definition: cclocalresidual.hh:31
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:64
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:49
typename ParentType::ElementResidualVector ElementResidualVector
Definition: cclocalresidual.hh:45
The element-wise residual for finite volume schemes.
Definition: fvlocalresidual.hh:35
Implementation & asImp()
Definition: fvlocalresidual.hh:488
const Problem & problem() const
the problem
Definition: fvlocalresidual.hh:473
ReservedBlockVector< NumEqVector, FVElementGeometry::maxNumElementScvs > ElementResidualVector
the container storing all element residuals
Definition: fvlocalresidual.hh:57
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
The element-wise residual for finite volume schemes.
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:34
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
Definition: adapt.hh:17
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
A helper to deduce a vector with the same size as numbers of equations.
A arithmetic block vector type based on DUNE's reserved vector.