diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 934c931ac8..ad3b96e6e4 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -33,9 +33,11 @@ regionSizeDistribution/regionSizeDistribution.C histogram/histogram.C fieldExpression/fieldExpression.C +components/components.C div/div.C grad/grad.C mag/mag.C +magSqr/magSqr.C vorticity/vorticity.C enstrophy/enstrophy.C Q/Q.C diff --git a/src/postProcessing/functionObjects/field/components/components.C b/src/postProcessing/functionObjects/field/components/components.C new file mode 100644 index 0000000000..3f31aeb510 --- /dev/null +++ b/src/postProcessing/functionObjects/field/components/components.C @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "components.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(components, 0); + addToRunTimeSelectionTable(functionObject, components, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::components::calc() +{ + bool processed = false; + + processed = processed || calcComponents(); + processed = processed || calcComponents(); + processed = processed || calcComponents(); + processed = processed || calcComponents(); + + return processed; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::components::components +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::components::~components() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::components::write(const bool postProcess) +{ + bool written = true; + + forAll(resultNames_, i) + { + written = written && writeObject(resultNames_[i]); + } + + return written; +} + + +bool Foam::functionObjects::components::clear() +{ + bool cleared = true; + + forAll(resultNames_, i) + { + cleared = cleared && clearObject(resultNames_[i]); + } + + return cleared; +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/components/components.H b/src/postProcessing/functionObjects/field/components/components.H new file mode 100644 index 0000000000..ebebd8d57c --- /dev/null +++ b/src/postProcessing/functionObjects/field/components/components.H @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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::functionObjects::components + +Group + grpFieldFunctionObjects + +Description + This function object calculates the components of a field. + + The operation can be applied to any volume or surface fields generating a + volume or surface scalar fields for each component. + +SeeAlso + Foam::functionObjects::fvMeshFunctionObject + +SourceFiles + components.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_components_H +#define functionObjects_components_H + +#include "fieldExpression.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class components Declaration +\*---------------------------------------------------------------------------*/ + +class components +: + public fieldExpression +{ + // Private member data + + //- List of the component field names + wordList resultNames_; + + + // Private Member Functions + + //- Calculate the components of the field with the specified type + // and register the result + template + bool calcFieldComponents(); + + //- Calculate the components of the field with the specified + // element type and register the result + template + bool calcComponents(); + + //- Calculate the components of the field and return true if successful + virtual bool calc(); + + +public: + + //- Runtime type information + TypeName("components"); + + + // Constructors + + //- Construct from Time and dictionary + components + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~components(); + + + // Member Functions + + //- Write the component fields + virtual bool write(const bool postProcess = false); + + //- Clear the component fields from the objectRegistry + virtual bool clear(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "componentsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/components/componentsTemplates.C b/src/postProcessing/functionObjects/field/components/componentsTemplates.C new file mode 100644 index 0000000000..7d56c3c41b --- /dev/null +++ b/src/postProcessing/functionObjects/field/components/componentsTemplates.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::functionObjects::components::calcFieldComponents() +{ + typedef typename GeoFieldType::value_type Type; + + const GeoFieldType& field(lookupObject(fieldName_)); + + resultNames_.setSize(Type::nComponents); + + bool stored = true; + + for (direction i=0; i +bool Foam::functionObjects::components::calcComponents() +{ + typedef GeometricField VolFieldType; + typedef GeometricField SurfaceFieldType; + + if (foundObject(fieldName_)) + { + return calcFieldComponents(); + } + else if (foundObject(fieldName_)) + { + return calcFieldComponents(); + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/magSqr/magSqr.C b/src/postProcessing/functionObjects/field/magSqr/magSqr.C new file mode 100644 index 0000000000..7f45431e82 --- /dev/null +++ b/src/postProcessing/functionObjects/field/magSqr/magSqr.C @@ -0,0 +1,78 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "magSqr.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(magSqr, 0); + addToRunTimeSelectionTable(functionObject, magSqr, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::magSqr::calc() +{ + bool processed = false; + + processed = processed || calcMagSqr(); + processed = processed || calcMagSqr(); + processed = processed || calcMagSqr(); + processed = processed || calcMagSqr(); + processed = processed || calcMagSqr(); + + return processed; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::magSqr::magSqr +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::magSqr::~magSqr() +{} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/magSqr/magSqr.H b/src/postProcessing/functionObjects/field/magSqr/magSqr.H new file mode 100644 index 0000000000..394700861a --- /dev/null +++ b/src/postProcessing/functionObjects/field/magSqr/magSqr.H @@ -0,0 +1,113 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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::functionObjects::magSqr + +Group + grpFieldFunctionObjects + +Description + This function object calculates the magnitude of the sqr of a field. + + The operation can be applied to any volume or surface field generating a + volume or surface scalar field. + +SeeAlso + Foam::functionObjects::fvMeshFunctionObject + +SourceFiles + magSqr.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_magSqr_H +#define functionObjects_magSqr_H + +#include "fieldExpression.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class magSqr Declaration +\*---------------------------------------------------------------------------*/ + +class magSqr +: + public fieldExpression +{ + // Private Member Functions + + //- Calculate the magnitude of the sqr of the field + // and register the result + template + bool calcMagSqr(); + + //- Calculate the magnitude of the sqr of the field + // and return true if successful + virtual bool calc(); + + +public: + + //- Runtime type information + TypeName("magSqr"); + + + // Constructors + + //- Construct from Time and dictionary + magSqr + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~magSqr(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "magSqrTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/magSqr/magSqrTemplates.C b/src/postProcessing/functionObjects/field/magSqr/magSqrTemplates.C new file mode 100644 index 0000000000..a5b1011c39 --- /dev/null +++ b/src/postProcessing/functionObjects/field/magSqr/magSqrTemplates.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::functionObjects::magSqr::calcMagSqr() +{ + typedef GeometricField VolFieldType; + typedef GeometricField SurfaceFieldType; + + if (foundObject(fieldName_)) + { + return store + ( + resultName_, + Foam::magSqr(lookupObject(fieldName_)) + ); + } + else if (foundObject(fieldName_)) + { + return store + ( + resultName_, + Foam::magSqr(lookupObject(fieldName_)) + ); + } + else + { + return false; + } +} + + +// ************************************************************************* //