mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
MRG: Integrated foundation code
This commit is contained in:
@ -3,7 +3,6 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
set -x
|
||||
|
||||
wmake $targetType field
|
||||
wmake $targetType forces
|
||||
|
||||
@ -52,11 +52,11 @@ bool Foam::functionObjects::MachNo::calc()
|
||||
if
|
||||
(
|
||||
foundObject<volVectorField>(fieldName_)
|
||||
&& mesh_.foundObject<fluidThermo>(fluidThermo::dictName)
|
||||
&& foundObject<fluidThermo>(fluidThermo::dictName)
|
||||
)
|
||||
{
|
||||
const fluidThermo& thermo =
|
||||
mesh_.lookupObject<fluidThermo>(fluidThermo::dictName);
|
||||
lookupObject<fluidThermo>(fluidThermo::dictName);
|
||||
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
|
||||
|
||||
@ -51,6 +51,10 @@ blendingFactor/blendingFactor.C
|
||||
pressure/pressure.C
|
||||
MachNo/MachNo.C
|
||||
|
||||
fieldsExpression/fieldsExpression.C
|
||||
add/add.C
|
||||
subtract/subtract.C
|
||||
|
||||
turbulenceFields/turbulenceFields.C
|
||||
yPlus/yPlus.C
|
||||
wallShearStress/wallShearStress.C
|
||||
|
||||
70
src/functionObjects/field/add/add.C
Normal file
70
src/functionObjects/field/add/add.C
Normal file
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "add.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(add, 0);
|
||||
addToRunTimeSelectionTable(functionObject, add, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::add::calc()
|
||||
{
|
||||
return calcAllTypes(*this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::add::add
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldsExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName("add");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::add::~add()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
129
src/functionObjects/field/add/add.H
Normal file
129
src/functionObjects/field/add/add.H
Normal file
@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::add
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Add a list of fields.
|
||||
|
||||
The operation can be applied to any volume or surface fields generating a
|
||||
volume or surface scalar field.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
Ttot
|
||||
{
|
||||
type add;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
fields (T Tdelta);
|
||||
result Ttot;
|
||||
executeControl writeTime;
|
||||
writeControl writeTime;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldsExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
add.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_add_H
|
||||
#define functionObjects_add_H
|
||||
|
||||
#include "fieldsExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class add Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class add
|
||||
:
|
||||
public fieldsExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Add the list of fields of the specified type
|
||||
// and return the result
|
||||
template<class GeoFieldType>
|
||||
tmp<GeoFieldType> calcFieldType() const;
|
||||
|
||||
//- Add the list of fields and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
friend class fieldsExpression;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("add");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
add
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~add();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "addTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
47
src/functionObjects/field/add/addTemplates.C
Normal file
47
src/functionObjects/field/add/addTemplates.C
Normal file
@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class GeoFieldType>
|
||||
Foam::tmp<GeoFieldType>
|
||||
Foam::functionObjects::add::calcFieldType() const
|
||||
{
|
||||
tmp<GeoFieldType> tresult
|
||||
(
|
||||
lookupObject<GeoFieldType>(fieldNames_[0])
|
||||
+ lookupObject<GeoFieldType>(fieldNames_[1])
|
||||
);
|
||||
|
||||
for (label i=2; i<fieldNames_.size(); i++)
|
||||
{
|
||||
tresult.ref() += lookupObject<GeoFieldType>(fieldNames_[i]);
|
||||
}
|
||||
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -40,7 +40,7 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldAverage::resetFields()
|
||||
{
|
||||
|
||||
@ -189,7 +189,7 @@ protected:
|
||||
label periodIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
// Protected Member Functions
|
||||
|
||||
// Initialisation routines
|
||||
|
||||
|
||||
@ -213,11 +213,10 @@ void Foam::functionObjects::fieldAverage::calculateMeanFieldType
|
||||
|
||||
if (faItems_[fieldi].iterBase())
|
||||
{
|
||||
dt = 1.0;
|
||||
dt = 1;
|
||||
Dt = scalar(totalIter_[fieldi]);
|
||||
}
|
||||
|
||||
scalar alpha = (Dt - dt)/Dt;
|
||||
scalar beta = dt/Dt;
|
||||
|
||||
if (faItems_[fieldi].window() > 0)
|
||||
@ -226,12 +225,11 @@ void Foam::functionObjects::fieldAverage::calculateMeanFieldType
|
||||
|
||||
if (Dt - dt >= w)
|
||||
{
|
||||
alpha = (w - dt)/w;
|
||||
beta = dt/w;
|
||||
}
|
||||
}
|
||||
|
||||
meanField = alpha*meanField + beta*baseField;
|
||||
meanField = (1 - beta)*meanField + beta*baseField;
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,11 +275,10 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
|
||||
|
||||
if (faItems_[fieldi].iterBase())
|
||||
{
|
||||
dt = 1.0;
|
||||
dt = 1;
|
||||
Dt = scalar(totalIter_[fieldi]);
|
||||
}
|
||||
|
||||
scalar alpha = (Dt - dt)/Dt;
|
||||
scalar beta = dt/Dt;
|
||||
|
||||
if (faItems_[fieldi].window() > 0)
|
||||
@ -290,13 +287,12 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
|
||||
|
||||
if (Dt - dt >= w)
|
||||
{
|
||||
alpha = (w - dt)/w;
|
||||
beta = dt/w;
|
||||
}
|
||||
}
|
||||
|
||||
prime2MeanField =
|
||||
alpha*prime2MeanField
|
||||
(1 - beta)*prime2MeanField
|
||||
+ beta*sqr(baseField)
|
||||
- sqr(meanField);
|
||||
}
|
||||
@ -316,11 +312,7 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
|
||||
{
|
||||
if (faItems_[i].prime2Mean())
|
||||
{
|
||||
calculatePrime2MeanFieldType<VolFieldType1, VolFieldType2>
|
||||
(
|
||||
i
|
||||
);
|
||||
|
||||
calculatePrime2MeanFieldType<VolFieldType1, VolFieldType2>(i);
|
||||
calculatePrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>
|
||||
(
|
||||
i
|
||||
|
||||
@ -39,13 +39,6 @@ namespace functionObjects
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::calc()
|
||||
{
|
||||
NotImplemented;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldExpression::setResultName
|
||||
(
|
||||
const word& typeName,
|
||||
@ -122,7 +115,7 @@ bool Foam::functionObjects::fieldExpression::execute()
|
||||
{
|
||||
Warning
|
||||
<< " functionObjects::" << type() << " " << name()
|
||||
<< " cannot find required field " << fieldName_ << endl;
|
||||
<< " failed to execute." << endl;
|
||||
|
||||
// Clear the result field from the objectRegistry if present
|
||||
clear();
|
||||
|
||||
@ -72,10 +72,13 @@ protected:
|
||||
|
||||
// Protected member functions
|
||||
|
||||
virtual bool calc();
|
||||
virtual bool calc() = 0;
|
||||
|
||||
void setResultName(const word& typeName, const word& defaultArg);
|
||||
|
||||
template<class Type>
|
||||
bool foundObject(const word& name);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -134,6 +137,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldExpressionTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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"
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::fieldExpression::foundObject
|
||||
(
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
if (fvMeshFunctionObject::foundObject<Type>(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning
|
||||
<< " functionObjects::" << type() << " " << this->name()
|
||||
<< " cannot find required object " << name << " of type "
|
||||
<< Type::typeName << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -52,7 +52,7 @@ const Foam::NamedEnum
|
||||
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the value and location of scalar minimim and maximum for a list
|
||||
Calculates the value and location of scalar minimum and maximum for a list
|
||||
of user-specified fields.
|
||||
|
||||
For variables with a rank greater than zero, either the min/max of a
|
||||
@ -127,7 +127,7 @@ protected:
|
||||
wordList fieldSet_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
// Protected Member Functions
|
||||
|
||||
//- Helper function to write the output
|
||||
template<class Type>
|
||||
|
||||
@ -97,7 +97,7 @@ const Foam::NamedEnum
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
||||
{
|
||||
|
||||
158
src/functionObjects/field/fieldsExpression/fieldsExpression.C
Normal file
158
src/functionObjects/field/fieldsExpression/fieldsExpression.C
Normal file
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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_.empty())
|
||||
{
|
||||
resultName_ = typeName + '(' + fieldNames_[0];
|
||||
for (label i=1; i<fieldNames_.size(); 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);
|
||||
|
||||
if (fieldNames_.size() < 2)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "functionObject::" << type() << " " << name
|
||||
<< " requires at least 2 fields only "
|
||||
<< fieldNames_.size() << " provided: " << fieldNames_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * 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_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
162
src/functionObjects/field/fieldsExpression/fieldsExpression.H
Normal file
162
src/functionObjects/field/fieldsExpression/fieldsExpression.H
Normal file
@ -0,0 +1,162 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
void setResultName
|
||||
(
|
||||
const word& typeName,
|
||||
const wordList& defaultArg = wordList::null()
|
||||
);
|
||||
|
||||
//- Call 'calcFieldType' for the given functionObject
|
||||
// for 'volField' and 'surfaceField' field types
|
||||
template<class Type, class FOType>
|
||||
bool calcFieldTypes(FOType& fo);
|
||||
|
||||
//- Call 'calcFieldTypes' for the given 'Type' and functionObject
|
||||
template<class Type, class FOType>
|
||||
bool calcType(FOType& fo);
|
||||
|
||||
//- Call 'calcType' for the given functionObject
|
||||
// for each primitive type
|
||||
template<class FOType>
|
||||
bool calcAllTypes(FOType& fo);
|
||||
|
||||
virtual bool calc() = 0;
|
||||
|
||||
|
||||
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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldsExpressionTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,82 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type, class FOType>
|
||||
bool Foam::functionObjects::fieldsExpression::calcFieldTypes(FOType& fo)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldNames_[0]))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fo.template calcFieldType<VolFieldType>()
|
||||
);
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldNames_[0]))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fo.template calcFieldType<SurfaceFieldType>()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class FOType>
|
||||
bool Foam::functionObjects::fieldsExpression::calcType(FOType& fo)
|
||||
{
|
||||
return calcFieldTypes<Type>(fo);
|
||||
}
|
||||
|
||||
|
||||
template<class FOType>
|
||||
bool Foam::functionObjects::fieldsExpression::calcAllTypes(FOType& fo)
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || fo.template calcType<scalar>(fo);
|
||||
processed = processed || fo.template calcType<vector>(fo);
|
||||
processed = processed || fo.template calcType<sphericalTensor>(fo);
|
||||
processed = processed || fo.template calcType<symmTensor>(fo);
|
||||
processed = processed || fo.template calcType<tensor>(fo);
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -39,7 +39,7 @@ bool Foam::functionObjects::grad::calcGrad()
|
||||
(
|
||||
resultName_,
|
||||
fvc::grad(lookupObject<VolFieldType>(fieldName_)),
|
||||
true
|
||||
mesh_.changing() && mesh_.cache(resultName_)
|
||||
);
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
@ -48,7 +48,7 @@ bool Foam::functionObjects::grad::calcGrad()
|
||||
(
|
||||
resultName_,
|
||||
fvc::grad(lookupObject<SurfaceFieldType>(fieldName_)),
|
||||
true
|
||||
mesh_.changing() && mesh_.cache(resultName_)
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -42,7 +42,7 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
{
|
||||
|
||||
70
src/functionObjects/field/subtract/subtract.C
Normal file
70
src/functionObjects/field/subtract/subtract.C
Normal file
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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()
|
||||
{
|
||||
return calcAllTypes(*this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::subtract::subtract
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldsExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName("subtract");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::subtract::~subtract()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
129
src/functionObjects/field/subtract/subtract.H
Normal file
129
src/functionObjects/field/subtract/subtract.H
Normal file
@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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> calcFieldType() const;
|
||||
|
||||
//- Subtract the list of fields and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
friend class fieldsExpression;
|
||||
|
||||
|
||||
//- 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
|
||||
|
||||
// ************************************************************************* //
|
||||
47
src/functionObjects/field/subtract/subtractTemplates.C
Normal file
47
src/functionObjects/field/subtract/subtractTemplates.C
Normal file
@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class GeoFieldType>
|
||||
Foam::tmp<GeoFieldType>
|
||||
Foam::functionObjects::subtract::calcFieldType() const
|
||||
{
|
||||
tmp<GeoFieldType> tresult
|
||||
(
|
||||
lookupObject<GeoFieldType>(fieldNames_[0])
|
||||
- lookupObject<GeoFieldType>(fieldNames_[1])
|
||||
);
|
||||
|
||||
for (label i=2; i<fieldNames_.size(); i++)
|
||||
{
|
||||
tresult.ref() -= lookupObject<GeoFieldType>(fieldNames_[i]);
|
||||
}
|
||||
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -33,7 +33,7 @@ const std::size_t Foam::wallBoundedParticle::sizeofFields_
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::edge Foam::wallBoundedParticle::currentEdge() const
|
||||
{
|
||||
|
||||
@ -50,7 +50,7 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::codedFunctionObject::prepare
|
||||
(
|
||||
|
||||
@ -56,12 +56,11 @@ Usage
|
||||
// Lookup U
|
||||
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
|
||||
// Write
|
||||
mag(U).write();
|
||||
}
|
||||
mag(U)().write();
|
||||
#};"
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::codedBase
|
||||
|
||||
@ -65,7 +65,9 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile()
|
||||
Log << nl << type() << ": copying file" << nl << timeVsFile_[i].second()
|
||||
<< nl << "to:" << nl << fileToUpdate_ << nl << endl;
|
||||
|
||||
cp(timeVsFile_[i].second(), fileToUpdate_);
|
||||
fileName destFile(fileToUpdate_ + Foam::name(pid()));
|
||||
cp(timeVsFile_[i].second(), destFile);
|
||||
mv(destFile, fileToUpdate_);
|
||||
lastIndex_ = i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user