From f682d6881b394c5c3b882c2811e4a90982be31f4 Mon Sep 17 00:00:00 2001 From: Markus Wolff <markus.wolff@twt-gmbh.de> Date: Thu, 12 Dec 2013 14:16:47 +0000 Subject: [PATCH] Added functions for output-time-intervals into the one-model base class of the decoupled models -reviewed by Martin git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@12188 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/decoupled/common/onemodelproblem.hh | 44 +++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/dumux/decoupled/common/onemodelproblem.hh b/dumux/decoupled/common/onemodelproblem.hh index acf0b5f784..88623d431e 100644 --- a/dumux/decoupled/common/onemodelproblem.hh +++ b/dumux/decoupled/common/onemodelproblem.hh @@ -94,7 +94,8 @@ public: bBoxMin_(std::numeric_limits<double>::max()), bBoxMax_(-std::numeric_limits<double>::max()), variables_(gridView), - outputInterval_(1) + outputInterval_(1), + outputTimeInterval_(0) { // calculate the bounding box of the grid view VertexIterator vIt = gridView.template begin<dim>(); @@ -121,7 +122,8 @@ public: bBoxMin_(std::numeric_limits<double>::max()), bBoxMax_(-std::numeric_limits<double>::max()), variables_(gridView), - outputInterval_(1) + outputInterval_(1), + outputTimeInterval_(0) { // calculate the bounding box of the grid view VertexIterator vIt = gridView.template begin<dim>(); @@ -393,6 +395,17 @@ public: (timeManager().timeStepIndex() % 5 == 0); } + /*! + * \brief Sets a time interval for Output + * + * The default is 0.0 -> Output determined by output number interval (<tt>setOutputInterval(int)</tt>) + */ + void setOutputTimeInterval(const Scalar timeInterval) + { + outputTimeInterval_ = (timeInterval > 0.0) ? timeInterval : 1e100; + timeManager().startNextEpisode(outputTimeInterval_); + } + /*! * \brief Sets the interval for Output * @@ -409,9 +422,20 @@ public: * very time step. This file is intented to be overwritten by the * implementation. */ + bool shouldWriteOutput() const { - if (this->timeManager().timeStepIndex() % outputInterval_ == 0 || this->timeManager().willBeFinished()) + if (outputInterval_ > 0) + { + if (timeManager().timeStepIndex() % outputInterval_ == 0 + || timeManager().willBeFinished() + || timeManager().episodeWillBeOver()) + { + return true; + } + } + else if (timeManager().willBeFinished() + || timeManager().episodeWillBeOver() || timeManager().timeStepIndex() == 0) { return true; } @@ -439,9 +463,16 @@ public: */ void episodeEnd() { - std::cerr << "The end of an episode is reached, but the problem " - << "does not override the episodeEnd() method. " - << "Doing nothing!\n"; + if (outputTimeInterval_ > 0.0 && !timeManager().finished()) + { + timeManager().startNextEpisode(outputTimeInterval_); + } + else if (!timeManager().finished()) + { + std::cerr << "The end of an episode is reached, but the problem " + << "does not override the episodeEnd() method. " + << "Doing nothing!\n"; + } }; // \} @@ -632,6 +663,7 @@ private: Dune::shared_ptr<VtkMultiWriter> resultWriter_; int outputInterval_; + Scalar outputTimeInterval_; }; } -- GitLab