GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/geomechanics/poroelastic/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 3 3 100.0%
Branches: 11 16 68.8%

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 PoroElastic
10 * \brief Element-wise calculation of the local residual
11 * for problems using the poroelastic model.
12 */
13 #ifndef DUMUX_PRORELASTIC_LOCAL_RESIDUAL_HH
14 #define DUMUX_PRORELASTIC_LOCAL_RESIDUAL_HH
15
16 #include <dumux/common/properties.hh>
17 #include <dumux/common/numeqvector.hh>
18 #include <dumux/geomechanics/elastic/localresidual.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup PoroElastic
24 * \brief Element-wise calculation of the local residual
25 * for problems using the poroelastic model.
26 */
27 template<class TypeTag>
28 class PoroElasticLocalResidual: public ElasticLocalResidual<TypeTag>
29 {
30 using ParentType = ElasticLocalResidual<TypeTag>;
31
32 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
33 using Element = typename GridView::template Codim<0>::Entity;
34
35 using Problem = GetPropType<TypeTag, Properties::Problem>;
36 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
37 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
38 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
39 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
40 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
41 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
42 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
43 using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
44
45 public:
46
2/4
✓ Branch 1 taken 5236 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5236 times.
✗ Branch 5 not taken.
10472 using ParentType::ParentType;
47
48 /*!
49 * \brief Calculate the source term of the equation
50 *
51 * \param problem The problem to solve
52 * \param element The DUNE Codim<0> entity for which the residual
53 * ought to be calculated
54 * \param fvGeometry The finite-volume geometry of the element
55 * \param elemVolVars The volume variables associated with the element stencil
56 * \param scv The sub-control volume over which we integrate the source term
57 * \note This is the default implementation for geomechanical models adding to
58 * the user defined sources the source stemming from the gravitational acceleration.
59 *
60 */
61 804784 NumEqVector computeSource(const Problem& problem,
62 const Element& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const SubControlVolume &scv) const
66 {
67 804784 NumEqVector source(0.0);
68
69 // add contributions from volume flux sources
70 817984 source += problem.source(element, fvGeometry, elemVolVars, scv);
71
72 // add contribution from possible point sources
73 804784 source += problem.scvPointSources(element, fvGeometry, elemVolVars, scv);
74
75 // maybe add gravitational acceleration
76
5/8
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 804780 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
804784 static const bool gravity = getParamFromGroup<bool>(problem.paramGroup(), "Problem.EnableGravity");
77
2/2
✓ Branch 0 taken 349184 times.
✓ Branch 1 taken 455600 times.
804784 if (gravity)
78 {
79 // compute average density
80 349184 const auto& vv = elemVolVars[scv];
81 349184 const auto phi = vv.porosity();
82 698368 const auto rhoFluid = problem.spatialParams().effectiveFluidDensity(element, scv);
83 349184 const auto rhoAverage = phi*rhoFluid + (1.0 - phi)*vv.solidDensity();
84
85 // add body force
86 1047552 const auto& g = problem.spatialParams().gravity(scv.center());
87
2/2
✓ Branch 0 taken 1047552 times.
✓ Branch 1 taken 349184 times.
1396736 for (int dir = 0; dir < GridView::dimensionworld; ++dir)
88 4190208 source[ Indices::momentum(dir) ] += rhoAverage*g[dir];
89 }
90
91 804784 return source;
92 }
93 };
94
95 } // end namespace Dumux
96
97 #endif
98