From f4a74600e178fa888a524b10192d697e1f5556e3 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Thu, 16 Apr 2015 19:59:21 +0000 Subject: [PATCH] Improve documentation and explanatory comments regarding the new implicit grid adapt classes git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/branches/gridadapt@14586 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- .../cellcentered/ccfvelementgeometry.hh | 2 +- dumux/implicit/common/gridadapt.hh | 28 ++++++++++--------- .../common/gridadaptindicatordefault.hh | 10 +++---- dumux/implicit/common/gridadaptproperties.hh | 5 ++-- .../common/gridadaptpropertydefaults.hh | 5 ++-- dumux/implicit/common/implicitproblem.hh | 28 ++++++++++--------- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dumux/implicit/cellcentered/ccfvelementgeometry.hh b/dumux/implicit/cellcentered/ccfvelementgeometry.hh index 0b52700004..ea2f67f3ef 100644 --- a/dumux/implicit/cellcentered/ccfvelementgeometry.hh +++ b/dumux/implicit/cellcentered/ccfvelementgeometry.hh @@ -51,7 +51,7 @@ class CCFVElementGeometry enum{dimWorld = GridView::dimensionworld}; enum{maxNFAP = 2}; //! maximum number of flux approximation points (two-point flux) - enum{maxNE = 2*dim*(1 << (dim - 1))}; //! maximum number of neighbors + enum{maxNE = 2*dim*(1 << (dim - 1))}; //! maximum number of neighbors (works for one hanging node per face) enum{maxBF = 2*dim}; //! maximum number of boundary faces typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; typedef typename GridView::ctype CoordScalar; diff --git a/dumux/implicit/common/gridadapt.hh b/dumux/implicit/common/gridadapt.hh index 5d111cd645..c154801726 100644 --- a/dumux/implicit/common/gridadapt.hh +++ b/dumux/implicit/common/gridadapt.hh @@ -18,7 +18,7 @@ *****************************************************************************/ /*! * \file - * \brief Base class for h-adaptive sequential models. + * \brief Base class for h-adaptive implicit models. */ #ifndef DUMUX_IMPLICIT_GRIDADAPT_HH #define DUMUX_IMPLICIT_GRIDADAPT_HH @@ -27,10 +27,12 @@ #include "adaptationhelper.hh" #include <unordered_map> +#include <dune/common/exceptions.hh> + namespace Dumux { -/*!\ingroup IMPET +/*!\ingroup ImplicitGridAdapt * @brief Standard Module for h-adaptive simulations * * This class is created by the problem class with the template @@ -38,7 +40,7 @@ namespace Dumux * for adaptive methods: * * A standard implementation adaptGrid() will prepare everything - * to calculate the next pressure field on the new grid. + * to calculate the next primary variables vector on the new grid. */ template<class TypeTag, bool adaptive> class ImplicitGridAdapt @@ -70,8 +72,9 @@ public: adaptationInterval_ = GET_PARAM_FROM_GROUP(TypeTag, int, GridAdapt, AdaptionInterval); if (levelMin_ < 0) - Dune::dgrave << __FILE__<< ":" <<__LINE__ - << " : Dune cannot coarsen to gridlevels smaller 0! "<< std::endl; + { + DUNE_THROW(Dune::InvalidStateException, "Coarsening the level 0 entities is not possible! Choose MinLevel >= 0"); + } } /*! @@ -103,9 +106,11 @@ public: int shouldInitialize = adaptionInitIndicator.initializeModel(); if (problem_.grid().comm().max(shouldInitialize)) + { problem_.model().init(problem_); - - iter++; + } + + ++iter; } } @@ -181,8 +186,6 @@ public: /**** 4) Adapt Grid and size of variable vectors *****/ problem_.grid().adapt(); - // forceRefineRatio(1); - // update mapper to new cell indices problem_.elementMapper().update(); @@ -203,7 +206,7 @@ public: /*! * Mark Elements for grid refinement according to applied Indicator - * @return Total ammount of marked cells + * @param indicator The refinement indicator that is applied */ template<class Indicator> void markElements(Indicator& indicator) @@ -306,8 +309,7 @@ public: void setLevels(int levMin, int levMax) { if (levMin < 0) - Dune::dgrave << __FILE__<< ":" <<__LINE__ - << " : Dune cannot coarsen to gridlevels smaller 0! "<< std::endl; + DUNE_THROW(Dune::InvalidStateException, "Coarsening the level 0 entities is not possible!"); levelMin_ = levMin; levelMax_ = levMax; } @@ -458,7 +460,7 @@ private: }; /*! - * @brief Class for NON-adaptive simulations + * @brief Class for non-adaptive simulations * * This class provides empty methods for non-adaptive simulations * for compilation reasons. If adaptivity is desired, create the diff --git a/dumux/implicit/common/gridadaptindicatordefault.hh b/dumux/implicit/common/gridadaptindicatordefault.hh index bf26bfd4ac..399d626825 100644 --- a/dumux/implicit/common/gridadaptindicatordefault.hh +++ b/dumux/implicit/common/gridadaptindicatordefault.hh @@ -21,12 +21,12 @@ /** * @file - * @brief Class defining a start indicator for grid adaption + * @brief Class defining a default indicator for grid adaption */ namespace Dumux { -/*!\ingroup IMPES - * @brief Class defining a start indicator for grid adaption +/*!\ingroup ImplicitGridAdaptIndicator + * @brief Class defining a default indicator for grid adaption * *Default implementation * @@ -81,9 +81,7 @@ public: * \param adaptionIndicator Indicator whether a be adapted */ ImplicitGridAdaptIndicatorDefault(Problem& problem) - { - - } + {} }; } diff --git a/dumux/implicit/common/gridadaptproperties.hh b/dumux/implicit/common/gridadaptproperties.hh index 28cd1888b7..fb0741d893 100644 --- a/dumux/implicit/common/gridadaptproperties.hh +++ b/dumux/implicit/common/gridadaptproperties.hh @@ -17,8 +17,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * *****************************************************************************/ /*! - * \ingroup IMPETProperties - * \ingroup IMPET + * \ingroup ImplicitGridAdaptProperties + * \ingroup ImplicitGridAdapt * \file * * \brief Defines a type tag and some fundamental properties for @@ -81,5 +81,4 @@ NEW_PROP_TAG(GridAdaptRefineAtSource); } // namespace Properties } // namespace Dumux - #endif diff --git a/dumux/implicit/common/gridadaptpropertydefaults.hh b/dumux/implicit/common/gridadaptpropertydefaults.hh index 6bcb7ead15..021814a64a 100644 --- a/dumux/implicit/common/gridadaptpropertydefaults.hh +++ b/dumux/implicit/common/gridadaptpropertydefaults.hh @@ -17,8 +17,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * *****************************************************************************/ /*! - * \ingroup IMPETProperties - * \ingroup IMPET + * \ingroup ImplicitGridAdaptPropertyDefaults + * \ingroup ImplicitGridAdapt * \file * * \brief Defines a type tag and some fundamental properties for @@ -64,5 +64,4 @@ SET_TYPE_PROP(GridAdapt, AdaptionInitializationIndicator, ImplicitGridAdaptInit } // namespace Properties } // namespace Dumux - #endif diff --git a/dumux/implicit/common/implicitproblem.hh b/dumux/implicit/common/implicitproblem.hh index 3049446ece..66eaeccddf 100644 --- a/dumux/implicit/common/implicitproblem.hh +++ b/dumux/implicit/common/implicitproblem.hh @@ -51,7 +51,6 @@ private: typedef typename GET_PROP_TYPE(TypeTag, VtkMultiWriter) VtkMultiWriter; - typedef typename GET_PROP_TYPE(TypeTag, NewtonMethod) NewtonMethod; typedef typename GET_PROP_TYPE(TypeTag, NewtonController) NewtonController; @@ -86,7 +85,6 @@ private: typedef ImplicitGridAdapt<TypeTag, adaptiveGrid> GridAdaptModel; - // copying a problem is not a good idea ImplicitProblem(const ImplicitProblem &); @@ -127,9 +125,9 @@ public: // set a default name for the problem simName_ = "sim"; + // if we are calculating on an adaptive grid get the grid adapt model if (adaptiveGrid) gridAdapt_ = Dune::make_shared<GridAdaptModel>(asImp_()); - } /*! @@ -143,8 +141,11 @@ public: { // set the initial condition of the model model().init(asImp_()); + if (adaptiveGrid) + { gridAdapt().init(); + } } /*! @@ -500,8 +501,9 @@ public: */ void preTimeStep() { - // if adaptivity is used, this method adapts the grid. - // if it is not used, this method does nothing. + // If adaptivity is used, this method adapts the grid. + // Remeber to call the parent class function if this is overwritten + // on a lower problem level when using an adaptive grid if (adaptiveGrid && timeManager().timeStepIndex() > 0) this->gridAdapt().adaptGrid(); } @@ -846,6 +848,9 @@ public: } } + /*! + * \brief Returns a reference to the grid + */ Grid &grid() { return GridCreator::grid(); @@ -871,9 +876,7 @@ public: * modification routine, GridAdapt::adaptGrid() . */ void preAdapt() - { - - } + {} /*! * \brief Capability to introduce problem-specific routines after grid adaptation @@ -883,9 +886,7 @@ public: * for problem-specific output etc. */ void postAdapt() - { - - } + {} protected: //! Returns the implementation of the problem (i.e. static polymorphism) @@ -916,6 +917,8 @@ private: { if (!resultWriter_) resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView_, asImp_().name()); + + // Tell the result writer that the grid changes if we are adaptive if (adaptiveGrid) resultWriter_->gridChanged(); } @@ -940,8 +943,7 @@ private: Dune::shared_ptr<GridAdaptModel> gridAdapt_; }; - -} +} // namespace Dumux #include <dumux/implicit/common/gridadaptpropertydefaults.hh> -- GitLab