diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.C b/src/postProcessing/functionObjects/utilities/residuals/residuals.C index 64ac3690b6..00e652b47d 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,6 +35,23 @@ namespace Foam 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 * * * * * * * * * * * * * * // Foam::residuals::residuals @@ -45,7 +62,7 @@ Foam::residuals::residuals const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFile(obr, name, typeName, dict), name_(name), obr_(obr), active_(true), @@ -68,7 +85,11 @@ Foam::residuals::residuals << endl; } - read(dict); + if (active_) + { + read(dict); + writeFileHeader(file()); + } } @@ -84,24 +105,11 @@ void Foam::residuals::read(const dictionary& dict) { if (active_) { - dict.lookup("fields") >> fieldSet_; - } -} + functionObjectFile::read(dict); - -void Foam::residuals::writeFileHeader(const label i) -{ - if (Pstream::master()) - { - writeHeader(file(), "Residuals"); - writeCommented(file(), "Time"); - - forAll(fieldSet_, fieldI) - { - writeTabbed(file(), fieldSet_[fieldI]); - } - - file() << endl; + wordList allFields(dict.lookup("fields")); + wordHashSet uniqueFields(allFields); + fieldSet_ = uniqueFields.toc(); } } @@ -128,8 +136,6 @@ void Foam::residuals::write() { if (active_) { - functionObjectFile::write(); - if (Pstream::master()) { file()<< obr_.time().value(); diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.H b/src/postProcessing/functionObjects/utilities/residuals/residuals.H index cb3d69cabd..01b24bbcee 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.H +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,7 +83,7 @@ class polyMesh; class mapPolyMesh; /*---------------------------------------------------------------------------*\ - Class residuals Declaration + Class residuals Declaration \*---------------------------------------------------------------------------*/ class residuals @@ -116,7 +116,7 @@ protected: void operator=(const residuals&); //- Output file header information - virtual void writeFileHeader(const label i); + virtual void writeFileHeader(Ostream& os) const; public: @@ -150,7 +150,7 @@ public: return name_; } - //- Read the field min/max data + //- Read the field residuals data virtual void read(const dictionary&); //- Execute, currently does nothing @@ -162,7 +162,7 @@ public: //- Called when time was set at the end of the Time::operator++ virtual void timeSet(); - //- Calculate the field min/max + //- Calculate the field residuals template void writeResidual(const word& fieldName); diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C b/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C index 4d7c0c032e..f36105eac3 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C @@ -32,10 +32,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::residuals::writeResidual -( - const word& fieldName -) +void Foam::residuals::writeResidual(const word& fieldName) { typedef GeometricField fieldType;