functionObjects::subtract: From the first field subtract the remaining fields in the list
The operation can be applied to any volume or surface fields generating a
volume or surface scalar field.
Example of function object specification:
\verbatim
Tdiff
{
type subtract;
libs ("libfieldFunctionObjects.so");
fields (T Tmean);
result Tdiff;
executeControl writeTime;
writeControl writeTime;
}
\endverbatim
This commit is contained in:
@ -61,4 +61,7 @@ writeCellVolumes/writeCellVolumes.C
|
|||||||
XiReactionRate/XiReactionRate.C
|
XiReactionRate/XiReactionRate.C
|
||||||
streamFunction/streamFunction.C
|
streamFunction/streamFunction.C
|
||||||
|
|
||||||
|
fieldsExpression/fieldsExpression.C
|
||||||
|
subtract/subtract.C
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
|
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
|
||||||
|
|||||||
@ -39,13 +39,6 @@ namespace functionObjects
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldExpression::calc()
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldExpression::setResultName
|
void Foam::functionObjects::fieldExpression::setResultName
|
||||||
(
|
(
|
||||||
const word& typeName,
|
const word& typeName,
|
||||||
|
|||||||
@ -71,7 +71,7 @@ protected:
|
|||||||
|
|
||||||
// Protected member functions
|
// Protected member functions
|
||||||
|
|
||||||
virtual bool calc();
|
virtual bool calc() = 0;
|
||||||
|
|
||||||
void setResultName(const word& typeName, const word& defaultArg);
|
void setResultName(const word& typeName, const word& defaultArg);
|
||||||
|
|
||||||
|
|||||||
149
src/functionObjects/field/fieldsExpression/fieldsExpression.C
Normal file
149
src/functionObjects/field/fieldsExpression/fieldsExpression.C
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "fieldsExpression.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(fieldsExpression, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::functionObjects::fieldsExpression::setResultName
|
||||||
|
(
|
||||||
|
const word& typeName,
|
||||||
|
const wordList& defaultArgs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (fieldNames_.empty())
|
||||||
|
{
|
||||||
|
fieldNames_ = defaultArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultName_.empty())
|
||||||
|
{
|
||||||
|
if (fieldNames_ != defaultArgs)
|
||||||
|
{
|
||||||
|
resultName_ = typeName + '(';
|
||||||
|
forAll(fieldNames_, i)
|
||||||
|
{
|
||||||
|
resultName_ += fieldNames_[i];
|
||||||
|
}
|
||||||
|
resultName_ += ')';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resultName_ = typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::fieldsExpression::fieldsExpression
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict,
|
||||||
|
const wordList& fieldNames,
|
||||||
|
const word& resultName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
|
fieldNames_(fieldNames),
|
||||||
|
resultName_(resultName)
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::fieldsExpression::~fieldsExpression()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldsExpression::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
fvMeshFunctionObject::read(dict);
|
||||||
|
|
||||||
|
if (fieldNames_.empty() || dict.found("fields"))
|
||||||
|
{
|
||||||
|
dict.lookup("fields") >> fieldNames_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dict.found("result"))
|
||||||
|
{
|
||||||
|
dict.lookup("result") >> resultName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldsExpression::execute()
|
||||||
|
{
|
||||||
|
if (!calc())
|
||||||
|
{
|
||||||
|
Warning
|
||||||
|
<< " functionObjects::" << type() << " " << name()
|
||||||
|
<< " cannot find required fields " << fieldNames_ << endl;
|
||||||
|
|
||||||
|
// Clear the result fields from the objectRegistry if present
|
||||||
|
clear();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldsExpression::write()
|
||||||
|
{
|
||||||
|
return writeObject(resultName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldsExpression::clear()
|
||||||
|
{
|
||||||
|
return clearObject(resultName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
138
src/functionObjects/field/fieldsExpression/fieldsExpression.H
Normal file
138
src/functionObjects/field/fieldsExpression/fieldsExpression.H
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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::fieldsExpression
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::functionObjects::fvMeshFunctionObject
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fieldsExpression.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_fieldsExpression_H
|
||||||
|
#define functionObjects_fieldsExpression_H
|
||||||
|
|
||||||
|
#include "fvMeshFunctionObject.H"
|
||||||
|
#include "volFieldsFwd.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fieldsExpression Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fieldsExpression
|
||||||
|
:
|
||||||
|
public fvMeshFunctionObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected member data
|
||||||
|
|
||||||
|
//- Names of fields to process
|
||||||
|
wordList fieldNames_;
|
||||||
|
|
||||||
|
//- Name of result fields
|
||||||
|
word resultName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected member functions
|
||||||
|
|
||||||
|
virtual bool calc() = 0;
|
||||||
|
|
||||||
|
void setResultName(const word& typeName, const wordList& defaultArg);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
fieldsExpression(const fieldsExpression&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const fieldsExpression&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("fieldsExpression");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary
|
||||||
|
fieldsExpression
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict,
|
||||||
|
const wordList& fieldNames = wordList::null(),
|
||||||
|
const word& resultName = word::null
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~fieldsExpression();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Read the fieldsExpression data
|
||||||
|
virtual bool read(const dictionary&);
|
||||||
|
|
||||||
|
//- Calculate the result fields
|
||||||
|
virtual bool execute();
|
||||||
|
|
||||||
|
//- Write the result fields
|
||||||
|
virtual bool write();
|
||||||
|
|
||||||
|
//- Clear the result fields from the objectRegistry
|
||||||
|
virtual bool clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
9
src/functionObjects/field/subtract/*grep*
Normal file
9
src/functionObjects/field/subtract/*grep*
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
-*- mode: grep; default-directory: "~/OpenFOAM/OpenFOAM-dev/src/functionObjects/field/subtract/" -*-
|
||||||
|
Grep started at Fri Nov 18 21:41:56
|
||||||
|
|
||||||
|
grep --color -nH -e nitude *
|
||||||
|
subtract.H:31: Calculates the subtract of a field.
|
||||||
|
subtract.H:66: //- Calculate the subtract of the field and register the result
|
||||||
|
subtract.H:70: //- Calculate the subtract of the field and return true if successful
|
||||||
|
|
||||||
|
Grep finished (matches found) at Fri Nov 18 21:41:56
|
||||||
86
src/functionObjects/field/subtract/subtract.C
Normal file
86
src/functionObjects/field/subtract/subtract.C
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "subtract.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(subtract, 0);
|
||||||
|
addToRunTimeSelectionTable(functionObject, subtract, dictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::subtract::calc()
|
||||||
|
{
|
||||||
|
bool processed = false;
|
||||||
|
|
||||||
|
processed = processed || calcSubtract<scalar>();
|
||||||
|
processed = processed || calcSubtract<vector>();
|
||||||
|
processed = processed || calcSubtract<sphericalTensor>();
|
||||||
|
processed = processed || calcSubtract<symmTensor>();
|
||||||
|
processed = processed || calcSubtract<tensor>();
|
||||||
|
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::subtract::subtract
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fieldsExpression(name, runTime, dict)
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
|
||||||
|
if (fieldNames_.size() < 2)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< type() << " requires at least 2 fields only "
|
||||||
|
<< fieldNames_.size() << " provided: " << fieldNames_
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::subtract::~subtract()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
130
src/functionObjects/field/subtract/subtract.H
Normal file
130
src/functionObjects/field/subtract/subtract.H
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::functionObjects::subtract
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
|
Description
|
||||||
|
From the first field subtract the remaining fields in the list.
|
||||||
|
|
||||||
|
The operation can be applied to any volume or surface fields generating a
|
||||||
|
volume or surface scalar field.
|
||||||
|
|
||||||
|
Example of function object specification:
|
||||||
|
\verbatim
|
||||||
|
Tdiff
|
||||||
|
{
|
||||||
|
type subtract;
|
||||||
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
fields (T Tmean);
|
||||||
|
result Tdiff;
|
||||||
|
executeControl writeTime;
|
||||||
|
writeControl writeTime;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::functionObjects::fieldsExpression
|
||||||
|
Foam::functionObjects::fvMeshFunctionObject
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
subtract.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_subtract_H
|
||||||
|
#define functionObjects_subtract_H
|
||||||
|
|
||||||
|
#include "fieldsExpression.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class subtract Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class subtract
|
||||||
|
:
|
||||||
|
public fieldsExpression
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Subtract the list of fields of the specified type
|
||||||
|
// and return the result
|
||||||
|
template<class GeoFieldType>
|
||||||
|
tmp<GeoFieldType> subtractFields() const;
|
||||||
|
|
||||||
|
//- Subtract the list of fields and register the result
|
||||||
|
template<class Type>
|
||||||
|
bool calcSubtract();
|
||||||
|
|
||||||
|
//- Subtract the list of fields and return true if successful
|
||||||
|
virtual bool calc();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("subtract");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary
|
||||||
|
subtract
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~subtract();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "subtractTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
79
src/functionObjects/field/subtract/subtractTemplates.C
Normal file
79
src/functionObjects/field/subtract/subtractTemplates.C
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "volFields.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class GeoFieldType>
|
||||||
|
Foam::tmp<GeoFieldType>
|
||||||
|
Foam::functionObjects::subtract::subtractFields() const
|
||||||
|
{
|
||||||
|
tmp<GeoFieldType> tresult
|
||||||
|
(
|
||||||
|
lookupObject<GeoFieldType>(fieldNames_[0])
|
||||||
|
- lookupObject<GeoFieldType>(fieldNames_[1])
|
||||||
|
);
|
||||||
|
|
||||||
|
for (label i=2; i<fieldNames_.size(); i++)
|
||||||
|
{
|
||||||
|
tresult = tresult - lookupObject<GeoFieldType>(fieldNames_[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tresult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool Foam::functionObjects::subtract::calcSubtract()
|
||||||
|
{
|
||||||
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
|
|
||||||
|
if (foundObject<VolFieldType>(fieldNames_[0]))
|
||||||
|
{
|
||||||
|
return store
|
||||||
|
(
|
||||||
|
resultName_,
|
||||||
|
subtractFields<VolFieldType>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (foundObject<SurfaceFieldType>(fieldNames_[0]))
|
||||||
|
{
|
||||||
|
return store
|
||||||
|
(
|
||||||
|
resultName_,
|
||||||
|
subtractFields<SurfaceFieldType>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user