Fixed solverPerformance residual backport
This commit is contained in:
parent
5b31dad987
commit
23765c920f
12 changed files with 135 additions and 728 deletions
|
@ -24,6 +24,7 @@ License
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "solutionControl.H"
|
#include "solutionControl.H"
|
||||||
|
#include "lduMatrix.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ void Foam::solutionControl::maxTypeResidual
|
||||||
|
|
||||||
if (mesh_.foundObject<fieldType>(fieldName))
|
if (mesh_.foundObject<fieldType>(fieldName))
|
||||||
{
|
{
|
||||||
const List<SolverPerformance<Type> > sp(data);
|
const List<lduSolverPerformance> sp(data);
|
||||||
firstRes = cmptMax(sp.first().initialResidual());
|
firstRes = cmptMax(sp.first().initialResidual());
|
||||||
lastRes = cmptMax(sp.last().initialResidual());
|
lastRes = cmptMax(sp.last().initialResidual());
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,8 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
|
||||||
|
|
||||||
psi_.correctBoundaryConditions();
|
psi_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
psi_.mesh().setSolverPerformance(psi_.name(), solverPerfVec);
|
||||||
|
|
||||||
return solverPerfVec;
|
return solverPerfVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,8 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
|
||||||
|
|
||||||
psi_.correctBoundaryConditions();
|
psi_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
psi_.mesh().setSolverPerformance(psi_.name(), solverPerf);
|
||||||
|
|
||||||
return solverPerf;
|
return solverPerf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,240 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
|
||||||
\\ / O peration | Version: 3.2
|
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of foam-extend.
|
|
||||||
|
|
||||||
foam-extend is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
foam-extend is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "SolverPerformance.H"
|
|
||||||
#include "IOstreams.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::SolverPerformance<Type>::checkSingularity
|
|
||||||
(
|
|
||||||
const Type& wApA
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
singular_[cmpt] =
|
|
||||||
component(wApA, cmpt) < vsmall_;
|
|
||||||
}
|
|
||||||
|
|
||||||
return singular();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::SolverPerformance<Type>::singular() const
|
|
||||||
{
|
|
||||||
for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
if (!singular_[cmpt]) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::SolverPerformance<Type>::checkConvergence
|
|
||||||
(
|
|
||||||
const Type& Tolerance,
|
|
||||||
const Type& RelTolerance
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (debug >= 2)
|
|
||||||
{
|
|
||||||
Info<< solverName_
|
|
||||||
<< ": Iteration " << noIterations_
|
|
||||||
<< " residual = " << finalResidual_
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
finalResidual_ < Tolerance
|
|
||||||
|| (
|
|
||||||
RelTolerance
|
|
||||||
> small_*pTraits<Type>::one
|
|
||||||
&& finalResidual_ < cmptMultiply(RelTolerance, initialResidual_)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
converged_ = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
converged_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return converged_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::SolverPerformance<Type>::print
|
|
||||||
(
|
|
||||||
Ostream& os
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
if (pTraits<Type>::nComponents == 1)
|
|
||||||
{
|
|
||||||
os << solverName_ << ": Solving for " << fieldName_;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << solverName_ << ": Solving for "
|
|
||||||
<< word(fieldName_ + pTraits<Type>::componentNames[cmpt]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (singular_[cmpt])
|
|
||||||
{
|
|
||||||
os << ": solution singularity" << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << ", Initial residual = " << component(initialResidual_, cmpt)
|
|
||||||
<< ", Final residual = " << component(finalResidual_, cmpt)
|
|
||||||
<< ", No Iterations " << noIterations_
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::SolverPerformance<Type>::replace
|
|
||||||
(
|
|
||||||
const Foam::label cmpt,
|
|
||||||
const Foam::SolverPerformance<typename pTraits<Type>::cmptType>& sp
|
|
||||||
)
|
|
||||||
{
|
|
||||||
initialResidual_.replace(cmpt, sp.initialResidual());
|
|
||||||
finalResidual_.replace(cmpt, sp.finalResidual());
|
|
||||||
singular_[cmpt] = sp.singular();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::SolverPerformance<typename Foam::pTraits<Type>::cmptType>
|
|
||||||
Foam::SolverPerformance<Type>::max()
|
|
||||||
{
|
|
||||||
return SolverPerformance<typename pTraits<Type>::cmptType>
|
|
||||||
(
|
|
||||||
solverName_,
|
|
||||||
fieldName_,
|
|
||||||
cmptMax(initialResidual_),
|
|
||||||
cmptMax(finalResidual_),
|
|
||||||
noIterations_,
|
|
||||||
converged_,
|
|
||||||
singular()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::SolverPerformance<Type>::operator!=
|
|
||||||
(
|
|
||||||
const SolverPerformance<Type>& sp
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
solverName() != sp.solverName()
|
|
||||||
|| fieldName() != sp.fieldName()
|
|
||||||
|| initialResidual() != sp.initialResidual()
|
|
||||||
|| finalResidual() != sp.finalResidual()
|
|
||||||
|| nIterations() != sp.nIterations()
|
|
||||||
|| converged() != sp.converged()
|
|
||||||
|| singular() != sp.singular()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
typename Foam::SolverPerformance<Type> Foam::max
|
|
||||||
(
|
|
||||||
const typename Foam::SolverPerformance<Type>& sp1,
|
|
||||||
const typename Foam::SolverPerformance<Type>& sp2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return SolverPerformance<Type>
|
|
||||||
(
|
|
||||||
sp1.solverName(),
|
|
||||||
sp1.fieldName_,
|
|
||||||
max(sp1.initialResidual(), sp2.initialResidual()),
|
|
||||||
max(sp1.finalResidual(), sp2.finalResidual()),
|
|
||||||
max(sp1.nIterations(), sp2.nIterations()),
|
|
||||||
sp1.converged() && sp2.converged(),
|
|
||||||
sp1.singular() || sp2.singular()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::Istream& Foam::operator>>
|
|
||||||
(
|
|
||||||
Istream& is,
|
|
||||||
typename Foam::SolverPerformance<Type>& sp
|
|
||||||
)
|
|
||||||
{
|
|
||||||
is.readBeginList("SolverPerformance<Type>");
|
|
||||||
is >> sp.solverName_
|
|
||||||
>> sp.fieldName_
|
|
||||||
>> sp.initialResidual_
|
|
||||||
>> sp.finalResidual_
|
|
||||||
>> sp.noIterations_
|
|
||||||
>> sp.converged_
|
|
||||||
>> sp.singular_;
|
|
||||||
is.readEndList("SolverPerformance<Type>");
|
|
||||||
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::Ostream& Foam::operator<<
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const typename Foam::SolverPerformance<Type>& sp
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << token::BEGIN_LIST
|
|
||||||
<< sp.solverName_ << token::SPACE
|
|
||||||
<< sp.fieldName_ << token::SPACE
|
|
||||||
<< sp.initialResidual_ << token::SPACE
|
|
||||||
<< sp.finalResidual_ << token::SPACE
|
|
||||||
<< sp.noIterations_ << token::SPACE
|
|
||||||
<< sp.converged_ << token::SPACE
|
|
||||||
<< sp.singular_ << token::SPACE
|
|
||||||
<< token::END_LIST;
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
|
@ -1,301 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
|
||||||
\\ / O peration | Version: 3.2
|
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of foam-extend.
|
|
||||||
|
|
||||||
foam-extend is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
foam-extend is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::SolverPerformance
|
|
||||||
|
|
||||||
Description
|
|
||||||
SolverPerformance is the class returned by the LduMatrix solver
|
|
||||||
containing performance statistics.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
SolverPerformance.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef SolverPerformance_H
|
|
||||||
#define SolverPerformance_H
|
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "FixedList.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
class SolverPerformance;
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
SolverPerformance<Type> max
|
|
||||||
(
|
|
||||||
const SolverPerformance<Type>&,
|
|
||||||
const SolverPerformance<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Istream& operator>>
|
|
||||||
(
|
|
||||||
Istream&,
|
|
||||||
SolverPerformance<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Ostream& operator<<
|
|
||||||
(
|
|
||||||
Ostream&,
|
|
||||||
const SolverPerformance<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class SolverPerformance Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
class SolverPerformance
|
|
||||||
{
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
word solverName_;
|
|
||||||
word fieldName_;
|
|
||||||
Type initialResidual_;
|
|
||||||
Type finalResidual_;
|
|
||||||
label noIterations_;
|
|
||||||
bool converged_;
|
|
||||||
FixedList<bool, pTraits<Type>::nComponents> singular_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
|
|
||||||
// Declare name of the class and its debug switch
|
|
||||||
ClassName("SolverPerformance");
|
|
||||||
|
|
||||||
//- Large Type for the use in solvers
|
|
||||||
static const scalar great_;
|
|
||||||
|
|
||||||
//- Small Type for the use in solvers
|
|
||||||
static const scalar small_;
|
|
||||||
|
|
||||||
//- Very small Type for the use in solvers
|
|
||||||
static const scalar vsmall_;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
SolverPerformance()
|
|
||||||
:
|
|
||||||
initialResidual_(pTraits<Type>::zero),
|
|
||||||
finalResidual_(pTraits<Type>::zero),
|
|
||||||
noIterations_(0),
|
|
||||||
converged_(false),
|
|
||||||
singular_(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
)
|
|
||||||
:
|
|
||||||
solverName_(solverName),
|
|
||||||
fieldName_(fieldName),
|
|
||||||
initialResidual_(iRes),
|
|
||||||
finalResidual_(fRes),
|
|
||||||
noIterations_(nIter),
|
|
||||||
converged_(converged),
|
|
||||||
singular_(singular)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
|
||||||
|
|
||||||
//- Return solver name
|
|
||||||
const word& solverName() const
|
|
||||||
{
|
|
||||||
return solverName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return solver name
|
|
||||||
word& solverName()
|
|
||||||
{
|
|
||||||
return solverName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Return field name
|
|
||||||
const word& fieldName() const
|
|
||||||
{
|
|
||||||
return fieldName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Return initial residual
|
|
||||||
const Type& initialResidual() const
|
|
||||||
{
|
|
||||||
return initialResidual_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return initial residual
|
|
||||||
Type& initialResidual()
|
|
||||||
{
|
|
||||||
return initialResidual_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Return final residual
|
|
||||||
const Type& finalResidual() const
|
|
||||||
{
|
|
||||||
return finalResidual_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return final residual
|
|
||||||
Type& finalResidual()
|
|
||||||
{
|
|
||||||
return finalResidual_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Return number of iterations
|
|
||||||
label nIterations() const
|
|
||||||
{
|
|
||||||
return noIterations_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return number of iterations
|
|
||||||
label& nIterations()
|
|
||||||
{
|
|
||||||
return noIterations_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Has the solver converged?
|
|
||||||
bool converged() const
|
|
||||||
{
|
|
||||||
return converged_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Is the matrix singular?
|
|
||||||
bool singular() const;
|
|
||||||
|
|
||||||
//- Check, store and return convergence
|
|
||||||
bool checkConvergence
|
|
||||||
(
|
|
||||||
const Type& tolerance,
|
|
||||||
const Type& relTolerance
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Singularity test
|
|
||||||
bool checkSingularity(const Type& residual);
|
|
||||||
|
|
||||||
//- Print summary of solver performance to the given stream
|
|
||||||
void print(Ostream& os) const;
|
|
||||||
|
|
||||||
//- Replace component based on the minimal SolverPerformance
|
|
||||||
void replace
|
|
||||||
(
|
|
||||||
const label cmpt,
|
|
||||||
const SolverPerformance<typename pTraits<Type>::cmptType>& sp
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return the summary maximum of SolverPerformance<Type>
|
|
||||||
// Effectively it will mostly return solverPerformanceScalar
|
|
||||||
SolverPerformance<typename pTraits<Type>::cmptType> max();
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
|
||||||
|
|
||||||
bool operator!=(const SolverPerformance<Type>&) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Friend functions
|
|
||||||
|
|
||||||
//- Return the element-wise maximum of two SolverPerformance<Type>s
|
|
||||||
friend SolverPerformance<Type> Foam::max <Type>
|
|
||||||
(
|
|
||||||
const SolverPerformance<Type>&,
|
|
||||||
const SolverPerformance<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
|
||||||
|
|
||||||
friend Istream& operator>> <Type>
|
|
||||||
(
|
|
||||||
Istream&,
|
|
||||||
SolverPerformance<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
friend Ostream& operator<< <Type>
|
|
||||||
(
|
|
||||||
Ostream&,
|
|
||||||
const SolverPerformance<Type>&
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#define makeSolverPerformance(Type) \
|
|
||||||
\
|
|
||||||
typedef Foam::SolverPerformance<Type> \
|
|
||||||
solverPerformance##Type; \
|
|
||||||
\
|
|
||||||
defineNamedTemplateTypeNameAndDebug(solverPerformance##Type, 0); \
|
|
||||||
\
|
|
||||||
template<> \
|
|
||||||
const scalar solverPerformance##Type::great_(1e20); \
|
|
||||||
\
|
|
||||||
template<> \
|
|
||||||
const scalar solverPerformance##Type::small_(1e-20); \
|
|
||||||
\
|
|
||||||
template<> \
|
|
||||||
const scalar solverPerformance##Type::vsmall_(VSMALL); \
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
# include "SolverPerformance.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
|
@ -56,7 +56,6 @@ SourceFiles
|
||||||
#include "primitiveFieldsFwd.H"
|
#include "primitiveFieldsFwd.H"
|
||||||
#include "FieldField.H"
|
#include "FieldField.H"
|
||||||
#include "lduInterfaceFieldPtrsList.H"
|
#include "lduInterfaceFieldPtrsList.H"
|
||||||
#include "SolverPerformance.H"
|
|
||||||
#include "typeInfo.H"
|
#include "typeInfo.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
|
@ -172,6 +171,18 @@ public:
|
||||||
return solverName_;
|
return solverName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return field name
|
||||||
|
const word& fieldName() const
|
||||||
|
{
|
||||||
|
return fieldName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return access to field name
|
||||||
|
word& fieldName()
|
||||||
|
{
|
||||||
|
return fieldName_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Return initial residual
|
//- Return initial residual
|
||||||
scalar initialResidual() const
|
scalar initialResidual() const
|
||||||
{
|
{
|
||||||
|
@ -235,6 +246,25 @@ public:
|
||||||
|
|
||||||
//- Print summary of solver performance
|
//- Print summary of solver performance
|
||||||
void print() const;
|
void print() const;
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
bool operator!=(const solverPerformance&) const;
|
||||||
|
|
||||||
|
// Ostream Operator
|
||||||
|
|
||||||
|
friend Istream& operator>>
|
||||||
|
(
|
||||||
|
Istream&,
|
||||||
|
solverPerformance&
|
||||||
|
);
|
||||||
|
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const solverPerformance&
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,4 +104,62 @@ void Foam::lduMatrix::solverPerformance::print() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::lduSolverPerformance::operator!=
|
||||||
|
(
|
||||||
|
const lduSolverPerformance& sp
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
solverName() != sp.solverName()
|
||||||
|
|| fieldName() != sp.fieldName()
|
||||||
|
|| initialResidual() != sp.initialResidual()
|
||||||
|
|| finalResidual() != sp.finalResidual()
|
||||||
|
|| nIterations() != sp.nIterations()
|
||||||
|
|| converged() != sp.converged()
|
||||||
|
|| singular() != sp.singular()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Istream& Foam::operator>>
|
||||||
|
(
|
||||||
|
Istream& is,
|
||||||
|
typename Foam::lduSolverPerformance& sp
|
||||||
|
)
|
||||||
|
{
|
||||||
|
is.readBeginList("SolverPerformance<Type>");
|
||||||
|
is >> sp.solverName_
|
||||||
|
>> sp.fieldName_
|
||||||
|
>> sp.initialResidual_
|
||||||
|
>> sp.finalResidual_
|
||||||
|
>> sp.noIterations_
|
||||||
|
>> sp.converged_
|
||||||
|
>> sp.singular_;
|
||||||
|
is.readEndList("SolverPerformance<Type>");
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const typename Foam::lduSolverPerformance& sp
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os << token::BEGIN_LIST
|
||||||
|
<< sp.solverName_ << token::SPACE
|
||||||
|
<< sp.fieldName_ << token::SPACE
|
||||||
|
<< sp.initialResidual_ << token::SPACE
|
||||||
|
<< sp.finalResidual_ << token::SPACE
|
||||||
|
<< sp.noIterations_ << token::SPACE
|
||||||
|
<< sp.converged_ << token::SPACE
|
||||||
|
<< sp.singular_ << token::SPACE
|
||||||
|
<< token::END_LIST;
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
|
||||||
\\ / O peration | Version: 3.2
|
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of foam-extend.
|
|
||||||
|
|
||||||
foam-extend is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
foam-extend is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "solverPerformance.H"
|
|
||||||
#include "fieldTypes.H"
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
makeSolverPerformance(scalar);
|
|
||||||
makeSolverPerformance(vector);
|
|
||||||
makeSolverPerformance(sphericalTensor);
|
|
||||||
makeSolverPerformance(symmTensor);
|
|
||||||
makeSolverPerformance(tensor);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
Foam::SolverPerformance<Foam::scalar>
|
|
||||||
Foam::SolverPerformance<Foam::scalar>::max()
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
|
||||||
\\ / O peration | Version: 3.2
|
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of foam-extend.
|
|
||||||
|
|
||||||
foam-extend is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
foam-extend is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Typedef
|
|
||||||
Foam::solverPerformance
|
|
||||||
|
|
||||||
Description
|
|
||||||
SolverPerformance instantiated for a scalar
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
solverPerformance.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef solverPerformance_H
|
|
||||||
#define solverPerformance_H
|
|
||||||
|
|
||||||
#include "SolverPerformance.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
typedef SolverPerformance<scalar> solverPerformance;
|
|
||||||
|
|
||||||
// Specialization of the max function for scalar object
|
|
||||||
template<>
|
|
||||||
SolverPerformance<scalar> SolverPerformance<scalar>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
|
@ -59,4 +59,41 @@ const Foam::dictionary& Foam::data::solverPerformanceDict() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::data::setSolverPerformance
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const lduSolverPerformance& sp
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
|
||||||
|
|
||||||
|
List<lduSolverPerformance> perfs;
|
||||||
|
|
||||||
|
if (prevTimeIndex_ != this->time().timeIndex())
|
||||||
|
{
|
||||||
|
// Reset solver performance between iterations
|
||||||
|
prevTimeIndex_ = this->time().timeIndex();
|
||||||
|
dict.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dict.readIfPresent(name, perfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append to list
|
||||||
|
perfs.setSize(perfs.size()+1, sp);
|
||||||
|
|
||||||
|
dict.set(name, perfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::data::setSolverPerformance
|
||||||
|
(
|
||||||
|
const lduSolverPerformance& sp
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
setSolverPerformance(sp.fieldName(), sp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
|
@ -39,7 +39,7 @@ SourceFiles
|
||||||
#define data_H
|
#define data_H
|
||||||
|
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
#include "solverPerformance.H"
|
#include "lduMatrix.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
@ -91,18 +91,16 @@ public:
|
||||||
const dictionary& solverPerformanceDict() const;
|
const dictionary& solverPerformanceDict() const;
|
||||||
|
|
||||||
//- Add/set the solverPerformance entry for the named field
|
//- Add/set the solverPerformance entry for the named field
|
||||||
template<class Type>
|
|
||||||
void setSolverPerformance
|
void setSolverPerformance
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const SolverPerformance<Type>&
|
const lduSolverPerformance&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add/set the solverPerformance entry, using its fieldName
|
//- Add/set the solverPerformance entry, using its fieldName
|
||||||
template<class Type>
|
|
||||||
void setSolverPerformance
|
void setSolverPerformance
|
||||||
(
|
(
|
||||||
const SolverPerformance<Type>&
|
const lduSolverPerformance&
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,12 +111,6 @@ public:
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
# include "dataTemplates.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
|
||||||
\\ / O peration | Version: 3.2
|
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of foam-extend.
|
|
||||||
|
|
||||||
foam-extend is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
foam-extend is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "data.H"
|
|
||||||
#include "foamTime.H"
|
|
||||||
#include "solverPerformance.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::data::setSolverPerformance
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const SolverPerformance<Type>& sp
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
|
|
||||||
|
|
||||||
List<SolverPerformance<Type> > perfs;
|
|
||||||
|
|
||||||
if (prevTimeIndex_ != this->time().timeIndex())
|
|
||||||
{
|
|
||||||
// Reset solver performance between iterations
|
|
||||||
prevTimeIndex_ = this->time().timeIndex();
|
|
||||||
dict.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dict.readIfPresent(name, perfs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append to list
|
|
||||||
perfs.setSize(perfs.size()+1, sp);
|
|
||||||
|
|
||||||
dict.set(name, perfs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::data::setSolverPerformance
|
|
||||||
(
|
|
||||||
const SolverPerformance<Type>& sp
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
setSolverPerformance(sp.fieldName(), sp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
Reference in a new issue