GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/geomechanics/elastic/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 10 15 66.7%
Functions: 1 9 11.1%
Branches: 8 16 50.0%

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 Elastic
10 * \brief Element-wise calculation of the local residual for problems
11 * using the elastic model considering linear elasticity.
12 */
13 #ifndef DUMUX_GEOMECHANICS_ELASTIC_LOCAL_RESIDUAL_HH
14 #define DUMUX_GEOMECHANICS_ELASTIC_LOCAL_RESIDUAL_HH
15
16 #include <dumux/common/parameters.hh>
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/parameters.hh>
19 #include <dumux/common/numeqvector.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup Elastic
25 * \brief Element-wise calculation of the local residual for problems
26 * using the elastic model considering linear elasticity.
27 */
28 template<class TypeTag>
29 class ElasticLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual>
30 {
31 using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>;
32
33 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
34 using Element = typename GridView::template Codim<0>::Entity;
35
36 using Problem = GetPropType<TypeTag, Properties::Problem>;
37 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
38 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
39 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
40 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
41 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
42 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
43 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
44 using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
45
46 // class assembling the stress tensor
47 using StressType = GetPropType<TypeTag, Properties::StressType>;
48
49 public:
50
2/4
✓ Branch 1 taken 5436 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5436 times.
✗ Branch 5 not taken.
10872 using ParentType::ParentType;
51
52 /*!
53 * \brief For the elastic model the storage term is zero since
54 * we neglect inertia forces.
55 *
56 * \param problem The problem
57 * \param scv The sub control volume
58 * \param volVars The current or previous volVars
59 */
60 NumEqVector computeStorage(const Problem& problem,
61 const SubControlVolume& scv,
62 const VolumeVariables& volVars) const
63 {
64 1402880 return NumEqVector(0.0);
65 }
66
67 /*!
68 * \brief Evaluates the force in all grid directions acting
69 * on a face of a sub-control volume.
70 *
71 * \param problem The problem
72 * \param element The current element.
73 * \param fvGeometry The finite-volume geometry
74 * \param elemVolVars The volume variables of the current element
75 * \param scvf The sub control volume face to compute the flux on
76 * \param elemFluxVarsCache The cache related to flux computation
77 */
78 NumEqVector computeFlux(const Problem& problem,
79 const Element& element,
80 const FVElementGeometry& fvGeometry,
81 const ElementVolumeVariables& elemVolVars,
82 const SubControlVolumeFace& scvf,
83 const ElementFluxVariablesCache& elemFluxVarsCache) const
84 {
85 // obtain force on the face from stress type
86 1204176 return StressType::force(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
87 }
88
89 /*!
90 * \brief Calculate the source term of the equation
91 *
92 * \param problem The problem to solve
93 * \param element The DUNE Codim<0> entity for which the residual
94 * ought to be calculated
95 * \param fvGeometry The finite-volume geometry of the element
96 * \param elemVolVars The volume variables associated with the element stencil
97 * \param scv The sub-control volume over which we integrate the source term
98 * \note This is the default implementation for geomechanical models adding to
99 * the user defined sources the source stemming from the gravitational acceleration.
100 *
101 */
102 7200 NumEqVector computeSource(const Problem& problem,
103 const Element& element,
104 const FVElementGeometry& fvGeometry,
105 const ElementVolumeVariables& elemVolVars,
106 const SubControlVolume &scv) const
107 {
108 7200 NumEqVector source(0.0);
109
110 // add contributions from volume flux sources
111 7200 source += problem.source(element, fvGeometry, elemVolVars, scv);
112
113 // add contribution from possible point sources
114 7200 source += problem.scvPointSources(element, fvGeometry, elemVolVars, scv);
115
116 // maybe add gravitational acceleration
117
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7199 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
7200 static const bool gravity = getParamFromGroup<bool>(problem.paramGroup(), "Problem.EnableGravity");
118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7200 times.
7200 if (gravity)
119 {
120 const auto& g = problem.spatialParams().gravity(scv.center());
121 for (int dir = 0; dir < GridView::dimensionworld; ++dir)
122 source[Indices::momentum(dir)] += elemVolVars[scv].solidDensity()*g[dir];
123 }
124
125 7200 return source;
126 }
127 };
128
129 } // end namespace Dumux
130
131 #endif
132