ENH: residuals FO updated follwing changes to functionObjectFile and minor code formatting

This commit is contained in:
Andrew Heather
2015-10-06 12:14:28 +01:00
parent bbd05f162e
commit 9b49b7bfa8
3 changed files with 34 additions and 31 deletions

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 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,6 +35,23 @@ namespace Foam
defineTypeNameAndDebug(residuals, 0); defineTypeNameAndDebug(residuals, 0);
} }
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::residuals::writeFileHeader(Ostream& os) const
{
writeHeader(os, "Residuals");
writeCommented(os, "Time");
forAll(fieldSet_, fieldI)
{
writeTabbed(os, fieldSet_[fieldI]);
}
os << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::residuals::residuals Foam::residuals::residuals
@ -45,7 +62,7 @@ Foam::residuals::residuals
const bool loadFromFiles const bool loadFromFiles
) )
: :
functionObjectFile(obr, name, typeName), functionObjectFile(obr, name, typeName, dict),
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true), active_(true),
@ -68,7 +85,11 @@ Foam::residuals::residuals
<< endl; << endl;
} }
if (active_)
{
read(dict); read(dict);
writeFileHeader(file());
}
} }
@ -84,24 +105,11 @@ void Foam::residuals::read(const dictionary& dict)
{ {
if (active_) if (active_)
{ {
dict.lookup("fields") >> fieldSet_; functionObjectFile::read(dict);
}
}
wordList allFields(dict.lookup("fields"));
void Foam::residuals::writeFileHeader(const label i) wordHashSet uniqueFields(allFields);
{ fieldSet_ = uniqueFields.toc();
if (Pstream::master())
{
writeHeader(file(), "Residuals");
writeCommented(file(), "Time");
forAll(fieldSet_, fieldI)
{
writeTabbed(file(), fieldSet_[fieldI]);
}
file() << endl;
} }
} }
@ -128,8 +136,6 @@ void Foam::residuals::write()
{ {
if (active_) if (active_)
{ {
functionObjectFile::write();
if (Pstream::master()) if (Pstream::master())
{ {
file()<< obr_.time().value(); file()<< obr_.time().value();

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 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -116,7 +116,7 @@ protected:
void operator=(const residuals&); void operator=(const residuals&);
//- Output file header information //- Output file header information
virtual void writeFileHeader(const label i); virtual void writeFileHeader(Ostream& os) const;
public: public:
@ -150,7 +150,7 @@ public:
return name_; return name_;
} }
//- Read the field min/max data //- Read the field residuals data
virtual void read(const dictionary&); virtual void read(const dictionary&);
//- Execute, currently does nothing //- Execute, currently does nothing
@ -162,7 +162,7 @@ public:
//- Called when time was set at the end of the Time::operator++ //- Called when time was set at the end of the Time::operator++
virtual void timeSet(); virtual void timeSet();
//- Calculate the field min/max //- Calculate the field residuals
template<class Type> template<class Type>
void writeResidual(const word& fieldName); void writeResidual(const word& fieldName);

View File

@ -32,10 +32,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::residuals::writeResidual void Foam::residuals::writeResidual(const word& fieldName)
(
const word& fieldName
)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;