GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/solidsystems/compositionalsolidphase.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 32 41 78.0%
Functions: 11 29 37.9%
Branches: 29 118 24.6%

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 SolidSystems
10 * \brief A solid phase consisting of multiple inert solid components.
11 */
12 #ifndef DUMUX_SOLIDSYSTEMS_COMPOSITIONAL_SOLID_PHASE_HH
13 #define DUMUX_SOLIDSYSTEMS_COMPOSITIONAL_SOLID_PHASE_HH
14
15 #include <string>
16 #include <dune/common/exceptions.hh>
17
18 namespace Dumux {
19 namespace SolidSystems {
20
21 /*!
22 * \ingroup SolidSystems
23 * \brief A solid phase consisting of multiple inert solid components.
24 * \note a solid is considered inert if it cannot dissolve in a liquid and
25 * and cannot increase its mass by precipitation from a fluid phase.
26 * \note inert components have to come after all non-inert components
27 */
28 template <class Scalar, class Component1, class Component2, int numInert = 0>
29 class CompositionalSolidPhase
30 {
31 public:
32 using ComponentOne = Component1;
33 using ComponentTwo = Component2;
34
35
36 /****************************************
37 * Solid phase related static parameters
38 ****************************************/
39 static constexpr int numComponents = 2;
40 static constexpr int numInertComponents = numInert;
41 static constexpr int comp0Idx = 0;
42 static constexpr int comp1Idx = 1;
43
44
45 /*!
46 * \brief Return the human readable name of a solid phase
47 *
48 * \param compIdx The index of the solid phase to consider
49 */
50 30 static std::string componentName(int compIdx)
51 {
52
2/3
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
30 switch (compIdx)
53 {
54 22 case comp0Idx: return ComponentOne::name();
55 18 case comp1Idx: return ComponentTwo::name();
56 default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx);
57 }
58 }
59
60 /*!
61 * \brief A human readable name for the solid system.
62 */
63 static std::string name()
64
12/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
6 { return "s"; }
65
66 /*!
67 * \brief Returns whether the phase is incompressible
68 */
69 static constexpr bool isCompressible(int compIdx)
70 { return false; }
71
72 /*!
73 * \brief Returns whether the component is inert (doesn't react)
74 */
75 static constexpr bool isInert()
76 { return (numComponents == numInertComponents); }
77
78 /*!
79 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of the component.
80 */
81 12 static Scalar molarMass(int compIdx)
82 {
83
2/3
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
12 switch (compIdx)
84 {
85 case comp0Idx: return ComponentOne::molarMass();
86 6 case comp1Idx: return ComponentTwo::molarMass();
87 default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx);
88 }
89 }
90
91 /*!
92 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of the solid phase at a given pressure and temperature.
93 */
94 template <class SolidState>
95 static Scalar density(const SolidState& solidState)
96 {
97 111151 Scalar rho1 = ComponentOne::solidDensity(solidState.temperature());
98 111151 Scalar rho2 = ComponentTwo::solidDensity(solidState.temperature());
99 111151 Scalar volFrac1 = solidState.volumeFraction(comp0Idx);
100 111151 Scalar volFrac2 = solidState.volumeFraction(comp1Idx);
101
102 222302 return (rho1*volFrac1+
103
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
111151 rho2*volFrac2)/(volFrac1+volFrac2);
104 }
105
106 /*!
107 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of the solid phase at a given pressure and temperature.
108 */
109 template <class SolidState>
110 615752 static Scalar density(const SolidState& solidState, const int compIdx)
111 {
112
2/3
✓ Branch 0 taken 273664 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 342088 times.
615752 switch (compIdx)
113 {
114 case comp0Idx: return ComponentOne::solidDensity(solidState.temperature());
115 273664 case comp1Idx: return ComponentTwo::solidDensity(solidState.temperature());
116 default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx);
117 }
118 }
119
120 /*!
121 * \brief The molar density of the solid phase at a given pressure and temperature.
122 */
123 template <class SolidState>
124 12706721 static Scalar molarDensity(const SolidState& solidState, const int compIdx)
125 {
126
2/3
✓ Branch 0 taken 134400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12572321 times.
12706721 switch (compIdx)
127 {
128 case comp0Idx: return ComponentOne::solidDensity(solidState.temperature())/ComponentOne::molarMass();
129 134400 case comp1Idx: return ComponentTwo::solidDensity(solidState.temperature())/ComponentTwo::molarMass();
130 default: DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx);
131 }
132 }
133
134 /*!
135 * \brief Thermal conductivity of the solid \f$\mathrm{[W/(m K)]}\f$.
136 */
137 template <class SolidState>
138 static Scalar thermalConductivity(const SolidState &solidState)
139 {
140 111151 Scalar lambda1 = ComponentOne::solidThermalConductivity(solidState.temperature());
141 111151 Scalar lambda2 = ComponentTwo::solidThermalConductivity(solidState.temperature());
142 111151 Scalar volFrac1 = solidState.volumeFraction(comp0Idx);
143 111151 Scalar volFrac2 = solidState.volumeFraction(comp1Idx);
144
145 222302 return (lambda1*volFrac1+
146
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
111151 lambda2*volFrac2)/(volFrac1+volFrac2);
147 }
148
149 /*!
150 * \brief Specific isobaric heat capacity of the pure solids \f$\mathrm{[J/(kg K)]}\f$.
151 */
152 template <class SolidState>
153 static Scalar heatCapacity(const SolidState &solidState)
154 {
155 111151 Scalar c1 = ComponentOne::solidHeatCapacity(solidState.temperature());
156 111151 Scalar c2 = ComponentTwo::solidHeatCapacity(solidState.temperature());
157 111151 Scalar volFrac1 = solidState.volumeFraction(comp0Idx);
158 111151 Scalar volFrac2 = solidState.volumeFraction(comp1Idx);
159
160 222302 return (c1*volFrac1+
161
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
111151 c2*volFrac2)/(volFrac1+volFrac2);
162 }
163
164 };
165
166 } // end namespace SolidSystems
167 } // end namespace Dumux
168
169 #endif
170