version 3.10-dev
plotmateriallaw3p.hh
Go to the documentation of this file.
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//
12#ifndef DUMUX_PLOT_FLUID_MATRIX_LAW_HH
13#define DUMUX_PLOT_FLUID_MATRIX_LAW_HH
14
15#include <cmath>
16#include <string>
17#include <vector>
18
19namespace Dumux {
20
21// forward declaration
22template<class Scalar> class GnuplotInterface;
23
29template<class Scalar, class MaterialLaw>
31{
32 using MaterialLawParams = typename MaterialLaw::Params;
33
34public:
36 PlotMaterialLaw(bool interaction = true)
37 : numIntervals_(1000)
38 {}
39
50 const MaterialLawParams &params,
51 Scalar lowerSat = 0.0,
52 Scalar upperSat = 1.0,
53 std::string curveTitle = "")
54 {
55 addpcgw(gnuplot, params, lowerSat, upperSat, curveTitle);
56 addpcnw(gnuplot, params, lowerSat, upperSat, curveTitle);
57 addpcgn(gnuplot, params, lowerSat, upperSat, curveTitle);
58 }
59
70 const MaterialLawParams &params,
71 Scalar lowerSat = 0.0,
72 Scalar upperSat = 1.0,
73 std::string curveTitle = "")
74 {
75 std::vector<Scalar> sw;
76 std::vector<Scalar> pc;
77 Scalar satInterval = upperSat - lowerSat;
78 Scalar pcMin = 0.0;
79 Scalar pcMax = -1e100;
80
81 Scalar swTemp, pcTemp = 0.0;
82 for (int i = 0; i <= numIntervals_; i++)
83 {
84 swTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
85 pcTemp = MaterialLaw::pcgw(params, swTemp);
86 using std::max;
87 using std::min;
88 if (checkValues_(swTemp, pcTemp))
89 {
90 sw.push_back(swTemp);
91 pc.push_back(pcTemp);
92 pcMin = min(pcMin, pcTemp);
93 pcMax = max(pcMax, pcTemp);
94 }
95 }
96
97 gnuplot.setXlabel("wetting phase saturation [-]");
98 gnuplot.setYlabel("capillary pressure [Pa]");
99 gnuplot.addDataSetToPlot(sw, pc, curveTitle + "_pcgw-Sw");
100 }
101
112 const MaterialLawParams &params,
113 Scalar lowerSat = 0.0,
114 Scalar upperSat = 1.0,
115 std::string curveTitle = "")
116 {
117 std::vector<Scalar> sw;
118 std::vector<Scalar> pc;
119 Scalar satInterval = upperSat - lowerSat;
120 Scalar pcMin = 0.0;
121 Scalar pcMax = -1e100;
122
123 Scalar swTemp, pcTemp = 0.0;
124 for (int i = 0; i <= numIntervals_; i++)
125 {
126 swTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
127 pcTemp = MaterialLaw::pcnw(params, swTemp);
128 using std::max;
129 using std::min;
130 if (checkValues_(swTemp, pcTemp))
131 {
132 sw.push_back(swTemp);
133 pc.push_back(pcTemp);
134 pcMin = min(pcMin, pcTemp);
135 pcMax = max(pcMax, pcTemp);
136 }
137 }
138
139 gnuplot.setXlabel("wetting phase saturation [-]");
140 gnuplot.setYlabel("capillary pressure [Pa]");
141 gnuplot.addDataSetToPlot(sw, pc, curveTitle + "_pcnw-Sw");
142 }
143
154 const MaterialLawParams &params,
155 Scalar lowerSat = 0.0,
156 Scalar upperSat = 1.0,
157 std::string curveTitle = "")
158 {
159 std::vector<Scalar> st;
160 std::vector<Scalar> pc;
161 Scalar satInterval = upperSat - lowerSat;
162 Scalar pcMin = 0.0;
163 Scalar pcMax = -1e100;
164
165 Scalar stTemp, pcTemp = 0.0;
166 for (int i = 0; i <= numIntervals_; i++)
167 {
168 stTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
169 pcTemp = MaterialLaw::pcgn(params, stTemp);
170 using std::max;
171 using std::min;
172 if (checkValues_(stTemp, pcTemp))
173 {
174 st.push_back(stTemp);
175 pc.push_back(pcTemp);
176 pcMin = min(pcMin, pcTemp);
177 pcMax = max(pcMax, pcTemp);
178 }
179 }
180
181 gnuplot.setXlabel("wetting phase saturation [-]");
182 gnuplot.setYlabel("capillary pressure [Pa]");
183 gnuplot.addDataSetToPlot(st, pc, curveTitle + "_pcgn-St");
184 }
185
186
197 const MaterialLawParams &params,
198 Scalar lowerSat = 0.0,
199 Scalar upperSat = 1.0,
200 std::string curveTitle = "")
201 {
202 std::vector<Scalar> sw(numIntervals_ + 1);
203 std::vector<Scalar> krw(numIntervals_ + 1);
204 std::vector<Scalar> krn(numIntervals_ + 1);
205 std::vector<Scalar> krg(numIntervals_ + 1);
206 Scalar satInterval = upperSat - lowerSat;
207 Scalar krMin = 1e100;
208 Scalar krMax = -1e100;
209
210 Scalar swTemp, krwTemp, krnTemp, krgTemp = 0.0;
211 for (int i = 0; i <= numIntervals_; i++)
212 {
213 swTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
214 krwTemp = MaterialLaw::krw(params, swTemp, 0.0);
215 krnTemp = MaterialLaw::krn(params, swTemp, 1.0 - swTemp);
216 krgTemp = MaterialLaw::krg(params, swTemp, 0.0);
217 using std::max;
218 using std::min;
219 if (checkValues_(swTemp, krwTemp)
220 && checkValues_(swTemp, krnTemp)
221 && checkValues_(swTemp, krgTemp))
222 {
223 sw.push_back(swTemp);
224 krw.push_back(krwTemp);
225 krn.push_back(krnTemp);
226 krg.push_back(krgTemp);
227 krMin = min({krMin, krwTemp, krnTemp, krgTemp});
228 krMax = max({krMax, krwTemp, krnTemp, krgTemp});
229 }
230 }
231
232 gnuplot.setXlabel("wetting phase saturation [-]");
233 gnuplot.setYlabel("relative permeability [-]");
234 gnuplot.addDataSetToPlot(sw, krw, curveTitle + "_krw");
235 gnuplot.addDataSetToPlot(sw, krn, curveTitle + "_krn");
236 gnuplot.addDataSetToPlot(sw, krg, curveTitle + "_krg");
237 }
238
249 const MaterialLawParams &params,
250 Scalar lowerSat = 0.0,
251 Scalar upperSat = 1.0,
252 std::string curveTitle = "")
253 {
254 std::vector<Scalar> sn(numIntervals_ + 1);
255 std::vector<Scalar> alpha(numIntervals_ + 1);
256 Scalar satInterval = upperSat - lowerSat;
257 Scalar alphaMin = -2;
258 Scalar alphaMax = 2;
259
260 Scalar snTemp, alphaTemp = 0.0;
261 for (int i = 0; i <= numIntervals_; i++)
262 {
263 snTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
264 alphaTemp = MaterialLaw::pcAlpha(params, snTemp);
265 using std::max;
266 using std::min;
267 if (checkValues_(snTemp, alphaTemp))
268 {
269 sn.push_back(snTemp);
270 alpha.push_back(alphaTemp);
271 alphaMin = min(alphaMin, alphaTemp);
272 alphaMax = max(alphaMax, alphaTemp);
273 }
274 }
275
276 gnuplot.setXlabel("nonwetting phase saturation [-]");
277 gnuplot.setYlabel("transition function [-]");
278 gnuplot.addDataSetToPlot(sn, alpha, curveTitle + "_alpha");
279 }
280
281private:
288 bool checkValues_(Scalar value1, Scalar value2)
289 {
290 using std::isnan;
291 using std::isinf;
292 return !isnan(value1) && !isinf(value1)
293 && !isnan(value2) && !isinf(value2);
294 }
295
296 int numIntervals_;
297};
298} // end of namespace Dumux
299
300#endif
Interface for passing data sets to a file and plotting them, if gnuplot is installed.
Definition: gnuplotinterface.hh:45
void setXlabel(const std::string &label)
Sets the label for the x-axis.
Definition: gnuplotinterface.hh:267
void addDataSetToPlot(const DataX &x, const DataY &y, const std::string &fileName, const std::string &options="with lines")
Adds a data set and writes a data file.
Definition: gnuplotinterface.hh:231
void setYlabel(const std::string &label)
Sets the label for the y-axis.
Definition: gnuplotinterface.hh:277
Interface for plotting the three-phase fluid-matrix-interaction laws TODO: add theta head pressure pl...
Definition: plotmateriallaw3p.hh:31
void addPcAlpha(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveTitle="")
Plot the transition (2P/3P) function.
Definition: plotmateriallaw3p.hh:248
void addpc(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveTitle="")
Plot the capillary pressure-saturation curve for all phases.
Definition: plotmateriallaw3p.hh:49
void addpcgw(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveTitle="")
Plot the capillary pressure-saturation curve for the water-gas interphase.
Definition: plotmateriallaw3p.hh:69
void addpcgn(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveTitle="")
Plot the capillary pressure-saturation curve for the gas-NAPL interface.
Definition: plotmateriallaw3p.hh:153
PlotMaterialLaw(bool interaction=true)
Constructor.
Definition: plotmateriallaw3p.hh:36
void addkr(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveTitle="")
Plot the relative permeabilities.
Definition: plotmateriallaw3p.hh:196
void addpcnw(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveTitle="")
Plot the capillary pressure-saturation curve for the water-NAPL interface.
Definition: plotmateriallaw3p.hh:111
Definition: adapt.hh:17