From c8f6918942717d2f1690b171b8641ddea3984deb Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Nov 2012 18:38:23 +0000 Subject: [PATCH] ENH: Added new function object to calculate deltas between 2 faceSources --- .../functionObjects/field/Make/files | 2 + .../faceSourceDelta/IOfaceSourceDelta.H | 50 +++++ .../faceSourceDelta/faceSourceDelta.C | 176 +++++++++++++++++ .../faceSourceDelta/faceSourceDelta.H | 179 ++++++++++++++++++ .../faceSourceDeltaFunctionObject.C | 46 +++++ .../faceSourceDeltaFunctionObject.H | 54 ++++++ .../faceSourceDeltaTemplates.C | 66 +++++++ 7 files changed, 573 insertions(+) create mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/IOfaceSourceDelta.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaTemplates.C diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 0abf314f96..f0223c3f94 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -14,6 +14,8 @@ fieldValues/faceSource/faceSource.C fieldValues/faceSource/faceSourceFunctionObject.C fieldValues/cellSource/cellSource.C fieldValues/cellSource/cellSourceFunctionObject.C +fieldValues/faceSourceDelta/faceSourceDelta.C +fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C nearWallFields/nearWallFields.C nearWallFields/nearWallFieldsFunctionObject.C diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/IOfaceSourceDelta.H b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/IOfaceSourceDelta.H new file mode 100644 index 0000000000..3dbf93f1ca --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/IOfaceSourceDelta.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Typedef + Foam::IOfaceSourceDelta + + +Description + Instance of the generic IOOutputFilter for faceSourceDelta. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOfaceSourceDelta_H +#define IOfaceSourceDelta_H + +#include "faceSourceDelta.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOfaceSourceDelta; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.C b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.C new file mode 100644 index 0000000000..22af9e4afe --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.C @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "faceSourceDelta.H" +#include "ListOps.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::fieldValues::faceSourceDelta, 0); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fieldValues::faceSourceDelta::updateMesh(const mapPolyMesh&) +{ + // Do nothing +} + + +void Foam::fieldValues::faceSourceDelta::movePoints(const Field&) +{ + // Do nothing +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldValues::faceSourceDelta::faceSourceDelta +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + functionObjectFile(obr, name, typeName), + obr_(obr), + log_(false), + faceSource1_ + ( + name + ".faceSource1", + obr, + dict.subDict("faceSource1"), + loadFromFiles + ), + faceSource2_ + ( + name + ".faceSource2", + obr, + dict.subDict("faceSource2"), + loadFromFiles + ) +{ + read(dict); +} + + +void Foam::fieldValues::faceSourceDelta::writeFileHeader(const label i) +{ + const wordList& fields1 = faceSource1_.fields(); + const wordList& fields2 = faceSource2_.fields(); + + DynamicList commonFields(fields1.size()); + forAll(fields1, i) + { + label index = findIndex(fields2, fields1[i]); + if (index != -1) + { + commonFields.append(fields1[i]); + } + } + + file() << "# Time"; + + forAll(commonFields, i) + { + file()<< tab << commonFields[i]; + } + + file() << endl; +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldValues::faceSourceDelta::~faceSourceDelta() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fieldValues::faceSourceDelta::read(const dictionary& dict) +{ + log_ = dict.lookupOrDefault("log", false); + faceSource1_.read(dict.subDict("faceSource1")); + faceSource2_.read(dict.subDict("faceSource2")); +} + + +void Foam::fieldValues::faceSourceDelta::write() +{ + functionObjectFile::write(); + + faceSource1_.write(); + faceSource2_.write(); + + if (Pstream::master()) + { + file()<< obr_.time().timeName(); + } + + if (log_) + { + Info<< type() << " output:" << endl; + } + + bool found = false; + processFields(found); + processFields(found); + processFields(found); + processFields(found); + processFields(found); + + if (Pstream::master()) + { + file()<< endl; + } + + if (log_) + { + if (!found) + { + Info<< " none" << endl; + } + else + { + Info<< endl; + } + } +} + + +void Foam::fieldValues::faceSourceDelta::execute() +{ + // Do nothing +} + + +void Foam::fieldValues::faceSourceDelta::end() +{ + // Do nothing +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.H b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.H new file mode 100644 index 0000000000..ba97b9e5a5 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDelta.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Class + Foam::fieldValues::faceSourceDelta + +Group + grpFieldFunctionObjects + +Description + This function object provides a differencing option between two 'face + source' function objects. + + Example of function object specification: + \verbatim + faceSourceDelta1 + { + type faceSourceDelta; + functionObjectLibs ("libfieldFunctionObjects.so"); + faceSource1 + { + ... + } + faceSource2 + { + ... + } + } + \endverbatim + + \heading Function object usage + \table + Property | Description | Required | Default value + type | type name: faceSourceDelta | yes | + \endtable + +SeeAlso + Foam::faceSource + +SourceFiles + faceSourceDelta.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceSourceDelta_H +#define faceSourceDelta_H + +#include "functionObjectFile.H" +#include "faceSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +namespace fieldValues +{ + +/*---------------------------------------------------------------------------*\ + Class faceSourceDelta Declaration +\*---------------------------------------------------------------------------*/ + +class faceSourceDelta +: + public functionObjectFile +{ + +private: + + // Private data + + //- Database this class is registered to + const objectRegistry& obr_; + + //- Switch to send output to Info as well as to file + Switch log_; + + //- Face source 1 + faceSource faceSource1_; + + //- Face source 2 + faceSource faceSource2_; + + + // Private Member Functions + + //- Templated function to process common fields + template + void processFields(bool& found); + + +protected: + + // Functions to be over-ridden from IOoutputFilter class + + //- Update mesh + virtual void updateMesh(const mapPolyMesh&); + + //- Move points + virtual void movePoints(const Field&); + + //- Output file header information + virtual void writeFileHeader(const label i); + + +public: + + //- Run-time type information + TypeName("faceSourceDelta"); + + + //- Construct from components + faceSourceDelta + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~faceSourceDelta(); + + + // Public Member Functions + + // Function object functions + + //- Read from dictionary + virtual void read(const dictionary&); + + //- Calculate and write + virtual void write(); + + //- Execute + virtual void execute(); + + //- Execute the at the final time-loop, currently does nothing + virtual void end(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fieldValues +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "faceSourceDeltaTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C new file mode 100644 index 0000000000..aec39668b5 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "faceSourceDeltaFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug + ( + faceSourceDeltaFunctionObject, + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + faceSourceDeltaFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.H new file mode 100644 index 0000000000..ceca4b9938 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Typedef + Foam::faceSourceDeltaFunctionObject + +Description + FunctionObject wrapper around faceSourceDelta to allow it to be + created via the functions entry within controlDict. + +SourceFiles + faceSourceDeltaFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceSourceDeltaFunctionObject_H +#define faceSourceDeltaFunctionObject_H + +#include "faceSourceDelta.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + faceSourceDeltaFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaTemplates.C new file mode 100644 index 0000000000..1cde69473e --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSourceDelta/faceSourceDeltaTemplates.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::fieldValues::faceSourceDelta::processFields(bool& found) +{ + typedef GeometricField vf; + + const wordList& fields1 = faceSource1_.fields(); + + const dictionary& results1 = faceSource1_.resultDict(); + const dictionary& results2 = faceSource2_.resultDict(); + + Type r1(pTraits::zero); + Type r2(pTraits::zero); + + forAll(fields1, i) + { + const word& fieldName = fields1[i]; + if (obr_.foundObject(fieldName) && results2.found(fieldName)) + { + results1.lookup(fieldName) >> r1; + results2.lookup(fieldName) >> r2; + + if (log_) + { + Info<< " field: " << fieldName << ", delta: " << r2 - r1 + << endl; + } + + if (Pstream::master()) + { + file()<< tab << r2 - r1; + } + + found = true; + } + } +} + + +// ************************************************************************* //