3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
plotmateriallaw.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_PLOT_FLUID_MATRIX_LAW_HH
25#define DUMUX_PLOT_FLUID_MATRIX_LAW_HH
26
27#include <cmath>
28#include <vector>
29#include <string>
30
31namespace Dumux {
32
33// forward declaration
34template<class Scalar> class GnuplotInterface;
35
40template<class Scalar, class MaterialLaw>
42{
43 using MaterialLawParams = typename MaterialLaw::Params;
44
45public:
48 : numIntervals_(1000)
49 { }
50
62 const MaterialLawParams &params,
63 Scalar lowerSat = 0.0,
64 Scalar upperSat = 1.0,
65 std::string curveName = "pc-Sw",
66 std::string curveOptions = "w l")
67 {
68 std::vector<Scalar> sw(numIntervals_+1);
69 std::vector<Scalar> pc(numIntervals_+1);
70 Scalar satInterval = upperSat - lowerSat;
71
72 for (int i = 0; i <= numIntervals_; i++)
73 {
74 sw[i] = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
75 pc[i] = MaterialLaw::pc(params, sw[i]);
76 }
77
78 gnuplot.setXlabel("wetting phase saturation [-]");
79 gnuplot.setYlabel("capillary pressure [Pa]");
80 gnuplot.addDataSetToPlot(sw, pc, curveName, curveOptions);
81 }
82
94 const MaterialLawParams &params,
95 Scalar lowerSat = 0.0,
96 Scalar upperSat = 1.0,
97 std::string curveName = "log10_pc-Sw.dat",
98 std::string curveOptions = "w l")
99 {
100 std::vector<Scalar> sw(numIntervals_+1);
101 std::vector<Scalar> log10pc(numIntervals_+1);
102 Scalar satInterval = upperSat - lowerSat;
103
104 for (int i = 0; i <= numIntervals_; i++)
105 {
106 sw[i] = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
107 const Scalar pc = std::log10(MaterialLaw::pc(params, sw[i]));
108 log10pc[i] = std::isnan(pc) ? 0.0 : pc;
109 }
110
111 gnuplot.setXlabel("wetting phase saturation [-]");
112 gnuplot.setYlabel("log10 of capillary pressure [Pa]");
113 gnuplot.addDataSetToPlot(sw, log10pc, curveName, curveOptions);
114 }
115
127 const MaterialLawParams &params,
128 Scalar lowerpc = 0.0,
129 Scalar upperpc = 5000.0,
130 std::string curveName = "Sw-pc",
131 std::string curveOptions = "w l")
132 {
133 std::vector<Scalar> sw;
134 std::vector<Scalar> pc;
135 Scalar pcInterval = upperpc - lowerpc;
136
137 Scalar pcTemp, swTemp = 0.0;
138 for (int i = 0; i <= numIntervals_; i++)
139 {
140 pcTemp = lowerpc + pcInterval * Scalar(i) / Scalar(numIntervals_);
141 swTemp = MaterialLaw::sw(params, pcTemp);
142 if (checkValues_(pcTemp, swTemp))
143 {
144 pc.push_back(pcTemp);
145 sw.push_back(swTemp);
146 }
147 }
148
149 gnuplot.setXlabel("capillary pressure [Pa]");
150 gnuplot.setYlabel("wetting phase saturation [-]");
151 gnuplot.addDataSetToPlot(pc, sw, curveName, curveOptions);
152 }
153
165 const MaterialLawParams &params,
166 Scalar lowerpc = 1,
167 Scalar upperpc = 1e9,
168 std::string curveName = "Sw-pc",
169 std::string curveOptions = "w l")
170 {
171 std::vector<Scalar> sw;
172 std::vector<Scalar> pc;
173 Scalar pcInterval = std::log10(upperpc) - std::log10(lowerpc);
174
175 Scalar pcTemp, swTemp = 0.0;
176 for (int i = 0; i <= numIntervals_; i++)
177 {
178 pcTemp = std::log10(lowerpc) + pcInterval * Scalar(i) / Scalar(numIntervals_);
179 swTemp = MaterialLaw::sw(params, std::pow(10, pcTemp));
180 pc.push_back(pcTemp);
181 sw.push_back(swTemp);
182 }
183
184 gnuplot.setXlabel("log10 capillary pressure [Pa]");
185 gnuplot.setYlabel("wetting phase saturation [-]");
186 gnuplot.addDataSetToPlot(pc, sw, curveName, curveOptions);
187 }
188
200 const MaterialLawParams &params,
201 Scalar lowerSat = 0.0,
202 Scalar upperSat = 1.0,
203 std::string curveName = "dpcdsw",
204 std::string curveOptions = "w l")
205 {
206 std::vector<Scalar> sw;
207 std::vector<Scalar> dpcdsw;
208 Scalar satInterval = upperSat - lowerSat;
209
210 Scalar swTemp, dpcdswTemp = 0.0;
211 for (int i = 0; i <= numIntervals_; i++)
212 {
213 swTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
214 dpcdswTemp = MaterialLaw::dpc_dsw(params, swTemp);
215 if (checkValues_(swTemp, dpcdsw))
216 {
217 sw.push_back(swTemp);
218 dpcdsw.push_back(dpcdswTemp);
219 }
220 }
221
222 gnuplot.setXlabel("wetting phase saturation [-]");
223 gnuplot.setYlabel("gradient of the pc-Sw curve [Pa]");
224 gnuplot.addDataSetToPlot(sw, dpcdsw, curveName, curveOptions);
225 }
226
238 const MaterialLawParams &params,
239 Scalar lowerpc = 0.0,
240 Scalar upperpc = 5000.0,
241 std::string curveName = "dswdpc",
242 std::string curveOptions = "w l")
243 {
244 std::vector<Scalar> pc;
245 std::vector<Scalar> dswdpc;
246 Scalar pcInterval = upperpc - lowerpc;
247
248 Scalar dswdpcTemp, pcTemp = 0.0;
249 for (int i = 0; i <= numIntervals_; i++)
250 {
251 pcTemp = lowerpc + pcInterval * Scalar(i) / Scalar(numIntervals_);
252 dswdpcTemp = MaterialLaw::dsw_dpc(params, pcTemp);
253 if (checkValues_(pcTemp, dswdpcTemp))
254 {
255 pc.push_back(pcTemp);
256 dswdpc.push_back(dswdpcTemp);
257 }
258 }
259
260 gnuplot.setXlabel("capillary pressure [Pa]");
261 gnuplot.setYlabel("gradient of the Sw-pc curve [1/Pa]");
262 gnuplot.addDataSetToPlot(pc, dswdpc, curveName, curveOptions);
263 }
264
276 const MaterialLawParams &params,
277 Scalar lowerSat = 0.0,
278 Scalar upperSat = 1.0,
279 std::string curveName = "kr",
280 std::string curveOptions = "w l")
281 {
282 std::vector<Scalar> sw;
283 std::vector<Scalar> krw;
284 std::vector<Scalar> krn;
285 Scalar satInterval = upperSat - lowerSat;
286
287 Scalar swTemp, krwTemp, krnTemp = 0.0;
288 for (int i = 0; i <= numIntervals_; i++)
289 {
290 swTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
291 krwTemp = MaterialLaw::krw(params, swTemp);
292 krnTemp = MaterialLaw::krn(params, swTemp);
293 if (checkValues_(swTemp, krwTemp) && checkValues_(swTemp, krnTemp))
294 {
295 sw.push_back(swTemp);
296 krw.push_back(krwTemp);
297 krn.push_back(krnTemp);
298 }
299 }
300
301 gnuplot.setXlabel("wetting phase saturation [-]");
302 gnuplot.setYlabel("relative permeability [-]");
303 gnuplot.addDataSetToPlot(sw, krw, curveName + "_krw", curveOptions);
304 gnuplot.addDataSetToPlot(sw, krn, curveName + "_krn", curveOptions);
305 }
306
318 const MaterialLawParams &params,
319 Scalar lowerSat = 0.0,
320 Scalar upperSat = 1.0,
321 std::string curveName = "dkrndsw",
322 std::string curveOptions = "w l")
323 {
324 std::vector<Scalar> sw;
325 std::vector<Scalar> dkrw_dsw;
326 std::vector<Scalar> dkrn_dsw;
327 Scalar satInterval = upperSat - lowerSat;
328
329 Scalar swTemp, dkrwdswTemp, dkrndswTemp = 0.0;
330 for (int i = 0; i <= numIntervals_; i++)
331 {
332 swTemp = lowerSat + satInterval * Scalar(i) / Scalar(numIntervals_);
333 dkrwdswTemp = MaterialLaw::dkrw_dsw(params, swTemp);
334 dkrndswTemp = MaterialLaw::dkrn_dsw(params, swTemp);
335 if (checkValues_(swTemp, dkrwdswTemp) && checkValues_(swTemp, dkrndswTemp))
336 {
337 sw.push_back(swTemp);
338 dkrw_dsw.push_back(dkrwdswTemp);
339 dkrn_dsw.push_back(dkrndswTemp);
340 }
341 }
342
343 gnuplot.setXlabel("wetting phase saturation [-]");
344 gnuplot.setYlabel("gradient of the kr-Sw function [-]");
345 gnuplot.addDataSetToPlot(sw, dkrw_dsw, curveName + "_dkrw_dsw", curveOptions);
346 gnuplot.addDataSetToPlot(sw, dkrn_dsw, curveName + "_dkrn_dsw", curveOptions);
347 }
348
349private:
356 bool checkValues_(Scalar value1, Scalar value2)
357 {
358 using std::isnan;
359 using std::isinf;
360 return !isnan(value1) && !isinf(value1)
361 && !isnan(value2) && !isinf(value2);
362 }
363
364 int numIntervals_;
365};
366
367} // end namespace Dumux
368
369#endif // DUMUX_PLOT_FLUID_MATRIX_LAW_HH
Definition: adapt.hh:29
Interface for passing data sets to a file and plotting them, if gnuplot is installed.
Definition: gnuplotinterface.hh:57
void setXlabel(const std::string &label)
Sets the label for the x-axis.
Definition: gnuplotinterface.hh:279
void addDataSetToPlot(const std::vector< Scalar > &x, const std::vector< Scalar > &y, const std::string &fileName, const std::string &options="with lines")
Adds a data set and writes a data file.
Definition: gnuplotinterface.hh:242
void setYlabel(const std::string &label)
Sets the label for the y-axis.
Definition: gnuplotinterface.hh:289
Interface for plotting the two-phase fluid-matrix-interaction laws.
Definition: plotmateriallaw.hh:42
void addLog10PcSwCurve(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveName="log10_pc-Sw.dat", std::string curveOptions="w l")
Add a capillary pressure-saturation data set to the plot.
Definition: plotmateriallaw.hh:93
void addswpccurve(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerpc=0.0, Scalar upperpc=5000.0, std::string curveName="Sw-pc", std::string curveOptions="w l")
Add a saturation-capillary pressure data set to the plot.
Definition: plotmateriallaw.hh:126
PlotMaterialLaw()
Constructor.
Definition: plotmateriallaw.hh:47
void addSwLog10PcCurve(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerpc=1, Scalar upperpc=1e9, std::string curveName="Sw-pc", std::string curveOptions="w l")
Add a saturation-capillary pressure data set to the plot.
Definition: plotmateriallaw.hh:164
void adddswdpccurve(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerpc=0.0, Scalar upperpc=5000.0, std::string curveName="dswdpc", std::string curveOptions="w l")
Add a saturation-capillary pressure gradient data set to the plot.
Definition: plotmateriallaw.hh:237
void adddkrdswcurves(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveName="dkrndsw", std::string curveOptions="w l")
Add relative permeabilities gradients data sets to the plot.
Definition: plotmateriallaw.hh:317
void adddpcdswcurve(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveName="dpcdsw", std::string curveOptions="w l")
Add a capillary pressure-saturation gradient data set to the plot.
Definition: plotmateriallaw.hh:199
void addpcswcurve(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveName="pc-Sw", std::string curveOptions="w l")
Add a capillary pressure-saturation data set to the plot.
Definition: plotmateriallaw.hh:61
void addkrcurves(GnuplotInterface< Scalar > &gnuplot, const MaterialLawParams &params, Scalar lowerSat=0.0, Scalar upperSat=1.0, std::string curveName="kr", std::string curveOptions="w l")
Add relative permeabilities data sets to the plot.
Definition: plotmateriallaw.hh:275