From 30aa55725a4c76347708398549fa184ab3319527 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Thu, 9 Jun 2016 11:35:23 +0200 Subject: [PATCH 1/2] [timemanager] Add possibility to set a custom maxTimeStepSize() in problem * User can e.g. specify a maxTimeStepSize depending on episodeIdx in problem * Might be useful for problems with initialisation period --- dumux/common/timemanager.hh | 2 +- dumux/implicit/problem.hh | 10 ++++++++++ dumux/porousmediumflow/sequential/onemodelproblem.hh | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dumux/common/timemanager.hh b/dumux/common/timemanager.hh index b77a0b6469..64a8a06924 100644 --- a/dumux/common/timemanager.hh +++ b/dumux/common/timemanager.hh @@ -262,7 +262,7 @@ public: return std::min(std::min(episodeMaxTimeStepSize(), - GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize)), + problem_->maxTimeStepSize()), std::max(0.0, endTime() - time())); } diff --git a/dumux/implicit/problem.hh b/dumux/implicit/problem.hh index 96c1677be3..b0511cc386 100644 --- a/dumux/implicit/problem.hh +++ b/dumux/implicit/problem.hh @@ -724,6 +724,16 @@ public: bool shouldWriteOutput() const { return true; } + /*! + * \brief Returns the user specified maximum time step size + * + * Overload in problem for custom needs. + */ + Scalar maxTimeStepSize() const + { + return GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize); + } + /*! * \brief Called by the time manager after the time integration to * do some post processing on the solution. diff --git a/dumux/porousmediumflow/sequential/onemodelproblem.hh b/dumux/porousmediumflow/sequential/onemodelproblem.hh index 96575f4cd2..cc4a7675bb 100644 --- a/dumux/porousmediumflow/sequential/onemodelproblem.hh +++ b/dumux/porousmediumflow/sequential/onemodelproblem.hh @@ -355,6 +355,16 @@ public: void advanceTimeLevel() {} + /*! + * \brief Returns the user specified maximum time step size + * + * Overload in problem for custom needs. + */ + Scalar maxTimeStepSize() const + { + return GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize); + } + /*! * \brief Returns the current time step size [seconds]. */ -- GitLab From c6e877425030446f06482233f9192c6af2b461a0 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer Date: Thu, 9 Jun 2016 14:18:10 +0200 Subject: [PATCH 2/2] [implicit][sequential][multidomain] Implement problem-forwarded maxTimeStep function --- dumux/common/timemanager.hh | 1 - dumux/implicit/problem.hh | 4 +++- dumux/multidomain/problem.hh | 8 ++++++++ dumux/porousmediumflow/sequential/impetproblem.hh | 9 ++++----- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dumux/common/timemanager.hh b/dumux/common/timemanager.hh index 64a8a06924..0fe4b470b0 100644 --- a/dumux/common/timemanager.hh +++ b/dumux/common/timemanager.hh @@ -36,7 +36,6 @@ namespace Properties { NEW_PROP_TAG(Scalar); NEW_PROP_TAG(Problem); -NEW_PROP_TAG(TimeManagerMaxTimeStepSize); } /*! diff --git a/dumux/implicit/problem.hh b/dumux/implicit/problem.hh index b0511cc386..d9b9e7e935 100644 --- a/dumux/implicit/problem.hh +++ b/dumux/implicit/problem.hh @@ -126,6 +126,7 @@ public: // set a default name for the problem simName_ = "sim"; + maxTimeStepSize_ = GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize); // if we are calculating on an adaptive grid get the grid adapt model if (adaptiveGrid) @@ -731,7 +732,7 @@ public: */ Scalar maxTimeStepSize() const { - return GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize); + return maxTimeStepSize_; } /*! @@ -1161,6 +1162,7 @@ private: VertexMapper vertexMapper_; TimeManager *timeManager_; + Scalar maxTimeStepSize_; Model model_; diff --git a/dumux/multidomain/problem.hh b/dumux/multidomain/problem.hh index 52fd9b77a8..53a3f83c6e 100644 --- a/dumux/multidomain/problem.hh +++ b/dumux/multidomain/problem.hh @@ -98,6 +98,7 @@ public: mdVertexMapper_ = std::make_shared (mdGrid_->leafGridView()); sdProblem1_ = std::make_shared (timeManager, mdGrid_->subDomain(sdID1()).leafGridView()); sdProblem2_ = std::make_shared (timeManager, mdGrid_->subDomain(sdID2()).leafGridView()); + maxTimeStepSize_ = GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize); } //! \copydoc Dumux::ImplicitProblem::init() @@ -204,6 +205,12 @@ public: asImp_().sdProblem2().postTimeStep(); } + //! \copydoc Dumux::ImplicitProblem::maxTimeStepSize() + Scalar maxTimeStepSize() const + { + return maxTimeStepSize_; + } + //! \copydoc Dumux::ImplicitProblem::nextTimeStepSize() Scalar nextTimeStepSize(const Scalar dt) { @@ -426,6 +433,7 @@ private: static std::string simname_; TimeManager &timeManager_; + Scalar maxTimeStepSize_; NewtonMethod newtonMethod_; NewtonController newtonCtl_; diff --git a/dumux/porousmediumflow/sequential/impetproblem.hh b/dumux/porousmediumflow/sequential/impetproblem.hh index aad34221fc..76852766b4 100644 --- a/dumux/porousmediumflow/sequential/impetproblem.hh +++ b/dumux/porousmediumflow/sequential/impetproblem.hh @@ -132,6 +132,7 @@ public: vtkOutputLevel_ = GET_PARAM_FROM_GROUP(TypeTag, int, Vtk, OutputLevel); dtVariationRestrictionFactor_ = GET_PARAM_FROM_GROUP(TypeTag, Scalar, Impet, DtVariationRestrictionFactor); + maxTimeStepSize_ = GET_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, MaxTimeStepSize); } /*! @@ -385,14 +386,11 @@ public: dt = std::min(dt, timeManager().timeStepSize()); } - // check maximum allowed time step size - dt = std::min(dt, asImp_().maxTimeStepSize()); - //make sure the right time-step is used by all processes in the parallel case if (this->gridView().comm().size() > 1) dt = this->gridView().comm().min(dt); - //assign next tiestep size + // check maximum allowed time step size timeManager().setTimeStepSize(dt); // explicit Euler: Sat <- Sat + dt*N(Sat) @@ -444,7 +442,7 @@ public: * By default this the time step size is unrestricted. */ Scalar maxTimeStepSize() const - { return std::numeric_limits::infinity(); } + { return maxTimeStepSize_; } /*! * \brief Returns true if a restart file should be written to @@ -850,6 +848,7 @@ private: GlobalPosition bBoxMax_; TimeManager *timeManager_; + Scalar maxTimeStepSize_; Variables variables_; -- GitLab