diff --git a/src/SIM/NonLinSIM.C b/src/SIM/NonLinSIM.C index c51793f7..5ceadf80 100644 --- a/src/SIM/NonLinSIM.C +++ b/src/SIM/NonLinSIM.C @@ -37,6 +37,7 @@ NonLinSIM::NonLinSIM (SIMbase* sim) convTol = 1.0e-6; divgLim = 1.0; eta = 0.0; + iteNorm = ENERGY; } @@ -263,18 +264,22 @@ NonLinSIM::ConvStatus NonLinSIM::checkConvergence (SolvePrm& param) static double prevNorm = 0.0; static int nIncrease = 0; - double norm, enorm, resNorm, linsolNorm; + double norm=1.f, enorm, resNorm, linsolNorm; model->iterationNorms(linsol,residual,enorm,resNorm,linsolNorm); + if (iteNorm == ENERGY) + norm = enorm; + else if (iteNorm == L2) + norm = resNorm; if (param.iter == 0) { - if (enorm > param.refNorm) - param.refNorm = enorm; + if (norm > param.refNorm) + param.refNorm = norm; norm = prevNorm = 1.0; nIncrease = 0; } else - norm = fabs(enorm)/param.refNorm; + norm = fabs(norm)/param.refNorm; if (msgLevel > 0 && myPid == 0 && !solution.empty()) { diff --git a/src/SIM/NonLinSIM.h b/src/SIM/NonLinSIM.h index 20f408d2..d077a6f7 100644 --- a/src/SIM/NonLinSIM.h +++ b/src/SIM/NonLinSIM.h @@ -75,6 +75,17 @@ public: //! \param[in] mode Solution mode to use for this step bool solveStep(SolvePrm& param, SIM::SolutionMode mode = SIM::STATIC); + //! \brief Enum describing the norm used for convergence tests in the + //! Newton-Raphson iterations + enum ERRORNORM { + L2, + ENERGY + }; + + //! \brief Set the current norm in used in iteration error estimates + //! param[in] norm The wanted error norm + void setErrorNorm(ERRORNORM norm) { iteNorm = norm; } + //! \brief Computes and prints some solution norm quantities. //! \param[in] time Parameters for nonlinear/time-dependent simulations. //! \param[in] compName Solution name to be used in the norm output @@ -130,6 +141,7 @@ private: double eta; //!< Line search tolerance int maxit; //!< Maximum number of iterations in a time/load step int nupdat; //!< Number of iterations with updated tangent + ERRORNORM iteNorm;//!< The norm used to measure the residual // Post-processing attributes int nBlock; //!< Running VTF result block counter