Commit 8c0718cb authored by Henry Weller's avatar Henry Weller
Browse files

LduMatrix/SolverPerformance: Changed nIterations from label to labelType...

LduMatrix/SolverPerformance: Changed nIterations from label to labelType corresponding to the type solved

Now the number of iterations to solve each component in a segregated
solution are stored and returned in the SolverPerformance class.

Resolves bug-report http://bugs.openfoam.org/view.php?id=2189
parent 5dea0770
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -66,7 +66,7 @@ bool Foam::SolverPerformance<Type>::checkConvergence
if (debug >= 2)
{
Info<< solverName_
<< ": Iteration " << noIterations_
<< ": Iteration " << nIterations_
<< " residual = " << finalResidual_
<< endl;
}
......@@ -119,7 +119,7 @@ void Foam::SolverPerformance<Type>::print
{
os << ", Initial residual = " << component(initialResidual_, cmpt)
<< ", Final residual = " << component(finalResidual_, cmpt)
<< ", No Iterations " << noIterations_
<< ", No Iterations " << nIterations_
<< endl;
}
}
......@@ -135,6 +135,7 @@ void Foam::SolverPerformance<Type>::replace
{
initialResidual_.replace(cmpt, sp.initialResidual());
finalResidual_.replace(cmpt, sp.finalResidual());
nIterations_.replace(cmpt, sp.nIterations());
singular_[cmpt] = sp.singular();
}
......@@ -149,7 +150,7 @@ Foam::SolverPerformance<Type>::max()
fieldName_,
cmptMax(initialResidual_),
cmptMax(finalResidual_),
noIterations_,
cmptMax(nIterations_),
converged_,
singular()
);
......@@ -207,7 +208,7 @@ Foam::Istream& Foam::operator>>
>> sp.fieldName_
>> sp.initialResidual_
>> sp.finalResidual_
>> sp.noIterations_
>> sp.nIterations_
>> sp.converged_
>> sp.singular_;
is.readEndList("SolverPerformance<Type>");
......@@ -228,7 +229,7 @@ Foam::Ostream& Foam::operator<<
<< sp.fieldName_ << token::SPACE
<< sp.initialResidual_ << token::SPACE
<< sp.finalResidual_ << token::SPACE
<< sp.noIterations_ << token::SPACE
<< sp.nIterations_ << token::SPACE
<< sp.converged_ << token::SPACE
<< sp.singular_ << token::SPACE
<< token::END_LIST;
......
......@@ -78,14 +78,17 @@ Ostream& operator<<
template<class Type>
class SolverPerformance
{
// Label type corresponding to Type
typedef typename pTraits<Type>::labelType labelType;
// Private data
word solverName_;
word fieldName_;
Type initialResidual_;
Type finalResidual_;
label noIterations_;
bool converged_;
word solverName_;
word fieldName_;
Type initialResidual_;
Type finalResidual_;
labelType nIterations_;
bool converged_;
FixedList<bool, pTraits<Type>::nComponents> singular_;
......@@ -112,7 +115,7 @@ public:
:
initialResidual_(Zero),
finalResidual_(Zero),
noIterations_(0),
nIterations_(Zero),
converged_(false),
singular_(false)
{}
......@@ -120,20 +123,20 @@ public:
SolverPerformance
(
const word& solverName,
const word& fieldName,
const Type& iRes = pTraits<Type>::zero,
const Type& fRes = pTraits<Type>::zero,
const label nIter = 0,
const bool converged = false,
const bool singular = false
const word& solverName,
const word& fieldName,
const Type& iRes = pTraits<Type>::zero,
const Type& fRes = pTraits<Type>::zero,
const labelType& nIter = pTraits<labelType>::zero,
const bool converged = false,
const bool singular = false
)
:
solverName_(solverName),
fieldName_(fieldName),
initialResidual_(iRes),
finalResidual_(fRes),
noIterations_(nIter),
nIterations_(nIter),
converged_(converged),
singular_(singular)
{}
......@@ -188,15 +191,15 @@ public:
//- Return number of iterations
label nIterations() const
const labelType& nIterations() const
{
return noIterations_;
return nIterations_;
}
//- Return number of iterations
label& nIterations()
labelType& nIterations()
{
return noIterations_;
return nIterations_;
}
......
......@@ -69,7 +69,7 @@ Foam::DiagonalSolver<Type, DType, LUType>::solve
this->fieldName_,
Zero,
Zero,
0,
Zero,
true,
false
);
......
......@@ -62,6 +62,8 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
this->fieldName_
);
label nIter = 0;
label nCells = psi.size();
Type* __restrict__ psiPtr = psi.begin();
......@@ -131,7 +133,7 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
// --- Update search directions:
wArT = gSumProd(wA, rT);
if (solverPerf.nIterations() == 0)
if (nIter == 0)
{
for (label cell=0; cell<nCells; cell++)
{
......@@ -187,13 +189,16 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
} while
(
(
solverPerf.nIterations()++ < this->maxIter_
nIter++ < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
|| solverPerf.nIterations() < this->minIter_
|| nIter < this->minIter_
);
}
solverPerf.nIterations() =
pTraits<typename pTraits<Type>::labelType>::one*nIter;
return solverPerf;
}
......
......@@ -59,6 +59,8 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
this->fieldName_
);
label nIter = 0;
label nCells = psi.size();
Type* __restrict__ psiPtr = psi.begin();
......@@ -124,7 +126,7 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
// --- Update search directions:
wArT = gSumCmptProd(wA, rT);
if (solverPerf.nIterations() == 0)
if (nIter == 0)
{
for (label cell=0; cell<nCells; cell++)
{
......@@ -187,11 +189,14 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
} while
(
solverPerf.nIterations()++ < this->maxIter_
nIter++ < this->maxIter_
&& !(solverPerf.checkConvergence(this->tolerance_, this->relTol_))
);
}
solverPerf.nIterations() =
pTraits<typename pTraits<Type>::labelType>::one*nIter;
return solverPerf;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -59,6 +59,8 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
this->fieldName_
);
label nIter = 0;
label nCells = psi.size();
Type* __restrict__ psiPtr = psi.begin();
......@@ -118,7 +120,7 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
// --- Update search directions:
wArA = gSumCmptProd(wA, rA);
if (solverPerf.nIterations() == 0)
if (nIter == 0)
{
for (label cell=0; cell<nCells; cell++)
{
......@@ -179,13 +181,16 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
} while
(
(
solverPerf.nIterations()++ < this->maxIter_
nIter++ < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
|| solverPerf.nIterations() < this->minIter_
|| nIter < this->minIter_
);
}
solverPerf.nIterations() =
pTraits<typename pTraits<Type>::labelType>::one*nIter;
return solverPerf;
}
......
......@@ -68,6 +68,8 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
this->fieldName_
);
label nIter = 0;
// If the nSweeps_ is negative do a fixed number of sweeps
if (nSweeps_ < 0)
{
......@@ -81,7 +83,7 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
smootherPtr->smooth(psi, -nSweeps_);
solverPerf.nIterations() -= nSweeps_;
nIter -= nSweeps_;
}
else
{
......@@ -145,14 +147,17 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
} while
(
(
(solverPerf.nIterations() += nSweeps_) < this->maxIter_
(nIter += nSweeps_) < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
|| solverPerf.nIterations() < this->minIter_
|| nIter < this->minIter_
);
}
}
solverPerf.nIterations() =
pTraits<typename pTraits<Type>::labelType>::one*nIter;
return solverPerf;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment