From 85ba37e6baf0980163b0c695a74ecd0279f68a34 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de> Date: Wed, 19 Oct 2016 11:22:30 +0200 Subject: [PATCH] [gnuplotinterface] Improve naming and add switches for fluidmatrixinteraction test cases interaction -> openPlotWindow --- dumux/io/gnuplotinterface.hh | 28 +++++++++++++------ dumux/io/ploteffectivediffusivitymodel.hh | 8 +++++- dumux/io/plotmateriallaw.hh | 8 +++++- dumux/io/plotmateriallaw3p.hh | 8 +++--- dumux/io/plotthermalconductivitymodel.hh | 27 ++++++++++++++++-- .../gnuplotinterface/test_gnuplotinterface.cc | 1 + .../2p/thermalconductivityspatialparams.hh | 8 +++++- .../effectivediffusivityspatialparams.hh | 8 +++++- .../2cnistokes2p2cni/2p2cnisubproblem.hh | 2 +- .../2p2c/implicit/waterairspatialparams.hh | 2 +- .../implicit/evaporationatmosphereproblem.hh | 1 - 11 files changed, 79 insertions(+), 22 deletions(-) diff --git a/dumux/io/gnuplotinterface.hh b/dumux/io/gnuplotinterface.hh index 7e8f4fed09..ea23705a49 100644 --- a/dumux/io/gnuplotinterface.hh +++ b/dumux/io/gnuplotinterface.hh @@ -63,17 +63,16 @@ public: //! \brief The constructor GnuplotInterface(bool persist = true) : - plotStyle_("lines"), pipe_(0), + pipe_(0), openPlotWindow_(true), persist_(persist), + datafileSeparator_(' '), plotStyle_("lines"), curveFile_(0), curveOptions_(0), curveTitle_(0), - interaction_(true), xRangeMin_(1e100), xRangeMax_(-1e100), yRangeMin_(1e100), yRangeMax_(-1e100), xLabel_(""), yLabel_(""), plotOptions_(""), - datafileSeparator_(' '), gnuplotPath_(GNUPLOT_EXECUTABLE) { - open(persist); + open(persist_); } //! \brief The destructor @@ -126,7 +125,7 @@ public: // live plot of the results if gnuplot is installed #ifdef HAVE_GNUPLOT - if (interaction_) + if (openPlotWindow_) executeGnuplot(plot.c_str()); #endif @@ -265,9 +264,10 @@ public: * * \param interaction Open window or not */ + DUNE_DEPRECATED_MSG("setInteraction() is deprecated. Use setOpenPlotWindow() instead.") void setInteraction(bool interaction) { - interaction_ = interaction; + setOpenPlotWindow(interaction); } /*! @@ -324,6 +324,16 @@ public: plotOptions_ += option + "\n"; } + /*! + * \brief Define whether the gnuplot window should be opened + * + * \param openPlotWindow Open gnuplot or not + */ + void setOpenPlotWindow(bool openPlotWindow) + { + openPlotWindow_ = openPlotWindow; + } + /*! * \brief Sets the datafile separator * @@ -360,8 +370,11 @@ private: return stream.str(); } - std::string plotStyle_; std::FILE * pipe_; + bool openPlotWindow_; + bool persist_; + char datafileSeparator_; + std::string plotStyle_; StringVector curveFile_; StringVector curveOptions_; StringVector curveTitle_; @@ -373,7 +386,6 @@ private: std::string xLabel_; std::string yLabel_; std::string plotOptions_; - char datafileSeparator_; std::string gnuplotPath_; }; } // end of namespace diff --git a/dumux/io/ploteffectivediffusivitymodel.hh b/dumux/io/ploteffectivediffusivitymodel.hh index 0ec3c5a082..d850723b74 100644 --- a/dumux/io/ploteffectivediffusivitymodel.hh +++ b/dumux/io/ploteffectivediffusivitymodel.hh @@ -49,12 +49,18 @@ class PlotEffectiveDiffusivityModel public: //! Constructor - PlotEffectiveDiffusivityModel(bool interaction = true) + DUNE_DEPRECATED_MSG("PlotEffectiveDiffusivityModel(bool) is deprecated. Use PlotEffectiveDiffusivityModel() instead.") + PlotEffectiveDiffusivityModel(bool interaction) : numIntervals_(1000) { gnuplot_.setInteraction(interaction); } + //! Constructor + PlotEffectiveDiffusivityModel() + : numIntervals_(1000) + { } + /*! * \brief Add a effective diffusion factor-saturation data set to the plot * diff --git a/dumux/io/plotmateriallaw.hh b/dumux/io/plotmateriallaw.hh index 78e5b81322..a94f381487 100644 --- a/dumux/io/plotmateriallaw.hh +++ b/dumux/io/plotmateriallaw.hh @@ -51,7 +51,8 @@ class PlotMaterialLaw public: //! Constructor - PlotMaterialLaw(bool interaction = true) + DUNE_DEPRECATED_MSG("PlotMaterialLaw(bool) is deprecated. Use PlotMaterialLaw() instead.") + PlotMaterialLaw(bool interaction) : numIntervals_(1000) { gnuplotpcsw_.setInteraction(interaction); @@ -62,6 +63,11 @@ public: gnuplotkrdsw_.setInteraction(interaction); } + //! Constructor + PlotMaterialLaw() + : numIntervals_(1000) + { } + /*! * \brief Add a capillary pressure-saturation data set to the plot * diff --git a/dumux/io/plotmateriallaw3p.hh b/dumux/io/plotmateriallaw3p.hh index 2dc8e41eea..444fa69748 100644 --- a/dumux/io/plotmateriallaw3p.hh +++ b/dumux/io/plotmateriallaw3p.hh @@ -54,10 +54,10 @@ public: PlotMaterialLaw(bool interaction = true) : numIntervals_(1000) { - gnuplotpc_.setInteraction(interaction); - gnuplotpcAlpha_.setInteraction(interaction); - gnuplotkr_.setInteraction(interaction); - gnuplotkrn_.setInteraction(interaction); + gnuplotpc_.setOpenPlotWindow(interaction); + gnuplotpcAlpha_.setOpenPlotWindow(interaction); + gnuplotkr_.setOpenPlotWindow(interaction); + gnuplotkrn_.setOpenPlotWindow(interaction); } /*! diff --git a/dumux/io/plotthermalconductivitymodel.hh b/dumux/io/plotthermalconductivitymodel.hh index b608716a05..45d934bbc9 100644 --- a/dumux/io/plotthermalconductivitymodel.hh +++ b/dumux/io/plotthermalconductivitymodel.hh @@ -70,9 +70,10 @@ public: * \param pressure reference pressure in \f$\mathrm{[Pa]}\f$ * \param interaction Specifies whether a live output via a gnuplot window is wanted */ - PlotThermalConductivityModel(Scalar temperature = 283.15, - Scalar pressure = 1e5, - bool interaction = true) + DUNE_DEPRECATED_MSG("PlotThermalConductivityModel(Scalar, Scalar, bool) is deprecated. Use PlotThermalConductivityModel(Scalar, Scalar) instead.") + PlotThermalConductivityModel(Scalar temperature, + Scalar pressure, + bool interaction) : numIntervals_(1000) { FluidState fluidstate; @@ -84,6 +85,26 @@ public: gnuplot_.setInteraction(interaction); } + /*! + * \brief Constructor + * + * Initializes the fluid system. + * + * \param temperature temperature in \f$\mathrm{[K]}\f$ + * \param pressure reference pressure in \f$\mathrm{[Pa]}\f$ + */ + PlotThermalConductivityModel(Scalar temperature = 283.15, + Scalar pressure = 1e5) + : numIntervals_(1000) + { + FluidState fluidstate; + fluidstate.setTemperature(temperature); + fluidstate.setPressure(wPhaseIdx, pressure); + fluidstate.setPressure(nPhaseIdx, pressure); + lambdaW_ = FluidSystem::template thermalConductivity<FluidState>(fluidstate, wPhaseIdx); + lambdaN_ = FluidSystem::template thermalConductivity<FluidState>(fluidstate, nPhaseIdx); + } + /*! * \brief Add a effective thermal conductivity-saturation curve to the plot * diff --git a/test/io/gnuplotinterface/test_gnuplotinterface.cc b/test/io/gnuplotinterface/test_gnuplotinterface.cc index 3e6087732c..7a1d2cdee2 100644 --- a/test/io/gnuplotinterface/test_gnuplotinterface.cc +++ b/test/io/gnuplotinterface/test_gnuplotinterface.cc @@ -31,6 +31,7 @@ int main() { Dumux::GnuplotInterface<double> gnuplot(false); + gnuplot.setOpenPlotWindow(false); unsigned int numIntervals = 100; std::vector<double> x(101); diff --git a/test/material/fluidmatrixinteractions/2p/thermalconductivityspatialparams.hh b/test/material/fluidmatrixinteractions/2p/thermalconductivityspatialparams.hh index 8c21280e58..90ba3d58d7 100644 --- a/test/material/fluidmatrixinteractions/2p/thermalconductivityspatialparams.hh +++ b/test/material/fluidmatrixinteractions/2p/thermalconductivityspatialparams.hh @@ -50,6 +50,10 @@ SET_TYPE_PROP(ThermalConductivitySpatialParams, SpatialParams, ThermalConductivi SET_TYPE_PROP(ThermalConductivitySpatialParams, MaterialLaw, EffToAbsLaw<RegularizedBrooksCorey<typename GET_PROP_TYPE(TypeTag, Scalar)> >); + +// Define whether to open a gnuplot window +NEW_PROP_TAG(OutputOpenPlotWindow); +SET_BOOL_PROP(ThermalConductivitySpatialParams, OutputOpenPlotWindow, false); } /*! @@ -106,11 +110,13 @@ public: */ void plotMaterialLaw() { - GnuplotInterface<Scalar> gnuplot(false); + GnuplotInterface<Scalar> gnuplot; + gnuplot.setOpenPlotWindow(GET_PARAM_FROM_GROUP(TypeTag, bool, Output, OpenPlotWindow)); PlotThermalConductivityModel<TypeTag> plotThermalConductivityModel_(293.15, 1e5); std::string fileName = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, std::string, Conductivity, File); plotThermalConductivityModel_.addlambdaeffcurve(gnuplot, porosity_, rhoSolid_, lambdaSolid_, 0.0, 1.0, fileName); + gnuplot.plot("lambda_eff"); } /*! diff --git a/test/material/fluidmatrixinteractions/effectivediffusivityspatialparams.hh b/test/material/fluidmatrixinteractions/effectivediffusivityspatialparams.hh index be57d35b29..038449e6bb 100644 --- a/test/material/fluidmatrixinteractions/effectivediffusivityspatialparams.hh +++ b/test/material/fluidmatrixinteractions/effectivediffusivityspatialparams.hh @@ -50,6 +50,10 @@ SET_TYPE_PROP(EffectiveDiffusivitySpatialParams, SpatialParams, EffectiveDiffusi SET_TYPE_PROP(EffectiveDiffusivitySpatialParams, MaterialLaw, EffToAbsLaw<RegularizedBrooksCorey<typename GET_PROP_TYPE(TypeTag, Scalar)> >); + +// Define whether to open a gnuplot window +NEW_PROP_TAG(OutputOpenPlotWindow); +SET_BOOL_PROP(EffectiveDiffusivitySpatialParams, OutputOpenPlotWindow, false); } /*! @@ -106,10 +110,12 @@ public: */ void plotMaterialLaw() { - GnuplotInterface<Scalar> gnuplot(false); + GnuplotInterface<Scalar> gnuplot; + gnuplot.setOpenPlotWindow(GET_PARAM_FROM_GROUP(TypeTag, bool, Output, OpenPlotWindow)); PlotEffectiveDiffusivityModel<TypeTag> plotEffectiveDiffusivityModel; std::string fileName = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, std::string, Diffusivity, File); plotEffectiveDiffusivityModel.adddeffcurve(gnuplot, porosity_, 0.0, 1.0, fileName); + gnuplot.plot("d_eff"); } /*! diff --git a/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh b/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh index 7ed89c2aa5..45d19fe9ea 100644 --- a/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh +++ b/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh @@ -388,7 +388,7 @@ public: evaporationFile << time/86400.0 << " " << storageChange[contiWEqIdx]*86400.0 << std::endl; gnuplot_.resetPlot(); - gnuplot_.setInteraction(liveEvaporationRates_); + gnuplot_.setOpenPlotWindow(liveEvaporationRates_); gnuplot_.setXRange(0.0, time/86400.0); gnuplot_.setYRange(0.0, 12.0); gnuplot_.setXlabel("time [d]"); diff --git a/test/porousmediumflow/2p2c/implicit/waterairspatialparams.hh b/test/porousmediumflow/2p2c/implicit/waterairspatialparams.hh index 68d348e991..30a2442084 100644 --- a/test/porousmediumflow/2p2c/implicit/waterairspatialparams.hh +++ b/test/porousmediumflow/2p2c/implicit/waterairspatialparams.hh @@ -128,7 +128,7 @@ public: { PlotMaterialLaw<TypeTag> plotMaterialLaw; GnuplotInterface<Scalar> gnuplot(plotFluidMatrixInteractions_); - gnuplot.setInteraction(plotFluidMatrixInteractions_); + gnuplot.setOpenPlotWindow(plotFluidMatrixInteractions_); plotMaterialLaw.addpcswcurve(gnuplot, fineMaterialParams_, 0.2, 1.0, "fine", "w lp"); plotMaterialLaw.addpcswcurve(gnuplot, coarseMaterialParams_, 0.2, 1.0, "coarse", "w l"); gnuplot.setOption("set xrange [0:1]"); diff --git a/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh b/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh index 2c682e3b2d..035541d793 100644 --- a/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh +++ b/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh @@ -346,7 +346,6 @@ public: // use gnuplot for plotting the line data gnuplot_.resetPlot(); - gnuplot_.setInteraction(true); gnuplot_.setXlabel("xN2w [-]"); gnuplot_.setYlabel("y [m]"); std::ostringstream stream; -- GitLab