GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/embedded/1d3d/root_soil_benchmark/plot.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 34 35 97.1%
Functions: 2 2 100.0%
Branches: 83 210 39.5%

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 * \author Timo Koch <timokoch@uio.no>
10 * \brief Plotting tools for root soil benchmark
11 */
12 #ifndef DUMUX_TEST_ROOT_SOIL_BENCHMARK_PLOT_HH
13 #define DUMUX_TEST_ROOT_SOIL_BENCHMARK_PLOT_HH
14
15 #include <vector>
16 #include <algorithm>
17 #include <tuple>
18 #include <utility>
19 #include <memory>
20
21 #include <dumux/common/parameters.hh>
22 #include <dumux/io/gnuplotinterface.hh>
23
24 namespace Dumux::RootSoil {
25
26 /*!
27 * \brief plot the transpiration curves
28 * \tparam Problem the problem type
29 */
30 template<class Problem>
31 class TranspirationPlot
32 {
33 public:
34 2 TranspirationPlot(std::shared_ptr<const Problem> problem)
35
6/24
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
2 : problem_(problem)
36 {
37
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 const std::string outputDir = getParam<std::string>("Output.GnuplotOutputDirectory", "");
38
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 filenamePrefix_ = getParam<std::string>("Output.GnuplotOutputFilenamePrefix", "");
39
1/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 const bool openGnuPlot = getParam<bool>("Output.GnuplotShow", true);
40 2 gnuplot_.setOpenPlotWindow(openGnuPlot);
41
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (outputDir != "")
42 gnuplot_.setOutputDirectory(outputDir);
43 2 }
44
45 /*!
46 * \brief add a data point to the transpiration plot
47 * \param curSol the current solution vector (root)
48 * \param curGridVars the current grid variables (root)
49 * \param t the time at the end of the current time step
50 * \param dt the time step size of the current time step
51 */
52 template<class SolutionVector, class GridVariables>
53 434 void addDataPoint(const SolutionVector& curSol, const GridVariables& curGridVars, double t, double dt)
54 {
55 434 gnuplot_.resetPlot();
56
57
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 434 times.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
868 gnuplot_.setXlabel("time [day]");
58
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 434 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1302 gnuplot_.setYlabel("transpiration rate [g/day]");
59
4/10
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 434 times.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1302 gnuplot_.setOption("set y2label \"cumulative transpiration [g]\"");
60
61 434 const auto conversion = 86400.0*1000.0; // convert to g/day
62 868 const auto tAct = problem_->computeActualTranspirationRate(curSol, curGridVars)*conversion;
63
64 434 tActPlot_.push_back(tAct);
65
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 432 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 432 times.
868 if (tCumulPlot_.empty())
66 2 tCumulPlot_.push_back(tAct*dt/86400.0);
67 else
68 864 tCumulPlot_.push_back(tCumulPlot_.back() + tAct*dt/86400.0);
69 434 timePlot_.push_back(t/86400.0);
70
7/18
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 434 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 434 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 434 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
1736 gnuplot_.addDataSetToPlot(timePlot_, tActPlot_, filenamePrefix_ + "actualtranspiration.out", "with lines axes x1y1 lw 3");
71
7/18
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 434 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 434 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 434 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1736 gnuplot_.addDataSetToPlot(timePlot_, tCumulPlot_, filenamePrefix_ + "cumulativetranspiration.out", "with lines axes x1y2 lw 3");
72
73
2/4
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
868 if (problem_->bcType() != Problem::BCType::constCollarPressure)
74 {
75 434 const auto tPot = problem_->potentialTranspirationRate()*conversion;
76 434 tPotPlot_.push_back(tPot);
77
6/16
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 434 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 434 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
2170 gnuplot_.addDataSetToPlot(timePlot_, tPotPlot_, filenamePrefix_ + "potentialtranspiration.out", "with lines axes x1y1 lw 2 lc rgb 'black'");
78 }
79
80
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 434 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1302 gnuplot_.setOption("set ytics nomirror");
81
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 434 times.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
868 gnuplot_.setOption("set y2tics");
82
83
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 434 times.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
868 gnuplot_.setOption("set autoscale x");
84
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 434 times.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
868 gnuplot_.setOption("set autoscale y");
85
5/12
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 434 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 434 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1302 gnuplot_.setOption("set autoscale y2");
86
87
4/10
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 434 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 434 times.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1302 gnuplot_.setOption("set title \"Plant transpiration\"");
88
2/6
✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 434 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
434 gnuplot_.plot(filenamePrefix_ + "transpiration");
89 434 }
90
91 private:
92 std::shared_ptr<const Problem> problem_;
93 GnuplotInterface<double> gnuplot_;
94 std::string filenamePrefix_;
95
96 // the cached data vectors (they are updated on each call to addDataPoint)
97 std::vector<double> tPotPlot_, tActPlot_, tCumulPlot_, timePlot_;
98 };
99
100 } // end namespace Dumux::RootSoil
101
102 #endif
103