Fixed: SIMbase::getWorstDofs should also use the iteNorm flag

This commit is contained in:
Knut Morten Okstad
2017-02-21 13:49:11 +01:00
committed by Arne Morten Kvarving
parent 81edcadbe8
commit 091c5a522e
3 changed files with 14 additions and 6 deletions

View File

@@ -464,8 +464,9 @@ ConvStatus NonLinSIM::checkConvergence (TimeStep& param)
if (status == SLOW && prnSlow > 0)
{
// Find and print out the worst DOF(s) when detecting slow convergence
double eps = convTol*refNorm;
std::map<std::pair<int,int>,RealArray> worstDOFs;
model.getWorstDofs(linsol,residual,prnSlow,convTol*refNorm,worstDOFs);
model.getWorstDofs(linsol,residual,prnSlow,eps,iteNorm,worstDOFs);
cout <<" ** Slow convergence detected";
if (worstDOFs.size() > 1)
cout <<", here are the "<< worstDOFs.size() <<" worst DOFs:";

View File

@@ -1081,7 +1081,7 @@ void SIMbase::printNorms (const Vectors& norms, size_t w) const
void SIMbase::getWorstDofs (const Vector& u, const Vector& r,
size_t nWorst, double eps,
size_t nWorst, double eps, int iteNorm,
std::map<std::pair<int,int>,RealArray>& worst) const
{
size_t i;
@@ -1090,7 +1090,12 @@ void SIMbase::getWorstDofs (const Vector& u, const Vector& r,
// Compute the energy at each DOF and insert into a map sorted on the energy
for (i = 0; i < u.size() && i < r.size(); i++)
energy.insert(std::make_pair(fabs(u[i]*r[i]),i+1));
if (iteNorm == 1) // L2-norm of residual
energy.insert(std::make_pair(fabs(r[i]),i+1));
else if (iteNorm == 2) // L2-norm of solution correction
energy.insert(std::make_pair(fabs(u[i]),i+1));
else // Energy norm
energy.insert(std::make_pair(fabs(u[i]*r[i]),i+1));
// Pick the nWorst highest energies from the back of the map
std::multimap<double,size_t>::reverse_iterator rit = energy.rbegin();

View File

@@ -276,13 +276,15 @@ public:
bool solveMatrixSystem(Vectors& solution, int printSol = 0,
const char* compName = "displacement");
//! \brief Finds the worst energy DOFs in the residual.
//! \brief Finds the DOFs showing the worst convergence behavior.
//! \param[in] x Global primary solution vector
//! \param[in] r Global residual vector associated with the solution vector
//! \param[in] nWorst How many bad DOFs to detect
//! \param[in] eps Only record the energies larger than this tolerance
//! \param[in] eps Only record values larger than this tolerance
//! \param[in] iteNorm Which norm to consider (1=res, 2=dis, 3=energy)
//! \param[out] worst Node and local DOF number and values of the worst DOFs
void getWorstDofs(const Vector& x, const Vector& r, size_t nWorst, double eps,
void getWorstDofs(const Vector& x, const Vector& r,
size_t nWorst, double eps, int iteNorm,
std::map<std::pair<int,int>,RealArray>& worst) const;
//! \brief Evaluates some iteration norms for convergence assessment.