GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/io/plotthermalconductivitymodel.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 22 36 61.1%
Functions: 4 15 26.7%
Branches: 7 20 35.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 InputOutput
10 * \brief Interface for plotting the non-isothermal two-phase fluid-matrix-interaction laws
11 */
12 #ifndef DUMUX_PLOT_THERMAL_CONDUCTIVITY_LAW_HH
13 #define DUMUX_PLOT_THERMAL_CONDUCTIVITY_LAW_HH
14
15 #include <string>
16 #include <vector>
17 #include <dumux/material/fluidstates/compositional.hh>
18
19 namespace Dumux {
20
21 // forward declaration
22 template<class Scalar> class GnuplotInterface;
23
24 /*!
25 * \ingroup InputOutput
26 * \brief Interface for plotting the non-isothermal two-phase fluid-matrix-interaction laws
27 */
28 template<class Scalar, class ThermalConductivityModel, class FS>
29 class PlotThermalConductivityModel
30 {
31 using FluidSystem = FS;
32 using FluidState = CompositionalFluidState<Scalar, FluidSystem>;
33
34 // phase indices
35 enum
36 {
37 phase0Idx = FluidSystem::phase0Idx,
38 phase1Idx = FluidSystem::phase1Idx
39 };
40
41 public:
42 /*!
43 * \brief Constructor
44 *
45 * Initializes the fluid system.
46 *
47 * \param temperature temperature in \f$\mathrm{[K]}\f$
48 * \param pressure reference pressure in \f$\mathrm{[Pa]}\f$
49 */
50 4 PlotThermalConductivityModel(Scalar temperature = 283.15,
51 Scalar pressure = 1e5)
52 4 : numIntervals_(1000)
53 {
54 4 FluidState fluidstate;
55 4 fluidstate.setTemperature(temperature);
56 4 fluidstate.setPressure(phase0Idx, pressure);
57 4 fluidstate.setPressure(phase1Idx, pressure);
58 4 lambdaW_ = FluidSystem::thermalConductivity(fluidstate, phase0Idx);
59 4 lambdaN_ = FluidSystem::thermalConductivity(fluidstate, phase1Idx);
60 4 }
61
62 /*!
63 * \brief Add a effective thermal conductivity-saturation curve to the plot
64 *
65 * \param gnuplot The gnuplot interface
66 * \param porosity The porosity
67 * \param rhoSolid The density of the solid phase
68 * \param lambdaSolid The conductivity of the solid phase
69 * \param lowerSat Minimum x-value for data set
70 * \param upperSat Maximum x-value for data set
71 * \param curveName Name of the data set
72 * \param curveOptions Plotting options associated with that data set
73 */
74 4 void addlambdaeffcurve(GnuplotInterface<Scalar> &gnuplot,
75 Scalar porosity,
76 Scalar rhoSolid,
77 Scalar lambdaSolid,
78 Scalar lowerSat = 0.0,
79 Scalar upperSat = 1.0,
80 std::string curveName = "lambdaeff",
81 std::string curveOptions = "w l")
82 {
83 8 std::vector<Scalar> sw(numIntervals_+1);
84
4/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
16 std::vector<Scalar> lambda(numIntervals_+1);
85 4 Scalar satInterval = upperSat - lowerSat;
86
87
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 2 times.
4008 for (int i = 0; i <= numIntervals_; i++)
88 {
89 4004 sw[i] = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
90 8008 VolumeVariables volVars(sw[i], lambdaN_, lambdaW_, lambdaSolid, porosity, rhoSolid);
91 8008 lambda[i] = ThermalConductivityModel::effectiveThermalConductivity(volVars);
92 }
93
94
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 gnuplot.addDataSetToPlot(sw, lambda, curveName, curveOptions);
95 4 }
96
97 private:
98
99 class VolumeVariables
100 {
101 public:
102 VolumeVariables(Scalar saturation, Scalar lambdaN, Scalar lambdaW, Scalar lambdaSolid, Scalar porosity, Scalar rhoSolid)
103 : saturation_(saturation)
104 , lambdaN_(lambdaN)
105 , lambdaW_(lambdaW)
106 , lambdaSolid_(lambdaSolid)
107 , porosity_(porosity)
108 2002 , rhoSolid_(rhoSolid)
109 {}
110
111 using FluidSystem = typename PlotThermalConductivityModel::FluidSystem;
112
113 Scalar saturation(const int phaseIdx) const
114 {
115
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
2002 if (phaseIdx == wettingPhase())
116 return saturation_;
117 else
118 return 1.0 - saturation_;
119 }
120
121 Scalar fluidThermalConductivity(const int phaseIdx) const
122 {
123
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4004 if (phaseIdx == wettingPhase())
124 return lambdaW_;
125 else
126 return lambdaN_;
127 }
128
129 int wettingPhase() const
130 { return phase0Idx; }
131
132 Scalar porosity() const
133 { return porosity_; }
134
135 Scalar solidThermalConductivity() const
136 { return lambdaSolid_; }
137
138 Scalar solidDensity() const
139 { return rhoSolid_;}
140
141 private:
142 Scalar saturation_;
143 Scalar lambdaN_;
144 Scalar lambdaW_;
145 Scalar lambdaSolid_;
146 Scalar porosity_;
147 Scalar rhoSolid_;
148 };
149
150 int numIntervals_;
151 Scalar lambdaN_;
152 Scalar lambdaW_;
153 };
154
155 } // end namespace Dumux
156
157 #endif
158