functionObjects: New abstract base-class 'fieldExpression' for simple field expression evaluation functionObjects

Updated and simplified 'div', 'grad' and 'mag' functionObjects by deriving from 'fieldExpression'.
Corrected the handling of cached gradients in 'grad'.
This commit is contained in:
Henry Weller
2016-05-21 13:58:08 +01:00
parent 6d562d1a5c
commit 16714f3569
15 changed files with 435 additions and 429 deletions

View File

@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fieldExpression.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(fieldExpression, 0);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldExpression::fieldExpression
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::fieldExpression::~fieldExpression()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
{
dict.lookup("field") >> fieldName_;
if (dict.found("result"))
{
dict.lookup("result") >> resultName_;
}
return true;
}
bool Foam::functionObjects::fieldExpression::write(const bool postProcess)
{
return fvMeshFunctionObject::write(resultName_);
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-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 <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::fieldExpression
Group
grpFieldFunctionObjects
Description
SeeAlso
Foam::functionObjects::fvMeshFunctionObject
SourceFiles
fieldExpression.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_fieldExpression_H
#define functionObjects_fieldExpression_H
#include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class fieldExpression Declaration
\*---------------------------------------------------------------------------*/
class fieldExpression
:
public fvMeshFunctionObject
{
protected:
// Protected member data
//- Name of field to process
word fieldName_;
//- Name of result field
word resultName_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
fieldExpression(const fieldExpression&);
//- Disallow default bitwise assignment
void operator=(const fieldExpression&);
public:
//- Runtime type information
TypeName("fieldExpression");
// Constructors
//- Construct from Time and dictionary
fieldExpression
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~fieldExpression();
// Member Functions
//- Read the fieldExpression data
virtual bool read(const dictionary&);
//- Calculate the fieldExpressionergence field
virtual bool execute(const bool postProcess = false) = 0;
//- Write the fieldExpressionergence field
virtual bool write(const bool postProcess = false);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //