STYLE: Renamed residuals FO -> solverInfo to reflect capabilities

This commit is contained in:
Andrew Heather
2019-01-29 13:52:37 +00:00
parent 216616638f
commit 94070f5ee7
4 changed files with 83 additions and 72 deletions

View File

@ -10,7 +10,7 @@ vtkWrite/vtkWriteUpdate.C
removeRegisteredObject/removeRegisteredObject.C removeRegisteredObject/removeRegisteredObject.C
residuals/residuals.C solverInfo/solverInfo.C
runTimeControl/runTimeControl.C runTimeControl/runTimeControl.C
runTimeControl/runTimeCondition/runTimeCondition/runTimeCondition.C runTimeControl/runTimeCondition/runTimeCondition/runTimeCondition.C

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "residuals.H" #include "solverInfo.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -32,12 +32,12 @@ namespace Foam
{ {
namespace functionObjects namespace functionObjects
{ {
defineTypeNameAndDebug(residuals, 0); defineTypeNameAndDebug(solverInfo, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
functionObject, functionObject,
residuals, solverInfo,
dictionary dictionary
); );
} }
@ -46,7 +46,7 @@ namespace functionObjects
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) void Foam::functionObjects::solverInfo::writeFileHeader(Ostream& os)
{ {
if (!fieldSet_.updateSelection()) if (!fieldSet_.updateSelection())
{ {
@ -59,7 +59,7 @@ void Foam::functionObjects::residuals::writeFileHeader(Ostream& os)
} }
else else
{ {
writeHeader(os, "Residuals"); writeHeader(os, "Solver information");
} }
writeCommented(os, "Time"); writeCommented(os, "Time");
@ -79,9 +79,12 @@ void Foam::functionObjects::residuals::writeFileHeader(Ostream& os)
} }
void Foam::functionObjects::residuals::createField(const word& fieldName) void Foam::functionObjects::solverInfo::createResidualField
(
const word& fieldName
)
{ {
if (!writeFields_) if (!writeResidualFields_)
{ {
return; return;
} }
@ -109,7 +112,10 @@ void Foam::functionObjects::residuals::createField(const word& fieldName)
} }
void Foam::functionObjects::residuals::writeField(const word& fieldName) const void Foam::functionObjects::solverInfo::writeResidualField
(
const word& fieldName
) const
{ {
const word residualName("initialResidual:" + fieldName); const word residualName("initialResidual:" + fieldName);
@ -143,7 +149,7 @@ void Foam::functionObjects::residuals::writeField(const word& fieldName) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::residuals::residuals Foam::functionObjects::solverInfo::solverInfo
( (
const word& name, const word& name,
const Time& runTime, const Time& runTime,
@ -153,28 +159,23 @@ Foam::functionObjects::residuals::residuals
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
writeFile(obr_, name, typeName, dict), writeFile(obr_, name, typeName, dict),
fieldSet_(mesh_), fieldSet_(mesh_),
writeFields_(false), writeResidualFields_(false),
initialised_(false) initialised_(false)
{ {
read(dict); read(dict);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::residuals::~residuals()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::residuals::read(const dictionary& dict) bool Foam::functionObjects::solverInfo::read(const dictionary& dict)
{ {
if (fvMeshFunctionObject::read(dict)) if (fvMeshFunctionObject::read(dict))
{ {
fieldSet_.read(dict); fieldSet_.read(dict);
writeFields_ = dict.lookupOrDefault("writeFields", false); writeResidualFields_ =
dict.lookupOrDefault("writeResidualFields", false);
return true; return true;
} }
@ -183,7 +184,7 @@ bool Foam::functionObjects::residuals::read(const dictionary& dict)
} }
bool Foam::functionObjects::residuals::execute() bool Foam::functionObjects::solverInfo::execute()
{ {
// Note: delaying initialisation until after first iteration so that // Note: delaying initialisation until after first iteration so that
// we can find wildcard fields // we can find wildcard fields
@ -191,15 +192,15 @@ bool Foam::functionObjects::residuals::execute()
{ {
writeFileHeader(file()); writeFileHeader(file());
if (writeFields_) if (writeResidualFields_)
{ {
for (const word& fieldName : fieldSet_.selectionNames()) for (const word& fieldName : fieldSet_.selectionNames())
{ {
initialiseField<scalar>(fieldName); initialiseResidualField<scalar>(fieldName);
initialiseField<vector>(fieldName); initialiseResidualField<vector>(fieldName);
initialiseField<sphericalTensor>(fieldName); initialiseResidualField<sphericalTensor>(fieldName);
initialiseField<symmTensor>(fieldName); initialiseResidualField<symmTensor>(fieldName);
initialiseField<tensor>(fieldName); initialiseResidualField<tensor>(fieldName);
} }
} }
@ -210,17 +211,17 @@ bool Foam::functionObjects::residuals::execute()
} }
bool Foam::functionObjects::residuals::write() bool Foam::functionObjects::solverInfo::write()
{ {
writeTime(file()); writeTime(file());
for (const word& fieldName : fieldSet_.selectionNames()) for (const word& fieldName : fieldSet_.selectionNames())
{ {
writeResidual<scalar>(fieldName); writeSolverInfo<scalar>(fieldName);
writeResidual<vector>(fieldName); writeSolverInfo<vector>(fieldName);
writeResidual<sphericalTensor>(fieldName); writeSolverInfo<sphericalTensor>(fieldName);
writeResidual<symmTensor>(fieldName); writeSolverInfo<symmTensor>(fieldName);
writeResidual<tensor>(fieldName); writeSolverInfo<tensor>(fieldName);
} }
file() << endl; file() << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -22,37 +22,44 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::functionObjects::residuals Foam::functionObjects::solverInfo
Group Group
grpUtilitiesFunctionObjects grpUtilitiesFunctionObjects
Description Description
Writes out the initial residual for specified fields. Writes solver information for a list of user-specified fields
Information written to file includes:
- residual fields
- solver type
- initial residual
- final residual
- number of solver iterations
- convergecnce flag
Usage Usage
Example of function object specification: Example of function object specification:
\verbatim \verbatim
residuals solverInfo
{ {
type residuals; type solverInfo;
libs ("libutilityFunctionObjects.so"); libs ("libutilityFunctionObjects.so");
... ...
fields (U p); fields (U p);
writeResidualFields yes;
} }
\endverbatim \endverbatim
Where the entries comprise: Where the entries comprise:
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
type | Type name: residua ls | yes | type | Type name: solverInfo | yes |
fields | List of fields to process | yes | fields | List of fields to process | yes |
writeFields | Write the residual fields | no | no writeResidualFields | Write the residual fields | no | no
\endtable \endtable
Output data is written to the dir postProcessing/residuals/\<timeDir\>/ Output data is written to the dir postProcessing/solverInfo/\<timeDir\>/
For vector/tensor fields, e.g. U, where an equation is solved for each
component, the largest residual of each component is written.
See also See also
Foam::functionObject Foam::functionObject
@ -61,12 +68,12 @@ See also
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
SourceFiles SourceFiles
residuals.C solverInfo.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef functionObjects_residuals_H #ifndef functionObjects_solverInfo_H
#define functionObjects_residuals_H #define functionObjects_solverInfo_H
#include "fvMeshFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "writeFile.H" #include "writeFile.H"
@ -80,10 +87,10 @@ namespace functionObjects
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class residuals Declaration Class solverInfo Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class residuals class solverInfo
: :
public fvMeshFunctionObject, public fvMeshFunctionObject,
public writeFile public writeFile
@ -92,11 +99,11 @@ protected:
// Protected data // Protected data
//- Fields to write residuals //- Fields to process
solverFieldSelection fieldSet_; solverFieldSelection fieldSet_;
//- Flag to write the residual as a vol field //- Flag to write the residual as a vol field
bool writeFields_; bool writeResidualFields_;
//- Initialisation flag //- Initialisation flag
bool initialised_; bool initialised_;
@ -108,10 +115,10 @@ protected:
void writeFileHeader(Ostream& os); void writeFileHeader(Ostream& os);
//- Create and store a residual field on the mesh database //- Create and store a residual field on the mesh database
void createField(const word& fieldName); void createResidualField(const word& fieldName);
//- Write a residual field //- Write a residual field
void writeField(const word& fieldName) const; void writeResidualField(const word& fieldName) const;
//- Output file header information per primitive type value //- Output file header information per primitive type value
template<class Type> template<class Type>
@ -119,11 +126,11 @@ protected:
//- Initialise a residual field //- Initialise a residual field
template<class Type> template<class Type>
void initialiseField(const word& fieldName); void initialiseResidualField(const word& fieldName);
//- Calculate the residual //- Calculate the solver information
template<class Type> template<class Type>
void writeResidual(const word& fieldName); void writeSolverInfo(const word& fieldName);
private: private:
@ -131,22 +138,22 @@ private:
// Private member functions // Private member functions
//- No copy construct //- No copy construct
residuals(const residuals&) = delete; solverInfo(const solverInfo&) = delete;
//- No copy assignment //- No copy assignment
void operator=(const residuals&) = delete; void operator=(const solverInfo&) = delete;
public: public:
//- Runtime type information //- Runtime type information
TypeName("residuals"); TypeName("solverInfo");
// Constructors // Constructors
//- Construct from Time and dictionary //- Construct from Time and dictionary
residuals solverInfo
( (
const word& name, const word& name,
const Time& runTime, const Time& runTime,
@ -155,7 +162,7 @@ public:
//- Destructor //- Destructor
virtual ~residuals(); virtual ~solverInfo() = default;
// Member Functions // Member Functions
@ -166,7 +173,7 @@ public:
//- Execute, currently does nothing //- Execute, currently does nothing
virtual bool execute(); virtual bool execute();
//- Write the residuals //- Write the solverInfo
virtual bool write(); virtual bool write();
}; };
@ -179,7 +186,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
#include "residualsTemplates.C" #include "solverInfoTemplates.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "residuals.H" #include "solverInfo.H"
#include "volFields.H" #include "volFields.H"
#include "ListOps.H" #include "ListOps.H"
#include "zeroGradientFvPatchField.H" #include "zeroGradientFvPatchField.H"
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::functionObjects::residuals::writeFileHeader void Foam::functionObjects::solverInfo::writeFileHeader
( (
Ostream& os, Ostream& os,
const word& fieldName const word& fieldName
@ -67,7 +67,10 @@ void Foam::functionObjects::residuals::writeFileHeader
template<class Type> template<class Type>
void Foam::functionObjects::residuals::initialiseField(const word& fieldName) void Foam::functionObjects::solverInfo::initialiseResidualField
(
const word& fieldName
)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> volFieldType; typedef GeometricField<Type, fvPatchField, volMesh> volFieldType;
@ -91,7 +94,7 @@ void Foam::functionObjects::residuals::initialiseField(const word& fieldName)
fieldName + word(pTraits<Type>::componentNames[cmpt]) fieldName + word(pTraits<Type>::componentNames[cmpt])
); );
createField(resultName); createResidualField(resultName);
} }
} }
} }
@ -100,7 +103,7 @@ void Foam::functionObjects::residuals::initialiseField(const word& fieldName)
template<class Type> template<class Type>
void Foam::functionObjects::residuals::writeResidual(const word& fieldName) void Foam::functionObjects::solverInfo::writeSolverInfo(const word& fieldName)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> volFieldType; typedef GeometricField<Type, fvPatchField, volMesh> volFieldType;
typedef typename pTraits<Type>::labelType labelType; typedef typename pTraits<Type>::labelType labelType;
@ -121,7 +124,7 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
const Type& initialResidual = sp0.initialResidual(); const Type& initialResidual = sp0.initialResidual();
const Type& finalResidual = sp0.finalResidual(); const Type& finalResidual = sp0.finalResidual();
const labelType nIterations = sp0.nIterations(); const labelType nIterations = sp0.nIterations();
const bool converged = sp0.converged(); const Switch converged(sp0.converged());
const labelType validComponents(mesh_.validComponents<Type>()); const labelType validComponents(mesh_.validComponents<Type>());
@ -146,7 +149,7 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
setResult(resultName + "_final", rf); setResult(resultName + "_final", rf);
setResult(resultName + "_iters", n); setResult(resultName + "_iters", n);
writeField(resultName); writeResidualField(resultName);
} }
} }