mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
GIT: Resolved conflict
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
|
||||
|
||||
@ -157,7 +157,7 @@ Foam::functionObjects::PecletNo::~PecletNo()
|
||||
|
||||
bool Foam::functionObjects::PecletNo::read(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("rho", rhoName_);
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -117,8 +117,13 @@ bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
|
||||
writeFile::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
dict.readIfPresent("tolerance", tolerance_);
|
||||
if ((tolerance_ < 0) || (tolerance_ > 1))
|
||||
|
||||
tolerance_ = 0.001;
|
||||
if
|
||||
(
|
||||
dict.readIfPresent("tolerance", tolerance_)
|
||||
&& (tolerance_ < 0 || tolerance_ > 1)
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "tolerance must be in the range 0 to 1. Supplied value: "
|
||||
|
||||
@ -112,7 +112,6 @@ Foam::functionObjects::ddt2::ddt2
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
prevTimeIndex_(-1),
|
||||
selectFields_(),
|
||||
resultName_(word::null),
|
||||
blacklist_(),
|
||||
@ -218,20 +217,12 @@ bool Foam::functionObjects::ddt2::execute()
|
||||
<< "Unprocessed field " << ignored << endl;
|
||||
}
|
||||
|
||||
// Update time index
|
||||
prevTimeIndex_ = obr_.time().timeIndex();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::ddt2::write()
|
||||
{
|
||||
if (prevTimeIndex_ < obr_.time().timeIndex())
|
||||
{
|
||||
// Ensure written results reflect the current state
|
||||
execute();
|
||||
}
|
||||
if (results_.size())
|
||||
{
|
||||
Log << type() << ' ' << name() << " write:" << endl;
|
||||
|
||||
@ -101,9 +101,6 @@ class ddt2
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Time at last execute, ensures write uses up-to-date values
|
||||
label prevTimeIndex_;
|
||||
|
||||
//- Name of fields to process
|
||||
wordReList selectFields_;
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldAverage::resetFields()
|
||||
{
|
||||
@ -302,17 +302,39 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
dict.readIfPresent("periodicRestart", periodicRestart_);
|
||||
dict.lookup("fields") >> faItems_;
|
||||
|
||||
const scalar currentTime = obr().time().value();
|
||||
|
||||
if (periodicRestart_)
|
||||
{
|
||||
dict.lookup("restartPeriod") >> restartPeriod_;
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
<< nl << endl;
|
||||
|
||||
if (restartPeriod_ > 0)
|
||||
{
|
||||
// Determine the appropriate interval for the next restart
|
||||
periodIndex_ = 1;
|
||||
while (currentTime > restartPeriod_*periodIndex_)
|
||||
{
|
||||
++periodIndex_;
|
||||
}
|
||||
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
<< " - next restart at " << (restartPeriod_*periodIndex_)
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
periodicRestart_ = false;
|
||||
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
<< " - ignored"
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
restartTime_ = GREAT;
|
||||
if (dict.readIfPresent("restartTime", restartTime_))
|
||||
{
|
||||
if (restartTime_ < obr_.time().value())
|
||||
if (currentTime > restartTime_)
|
||||
{
|
||||
// The restart time is already in the past - ignore
|
||||
restartTime_ = GREAT;
|
||||
|
||||
@ -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 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
|
||||
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("writeFields") >> writeFields_;
|
||||
dict.readIfPresent("scaleFactor", scaleFactor_);
|
||||
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Optional scale value
|
||||
//- Optional scaling factor
|
||||
scalar scaleFactor_;
|
||||
|
||||
//- Construction dictionary
|
||||
|
||||
@ -64,7 +64,7 @@ template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
|
||||
15
|
||||
16
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
@ -77,6 +77,7 @@ const char* Foam::NamedEnum
|
||||
"areaAverage",
|
||||
"weightedAreaAverage",
|
||||
"areaIntegrate",
|
||||
"weightedAreaIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
"CoV",
|
||||
@ -93,11 +94,11 @@ const Foam::NamedEnum
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
|
||||
15
|
||||
16
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
||||
{
|
||||
|
||||
@ -109,14 +109,15 @@ Usage
|
||||
sumDirectionBalance | sum of balance of values in given direction
|
||||
average | ensemble average
|
||||
weightedAverage | weighted average
|
||||
areaAverage | area weighted average
|
||||
areaAverage | area-weighted average
|
||||
weightedAreaAverage | weighted area average
|
||||
areaIntegrate | area integral
|
||||
weightedAreaIntegrate | weighted area integral
|
||||
min | minimum
|
||||
max | maximum
|
||||
CoV | coefficient of variation: standard deviation/mean
|
||||
areaNormalAverage| area weighted average in face normal direction
|
||||
areaNormalIntegrate | area weighted integral in face normal directon
|
||||
areaNormalAverage| area-weighted average in face normal direction
|
||||
areaNormalIntegrate | area-weighted integral in face normal directon
|
||||
\endplaintable
|
||||
|
||||
Note
|
||||
@ -210,6 +211,7 @@ public:
|
||||
opAreaAverage, //!< Area average
|
||||
opWeightedAreaAverage, //!< Weighted area average
|
||||
opAreaIntegrate, //!< Area integral
|
||||
opWeightedAreaIntegrate, //!< Weighted area integral
|
||||
opMin, //!< Minimum
|
||||
opMax, //!< Maximum
|
||||
opCoV, //!< Coefficient of variation
|
||||
@ -218,7 +220,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 15> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 16> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -176,10 +176,9 @@ processSameTypeValues
|
||||
}
|
||||
case opWeightedAverage:
|
||||
{
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (wSize > 0)
|
||||
if (returnReduce(weightField.size(), sumOp<label>()))
|
||||
{
|
||||
// has weights
|
||||
result =
|
||||
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
|
||||
}
|
||||
@ -192,31 +191,40 @@ processSameTypeValues
|
||||
}
|
||||
case opAreaAverage:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
const scalarField factor(mag(Sf));
|
||||
|
||||
result = gSum(magSf*values)/gSum(magSf);
|
||||
result = gSum(factor*values)/gSum(factor);
|
||||
break;
|
||||
}
|
||||
case opWeightedAreaAverage:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
const scalarField factor
|
||||
(
|
||||
returnReduce(weightField.size(), sumOp<label>()) // has weights
|
||||
? weightField*mag(Sf)
|
||||
: mag(Sf)
|
||||
);
|
||||
|
||||
if (wSize > 0)
|
||||
{
|
||||
result = gSum(weightField*magSf*values)/gSum(magSf*weightField);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = gSum(magSf*values)/gSum(magSf);
|
||||
}
|
||||
result = gSum(factor*values)/gSum(factor);
|
||||
break;
|
||||
}
|
||||
case opAreaIntegrate:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
const scalarField factor(mag(Sf));
|
||||
|
||||
result = gSum(magSf*values);
|
||||
result = gSum(factor*values);
|
||||
break;
|
||||
}
|
||||
case opWeightedAreaIntegrate:
|
||||
{
|
||||
const scalarField factor
|
||||
(
|
||||
returnReduce(weightField.size(), sumOp<label>()) // has weights
|
||||
? weightField*mag(Sf)
|
||||
: mag(Sf)
|
||||
);
|
||||
|
||||
result = gSum(factor*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -79,21 +79,19 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
|
||||
DynamicList<List<scalar>>& faceSign
|
||||
) const
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
label zonei = mesh.faceZones().findZoneID(faceZoneName);
|
||||
label zonei = mesh_.faceZones().findZoneID(faceZoneName);
|
||||
|
||||
if (zonei == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find faceZone " << faceZoneName
|
||||
<< ". Valid faceZones are: " << mesh.faceZones().names()
|
||||
<< ". Valid faceZones are: " << mesh_.faceZones().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
faceZoneNames.append(faceZoneName);
|
||||
|
||||
const faceZone& fZone = mesh.faceZones()[zonei];
|
||||
const faceZone& fZone = mesh_.faceZones()[zonei];
|
||||
|
||||
DynamicList<label> faceIDs(fZone.size());
|
||||
DynamicList<label> facePatchIDs(fZone.size());
|
||||
@ -105,15 +103,15 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
|
||||
|
||||
label faceID = -1;
|
||||
label facePatchID = -1;
|
||||
if (mesh.isInternalFace(facei))
|
||||
if (mesh_.isInternalFace(facei))
|
||||
{
|
||||
faceID = facei;
|
||||
facePatchID = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
facePatchID = mesh.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh.boundaryMesh()[facePatchID];
|
||||
facePatchID = mesh_.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
|
||||
if (isA<coupledPolyPatch>(pp))
|
||||
{
|
||||
if (refCast<const coupledPolyPatch>(pp).owner())
|
||||
@ -170,31 +168,29 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
|
||||
DynamicList<List<scalar>>& faceSign
|
||||
) const
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
vector refDir = dir/(mag(dir) + ROOTVSMALL);
|
||||
|
||||
label zonei = mesh.faceZones().findZoneID(faceZoneName);
|
||||
label zonei = mesh_.faceZones().findZoneID(faceZoneName);
|
||||
|
||||
if (zonei == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find faceZone " << faceZoneName
|
||||
<< ". Valid faceZones are: " << mesh.faceZones().names()
|
||||
<< ". Valid faceZones are: " << mesh_.faceZones().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
faceZoneNames.append(faceZoneName);
|
||||
zoneRefDir.append(refDir);
|
||||
|
||||
const faceZone& fZone = mesh.faceZones()[zonei];
|
||||
const faceZone& fZone = mesh_.faceZones()[zonei];
|
||||
|
||||
DynamicList<label> faceIDs(fZone.size());
|
||||
DynamicList<label> facePatchIDs(fZone.size());
|
||||
DynamicList<scalar> faceSigns(fZone.size());
|
||||
|
||||
const surfaceVectorField& Sf = mesh.Sf();
|
||||
const surfaceScalarField& magSf = mesh.magSf();
|
||||
const surfaceVectorField& Sf = mesh_.Sf();
|
||||
const surfaceScalarField& magSf = mesh_.magSf();
|
||||
|
||||
vector n(Zero);
|
||||
|
||||
@ -204,15 +200,15 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
|
||||
|
||||
label faceID = -1;
|
||||
label facePatchID = -1;
|
||||
if (mesh.isInternalFace(facei))
|
||||
if (mesh_.isInternalFace(facei))
|
||||
{
|
||||
faceID = facei;
|
||||
facePatchID = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
facePatchID = mesh.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh.boundaryMesh()[facePatchID];
|
||||
facePatchID = mesh_.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
|
||||
if (isA<coupledPolyPatch>(pp))
|
||||
{
|
||||
if (refCast<const coupledPolyPatch>(pp).owner())
|
||||
@ -279,27 +275,25 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
DynamicList<List<scalar>>& faceSign
|
||||
) const
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
vector refDir = dir/(mag(dir) + ROOTVSMALL);
|
||||
|
||||
const label cellZonei = mesh.cellZones().findZoneID(cellZoneName);
|
||||
const label cellZonei = mesh_.cellZones().findZoneID(cellZoneName);
|
||||
|
||||
if (cellZonei == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find cellZone " << cellZoneName
|
||||
<< ". Valid zones are: " << mesh.cellZones().names()
|
||||
<< ". Valid zones are: " << mesh_.cellZones().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const label nInternalFaces = mesh.nInternalFaces();
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
const label nInternalFaces = mesh_.nInternalFaces();
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
labelList cellAddr(mesh.nCells(), -1);
|
||||
const labelList& cellIDs = mesh.cellZones()[cellZonei];
|
||||
labelList cellAddr(mesh_.nCells(), -1);
|
||||
const labelList& cellIDs = mesh_.cellZones()[cellZonei];
|
||||
UIndirectList<label>(cellAddr, cellIDs) = identity(cellIDs.size());
|
||||
labelList nbrFaceCellAddr(mesh.nFaces() - nInternalFaces, -1);
|
||||
labelList nbrFaceCellAddr(mesh_.nFaces() - nInternalFaces, -1);
|
||||
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
@ -311,17 +305,17 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
{
|
||||
label facei = pp.start() + i;
|
||||
label nbrFacei = facei - nInternalFaces;
|
||||
label own = mesh.faceOwner()[facei];
|
||||
label own = mesh_.faceOwner()[facei];
|
||||
nbrFaceCellAddr[nbrFacei] = cellAddr[own];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Correct boundary values for parallel running
|
||||
syncTools::swapBoundaryFaceList(mesh, nbrFaceCellAddr);
|
||||
syncTools::swapBoundaryFaceList(mesh_, nbrFaceCellAddr);
|
||||
|
||||
// Collect faces
|
||||
DynamicList<label> faceIDs(floor(0.1*mesh.nFaces()));
|
||||
DynamicList<label> faceIDs(floor(0.1*mesh_.nFaces()));
|
||||
DynamicList<label> facePatchIDs(faceIDs.size());
|
||||
DynamicList<label> faceLocalPatchIDs(faceIDs.size());
|
||||
DynamicList<scalar> faceSigns(faceIDs.size());
|
||||
@ -329,12 +323,12 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
// Internal faces
|
||||
for (label facei = 0; facei < nInternalFaces; facei++)
|
||||
{
|
||||
const label own = cellAddr[mesh.faceOwner()[facei]];
|
||||
const label nbr = cellAddr[mesh.faceNeighbour()[facei]];
|
||||
const label own = cellAddr[mesh_.faceOwner()[facei]];
|
||||
const label nbr = cellAddr[mesh_.faceNeighbour()[facei]];
|
||||
|
||||
if (((own != -1) && (nbr == -1)) || ((own == -1) && (nbr != -1)))
|
||||
{
|
||||
vector n = mesh.faces()[facei].normal(mesh.points());
|
||||
vector n = mesh_.faces()[facei].normal(mesh_.points());
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
|
||||
if ((n & refDir) > tolerance_)
|
||||
@ -362,12 +356,12 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
forAll(pp, localFacei)
|
||||
{
|
||||
const label facei = pp.start() + localFacei;
|
||||
const label own = cellAddr[mesh.faceOwner()[facei]];
|
||||
const label own = cellAddr[mesh_.faceOwner()[facei]];
|
||||
const label nbr = nbrFaceCellAddr[facei - nInternalFaces];
|
||||
|
||||
if ((own != -1) && (nbr == -1))
|
||||
{
|
||||
vector n = mesh.faces()[facei].normal(mesh.points());
|
||||
vector n = mesh_.faces()[facei].normal(mesh_.points());
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
|
||||
if ((n & refDir) > tolerance_)
|
||||
@ -391,15 +385,15 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
// Convert into primitivePatch for convenience
|
||||
indirectPrimitivePatch patch
|
||||
(
|
||||
IndirectList<face>(mesh.faces(), faceIDs),
|
||||
mesh.points()
|
||||
IndirectList<face>(mesh_.faces(), faceIDs),
|
||||
mesh_.points()
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
OBJstream os(mesh.time().path()/"patch.obj");
|
||||
OBJstream os(mesh_.time().path()/"patch.obj");
|
||||
faceList faces(patch);
|
||||
os.write(faces, mesh.points(), false);
|
||||
os.write(faces, mesh_.points(), false);
|
||||
}
|
||||
|
||||
|
||||
@ -467,7 +461,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
patchEdgeFaceRegion
|
||||
> calc
|
||||
(
|
||||
mesh,
|
||||
mesh_,
|
||||
patch,
|
||||
changedEdges,
|
||||
changedInfo,
|
||||
@ -524,9 +518,9 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
// Write OBj of faces to file
|
||||
if (debug)
|
||||
{
|
||||
OBJstream os(mesh.time().path()/zoneName + ".obj");
|
||||
faceList faces(mesh.faces(), regionFaceIDs[regioni]);
|
||||
os.write(faces, mesh.points(), false);
|
||||
OBJstream os(mesh_.time().path()/zoneName + ".obj");
|
||||
faceList faces(mesh_.faces(), regionFaceIDs[regioni]);
|
||||
os.write(faces, mesh_.points(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,8 +546,7 @@ void Foam::functionObjects::fluxSummary::initialiseFaceArea()
|
||||
{
|
||||
faceArea_.setSize(faceID_.size(), 0);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
const surfaceScalarField& magSf = mesh.magSf();
|
||||
const surfaceScalarField& magSf = mesh_.magSf();
|
||||
|
||||
forAll(faceID_, zonei)
|
||||
{
|
||||
@ -623,9 +616,9 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
writeFile::read(dict);
|
||||
|
||||
mode_ = modeTypeNames_.read(dict.lookup("mode"));
|
||||
phiName_= dict.lookupOrDefault<word>("phi", "phi");
|
||||
dict.readIfPresent("scaleFactor", scaleFactor_);
|
||||
dict.readIfPresent("tolerance", tolerance_);
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
|
||||
tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8);
|
||||
|
||||
// Initialise with capacity of 10 faceZones
|
||||
DynamicList<vector> refDir(10);
|
||||
@ -788,7 +781,7 @@ bool Foam::functionObjects::fluxSummary::write()
|
||||
{
|
||||
const surfaceScalarField& phi = lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
word flowType = "";
|
||||
word flowType;
|
||||
if (phi.dimensions() == dimVolume/dimTime)
|
||||
{
|
||||
flowType = "volumetric";
|
||||
@ -801,7 +794,7 @@ bool Foam::functionObjects::fluxSummary::write()
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unsupported flux field " << phi.name() << " with dimensions "
|
||||
<< phi.dimensions() << ". Expected eithe mass flow or volumetric "
|
||||
<< phi.dimensions() << ". Expected either mass flow or volumetric "
|
||||
<< "flow rate" << abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -50,7 +50,7 @@ Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: mapFields | yes |
|
||||
mapRgion | Name of region to map to | yes |
|
||||
mapRegion | Name of region to map to | yes |
|
||||
mapMethod | Mapping method | yes |
|
||||
patchMapMethod | Patch mapping method | no | <auto>
|
||||
consistent | Mapping meshes have consistent boundaries | yes |
|
||||
@ -61,7 +61,6 @@ Usage
|
||||
|
||||
SourceFiles
|
||||
mapFields.C
|
||||
IOmapFields.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
{
|
||||
|
||||
@ -232,8 +232,8 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
dict.readIfPresent("U", UName_);
|
||||
dict.readIfPresent("rho", rhoName_);
|
||||
UName_ = dict.lookupOrDefault<word>("U", "U");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
|
||||
@ -114,8 +114,16 @@ Usage
|
||||
minDiameter | minimum region equivalent diameter | no | 0
|
||||
setFormat | writing format | yes |
|
||||
origin | origin of local co-ordinate system | yes |
|
||||
coordinateRoation | orientation of local co-ordinate system | no |
|
||||
coordinateRoation | orientation of local co-ordinate system | no
|
||||
log | Log to standard output | no | yes
|
||||
isoPlanes | switch for isoPlanes | no | false
|
||||
origin | origin of the plane when isoPlanes is used | no | none
|
||||
direction | direction of the plane when isoPlanes is used | no | none
|
||||
maxDiameter | maximum diameter of the sampling cylinder when
|
||||
isoPlanes is used | no | none
|
||||
nDownstreamBins | number of bins when isoPlanes is used | no | none
|
||||
maxDownstream | maximum distance from origin when isoPlanes is used
|
||||
| no | none
|
||||
\endtable
|
||||
|
||||
See also
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -95,7 +95,7 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of function object to retrueve data from
|
||||
//- Name of function object to retrieve data from
|
||||
word functionObjectName_;
|
||||
|
||||
//- List of fields on which to operate
|
||||
|
||||
@ -33,7 +33,7 @@ const std::size_t Foam::wallBoundedParticle::sizeofFields_
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::edge Foam::wallBoundedParticle::currentEdge() const
|
||||
{
|
||||
|
||||
@ -100,7 +100,6 @@ Foam::functionObjects::zeroGradient::zeroGradient
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
prevTimeIndex_(-1),
|
||||
selectFields_(),
|
||||
resultName_(string::null),
|
||||
results_()
|
||||
@ -175,20 +174,12 @@ bool Foam::functionObjects::zeroGradient::execute()
|
||||
<< "Unprocessed field " << ignored << endl;
|
||||
}
|
||||
|
||||
// Update time index
|
||||
prevTimeIndex_ = obr_.time().timeIndex();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::zeroGradient::write()
|
||||
{
|
||||
if (prevTimeIndex_ < obr_.time().timeIndex())
|
||||
{
|
||||
// Ensure written results reflect the current state
|
||||
execute();
|
||||
}
|
||||
if (results_.size())
|
||||
{
|
||||
Log << type() << ' ' << name() << " write:" << endl;
|
||||
|
||||
@ -95,9 +95,6 @@ class zeroGradient
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Time at last execute, ensures write uses up-to-date values
|
||||
label prevTimeIndex_;
|
||||
|
||||
//- Name of fields to process
|
||||
wordReList selectFields_;
|
||||
|
||||
|
||||
@ -256,8 +256,6 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField* forceCoeffPtr
|
||||
(
|
||||
new volVectorField
|
||||
@ -265,12 +263,12 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
||||
IOobject
|
||||
(
|
||||
fieldName("forceCoeff"),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
mesh_,
|
||||
dimensionedVector("0", dimless, Zero)
|
||||
)
|
||||
);
|
||||
@ -284,12 +282,12 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
||||
IOobject
|
||||
(
|
||||
fieldName("momentCoeff"),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
mesh_,
|
||||
dimensionedVector("0", dimless, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
@ -4,37 +4,58 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
|
||||
# The source directory
|
||||
sourceDir=$PWD
|
||||
|
||||
# Where are any generated files stored?
|
||||
findObjectDir $sourceDir
|
||||
depDir="$objectsDir"
|
||||
# Ensure CMake gets the correct C/C++ compilers
|
||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
||||
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "${PWD##*/} : $PWD"
|
||||
echo
|
||||
|
||||
|
||||
# CMake into objectsDir,
|
||||
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
|
||||
doCmake()
|
||||
{
|
||||
local sourceDir="$1"
|
||||
|
||||
findObjectDir $sourceDir # Where are generated files stored?
|
||||
test -f "$objectsDir/CMakeCache.txt"
|
||||
retry=$? # CMakeCache.txt exists, but sources may have moved
|
||||
|
||||
mkdir -p $objectsDir && \
|
||||
(
|
||||
cd $objectsDir || exit 1
|
||||
|
||||
cmake $sourceDir || {
|
||||
if [ $retry -eq 0 ]
|
||||
then
|
||||
echo "Removing CMakeCache.txt and attempt again"
|
||||
rm -f CMakeCache.txt
|
||||
cmake $sourceDir
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
} && make
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ]
|
||||
then
|
||||
# ensure CMake gets the correct C/C++ compilers
|
||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
||||
|
||||
if type cmake > /dev/null 2>&1
|
||||
if [ "$targetType" != objects ]
|
||||
then
|
||||
(
|
||||
mkdir -p $depDir \
|
||||
&& cd $depDir \
|
||||
&& cmake $sourceDir \
|
||||
&& make
|
||||
) || {
|
||||
echo
|
||||
echo "WARNING: incomplete build of VTK-based post-processing"
|
||||
}
|
||||
else
|
||||
echo "WARNING: skipped - needs cmake"
|
||||
if type cmake > /dev/null 2>&1
|
||||
then
|
||||
doCmake $PWD || {
|
||||
echo
|
||||
echo " WARNING: incomplete build of VTK-based post-processing"
|
||||
echo
|
||||
}
|
||||
else
|
||||
echo "WARNING: skipped - needs cmake"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "WARNING: skipped - needs a VTK or a ParaView installation"
|
||||
@ -45,4 +66,4 @@ fi
|
||||
echo "======================================================================"
|
||||
echo
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@ -38,28 +38,6 @@ License
|
||||
#include "vtkRenderWindow.h"
|
||||
#include "vtkWindowToImageFilter.h"
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::runTimePostPro::scene::modeType,
|
||||
2
|
||||
>::names[] =
|
||||
{
|
||||
"static",
|
||||
"flightPath"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::runTimePostPro::scene::modeType,
|
||||
2
|
||||
> modeTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -92,9 +70,6 @@ void Foam::functionObjects::runTimePostPro::scene::readCamera
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dict.lookup("parallelProjection") >> parallelProjection_;
|
||||
|
||||
if (nFrameTotal_ > 1)
|
||||
{
|
||||
scalar endPosition = dict.lookupOrDefault<scalar>("endPosition", 1);
|
||||
@ -107,60 +82,36 @@ void Foam::functionObjects::runTimePostPro::scene::readCamera
|
||||
dPosition_ = (endPosition - startPosition_)/scalar(nFrameTotal_ - 1);
|
||||
}
|
||||
|
||||
mode_ = modeTypeNames_.read(dict.lookup("mode"));
|
||||
cameraPosition_ = Function1<vector>::New("position", dict);
|
||||
cameraFocalPoint_ = Function1<point>::New("focalPoint", dict);
|
||||
cameraUp_ = Function1<vector>::New("up", dict);
|
||||
|
||||
word coeffsName = modeTypeNames_[mode_] + word("Coeffs");
|
||||
const dictionary& coeffs = dict.subDict(coeffsName);
|
||||
|
||||
switch (mode_)
|
||||
dict.readIfPresent("clipBox", clipBox_);
|
||||
dict.lookup("parallelProjection") >> parallelProjection_;
|
||||
if (!parallelProjection_)
|
||||
{
|
||||
case mtStatic:
|
||||
if (dict.found("viewAngle"))
|
||||
{
|
||||
clipBox_ = boundBox(coeffs.lookup("clipBox"));
|
||||
const vector lookDir(vector(coeffs.lookup("lookDir")));
|
||||
cameraPosition_.reset
|
||||
(
|
||||
new Function1Types::Constant<point>("position", -lookDir)
|
||||
);
|
||||
const vector focalPoint(coeffs.lookup("focalPoint"));
|
||||
cameraFocalPoint_.reset
|
||||
(
|
||||
new Function1Types::Constant<point>("focalPoint", focalPoint)
|
||||
);
|
||||
const vector up(coeffs.lookup("up"));
|
||||
cameraUp_.reset(new Function1Types::Constant<point>("up", up));
|
||||
break;
|
||||
cameraViewAngle_ = Function1<scalar>::New("viewAngle", dict);
|
||||
}
|
||||
case mtFlightPath:
|
||||
else
|
||||
{
|
||||
cameraPosition_.reset
|
||||
cameraViewAngle_.reset
|
||||
(
|
||||
Function1<vector>::New("position", coeffs).ptr()
|
||||
new Function1Types::Constant<scalar>("viewAngle", 35.0)
|
||||
);
|
||||
cameraFocalPoint_.reset
|
||||
(
|
||||
Function1<point>::New("focalPoint", coeffs).ptr()
|
||||
);
|
||||
cameraUp_.reset(Function1<vector>::New("up", coeffs).ptr());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unhandled enumeration " << modeTypeNames_[mode_]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.found("viewAngle"))
|
||||
if (dict.found("zoom"))
|
||||
{
|
||||
cameraViewAngle_.reset(Function1<scalar>::New("viewAngle", dict).ptr());
|
||||
cameraZoom_ = Function1<scalar>::New("zoom", dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraViewAngle_.reset
|
||||
cameraZoom_.reset
|
||||
(
|
||||
new Function1Types::Constant<scalar>("viewAngle", 35.0)
|
||||
new Function1Types::Constant<scalar>("zoom", 1.0)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -224,25 +175,11 @@ void Foam::functionObjects::runTimePostPro::scene::initialise
|
||||
camera->SetParallelProjection(parallelProjection_);
|
||||
renderer->SetActiveCamera(camera);
|
||||
|
||||
|
||||
// Initialise the camera
|
||||
const vector up = cameraUp_->value(position_);
|
||||
const vector pos = cameraPosition_->value(position_);
|
||||
const point focalPoint = cameraFocalPoint_->value(position_);
|
||||
|
||||
camera->SetViewUp(up.x(), up.y(), up.z());
|
||||
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
||||
camera->Modified();
|
||||
|
||||
|
||||
// Add the lights
|
||||
vtkSmartPointer<vtkLightKit> lightKit = vtkSmartPointer<vtkLightKit>::New();
|
||||
lightKit->AddLightsToRenderer(renderer);
|
||||
|
||||
|
||||
// For static mode initialise the clip box
|
||||
if (mode_ == mtStatic)
|
||||
if (clipBox_ != boundBox::greatBox)
|
||||
{
|
||||
const point& min = clipBox_.min();
|
||||
const point& max = clipBox_.max();
|
||||
@ -261,15 +198,10 @@ void Foam::functionObjects::runTimePostPro::scene::initialise
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
clipMapper->SetInputConnection(clipBox->GetOutputPort());
|
||||
|
||||
vtkSmartPointer<vtkActor> clipActor = vtkSmartPointer<vtkActor>::New();
|
||||
clipActor->SetMapper(clipMapper);
|
||||
clipActor->VisibilityOff();
|
||||
renderer->AddActor(clipActor);
|
||||
|
||||
// Call resetCamera to fit clip box in view
|
||||
clipActor->VisibilityOn();
|
||||
renderer->ResetCamera();
|
||||
clipActor->VisibilityOff();
|
||||
clipBoxActor_ = vtkSmartPointer<vtkActor>::New();
|
||||
clipBoxActor_->SetMapper(clipMapper);
|
||||
clipBoxActor_->VisibilityOff();
|
||||
renderer->AddActor(clipBoxActor_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,26 +211,44 @@ void Foam::functionObjects::runTimePostPro::scene::setCamera
|
||||
vtkRenderer* renderer
|
||||
) const
|
||||
{
|
||||
if (mode_ == mtFlightPath)
|
||||
vtkCamera* camera = renderer->GetActiveCamera();
|
||||
|
||||
if (parallelProjection_)
|
||||
{
|
||||
const vector up = cameraUp_->value(position_);
|
||||
const vector pos = cameraPosition_->value(position_);
|
||||
const point focalPoint = cameraFocalPoint_->value(position_);
|
||||
|
||||
vtkCamera* camera = renderer->GetActiveCamera();
|
||||
camera->SetViewUp(up.x(), up.y(), up.z());
|
||||
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
||||
camera->Modified();
|
||||
// Restore parallel scale to allow application of zoom (later)
|
||||
camera->SetParallelScale(1);
|
||||
}
|
||||
|
||||
if (!parallelProjection_)
|
||||
else
|
||||
{
|
||||
// Restore viewAngle (it might be reset by clipping)
|
||||
vtkCamera* camera = renderer->GetActiveCamera();
|
||||
camera->SetViewAngle(cameraViewAngle_->value(position_));
|
||||
camera->Modified();
|
||||
}
|
||||
|
||||
const vector up = cameraUp_->value(position_);
|
||||
const vector pos = cameraPosition_->value(position_);
|
||||
const point focalPoint = cameraFocalPoint_->value(position_);
|
||||
const scalar zoom = cameraZoom_->value(position_);
|
||||
|
||||
camera->SetViewUp(up.x(), up.y(), up.z());
|
||||
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
||||
|
||||
|
||||
// Apply clipping if required
|
||||
// Note: possible optimisation - if the camera is static, this only needs
|
||||
// to be done once on initialisation
|
||||
if (clipBox_ != boundBox::greatBox)
|
||||
{
|
||||
// Call ResetCamera() to fit clip box in view
|
||||
clipBoxActor_->VisibilityOn();
|
||||
renderer->ResetCamera();
|
||||
clipBoxActor_->VisibilityOff();
|
||||
}
|
||||
|
||||
// Zoom applied after all other operations
|
||||
camera->Zoom(zoom);
|
||||
|
||||
camera->Modified();
|
||||
}
|
||||
|
||||
|
||||
@ -323,12 +273,13 @@ Foam::functionObjects::runTimePostPro::scene::scene
|
||||
obr_(obr),
|
||||
name_(name),
|
||||
colours_(),
|
||||
mode_(mtStatic),
|
||||
cameraPosition_(nullptr),
|
||||
cameraFocalPoint_(nullptr),
|
||||
cameraUp_(nullptr),
|
||||
cameraViewAngle_(nullptr),
|
||||
clipBox_(),
|
||||
cameraZoom_(nullptr),
|
||||
clipBox_(boundBox::greatBox),
|
||||
clipBoxActor_(),
|
||||
parallelProjection_(true),
|
||||
nFrameTotal_(1),
|
||||
startPosition_(0),
|
||||
@ -366,7 +317,10 @@ Foam::scalar Foam::functionObjects::runTimePostPro::scene::position() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimePostPro::scene::read(const dictionary& dict)
|
||||
void Foam::functionObjects::runTimePostPro::scene::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
readCamera(dict.subDict("camera"));
|
||||
readColours(dict.subDict("colours"));
|
||||
|
||||
@ -25,6 +25,28 @@ Class
|
||||
Foam::functionObjects::runTimePostPro::scene
|
||||
|
||||
Description
|
||||
Class to control scene construction and provide main rendering loop
|
||||
|
||||
Usage
|
||||
\verbatim
|
||||
camera
|
||||
{
|
||||
// Total number of frames to generate
|
||||
nFrameTotal 1;
|
||||
|
||||
// Parallel projection flag
|
||||
parallelProjection no;
|
||||
|
||||
focalPoint (0 0 0);
|
||||
up (0 1 0);
|
||||
position (0 0 1);
|
||||
|
||||
// Optional entries
|
||||
clipBox (-0.0206 -0.0254 -0.0005) (0.29 0.0254 0.0005);
|
||||
viewAngle 20;
|
||||
zoom 1.1;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
scene.C
|
||||
@ -49,6 +71,7 @@ SourceFiles
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkActor;
|
||||
class vtkRenderer;
|
||||
class vtkRenderWindow;
|
||||
|
||||
@ -58,22 +81,12 @@ namespace functionObjects
|
||||
{
|
||||
namespace runTimePostPro
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class scene Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class scene
|
||||
{
|
||||
public:
|
||||
|
||||
enum modeType{mtStatic, mtFlightPath};
|
||||
|
||||
NamedEnum<modeType, 2> modeTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the object registry
|
||||
@ -88,7 +101,7 @@ private:
|
||||
//- Read camera properties
|
||||
void readCamera(const dictionary& dict);
|
||||
|
||||
//- Read solour properties
|
||||
//- Read colour properties
|
||||
void readColours(const dictionary& dict);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -108,9 +121,6 @@ protected:
|
||||
|
||||
// Camera settings
|
||||
|
||||
//- Mode
|
||||
modeType mode_;
|
||||
|
||||
//- Position
|
||||
autoPtr<Function1<point>> cameraPosition_;
|
||||
|
||||
@ -123,12 +133,20 @@ protected:
|
||||
//- View angle
|
||||
autoPtr<Function1<scalar>> cameraViewAngle_;
|
||||
|
||||
//- Zoom: 1 = do nothing, >1 = zoom in, <1 = zoom out
|
||||
// - perspective mode: reduces view angle
|
||||
// - parallel mode: manipulate parallel scale
|
||||
autoPtr<Function1<scalar>> cameraZoom_;
|
||||
|
||||
|
||||
// Scene management
|
||||
|
||||
//- Clipping box
|
||||
boundBox clipBox_;
|
||||
|
||||
//- Clipping box actor
|
||||
vtkSmartPointer<vtkActor> clipBoxActor_;
|
||||
|
||||
//- Parallel projection flag
|
||||
bool parallelProjection_;
|
||||
|
||||
|
||||
@ -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