Added data and SolverPerformance classes from vanilla 3.0.1
This commit is contained in:
parent
964b873d22
commit
6fbeca5204
5 changed files with 798 additions and 0 deletions
240
src/foam/matrices/lduMatrix/lduMatrix/SolverPerformance.C
Normal file
240
src/foam/matrices/lduMatrix/lduMatrix/SolverPerformance.C
Normal file
|
@ -0,0 +1,240 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
301
src/foam/matrices/lduMatrix/lduMatrix/SolverPerformance.H
Normal file
301
src/foam/matrices/lduMatrix/lduMatrix/SolverPerformance.H
Normal file
|
@ -0,0 +1,301 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. 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
|
||||
|
||||
// ************************************************************************* //
|
62
src/foam/meshes/data/data.C
Normal file
62
src/foam/meshes/data/data.C
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "data.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
int Foam::data::debug(Foam::debug::debugSwitch("data", false));
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::data::data(const objectRegistry& obr)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"data",
|
||||
obr.time().system(),
|
||||
obr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
prevTimeIndex_(0)
|
||||
{
|
||||
set("solverPerformance", dictionary());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::dictionary& Foam::data::solverPerformanceDict() const
|
||||
{
|
||||
return subDict("solverPerformance");
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
124
src/foam/meshes/data/data.H
Normal file
124
src/foam/meshes/data/data.H
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::data
|
||||
|
||||
Description
|
||||
Database for solution data, solver performance and other reduced data.
|
||||
|
||||
fvMesh is derived from data so that all fields have access to the data from
|
||||
the mesh reference they hold.
|
||||
|
||||
SourceFiles
|
||||
data.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef data_H
|
||||
#define data_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "solverPerformance.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class data Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class data
|
||||
:
|
||||
public IOdictionary
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Previously used time-index, used for reset between iterations
|
||||
mutable label prevTimeIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
data(const data&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const data&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch
|
||||
static int debug;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for objectRegistry
|
||||
data(const objectRegistry& obr);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the dictionary of solver performance data
|
||||
// which includes initial and final residuals for convergence
|
||||
// checking
|
||||
const dictionary& solverPerformanceDict() const;
|
||||
|
||||
//- Add/set the solverPerformance entry for the named field
|
||||
template<class Type>
|
||||
void setSolverPerformance
|
||||
(
|
||||
const word& name,
|
||||
const SolverPerformance<Type>&
|
||||
) const;
|
||||
|
||||
//- Add/set the solverPerformance entry, using its fieldName
|
||||
template<class Type>
|
||||
void setSolverPerformance
|
||||
(
|
||||
const SolverPerformance<Type>&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "dataTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
71
src/foam/meshes/data/dataTemplates.C
Normal file
71
src/foam/meshes/data/dataTemplates.C
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "data.H"
|
||||
#include "Time.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