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-FileCopyrightInfo: 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 42511641 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11312824 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1277064 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.
|
57235774 | using ParentType::ParentType; |
47 | |||
48 | //! evaluate the flux residual for a sub control volume face and add to residual | ||
49 | ✗ | 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 |
0/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
770513594 | const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); |
59 | 431342901 | const auto localScvIdx = scv.localDofIndex(); | |
60 |
9/9✓ Branch 1 taken 709104 times.
✓ Branch 2 taken 354552 times.
✓ Branch 3 taken 585024861 times.
✓ Branch 4 taken 245710153 times.
✓ Branch 5 taken 584315757 times.
✓ Branch 6 taken 249504961 times.
✓ Branch 7 taken 2074680 times.
✓ Branch 8 taken 4149360 times.
✓ Branch 9 taken 2074680 times.
|
1609691343 | residual[localScvIdx] += this->asImp().evalFlux(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf); |
61 | ✗ | } | |
62 | |||
63 | //! evaluate the flux residual for a sub control volume face | ||
64 | 1010406263 | 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 111953224 times.
✓ Branch 1 taken 6849628 times.
|
1010406263 | NumEqVector flux(0.0); |
72 | |||
73 | // inner faces | ||
74 |
2/2✓ Branch 0 taken 742055055 times.
✓ Branch 1 taken 20916578 times.
|
1010406263 | if (!scvf.boundary()) |
75 | { | ||
76 | 1641753844 | flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); | |
77 | } | ||
78 | |||
79 | // boundary faces | ||
80 | else | ||
81 | { | ||
82 |
2/2✓ Branch 0 taken 5911392 times.
✓ Branch 1 taken 895474 times.
|
27048756 | const auto& bcTypes = problem.boundaryTypes(element, scvf); |
83 | |||
84 | // Dirichlet boundaries | ||
85 |
8/8✓ Branch 0 taken 1751970 times.
✓ Branch 1 taken 19164608 times.
✓ Branch 2 taken 1751970 times.
✓ Branch 3 taken 19164608 times.
✓ Branch 4 taken 1619666 times.
✓ Branch 5 taken 132304 times.
✓ Branch 6 taken 1619666 times.
✓ Branch 7 taken 132304 times.
|
54097512 | if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann()) |
86 | 3967690 | flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); | |
87 | |||
88 | // Neumann and Robin ("solution dependent Neumann") boundary conditions | ||
89 |
4/8✓ Branch 0 taken 19164608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19164608 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 19164608 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 19164608 times.
|
49812264 | else if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet()) |
90 | { | ||
91 |
2/2✓ Branch 0 taken 5769782 times.
✓ Branch 1 taken 28798 times.
|
24906132 | auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf); |
92 | |||
93 | // multiply neumann fluxes with the area and the extrusion factor | ||
94 |
3/4✓ Branch 0 taken 9187844 times.
✓ Branch 1 taken 753555 times.
✓ Branch 2 taken 8418780 times.
✗ Branch 3 not taken.
|
44041615 | const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); |
95 | 52226868 | neumannFluxes *= Extrusion::area(fvGeometry, scvf)*elemVolVars[scv].extrusionFactor(); | |
96 | |||
97 | 24906192 | 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 | 1010406263 | return flux; | |
105 | } | ||
106 | }; | ||
107 | |||
108 | } // end namespace Dumux | ||
109 | |||
110 | #endif | ||
111 |