GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/geomechanics/elastic/volumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 3 13 23.1%
Functions: 0 2 0.0%
Branches: 0 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 Quantities required by the elastic model defined on a sub-control volume.
11 */
12 #ifndef DUMUX_ELASTIC_VOLUME_VARIABLES_HH
13 #define DUMUX_ELASTIC_VOLUME_VARIABLES_HH
14
15 #include <type_traits>
16
17 #include <dune/common/exceptions.hh>
18
19 #include <dumux/material/solidstates/updatesolidvolumefractions.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup Elastic
25 * \brief Contains the quantities which are constant within a
26 * finite volume in the elastic model.
27 *
28 * \tparam Traits Class encapsulating types to be used by the vol vars
29 */
30 template<class Traits>
31 3216 class ElasticVolumeVariables
32 {
33 using Scalar = typename Traits::PrimaryVariables::value_type;
34 using ModelTraits = typename Traits::ModelTraits;
35
36 //! The elastic model only makes sense with inert solid systems
37 static_assert(Traits::SolidSystem::isInert(), "Elastic model can only be used with inert solid systems");
38 public:
39 //! export the type used for the primary variables
40 using PrimaryVariables = typename Traits::PrimaryVariables;
41 //! export the type used for displacement vectors
42 using DisplacementVector = typename Traits::DisplacementVector;
43 //! export the type encapsulating primary variable indices
44 using Indices = typename ModelTraits::Indices;
45 //! export type of solid state
46 using SolidState = typename Traits::SolidState;
47 //! export the solid system used
48 using SolidSystem = typename Traits::SolidSystem;
49
50 /*!
51 * \brief Update all quantities for a given control volume
52 *
53 * \param elemSol A vector containing all primary variables connected to the element
54 * \param problem The object specifying the problem which ought to
55 * be simulated
56 * \param element An element which contains part of the control volume
57 * \param scv The sub-control volume
58 */
59 template<class ElemSol, class Problem, class Element, class Scv>
60 void update(const ElemSol& elemSol,
61 const Problem& problem,
62 const Element& element,
63 const Scv& scv)
64 {
65 priVars_ = elemSol[scv.localDofIndex()];
66 extrusionFactor_ = problem.spatialParams().extrusionFactor(element, scv, elemSol);
67
68 //! set the volume fractions of the solid components
69 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, /*numFluidComps=*/0);
70 // set the temperature of the solid phase
71 setSolidTemperature_(problem, element, scv, elemSol);
72 // update the density of the solid phase
73 solidState_.setDensity(SolidSystem::density(solidState_));
74 }
75
76 //! Return the average porosity \f$\mathrm{[-]}\f$ within the control volume.
77 Scalar solidDensity() const
78 { return solidState_.density(); }
79
80 //! Returns the permeability within the control volume in \f$[m]\f$.
81 Scalar displacement(unsigned int dir) const
82 172800 { return priVars_[ Indices::momentum(dir) ]; }
83
84 //! Returns the displacement vector within the scv in \f$[m]\f$.
85 DisplacementVector displacement() const
86 {
87 DisplacementVector d;
88 for (int dir = 0; dir < d.size(); ++dir)
89 d[dir] = displacement(dir);
90 return d;
91 }
92
93 //! Return a component of primary variable vector for a given index
94 Scalar priVar(const int pvIdx) const
95 { return priVars_[pvIdx]; }
96
97 //! Return the vector of primary variables
98 const PrimaryVariables& priVars() const
99 232 { return priVars_; }
100
101 //! TODO We don't know yet how to interpret extrusion for mechanics
102 static constexpr Scalar extrusionFactor()
103 { return 1.0; }
104
105 private:
106 //! sets the temperature in the solid state for non-isothermal models
107 static constexpr bool enableEnergyBalance = ModelTraits::enableEnergyBalance();
108 template< class Problem, class Element, class Scv, class ElemSol,
109 bool enableEB = enableEnergyBalance, typename std::enable_if_t<enableEB, bool> = 0 >
110 void setSolidTemperature_(const Problem& problem, const Element& element, const Scv& scv, const ElemSol& elemSol)
111 { DUNE_THROW(Dune::NotImplemented, "Non-isothermal elastic model."); }
112
113 //! sets the temperature in the solid state for isothermal models
114 template< class Problem, class Element, class Scv, class ElemSol,
115 bool enableEB = enableEnergyBalance, typename std::enable_if_t<!enableEB, bool> = 0 >
116 void setSolidTemperature_(const Problem& problem, const Element& element, const Scv& scv, const ElemSol& elemSol)
117 { solidState_.setTemperature(problem.spatialParams().temperature(element, scv, elemSol)); }
118
119 // data members
120 Scalar extrusionFactor_;
121 PrimaryVariables priVars_;
122 SolidState solidState_;
123 };
124
125 } // end namespace Dumux
126
127 #endif
128