Line | Branch | Exec | Source |
---|---|---|---|
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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup Assembly | ||
10 | * \ingroup CCDiscretization | ||
11 | * \brief Calculates the element-wise residual for cell-centered discretization schemes | ||
12 | */ | ||
13 | #ifndef DUMUX_CC_LOCAL_RESIDUAL_HH | ||
14 | #define DUMUX_CC_LOCAL_RESIDUAL_HH | ||
15 | |||
16 | #include <dumux/common/reservedblockvector.hh> | ||
17 | #include <dumux/common/properties.hh> | ||
18 | #include <dumux/common/numeqvector.hh> | ||
19 | #include <dumux/assembly/fvlocalresidual.hh> | ||
20 | #include <dumux/discretization/extrusion.hh> | ||
21 | |||
22 | namespace Dumux { | ||
23 | |||
24 | /*! | ||
25 | * \ingroup Assembly | ||
26 | * \ingroup CCDiscretization | ||
27 | * \brief Calculates the element-wise residual for the cell-centered discretization schemes | ||
28 | */ | ||
29 | template<class TypeTag> | ||
30 | class CCLocalResidual : public FVLocalResidual<TypeTag> | ||
31 | { | ||
32 | using ParentType = FVLocalResidual<TypeTag>; | ||
33 | using Problem = GetPropType<TypeTag, Properties::Problem>; | ||
34 | using Element = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView::template Codim<0>::Entity; | ||
35 | using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; | ||
36 | using ElementBoundaryTypes = GetPropType<TypeTag, Properties::ElementBoundaryTypes>; | ||
37 | using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView; | ||
38 | using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView; | ||
39 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
40 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
41 | using Extrusion = Extrusion_t<GridGeometry>; | ||
42 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
43 | |||
44 | public: | ||
45 | using ElementResidualVector = typename ParentType::ElementResidualVector; | ||
46 |
7/14✓ Branch 1 taken 44282087 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20841882 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 563526 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 100264 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 105781 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1928000 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 200 times.
✗ Branch 20 not taken.
|
67821740 | using ParentType::ParentType; |
47 | |||
48 | //! evaluate the flux residual for a sub control volume face and add to residual | ||
49 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108077375 times.
|
656625332 | void evalFlux(ElementResidualVector& residual, |
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 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108077375 times.
|
641137972 | const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); |
59 | 656625332 | const auto localScvIdx = scv.localDofIndex(); | |
60 |
2/2✓ Branch 1 taken 596894149 times.
✓ Branch 2 taken 251101161 times.
|
1258377945 | residual[localScvIdx] += this->asImp().evalFlux(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf); |
61 | 384720904 | } | |
62 | |||
63 | //! evaluate the flux residual for a sub control volume face | ||
64 | 1162087432 | 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 |
2/2✓ Branch 0 taken 751819341 times.
✓ Branch 1 taken 21512897 times.
|
1162087432 | NumEqVector flux(0.0); |
72 | |||
73 | // inner faces | ||
74 |
2/2✓ Branch 0 taken 751819341 times.
✓ Branch 1 taken 21512897 times.
|
1162087432 | if (!scvf.boundary()) |
75 | { | ||
76 | 1798878500 | flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); | |
77 | } | ||
78 | |||
79 | // boundary faces | ||
80 | else | ||
81 | { | ||
82 |
5/5✓ Branch 0 taken 1527070 times.
✓ Branch 1 taken 18527943 times.
✓ Branch 2 taken 1489664 times.
✓ Branch 3 taken 95188 times.
✓ Branch 4 taken 38094 times.
|
32250558 | const auto& bcTypes = problem.boundaryTypes(element, scvf); |
83 | |||
84 | // Dirichlet boundaries | ||
85 |
4/4✓ Branch 0 taken 1787538 times.
✓ Branch 1 taken 19725359 times.
✓ Branch 2 taken 1643606 times.
✓ Branch 3 taken 143932 times.
|
32026331 | if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann()) |
86 |
1/2✓ Branch 1 taken 143932 times.
✗ Branch 2 not taken.
|
4150430 | flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); |
87 | |||
88 | // Neumann and Robin ("solution dependent Neumann") boundary conditions | ||
89 |
2/4✓ Branch 0 taken 19725359 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19725359 times.
|
29786523 | else if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet()) |
90 | { | ||
91 |
4/5✓ Branch 0 taken 7796336 times.
✓ Branch 1 taken 4234765 times.
✓ Branch 2 taken 592054 times.
✓ Branch 3 taken 24896 times.
✗ Branch 4 not taken.
|
35119291 | auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf); |
92 | |||
93 | // multiply neumann fluxes with the area and the extrusion factor | ||
94 |
2/2✓ Branch 0 taken 9186832 times.
✓ Branch 1 taken 792739 times.
|
40326394 | const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); |
95 |
2/2✓ Branch 1 taken 33418282 times.
✓ Branch 2 taken 12729795 times.
|
93951896 | neumannFluxes *= Extrusion::area(fvGeometry, scvf)*elemVolVars[scv].extrusionFactor(); |
96 | |||
97 | 29786523 | flux += neumannFluxes; | |
98 | } | ||
99 | |||
100 | else | ||
101 |
0/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
32026331 | DUNE_THROW(Dune::NotImplemented, "Mixed boundary conditions. Use pure boundary conditions by converting Dirichlet BCs to Robin BCs"); |
102 | } | ||
103 | |||
104 | 1162087432 | return flux; | |
105 | } | ||
106 | }; | ||
107 | |||
108 | } // end namespace Dumux | ||
109 | |||
110 | #endif | ||
111 |