diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index c1497c5e5484b0fa8ac62e29f7afdbdd0fbe4e05..9d465d2663337a86c4472089e6cd2ad239373e38 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -3,6 +3,9 @@ fieldAverage/fieldAverageItem/fieldAverageItem.C fieldAverage/fieldAverageItem/fieldAverageItemIO.C fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C +fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C + fieldMinMax/fieldMinMax.C fieldMinMax/fieldMinMaxFunctionObject.C diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H new file mode 100644 index 0000000000000000000000000000000000000000..36216f399bf18258482528045045a7a11f340afb --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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/>. + +Typedef + Foam::IOfieldCoordinateSystemTransform + +Description + Instance of the generic IOOutputFilter for fieldCoordinateSystemTransform. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOfieldCoordinateSystemTransform_H +#define IOfieldCoordinateSystemTransform_H + +#include "fieldCoordinateSystemTransform.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<fieldCoordinateSystemTransform> + IOfieldCoordinateSystemTransform; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C new file mode 100644 index 0000000000000000000000000000000000000000..afb592bc78dab27c912d39f5fdab4a760b072e87 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "fieldCoordinateSystemTransform.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::fieldCoordinateSystemTransform, 0); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + fieldSet_(), + coordSys_(dict, obr) +{ + // Check if the available mesh is an fvMesh otherise deactivate + if (!isA<fvMesh>(obr_)) + { + active_ = false; + WarningIn + ( + "fieldCoordinateSystemTransform::fieldCoordinateSystemTransform" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." + << endl; + } + + read(dict); + + Info<< type() << ":" << nl + << " Applying transformation from global Cartesian to local " + << coordSys_ << nl << endl; +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldCoordinateSystemTransform::~fieldCoordinateSystemTransform() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fieldCoordinateSystemTransform::read(const dictionary& dict) +{ + if (active_) + { + dict.lookup("fields") >> fieldSet_; + } +} + + +void Foam::fieldCoordinateSystemTransform::execute() +{ + // Do nothing +} + + +void Foam::fieldCoordinateSystemTransform::end() +{ + // Do nothing +} + + +void Foam::fieldCoordinateSystemTransform::write() +{ + forAll(fieldSet_, fieldI) + { + // If necessary load field + transform<scalar>(fieldSet_[fieldI]); + transform<vector>(fieldSet_[fieldI]); + transform<sphericalTensor>(fieldSet_[fieldI]); + transform<symmTensor>(fieldSet_[fieldI]); + transform<tensor>(fieldSet_[fieldI]); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H new file mode 100644 index 0000000000000000000000000000000000000000..138d2d09d5fbe65cc6b424de9aa5337b441ff6df --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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::fieldCoordinateSystemTransform + +Description + Transforms fields from global cartesian co-ordinates to local co-ordinate + system + +SourceFiles + fieldCoordinateSystemTransform.C + IOfieldCoordinateSystemTransform.H + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldCoordinateSystemTransform_H +#define fieldCoordinateSystemTransform_H + +#include "OFstream.H" +#include "pointFieldFwd.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "coordinateSystem.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class fieldCoordinateSystemTransform Declaration +\*---------------------------------------------------------------------------*/ + +class fieldCoordinateSystemTransform +{ +protected: + + // Protected data + + //- Name + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Fields to transform + wordList fieldSet_; + + //- Co-ordinate system to transform to + coordinateSystem coordSys_; + + + // Protected Member Functions + + //- Disallow default bitwise copy construct + fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform&); + + //- Disallow default bitwise assignment + void operator=(const fieldCoordinateSystemTransform&); + + template<class Type> + void transform(const word& fieldName) const; + + template<class Type> + void transformField(const Type& field) const; + + +public: + + //- Runtime type information + TypeName("fieldCoordinateSystemTransform"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + fieldCoordinateSystemTransform + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~fieldCoordinateSystemTransform(); + + + // Member Functions + + //- Return name of the fieldCoordinateSystemTransform object + virtual const word& name() const + { + return name_; + } + + //- Read the input data + virtual void read(const dictionary&); + + //- Execute, currently does nothing + virtual void execute(); + + //- Execute at the final time-loop, currently does nothing + virtual void end(); + + //- Write + virtual void write(); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const pointField&) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fieldCoordinateSystemTransformTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C new file mode 100644 index 0000000000000000000000000000000000000000..be3f5624b474da841e9ddb374c0aed611ecf4a16 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "fieldCoordinateSystemTransformFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug + ( + fieldCoordinateSystemTransformFunctionObject, 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + fieldCoordinateSystemTransformFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H new file mode 100644 index 0000000000000000000000000000000000000000..20cf0fccbf9b73b590cfe41b5d61af920162c6ab --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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/>. + +Typedef + Foam::fieldCoordinateSystemTransformFunctionObject + +Description + FunctionObject wrapper around fieldCoordinateSystemTransform to allow + them to be created via the functions entry within controlDict. + +SourceFiles + fieldCoordinateSystemTransformFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldCoordinateSystemTransformFunctionObject_H +#define fieldCoordinateSystemTransformFunctionObject_H + +#include "fieldCoordinateSystemTransform.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<fieldCoordinateSystemTransform> + fieldCoordinateSystemTransformFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..c1ecc72707bce985a0705929006be29edaf1a993 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "fieldCoordinateSystemTransform.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "Time.H" +#include "transformGeometricField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> +void Foam::fieldCoordinateSystemTransform::transformField +( + const Type& field +) const +{ + const word& fieldName = field.name() + "Transformed"; + + dimensionedTensor R("R", field.dimensions(), coordSys_.R()); + + if (obr_.foundObject<Type>(fieldName)) + { + Type& transField = + const_cast<Type&>(obr_.lookupObject<Type>(fieldName)); + + transField == field; + + forAll(field, i) + { + Foam::transform(transField, R, transField); + } + + transField.write(); + } + else + { + Type& transField = obr_.store + ( + new Type + ( + IOobject + ( + fieldName, + obr_.time().timeName(), + obr_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + field + ) + ); + + forAll(field, i) + { + Foam::transform(transField, R, transField); + } + + transField.write(); + } +} + + +template<class Type> +void Foam::fieldCoordinateSystemTransform::transform +( + const word& fieldName +) const +{ + typedef GeometricField<Type, fvPatchField, volMesh> vfType; + typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType; + + if (obr_.foundObject<vfType>(fieldName)) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " already in database" + << endl; + } + + transformField<vfType>(obr_.lookupObject<vfType>(fieldName)); + } + else if (obr_.foundObject<sfType>(fieldName)) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " already in database" + << endl; + } + + transformField<sfType>(obr_.lookupObject<sfType>(fieldName)); + } + else + { + IOobject fieldHeader + ( + fieldName, + obr_.time().timeName(), + obr_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if + ( + fieldHeader.headerOk() + && fieldHeader.headerClassName() == vfType::typeName + ) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " read from file" + << endl; + } + + transformField<vfType>(obr_.lookupObject<vfType>(fieldName)); + } + else if + ( + fieldHeader.headerOk() + && fieldHeader.headerClassName() == sfType::typeName + ) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " read from file" + << endl; + } + + transformField<sfType>(obr_.lookupObject<sfType>(fieldName)); + } + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict new file mode 100644 index 0000000000000000000000000000000000000000..e0d17f6271ab7d9e767ffe454713e2c917eaae7e --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object postProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +functions +{ + fieldCoordinateSystemTransform1 + { + // Type of functionObject + type fieldCoordinateSystemTransform; + + // Where to load it from (if not already in solver) + functionObjectLibs ("libfieldCoordinateSystemTransform.so"); + + // Function object enabled flag + enabled true; + + // When to output the average fields + outputControl outputTime; + + // Fields to be transformed - runTime modifiable + fields + ( + U + UMean + UPrime2Mean + ); + + coordinateSystem + { + origin (0.001 0 0); + e1 (1 0.15 0); + e3 (0 0 -1); + } + } +} + +// ************************************************************************* //