From 1d83395638d00664e6029aa987e9be84779e8f13 Mon Sep 17 00:00:00 2001 From: Andreas Lauser <and@poware.org> Date: Mon, 30 Jan 2012 19:22:24 +0000 Subject: [PATCH] partial reassemble: some modifications and disable it by default git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7561 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/boxmodels/1p2c/1p2cpropertydefaults.hh | 6 ---- dumux/boxmodels/2p/2ppropertydefaults.hh | 4 --- dumux/boxmodels/2p2c/2p2cpropertydefaults.hh | 8 ----- dumux/boxmodels/3p3c/3p3cpropertydefaults.hh | 6 ---- dumux/boxmodels/MpNc/MpNcnewtoncontroller.hh | 6 ++-- dumux/boxmodels/MpNc/MpNcpropertydefaults.hh | 7 +--- dumux/boxmodels/common/boxassembler.hh | 6 ++-- dumux/boxmodels/common/boxpropertydefaults.hh | 1 + dumux/common/parameters.hh | 36 ++++++++++++------- dumux/material/components/mesitylene.hh | 5 +-- dumux/nonlinear/newtoncontroller.hh | 8 ++--- test/boxmodels/2p2c/injectionproblem.hh | 1 - 12 files changed, 39 insertions(+), 55 deletions(-) diff --git a/dumux/boxmodels/1p2c/1p2cpropertydefaults.hh b/dumux/boxmodels/1p2c/1p2cpropertydefaults.hh index b073b159e5..99a5cbdf89 100644 --- a/dumux/boxmodels/1p2c/1p2cpropertydefaults.hh +++ b/dumux/boxmodels/1p2c/1p2cpropertydefaults.hh @@ -73,12 +73,6 @@ SET_SCALAR_PROP(BoxOnePTwoC, UpwindWeight, 1.0); //! Set the indices used by the 1p2c model SET_TYPE_PROP(BoxOnePTwoC, OnePTwoCIndices, Dumux::OnePTwoCIndices<0>); - -// enable jacobian matrix recycling by default -SET_BOOL_PROP(BoxOnePTwoC, EnableJacobianRecycling, true); -// enable partial reassembling by default -SET_BOOL_PROP(BoxOnePTwoC, EnablePartialReassemble, true); - } // \} } diff --git a/dumux/boxmodels/2p/2ppropertydefaults.hh b/dumux/boxmodels/2p/2ppropertydefaults.hh index 3fdd5cab0a..7ad923dc85 100644 --- a/dumux/boxmodels/2p/2ppropertydefaults.hh +++ b/dumux/boxmodels/2p/2ppropertydefaults.hh @@ -126,10 +126,6 @@ public: typedef ImmiscibleFluidState<Scalar, FluidSystem> type; }; -// enable jacobian matrix recycling by default -SET_BOOL_PROP(BoxTwoP, EnableJacobianRecycling, true); -// enable partial reassembling by default -SET_BOOL_PROP(BoxTwoP, EnablePartialReassemble, true); // disable velocity output by default SET_BOOL_PROP(BoxTwoP, EnableVelocityOutput, false); diff --git a/dumux/boxmodels/2p2c/2p2cpropertydefaults.hh b/dumux/boxmodels/2p2c/2p2cpropertydefaults.hh index 900861e2c2..a7b0332672 100644 --- a/dumux/boxmodels/2p2c/2p2cpropertydefaults.hh +++ b/dumux/boxmodels/2p2c/2p2cpropertydefaults.hh @@ -135,16 +135,8 @@ SET_PROP(BoxTwoPTwoC, public: typedef TwoPTwoCIndices<TypeTag, Formulation, 0> type; }; - -// enable jacobian matrix recycling by default -SET_BOOL_PROP(BoxTwoPTwoC, EnableJacobianRecycling, true); -// enable partial reassembling by default -SET_BOOL_PROP(BoxTwoPTwoC, EnablePartialReassemble, true); // disable velocity output by default SET_BOOL_PROP(BoxTwoPTwoC, EnableVelocityOutput, false); -// set some Newton properties deviating from the default ones -SET_SCALAR_PROP(BoxTwoPTwoC, NewtonRelTolerance, 1e-7); -SET_INT_PROP(BoxTwoPTwoC, NewtonTargetSteps, 9); // } diff --git a/dumux/boxmodels/3p3c/3p3cpropertydefaults.hh b/dumux/boxmodels/3p3c/3p3cpropertydefaults.hh index 87ae809933..5ef51f5f38 100644 --- a/dumux/boxmodels/3p3c/3p3cpropertydefaults.hh +++ b/dumux/boxmodels/3p3c/3p3cpropertydefaults.hh @@ -140,12 +140,6 @@ SET_PROP(BoxThreePThreeC, typedef ThreePThreeCIndices<TypeTag, Formulation, 0> type; }; -// enable jacobian matrix recycling by default -SET_BOOL_PROP(BoxThreePThreeC, EnableJacobianRecycling, true); -// enable partial reassembling by default -SET_BOOL_PROP(BoxThreePThreeC, EnablePartialReassemble, true); - -// } } diff --git a/dumux/boxmodels/MpNc/MpNcnewtoncontroller.hh b/dumux/boxmodels/MpNc/MpNcnewtoncontroller.hh index 2e8cca11b7..beba505cc0 100644 --- a/dumux/boxmodels/MpNc/MpNcnewtoncontroller.hh +++ b/dumux/boxmodels/MpNc/MpNcnewtoncontroller.hh @@ -200,9 +200,9 @@ public: // compute the vertex and element colors for partial // reassembly if (this->enablePartialReassemble_) { - Scalar minReasmTol = 0.1*this->tolerance_; - Scalar reassembleTol = Dumux::geometricMean(this->error_, minReasmTol); - reassembleTol = std::max(reassembleTol, minReasmTol); + const Scalar minReasmTol = 1e-2*tolerance_; + const Scalar maxReasmTol = 1e1*tolerance_; + Scalar reassembleTol = std::max(minReasmTol, std::min(maxReasmTol, this->error_/1e4)); this->model_().jacobianAssembler().updateDiscrepancy(uLastIter, deltaU); this->model_().jacobianAssembler().computeColors(reassembleTol); diff --git a/dumux/boxmodels/MpNc/MpNcpropertydefaults.hh b/dumux/boxmodels/MpNc/MpNcpropertydefaults.hh index 1655cd7879..07d6626bae 100644 --- a/dumux/boxmodels/MpNc/MpNcpropertydefaults.hh +++ b/dumux/boxmodels/MpNc/MpNcpropertydefaults.hh @@ -160,14 +160,9 @@ SET_TYPE_PROP(BoxMPNC, VolumeVariables, MPNCVolumeVariables<TypeTag>); //! the FluxVariables property SET_TYPE_PROP(BoxMPNC, FluxVariables, MPNCFluxVariables<TypeTag>); -// enable jacobian matrix recycling by default -SET_BOOL_PROP(BoxMPNC, EnableJacobianRecycling, false); -// enable partial reassembling by default -SET_BOOL_PROP(BoxMPNC, EnablePartialReassemble, true); -// truncate the newton update in the beginning +//! truncate the newton update for the first few Newton iterations of a time step SET_BOOL_PROP(BoxMPNC, NewtonEnableChop, true); - //! The indices required by the compositional twophase model SET_PROP(BoxMPNC, MPNCIndices) { diff --git a/dumux/boxmodels/common/boxassembler.hh b/dumux/boxmodels/common/boxassembler.hh index bb1f400f82..464ecd199f 100644 --- a/dumux/boxmodels/common/boxassembler.hh +++ b/dumux/boxmodels/common/boxassembler.hh @@ -642,7 +642,7 @@ private: return; } - // reset all entries corrosponding to a red vertex + // reset all entries corrosponding to a red or yellow vertex for (int rowIdx = 0; rowIdx < matrix_->N(); ++rowIdx) { if (vertexColor_[rowIdx] == Green) continue; // the equations for this control volume are @@ -741,12 +741,14 @@ private: // update the right hand side residual_[globI] += model_().localJacobian().residual(i); + for (int j = 0; j < residual_[globI].dimension; ++j) + assert(std::isfinite(residual_[globI][j])); if (enableJacobianRecycling_()) { storageTerm_[globI] += model_().localJacobian().storageTerm(i); } - // skip updating the jacobian matrix for green vertices + // only update the jacobian matrix for non-green vertices if (vertexColor(globI) != Green) { if (enableJacobianRecycling_()) storageJacobian_[globI] += diff --git a/dumux/boxmodels/common/boxpropertydefaults.hh b/dumux/boxmodels/common/boxpropertydefaults.hh index 65ce8e3a1f..dcf8f42046 100644 --- a/dumux/boxmodels/common/boxpropertydefaults.hh +++ b/dumux/boxmodels/common/boxpropertydefaults.hh @@ -164,6 +164,7 @@ SET_BOOL_PROP(BoxModel, EnableHints, false); // disable jacobian matrix recycling by default SET_BOOL_PROP(BoxModel, EnableJacobianRecycling, false); + // disable partial reassembling by default SET_BOOL_PROP(BoxModel, EnablePartialReassemble, false); diff --git a/dumux/common/parameters.hh b/dumux/common/parameters.hh index e8d84eae36..36851b84a0 100644 --- a/dumux/common/parameters.hh +++ b/dumux/common/parameters.hh @@ -54,7 +54,7 @@ #define GET_PARAM(TypeTag, ParamType, ParamName) \ Dumux::Parameters::get<TypeTag, \ ParamType, \ - PTAG_(ParamName)>(#ParamName) + PTAG_(ParamName)>(#ParamName, #ParamName) /*! * \ingroup Parameter @@ -73,7 +73,7 @@ #define GET_PARAM_FROM_GROUP(TypeTag, ParamType, GroupName, ParamName) \ Dumux::Parameters::get<TypeTag, \ ParamType, \ - PTAG_(GroupName##ParamName)>(#GroupName, #ParamName) + PTAG_(GroupName##ParamName)>(#GroupName#ParamName, #GroupName, #ParamName) /*! * \ingroup Parameter @@ -161,13 +161,22 @@ void print(std::ostream &os = std::cout) const Dune::ParameterTree &ct = Params::compileTimeParams(); os << "###############################\n"; - os << "# Run-time parameters:\n"; + os << "# Run-time specified parameters:\n"; os << "###############################\n"; rt.report(os); os << "###############################\n"; - os << "# Compile-time parameters:\n"; + os << "# Compile-time specified parameters:\n"; os << "###############################\n"; ct.report(os); +/* + printParamTree_(ct); + typename Dune::ParameterTree::KeyVector::const_iterator it = ct.begin(); + for (; it != ct.end(); ++it) { + os << *it << " = \"" << ct.get(*it, "") << "\"" + // << " # Taken From Property: " << + << "\n"; + }; +*/ std::list<std::string> unusedParams; findUnusedKeys_<TypeTag>(unusedParams, tree); @@ -192,7 +201,8 @@ class Param typedef typename GET_PROP(TypeTag, ParameterTree) Params; public: template <class ParamType, class PropTag> - static const ParamType &get(const char *groupOrParamName, + static const ParamType &get(const char *propertyName, + const char *groupOrParamName, const char *paramNameOrNil = 0) { #ifndef NDEBUG @@ -200,23 +210,19 @@ public: // this is potentially quite expensive, it is only done if // debugging code is not explicitly turned off. const char *paramName, *groupName; - std::string propertyName; if (paramNameOrNil && strlen(paramNameOrNil) > 0) { groupName = groupOrParamName; paramName = paramNameOrNil; - propertyName = groupName; - propertyName += paramName; } else { groupName = ""; paramName = groupOrParamName; - propertyName = paramName; } check_<ParamType>(propertyName, groupName, paramName); #endif - static const ParamType &value = retrieve_<ParamType, PropTag>(groupOrParamName, paramNameOrNil); + static const ParamType &value = retrieve_<ParamType, PropTag>(propertyName, groupOrParamName, paramNameOrNil); return value; } @@ -307,7 +313,9 @@ private: } template <class ParamType, class PropTag> - static const ParamType &retrieve_(const char *groupOrParamName, const char *paramNameOrNil = 0) + static const ParamType &retrieve_(const char *propertyName, + const char *groupOrParamName, + const char *paramNameOrNil = 0) { const char *paramName, *groupName; if (paramNameOrNil && strlen(paramNameOrNil) > 0) { @@ -439,10 +447,12 @@ private: }; template <class TypeTag, class ParamType, class PropTag> -const ParamType &get(const char *paramOrGroupName, +const ParamType &get(const char *propertyName, + const char *paramOrGroupName, const char *paramNameOrNil = 0) { - return Param<TypeTag>::template get<ParamType, PropTag>(paramOrGroupName, + return Param<TypeTag>::template get<ParamType, PropTag>(propertyName, + paramOrGroupName, paramNameOrNil); } diff --git a/dumux/material/components/mesitylene.hh b/dumux/material/components/mesitylene.hh index fa67cac880..3c56b715df 100644 --- a/dumux/material/components/mesitylene.hh +++ b/dumux/material/components/mesitylene.hh @@ -81,8 +81,9 @@ public: }; /*! - * \brief The saturation vapor pressure in \f$\mathrm{[Pa]}\f$ of pure mesitylene - * at a given temperature according to Antoine after Betz 1997 -> Gmehling et al 1980 + * \brief The saturation vapor pressure in \f$\mathrm{[Pa]}\f$ of + * pure mesitylene at a given temperature according to + * Antoine after Betz 1997, see Gmehling et al 1980 * * \param T temperature of component in \f$\mathrm{[K]}\f$ */ diff --git a/dumux/nonlinear/newtoncontroller.hh b/dumux/nonlinear/newtoncontroller.hh index a3b14efc0c..e825cc3202 100644 --- a/dumux/nonlinear/newtoncontroller.hh +++ b/dumux/nonlinear/newtoncontroller.hh @@ -453,10 +453,10 @@ public: // compute the vertex and element colors for partial reassembly if (enablePartialReassemble_) { - Scalar minReasmTol, tmp, reassembleTol; - minReasmTol = 0.1*tolerance_; - tmp = Dumux::geometricMean(error_, minReasmTol); - reassembleTol = Dumux::geometricMean(error_, tmp); + const Scalar minReasmTol = 1e-2*tolerance_; + const Scalar maxReasmTol = 1e1*tolerance_; + Scalar reassembleTol = std::max(minReasmTol, std::min(maxReasmTol, this->error_/1e4)); + //Scalar reassembleTol = minReasmTol; this->model_().jacobianAssembler().updateDiscrepancy(uLastIter, deltaU); this->model_().jacobianAssembler().computeColors(reassembleTol); diff --git a/test/boxmodels/2p2c/injectionproblem.hh b/test/boxmodels/2p2c/injectionproblem.hh index 6900fb5123..a094100eb9 100644 --- a/test/boxmodels/2p2c/injectionproblem.hh +++ b/test/boxmodels/2p2c/injectionproblem.hh @@ -71,7 +71,6 @@ public: SET_BOOL_PROP(InjectionProblem, EnableGravity, true); SET_BOOL_PROP(InjectionProblem, EnableJacobianRecycling, true); -SET_BOOL_PROP(InjectionProblem, EnablePartialReassemble, true); SET_BOOL_PROP(InjectionProblem, EnableVelocityOutput, false); } -- GitLab