Changed: Always use SIMinput::adm::cout (and not IFEM::cout)

when printing norms and convergence history for the MultiStepSIM drivers.
This commit is contained in:
Knut Morten Okstad 2016-11-17 15:12:26 +01:00
parent ffb7db391e
commit 46b6834208
3 changed files with 53 additions and 53 deletions

View File

@ -138,7 +138,7 @@ SIM::ConvStatus EigenModeSIM::solveStep (TimeStep& param, SIM::SolutionMode,
for (size_t i = 0; i < amplitude.size() && i < modes.size(); i++)
solution.front().add(modes[i].eigVec,amplitude[i]*sin(modes[i].eigVal*t));
if (msgLevel >= 0 && myPid == 0) std::cout << std::endl;
if (msgLevel >= 0) model.getProcessAdm().cout << std::endl;
return this->solutionNorms(param.time,zero_tolerance,outPrec) ?
SIM::CONVERGED : SIM::FAILURE;
}

View File

@ -314,12 +314,11 @@ SIM::ConvStatus NewmarkSIM::solveStep (TimeStep& param, SIM::SolutionMode,
if (msgLevel >= 0)
{
std::streamsize oldPrec = 0;
utl::LogStream& cout = model.getProcessAdm().cout;
double digits = log10(param.time.t)-log10(param.time.dt);
if (digits > 6.0) oldPrec = IFEM::cout.precision(ceil(digits));
IFEM::cout <<"\n step="<< param.step
<<" time="<< param.time.t << std::endl;
if (digits > 6.0) IFEM::cout.precision(oldPrec);
size_t stdPrec = digits > 6.0 ? cout.precision(ceil(digits)) : 0;
cout <<"\n step="<< param.step <<" time="<< param.time.t << std::endl;
if (digits > 6.0) cout.precision(stdPrec);
}
if (subiter&FIRST && !model.updateDirichlet(param.time.t,&solution.front()))
@ -462,15 +461,16 @@ SIM::ConvStatus NewmarkSIM::checkConvergence (TimeStep& param)
if (msgLevel > 0)
{
// Print convergence history
std::ios::fmtflags oldFlags = IFEM::cout.flags(std::ios::scientific);
std::streamsize oldPrec = IFEM::cout.precision(3);
IFEM::cout <<" iter="<< param.iter
utl::LogStream& cout = model.getProcessAdm().cout;
std::ios::fmtflags stdFlags = cout.flags(std::ios::scientific);
std::streamsize stdPrec = cout.precision(3);
cout <<" iter="<< param.iter
<<" conv="<< fabs(norm)
<<" enen="<< norms[0]
<<" resn="<< norms[1]
<<" incn="<< norms[2] << std::endl;
IFEM::cout.flags(oldFlags);
IFEM::cout.precision(oldPrec);
cout.flags(stdFlags);
cout.precision(stdPrec);
}
// Check for convergence or divergence

View File

@ -47,17 +47,21 @@ NonLinSIM::~NonLinSIM ()
{
if (slowNodes.empty()) return;
utl::LogStream& cout = model.getProcessAdm().cout;
std::map<int,int>::const_iterator nit;
std::cout <<"\n *** Here are the nodal points flagged with slow convergence"
cout <<"\n *** Here are the nodal points flagged with slow convergence"
<<"\n ======================================================="
<<"\n Node Count Patch Coordinates\n";
for (nit = slowNodes.begin(); nit != slowNodes.end(); ++nit)
{
Vec4 X = model.getNodeCoord(nit->first);
std::cout << std::setw(9) << nit->first
cout << std::setw(9) << nit->first
<< std::setw(5) << nit->second
<< std::setw(7) << X.idx <<" ";
X.Vec3::print(std::cout) << std::endl;
for (int i = 0; i < 3; i++)
cout <<" "<< utl::trunc(X[i]);
cout << std::endl;
}
}
@ -197,20 +201,15 @@ ConvStatus NonLinSIM::solveStep (TimeStep& param, SolutionMode mode,
if (msgLevel >= 0)
{
std::streamsize oldPrec = 0;
utl::LogStream& cout = model.getProcessAdm().cout;
double digits = log10(param.time.t)-log10(param.time.dt);
if (digits > 6.0)
{
oldPrec = std::cout.precision();
model.getProcessAdm().cout << std::setprecision(ceil(digits));
}
model.getProcessAdm().cout <<"\n step="<< param.step <<" time="<< param.time.t;
std::streamsize oldPrec = digits > 6.0 ? cout.precision(ceil(digits)) : 0;
cout <<"\n step="<< param.step <<" time="<< param.time.t;
if (param.maxCFL > 0.0)
model.getProcessAdm().cout <<" CFL = "<< param.time.CFL << std::endl;
cout <<" CFL = "<< param.time.CFL << std::endl;
else
model.getProcessAdm().cout << std::endl;
if (oldPrec > 0)
model.getProcessAdm().cout << std::setprecision(oldPrec);
cout << std::endl;
if (oldPrec > 0) cout << std::setprecision(oldPrec);
}
param.iter = 0;
@ -427,9 +426,10 @@ ConvStatus NonLinSIM::checkConvergence (TimeStep& param)
if (msgLevel > 0)
{
// Print convergence history
std::ios::fmtflags oldFlags = std::cout.flags(std::ios::scientific);
std::streamsize oldPrec = std::cout.precision(3);
model.getProcessAdm().cout <<" iter="<< param.iter
utl::LogStream& cout = model.getProcessAdm().cout;
std::ios::fmtflags oldFlags = cout.flags(std::ios::scientific);
std::streamsize oldPrec = cout.precision(3);
cout <<" iter="<< param.iter
<<" conv="<< fabs(norm)
<<" enen="<< enorm
<<" resn="<< resNorm
@ -439,22 +439,22 @@ ConvStatus NonLinSIM::checkConvergence (TimeStep& param)
// Find and print out the worst DOF(s) when detecting slow convergence
std::map<std::pair<int,int>,RealArray> worstDOFs;
model.getWorstDofs(linsol,residual,prnSlow,convTol*refNorm,worstDOFs);
std::cout <<" ** Slow convergence detected";
cout <<" ** Slow convergence detected";
if (worstDOFs.size() > 1)
std::cout <<", here are the "<< worstDOFs.size() <<" worst DOFs:";
cout <<", here are the "<< worstDOFs.size() <<" worst DOFs:";
else if (worstDOFs.size() == 1)
std::cout <<", here is the worst DOF:";
cout <<", here is the worst DOF:";
else
std::cout <<".";
cout <<".";
std::map<std::pair<int,int>,RealArray>::const_iterator it;
for (it = worstDOFs.begin(); it != worstDOFs.end(); it++)
{
std::cout <<"\n Node "<< it->first.first
cout <<"\n Node "<< it->first.first
<<" local DOF "<< it->first.second;
char nodeType = model.getNodeType(it->first.first);
if (nodeType != ' ')
std::cout <<" ("<< nodeType <<")";
std::cout <<" :\tEnergy = "<< it->second[0]
cout <<" ("<< nodeType <<")";
cout <<" :\tEnergy = "<< it->second[0]
<<"\tdu = "<< it->second[1]
<<"\tres = "<< it->second[2];
std::map<int,int>::iterator nit = slowNodes.find(it->first.first);
@ -463,10 +463,10 @@ ConvStatus NonLinSIM::checkConvergence (TimeStep& param)
else
++nit->second;
}
std::cout << std::endl;
cout << std::endl;
}
std::cout.flags(oldFlags);
std::cout.precision(oldPrec);
cout.flags(oldFlags);
cout.precision(oldPrec);
}
// Check for convergence or divergence