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 Quantities required by the poroelastic model defined on a sub-control volume. | ||
11 | */ | ||
12 | #ifndef DUMUX_POROELASTIC_VOLUME_VARIABLES_HH | ||
13 | #define DUMUX_POROELASTIC_VOLUME_VARIABLES_HH | ||
14 | #include <type_traits> | ||
15 | #include <dune/common/exceptions.hh> | ||
16 | |||
17 | |||
18 | namespace Dumux { | ||
19 | |||
20 | /*! | ||
21 | * \ingroup PoroElastic | ||
22 | * \brief Contains the quantities which are constant within a | ||
23 | * finite volume in the poroelastic model. | ||
24 | * | ||
25 | * \tparam Traits Class encapsulating types to be used by the vol vars | ||
26 | */ | ||
27 | template<class Traits> | ||
28 | 139472 | class PoroElasticVolumeVariables | |
29 | { | ||
30 | using Scalar = typename Traits::PrimaryVariables::value_type; | ||
31 | using ModelTraits = typename Traits::ModelTraits; | ||
32 | |||
33 | public: | ||
34 | //! export the type used for the primary variables | ||
35 | using PrimaryVariables = typename Traits::PrimaryVariables; | ||
36 | //! export the type used for displacement vectors | ||
37 | using DisplacementVector = typename Traits::DisplacementVector; | ||
38 | //! export the type encapsulating primary variable indices | ||
39 | using Indices = typename ModelTraits::Indices; | ||
40 | //! export type of solid state | ||
41 | using SolidState = typename Traits::SolidState; | ||
42 | //! export the solid system used | ||
43 | using SolidSystem = typename Traits::SolidSystem; | ||
44 | |||
45 | /*! | ||
46 | * \brief Update all quantities for a given control volume | ||
47 | * | ||
48 | * \param elemSol A vector containing all primary variables connected to the element | ||
49 | * \param problem The object specifying the problem which ought to | ||
50 | * be simulated | ||
51 | * \param element An element which contains part of the control volume | ||
52 | * \param scv The sub-control volume | ||
53 | */ | ||
54 | template<class ElemSol, class Problem, class Element, class Scv> | ||
55 | 225840 | void update(const ElemSol& elemSol, | |
56 | const Problem& problem, | ||
57 | const Element& element, | ||
58 | const Scv& scv) | ||
59 | { | ||
60 | 225840 | priVars_ = elemSol[scv.localDofIndex()]; | |
61 | 451680 | extrusionFactor_ = problem.spatialParams().extrusionFactor(element, scv, elemSol); | |
62 | |||
63 | //! set the volume fractions of the solid components | ||
64 | 225840 | updateSolidVolumeFractions_(elemSol, problem, element, scv); | |
65 | // set the temperature of the solid phase | ||
66 | 451680 | setSolidTemperature_(problem, element, scv, elemSol); | |
67 | // update the density of the solid phase | ||
68 | 677520 | solidState_.setDensity(SolidSystem::density(solidState_)); | |
69 | 225840 | } | |
70 | |||
71 | //! Return the average porosity \f$\mathrm{[-]}\f$ within the scv. | ||
72 | Scalar solidDensity() const | ||
73 | 349184 | { return solidState_.density(); } | |
74 | |||
75 | //! Return the average porosity \f$\mathrm{[-]}\f$ within the scv | ||
76 | Scalar porosity() const | ||
77 | 698368 | { return solidState_.porosity(); } | |
78 | |||
79 | //! Returns the permeability within the scv in \f$[m^2]\f$. | ||
80 | Scalar displacement(unsigned int dir) const | ||
81 | 85249664 | { return priVars_[ Indices::momentum(dir) ]; } | |
82 | |||
83 | //! Returns the displacement vector within the scv in \f$[m]\f$. | ||
84 | DisplacementVector displacement() const | ||
85 | { | ||
86 | 12864 | DisplacementVector d; | |
87 |
2/4✓ Branch 0 taken 36992 times.
✓ Branch 1 taken 12864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
49856 | for (int dir = 0; dir < d.size(); ++dir) |
88 | 110976 | d[dir] = displacement(dir); | |
89 | 1600 | return d; | |
90 | } | ||
91 | |||
92 | //! Return a component of primary variable vector for a given index | ||
93 | Scalar priVar(const int pvIdx) const | ||
94 | { return priVars_[pvIdx]; } | ||
95 | |||
96 | //! Return the vector of primary variables | ||
97 | const PrimaryVariables& priVars() const | ||
98 | 48712 | { return priVars_; } | |
99 | |||
100 | //! TODO We don't know yet how to interpret extrusion for mechanics | ||
101 | static constexpr Scalar extrusionFactor() | ||
102 | { return 1.0; } | ||
103 | |||
104 | private: | ||
105 | //! updates the volume fractions of the solid components | ||
106 | template<class ElemSol, class Problem, class Element, class Scv> | ||
107 | 225840 | void updateSolidVolumeFractions_(const ElemSol& elemSol, | |
108 | const Problem& problem, | ||
109 | const Element& element, | ||
110 | const Scv& scv) | ||
111 | { | ||
112 | static constexpr int numSolidComp = SolidState::numComponents; | ||
113 | static constexpr int numInertComp = SolidState::numInertComponents; | ||
114 | |||
115 | // first, set inert volume fractions from the spatial params | ||
116 | 225840 | const auto& sp = problem.spatialParams(); | |
117 |
2/2✓ Branch 0 taken 225840 times.
✓ Branch 1 taken 225840 times.
|
451680 | for (int sCompIdx = numSolidComp-numInertComp; sCompIdx < numSolidComp; ++sCompIdx) |
118 | 225840 | solidState_.setVolumeFraction(sCompIdx, | |
119 | sp.template inertVolumeFraction<SolidSystem>(element, scv, elemSol, sCompIdx)); | ||
120 | |||
121 | // second, set the volume fractions of the (possibly) reacting components | ||
122 | // these may come from a coupled flow model which considers mineralization, | ||
123 | // so we make reactiveVolumeFraction a params interface in which users can | ||
124 | // retrieve the current volume fractions from the flow model. | ||
125 | if (!(SolidState::isInert())) | ||
126 | for (int sCompIdx = 0; sCompIdx < numSolidComp-numInertComp; ++sCompIdx) | ||
127 | solidState_.setVolumeFraction(sCompIdx, | ||
128 | sp.template reactiveVolumeFraction<SolidSystem>(element, scv, elemSol, sCompIdx)); | ||
129 | 225840 | } | |
130 | |||
131 | //! sets the temperature in the solid state for non-isothermal models | ||
132 | static constexpr bool enableEnergyBalance = ModelTraits::enableEnergyBalance(); | ||
133 | template< class Problem, class Element, class Scv, class ElemSol, | ||
134 | bool enableEB = enableEnergyBalance, typename std::enable_if_t<enableEB, bool> = 0 > | ||
135 | void setSolidTemperature_(const Problem& problem, const Element& element, const Scv& scv, const ElemSol& elemSol) | ||
136 | { DUNE_THROW(Dune::NotImplemented, "Non-isothermal poroelastic model."); } | ||
137 | |||
138 | //! sets the temperature in the solid state for isothermal models | ||
139 | template< class Problem, class Element, class Scv, class ElemSol, | ||
140 | bool enableEB = enableEnergyBalance, typename std::enable_if_t<!enableEB, bool> = 0 > | ||
141 | ✗ | void setSolidTemperature_(const Problem& problem, const Element& element, const Scv& scv, const ElemSol& elemSol) | |
142 | 881760 | { solidState_.setTemperature(problem.spatialParams().temperature(element, scv, elemSol)); } | |
143 | |||
144 | // data members | ||
145 | Scalar extrusionFactor_; | ||
146 | PrimaryVariables priVars_; | ||
147 | SolidState solidState_; | ||
148 | }; | ||
149 | } // end namespace Dumux | ||
150 | |||
151 | #endif | ||
152 |