mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'release-v1812'
This commit is contained in:
@ -10,6 +10,6 @@ wmake $targetType lagrangian
|
||||
wmake $targetType utilities
|
||||
wmake $targetType solvers
|
||||
|
||||
./graphics/Allwmake
|
||||
./graphics/Allwmake $targetType
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
396
src/functionObjects/field/AMIWeights/AMIWeights.C
Normal file
396
src/functionObjects/field/AMIWeights/AMIWeights.C
Normal file
@ -0,0 +1,396 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "AMIWeights.H"
|
||||
#include "fvMesh.H"
|
||||
#include "foamVtkSurfaceWriter.H"
|
||||
#include "PatchTools.H"
|
||||
#include "cyclicACMIPolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(AMIWeights, 0);
|
||||
addToRunTimeSelectionTable(functionObject, AMIWeights, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::AMIWeights::writeFileHeader(Ostream& os)
|
||||
{
|
||||
writeHeader(os, "AMI");
|
||||
|
||||
writeCommented(os, "Time");
|
||||
forAll(patchIDs_, patchi)
|
||||
{
|
||||
writeTabbed(os, "Patch");
|
||||
writeTabbed(os, "nbr_patch");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "distributed");
|
||||
}
|
||||
|
||||
writeTabbed(os, "src_min_weight");
|
||||
writeTabbed(os, "src_max_weight");
|
||||
writeTabbed(os, "src_average_weight");
|
||||
writeTabbed(os, "src_min_neighbours");
|
||||
writeTabbed(os, "src_max_neighbours");
|
||||
writeTabbed(os, "src_average_neighbours");
|
||||
writeTabbed(os, "tgt_min_weight");
|
||||
writeTabbed(os, "tgt_max_weight");
|
||||
writeTabbed(os, "tgt_average_weight");
|
||||
writeTabbed(os, "tgt_min_neighbours");
|
||||
writeTabbed(os, "tgt_max_neighbours");
|
||||
writeTabbed(os, "tgt_average_neighbours");
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::AMIWeights::reportPatch
|
||||
(
|
||||
const cyclicAMIPolyPatch& pp
|
||||
)
|
||||
{
|
||||
const word& nbrPatchName = pp.neighbPatchName();
|
||||
|
||||
const Switch distributed = pp.AMI().singlePatchProc() == -1;
|
||||
|
||||
const scalarField& srcWeightsSum = pp.AMI().srcWeightsSum();
|
||||
const scalar srcMinWeight = gMin(srcWeightsSum);
|
||||
const scalar srcMaxWeight = gMax(srcWeightsSum);
|
||||
const scalar srcAveWeight = gAverage(srcWeightsSum);
|
||||
|
||||
const labelListList& srcAddress = pp.AMI().srcAddress();
|
||||
label srcMinNbr = labelMax;
|
||||
label srcMaxNbr = labelMin;
|
||||
scalar srcAveNbr = 0;
|
||||
for (const labelList& srcFace : srcAddress)
|
||||
{
|
||||
const label n = srcFace.size();
|
||||
srcAveNbr += n;
|
||||
srcMinNbr = min(srcMinNbr, n);
|
||||
srcMaxNbr = max(srcMaxNbr, n);
|
||||
}
|
||||
|
||||
reduce(srcMinNbr, minOp<label>());
|
||||
reduce(srcMaxNbr, maxOp<label>());
|
||||
|
||||
srcAveNbr =
|
||||
returnReduce(srcAveNbr, sumOp<scalar>())
|
||||
/(returnReduce(srcAddress.size(), sumOp<scalar>()) + ROOTVSMALL);
|
||||
|
||||
const scalarField& tgtWeightsSum = pp.AMI().tgtWeightsSum();
|
||||
const scalar tgtMinWeight = gMin(tgtWeightsSum);
|
||||
const scalar tgtMaxWeight = gMax(tgtWeightsSum);
|
||||
const scalar tgtAveWeight = gAverage(tgtWeightsSum);
|
||||
|
||||
const labelListList& tgtAddress = pp.AMI().tgtAddress();
|
||||
label tgtMinNbr = labelMax;
|
||||
label tgtMaxNbr = labelMin;
|
||||
scalar tgtAveNbr = 0;
|
||||
for (const labelList& tgtFace : tgtAddress)
|
||||
{
|
||||
const label n = tgtFace.size();
|
||||
tgtAveNbr += n;
|
||||
tgtMinNbr = min(tgtMinNbr, n);
|
||||
tgtMaxNbr = max(tgtMaxNbr, n);
|
||||
}
|
||||
|
||||
reduce(tgtMinNbr, minOp<label>());
|
||||
reduce(tgtMaxNbr, maxOp<label>());
|
||||
|
||||
tgtAveNbr =
|
||||
returnReduce(tgtAveNbr, sumOp<scalar>())
|
||||
/(returnReduce(tgtAddress.size(), sumOp<scalar>()) + ROOTVSMALL);
|
||||
|
||||
file()
|
||||
<< mesh_.time().timeName() << tab
|
||||
<< pp.name() << tab
|
||||
<< nbrPatchName << tab;
|
||||
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file() << distributed << tab;
|
||||
}
|
||||
|
||||
file()
|
||||
<< srcMinWeight << tab
|
||||
<< srcMaxWeight << tab
|
||||
<< srcAveWeight << tab
|
||||
<< srcMinNbr << tab
|
||||
<< srcMaxNbr << tab
|
||||
<< srcAveNbr << tab
|
||||
<< tgtMinWeight << tab
|
||||
<< tgtMaxWeight << tab
|
||||
<< tgtAveWeight << tab
|
||||
<< tgtMinNbr << tab
|
||||
<< tgtMaxNbr << tab
|
||||
<< tgtAveNbr << tab
|
||||
<< endl;
|
||||
|
||||
Log << " Patches: " << nl
|
||||
<< " Source: " << pp.name() << nl
|
||||
<< " Target: " << nbrPatchName << nl;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Log << " Parallel distributed: " << distributed << nl;
|
||||
}
|
||||
|
||||
Log << nl;
|
||||
|
||||
const label w = IOstream::defaultPrecision() + 8;
|
||||
|
||||
Log << " | " << setw(w) << pp.name()
|
||||
<< " | " << setw(w) << nbrPatchName << " | " << nl
|
||||
<< " min(weight) | " << setw(w) << srcMinWeight
|
||||
<< " | " << setw(w) << tgtMinWeight << " | " << nl
|
||||
<< " max(weight) | " << setw(w) << srcMaxWeight
|
||||
<< " | " << setw(w) << tgtMaxWeight << " | " << nl
|
||||
<< " ave(weight) | " << setw(w) << srcAveWeight
|
||||
<< " | " << setw(w) << tgtAveWeight << " | " << nl
|
||||
<< " min(address) | " << setw(w) << srcMinNbr
|
||||
<< " | " << setw(w) << tgtMinNbr << " | " << nl
|
||||
<< " max(address) | " << setw(w) << srcMaxNbr
|
||||
<< " | " << setw(w) << tgtMaxNbr << " | " << nl
|
||||
<< " ave(address) | " << setw(w) << srcAveNbr
|
||||
<< " | " << setw(w) << tgtAveNbr << " | " << nl
|
||||
<< endl;
|
||||
|
||||
setResult(pp.name() + ":src", pp.name());
|
||||
setResult(pp.name() + ":tgt", nbrPatchName);
|
||||
setResult(pp.name() + ":src:min(weight)", srcMinWeight);
|
||||
setResult(pp.name() + ":src:max(weight)", srcMaxWeight);
|
||||
setResult(pp.name() + ":src:ave(weight)", srcAveWeight);
|
||||
setResult(pp.name() + ":src:min(address)", srcMinNbr);
|
||||
setResult(pp.name() + ":src:max(address)", srcMaxNbr);
|
||||
setResult(pp.name() + ":src:ave(address)", srcAveNbr);
|
||||
setResult(pp.name() + ":tgt:min(weight)", tgtMinWeight);
|
||||
setResult(pp.name() + ":tgt:max(weight)", tgtMaxWeight);
|
||||
setResult(pp.name() + ":tgt:ave(weight)", tgtAveWeight);
|
||||
setResult(pp.name() + ":tgt:min(address)", tgtMinNbr);
|
||||
setResult(pp.name() + ":tgt:max(address)", tgtMaxNbr);
|
||||
setResult(pp.name() + ":tgt:ave(address)", tgtAveNbr);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::AMIWeights::writeWeightField
|
||||
(
|
||||
const cyclicAMIPolyPatch& cpp,
|
||||
const scalarField& weightSum,
|
||||
const word& side
|
||||
) const
|
||||
{
|
||||
// Collect geometry
|
||||
labelList pointToGlobal;
|
||||
labelList uniqueMeshPointLabels;
|
||||
autoPtr<globalIndex> globalPoints;
|
||||
autoPtr<globalIndex> globalFaces;
|
||||
faceList mergedFaces;
|
||||
pointField mergedPoints;
|
||||
Foam::PatchTools::gatherAndMerge
|
||||
(
|
||||
mesh_,
|
||||
cpp.localFaces(),
|
||||
cpp.meshPoints(),
|
||||
cpp.meshPointMap(),
|
||||
|
||||
pointToGlobal,
|
||||
uniqueMeshPointLabels,
|
||||
globalPoints,
|
||||
globalFaces,
|
||||
|
||||
mergedFaces,
|
||||
mergedPoints
|
||||
);
|
||||
|
||||
// Collect field
|
||||
scalarField mergedWeights;
|
||||
globalFaces().gather
|
||||
(
|
||||
UPstream::worldComm,
|
||||
ListOps::create<label>
|
||||
(
|
||||
UPstream::procID(UPstream::worldComm),
|
||||
labelOp<int>() // int -> label
|
||||
),
|
||||
weightSum,
|
||||
mergedWeights
|
||||
);
|
||||
|
||||
const bool isACMI = isA<cyclicACMIPolyPatch>(cpp);
|
||||
|
||||
scalarField mergedMask;
|
||||
if (isACMI)
|
||||
{
|
||||
const cyclicACMIPolyPatch& pp = refCast<const cyclicACMIPolyPatch>(cpp);
|
||||
|
||||
globalFaces().gather
|
||||
(
|
||||
UPstream::worldComm,
|
||||
ListOps::create<label>
|
||||
(
|
||||
UPstream::procID(UPstream::worldComm),
|
||||
labelOp<int>() // int -> label
|
||||
),
|
||||
pp.mask(),
|
||||
mergedMask
|
||||
);
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
instant inst(mesh_.time().value(), mesh_.time().timeName());
|
||||
|
||||
vtk::surfaceWriter writer
|
||||
(
|
||||
mergedPoints,
|
||||
mergedFaces,
|
||||
(baseTimeDir()/cpp.name() + "_" + side),
|
||||
false // serial: master-only
|
||||
);
|
||||
|
||||
writer.setTime(inst);
|
||||
writer.writeTimeValue();
|
||||
writer.writeGeometry();
|
||||
|
||||
writer.beginCellData(1 + (isACMI ? 1 : 0));
|
||||
writer.write("weightsSum", mergedWeights);
|
||||
|
||||
if (isACMI)
|
||||
{
|
||||
writer.write("mask", mergedMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::AMIWeights::writeWeightFields
|
||||
(
|
||||
const cyclicAMIPolyPatch& cpp
|
||||
) const
|
||||
{
|
||||
if (cpp.owner())
|
||||
{
|
||||
writeWeightField(cpp, cpp.AMI().srcWeightsSum(), "src");
|
||||
writeWeightField(cpp.neighbPatch(), cpp.AMI().tgtWeightsSum(), "tgt");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::AMIWeights::AMIWeights
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(mesh_, name, typeName, dict),
|
||||
writeFields_(false),
|
||||
patchIDs_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::AMIWeights::read(const dictionary& dict)
|
||||
{
|
||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
patchIDs_.clear();
|
||||
labelHashSet ids;
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (isA<cyclicAMIPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
const auto& ami =
|
||||
static_cast<const cyclicAMIPolyPatch&>(pbm[patchi]);
|
||||
|
||||
if (ami.owner())
|
||||
{
|
||||
ids.insert(patchi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
patchIDs_ = ids.sortedToc();
|
||||
|
||||
writeFileHeader(file());
|
||||
|
||||
writeFields_ = dict.get<bool>("writeFields");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::AMIWeights::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::AMIWeights::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
const polyPatch& pp = pbm[patchi];
|
||||
const auto& cpp = static_cast<const cyclicAMIPolyPatch&>(pp);
|
||||
|
||||
reportPatch(cpp);
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
writeWeightFields(cpp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
163
src/functionObjects/field/AMIWeights/AMIWeights.H
Normal file
163
src/functionObjects/field/AMIWeights/AMIWeights.H
Normal file
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::AMIWeights
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
AMIWeights1
|
||||
{
|
||||
type AMIWeights;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
writeFields yes;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: AMIWeights | yes |
|
||||
writeFields | write weights as VTK fields | yes |
|
||||
\endtable
|
||||
|
||||
Output data is written to the file \<timeDir\>/AMIWeights.dat
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
AMIWeights.C
|
||||
AMIWeightsTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_AMIWeights_H
|
||||
#define functionObjects_AMIWeights_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "cyclicAMIPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AMIWeights Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class AMIWeights
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Flag to write AMI fields (as VTK files)
|
||||
bool writeFields_;
|
||||
|
||||
//- List of AMI patch IDs
|
||||
labelList patchIDs_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os);
|
||||
|
||||
//- Helper function to report patch information
|
||||
virtual void reportPatch(const cyclicAMIPolyPatch& pp);
|
||||
|
||||
void writeWeightField
|
||||
(
|
||||
const cyclicAMIPolyPatch& cpp,
|
||||
const scalarField& weightSum,
|
||||
const word& side
|
||||
) const;
|
||||
|
||||
void writeWeightFields(const cyclicAMIPolyPatch& cpp) const;
|
||||
|
||||
//- No copy construct
|
||||
AMIWeights(const AMIWeights&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const AMIWeights&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("AMIWeights");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
AMIWeights
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~AMIWeights() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the AMIWeights
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -59,10 +59,8 @@ Foam::functionObjects::CourantNo::byRho
|
||||
{
|
||||
return Co/obr_.lookupObject<volScalarField>(rhoName_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Co;
|
||||
}
|
||||
|
||||
return Co;
|
||||
}
|
||||
|
||||
|
||||
@ -85,35 +83,27 @@ bool Foam::functionObjects::CourantNo::calc()
|
||||
|
||||
if (foundObject<volScalarField>(resultName_, false))
|
||||
{
|
||||
volScalarField& Co
|
||||
(
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupObject<volScalarField>(resultName_)
|
||||
)
|
||||
);
|
||||
volScalarField& Co =
|
||||
lookupObjectRef<volScalarField>(resultName_);
|
||||
|
||||
Co.ref() = Coi();
|
||||
Co.correctBoundaryConditions();
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp<volScalarField> tCo
|
||||
auto tCo = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
resultName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
tCo.ref().ref() = Coi();
|
||||
tCo.ref().correctBoundaryConditions();
|
||||
@ -122,10 +112,8 @@ bool Foam::functionObjects::CourantNo::calc()
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -75,33 +75,28 @@ bool Foam::functionObjects::Curle::calc()
|
||||
|
||||
const volVectorField& C = mesh_.C();
|
||||
|
||||
tmp<volScalarField> tpDash
|
||||
auto tpDash = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
resultName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(p.dimensions(), Zero)
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(p.dimensions(), Zero)
|
||||
);
|
||||
auto& pDash = tpDash.ref();
|
||||
|
||||
volScalarField& pDash = tpDash.ref();
|
||||
const volVectorField d(scopedName("d"), C - x0_);
|
||||
pDash = (d/magSqr(d) & dfdt)/(4.0*mathematical::pi*c0_);
|
||||
|
||||
return store(resultName_, tpDash);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -136,8 +131,7 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict)
|
||||
{
|
||||
if (fieldExpression::read(dict))
|
||||
{
|
||||
patchSet_ =
|
||||
mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches")));
|
||||
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
|
||||
|
||||
if (patchSet_.empty())
|
||||
{
|
||||
@ -149,7 +143,7 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
// Read the reference speed of sound
|
||||
dict.lookup("c0") >> c0_;
|
||||
dict.readEntry("c0", c0_);
|
||||
|
||||
|
||||
// Set the location of the effective point source to the area-average
|
||||
|
||||
@ -75,26 +75,21 @@ Foam::functionObjects::DESModelRegions::DESModelRegions
|
||||
{
|
||||
read(dict);
|
||||
|
||||
tmp<volScalarField> tDESModelRegions
|
||||
auto tmodelRegions = tmp<volScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
)
|
||||
)
|
||||
resultName_,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
);
|
||||
|
||||
store(resultName_, tDESModelRegions);
|
||||
store(resultName_, tmodelRegions);
|
||||
|
||||
writeFileHeader(file());
|
||||
}
|
||||
@ -124,10 +119,7 @@ bool Foam::functionObjects::DESModelRegions::execute()
|
||||
Log << type() << " " << name() << " execute:" << nl;
|
||||
|
||||
volScalarField& DESModelRegions =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupObject<volScalarField>(resultName_)
|
||||
);
|
||||
lookupObjectRef<volScalarField>(resultName_);
|
||||
|
||||
|
||||
if (foundObject<DESModelBase>(turbulenceModel::propertiesName))
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
AMIWeights/AMIWeights.C
|
||||
|
||||
columnAverage/columnAverage.C
|
||||
|
||||
fieldAverage/fieldAverage.C
|
||||
fieldAverage/fieldAverageItem/fieldAverageItem.C
|
||||
fieldAverage/fieldAverageItem/fieldAverageItemIO.C
|
||||
|
||||
fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C
|
||||
fieldExtents/fieldExtents.C
|
||||
fieldMinMax/fieldMinMax.C
|
||||
|
||||
fieldValues/fieldValue/fieldValue.C
|
||||
@ -47,6 +52,7 @@ components/components.C
|
||||
randomise/randomise.C
|
||||
div/div.C
|
||||
grad/grad.C
|
||||
ddt/ddt.C
|
||||
mag/mag.C
|
||||
magSqr/magSqr.C
|
||||
vorticity/vorticity.C
|
||||
@ -57,6 +63,7 @@ flowType/flowType.C
|
||||
CourantNo/CourantNo.C
|
||||
PecletNo/PecletNo.C
|
||||
blendingFactor/blendingFactor.C
|
||||
momentum/momentum.C
|
||||
pressure/pressure.C
|
||||
MachNo/MachNo.C
|
||||
Curle/Curle.C
|
||||
|
||||
@ -57,10 +57,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::functionObjects::PecletNo::rhoScale
|
||||
{
|
||||
return phi/fvc::interpolate(lookupObject<volScalarField>(rhoName_));
|
||||
}
|
||||
else
|
||||
{
|
||||
return phi;
|
||||
}
|
||||
|
||||
return phi;
|
||||
}
|
||||
|
||||
|
||||
@ -84,23 +82,19 @@ bool Foam::functionObjects::PecletNo::calc()
|
||||
const dictionary& model =
|
||||
mesh_.lookupObject<dictionary>("transportProperties");
|
||||
|
||||
nuEff =
|
||||
tmp<volScalarField>
|
||||
nuEff = tmp<volScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"nuEff",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(model.lookup("nu"))
|
||||
)
|
||||
);
|
||||
"nuEff",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("nu", dimViscosity, model)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -81,22 +81,19 @@ Foam::functionObjects::blendingFactor::blendingFactor
|
||||
writeFileHeader(file());
|
||||
setResultName(typeName, "");
|
||||
|
||||
tmp<volScalarField> indicatorPtr
|
||||
auto indicatorPtr = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
resultName_,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
store(resultName_, indicatorPtr);
|
||||
|
||||
@ -72,10 +72,8 @@ void Foam::functionObjects::blendingFactor::calcBlendingFactor
|
||||
// - factor applied to 1st scheme, and (1-factor) to 2nd scheme
|
||||
// - not using the store(...) mechanism due to need to correct BCs
|
||||
volScalarField& indicator =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupObject<volScalarField>(resultName_)
|
||||
);
|
||||
lookupObjectRef<volScalarField>(resultName_);
|
||||
|
||||
indicator = 1 - fvc::cellReduce(factorf, minEqOp<scalar>(), GREAT);
|
||||
indicator.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
185
src/functionObjects/field/columnAverage/columnAverage.C
Normal file
185
src/functionObjects/field/columnAverage/columnAverage.C
Normal file
@ -0,0 +1,185 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "columnAverage.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "meshStructure.H"
|
||||
#include "globalIndex.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(columnAverage, 0);
|
||||
addToRunTimeSelectionTable(functionObject, columnAverage, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::meshStructure&
|
||||
Foam::functionObjects::columnAverage::meshAddressing(const polyMesh& mesh) const
|
||||
{
|
||||
if (!meshStructurePtr_.valid())
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
const labelList patchIDs(patchSet_.sortedToc());
|
||||
|
||||
// Count
|
||||
label sz = 0;
|
||||
for (const label patchi : patchIDs)
|
||||
{
|
||||
sz += pbm[patchi].size();
|
||||
}
|
||||
|
||||
// Fill
|
||||
labelList meshFaces(sz);
|
||||
sz = 0;
|
||||
for (const label patchi : patchIDs)
|
||||
{
|
||||
label start = pbm[patchi].start();
|
||||
label size = pbm[patchi].size();
|
||||
for (label i = 0; i < size; ++i)
|
||||
{
|
||||
meshFaces[sz++] = start+i;
|
||||
}
|
||||
}
|
||||
|
||||
if (sz == 0)
|
||||
{
|
||||
// TODO: If source patch is a cyclic it may have have been
|
||||
// converted to a processorCyclic for parallel runs
|
||||
|
||||
WarningInFunction
|
||||
<< "Requested patches have zero faces"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
uindirectPrimitivePatch uip
|
||||
(
|
||||
UIndirectList<face>(mesh.faces(), meshFaces),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
globalFaces_.set(new globalIndex(uip.size()));
|
||||
globalEdges_.set(new globalIndex(uip.nEdges()));
|
||||
globalPoints_.set(new globalIndex(uip.nPoints()));
|
||||
meshStructurePtr_.set
|
||||
(
|
||||
new meshStructure
|
||||
(
|
||||
mesh,
|
||||
uip,
|
||||
globalFaces_(),
|
||||
globalEdges_(),
|
||||
globalPoints_()
|
||||
)
|
||||
);
|
||||
}
|
||||
return meshStructurePtr_();
|
||||
}
|
||||
|
||||
|
||||
const Foam::word Foam::functionObjects::columnAverage::averageName
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return name() + ":columnAverage(" + fieldName + ")";
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::columnAverage::columnAverage
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
patchSet_(),
|
||||
fieldSet_(mesh_)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::columnAverage::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
|
||||
|
||||
fieldSet_.read(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::columnAverage::execute()
|
||||
{
|
||||
// Make fields up to date with current selection
|
||||
fieldSet_.updateSelection();
|
||||
|
||||
for (const word& fieldName : fieldSet_.selection())
|
||||
{
|
||||
columnAverageField<scalar>(fieldName);
|
||||
columnAverageField<vector>(fieldName);
|
||||
columnAverageField<sphericalTensor>(fieldName);
|
||||
columnAverageField<symmTensor>(fieldName);
|
||||
columnAverageField<tensor>(fieldName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::columnAverage::write()
|
||||
{
|
||||
for (const word& fieldName : fieldSet_.selection())
|
||||
{
|
||||
const word resultName("columnAverage(" + fieldName + ")");
|
||||
const regIOobject* obj =
|
||||
obr_.lookupObjectPtr<regIOobject>(averageName(fieldName));
|
||||
|
||||
if (obj)
|
||||
{
|
||||
obj->write();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
171
src/functionObjects/field/columnAverage/columnAverage.H
Normal file
171
src/functionObjects/field/columnAverage/columnAverage.H
Normal file
@ -0,0 +1,171 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::columnAverage
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Averages columns of cells for layered meshes.
|
||||
|
||||
For each patch face, calculates the average value of all cells attached in
|
||||
the patch face normal direction, and then pushes the average value back
|
||||
to all cells in the column.
|
||||
|
||||
Useful for channel-like cases where we want to average fields in the
|
||||
spanwise direction.
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
columnAverage1
|
||||
{
|
||||
type columnAverage;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
patches (front side);
|
||||
fields (U p);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldMinMax | yes |
|
||||
patches | list of patches to collapse onto | yes |
|
||||
fields | list of fields to process | yes |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
columnAverage.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_columnAverage_H
|
||||
#define functionObjects_columnAverage_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFieldSelection.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class globalIndex;
|
||||
class meshStructure;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class columnAverage Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class columnAverage
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Patches on which to collapse the fields
|
||||
labelHashSet patchSet_;
|
||||
|
||||
//- Fields to collapse
|
||||
volFieldSelection fieldSet_;
|
||||
|
||||
mutable autoPtr<globalIndex> globalFaces_;
|
||||
mutable autoPtr<globalIndex> globalEdges_;
|
||||
mutable autoPtr<globalIndex> globalPoints_;
|
||||
mutable autoPtr<meshStructure> meshStructurePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Create the column average field name
|
||||
const word averageName(const word& fieldName) const;
|
||||
|
||||
//- Return the column-based addressing
|
||||
const meshStructure& meshAddressing(const polyMesh&) const;
|
||||
|
||||
//- Calculate the averaged field and return true if successful
|
||||
template<class Type>
|
||||
bool columnAverageField(const word& fieldName);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("columnAverage");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
columnAverage
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~columnAverage() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the settings
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the results
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "columnAverageTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
114
src/functionObjects/field/columnAverage/columnAverageTemplates.C
Normal file
114
src/functionObjects/field/columnAverage/columnAverageTemplates.C
Normal file
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "meshStructure.H"
|
||||
#include "globalIndex.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::columnAverage::columnAverageField
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
const fieldType* fldPtr = lookupObjectPtr<fieldType>(fieldName);
|
||||
|
||||
if (fldPtr)
|
||||
{
|
||||
const fieldType& fld = *fldPtr;
|
||||
|
||||
const word resultName(averageName(fieldName));
|
||||
|
||||
if (!obr_.foundObject<fieldType>(resultName))
|
||||
{
|
||||
fieldType* ptr = new fieldType
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName,
|
||||
fld.mesh().time().timeName(),
|
||||
fld.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
fld
|
||||
);
|
||||
obr_.objectRegistry::store(ptr);
|
||||
}
|
||||
|
||||
fieldType& res = obr_.lookupObjectRef<fieldType>(resultName);
|
||||
|
||||
const meshStructure& ms = meshAddressing(fld.mesh());
|
||||
if (globalFaces_().empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelList& cellToPatchFace = ms.cellToPatchFaceAddressing();
|
||||
|
||||
// Brute force: collect per-global-patchface on all processors
|
||||
Field<Type> regionField(globalFaces_().size(), Zero);
|
||||
labelList regionCount(globalFaces_().size(), 0);
|
||||
|
||||
forAll(cellToPatchFace, celli)
|
||||
{
|
||||
const label regioni = cellToPatchFace[celli];
|
||||
regionField[regioni] += fld[celli];
|
||||
regionCount[regioni]++;
|
||||
}
|
||||
|
||||
// Global sum
|
||||
Pstream::listCombineGather(regionField, plusEqOp<Type>());
|
||||
Pstream::listCombineScatter(regionField);
|
||||
Pstream::listCombineGather(regionCount, plusEqOp<label>());
|
||||
Pstream::listCombineScatter(regionCount);
|
||||
|
||||
forAll(regionField, regioni)
|
||||
{
|
||||
regionField[regioni] /= regionCount[regioni];
|
||||
}
|
||||
|
||||
// And send result back
|
||||
forAll(cellToPatchFace, celli)
|
||||
{
|
||||
const label regioni = cellToPatchFace[celli];
|
||||
res[celli] = regionField[regioni];
|
||||
}
|
||||
res.correctBoundaryConditions();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
87
src/functionObjects/field/ddt/ddt.C
Normal file
87
src/functionObjects/field/ddt/ddt.C
Normal file
@ -0,0 +1,87 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 "ddt.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(ddt, 0);
|
||||
addToRunTimeSelectionTable(functionObject, ddt, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::ddt::calc()
|
||||
{
|
||||
if (functionObject::postProcess)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "ddt is not supported with the postProcess utility"
|
||||
<< endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcDdt<scalar>();
|
||||
processed = processed || calcDdt<vector>();
|
||||
processed = processed || calcDdt<sphericalTensor>();
|
||||
processed = processed || calcDdt<symmTensor>();
|
||||
processed = processed || calcDdt<tensor>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::ddt::ddt
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::ddt::~ddt()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
112
src/functionObjects/field/ddt/ddt.H
Normal file
112
src/functionObjects/field/ddt/ddt.H
Normal file
@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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::ddt
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the Eulerian time derivative of a field.
|
||||
|
||||
The operation can be applied to any volume field generating a field of the
|
||||
same type.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
ddt.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_ddt_H
|
||||
#define functionObjects_ddt_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ddt Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ddt
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the magnitude of the field and register the result
|
||||
template<class Type>
|
||||
bool calcDdt();
|
||||
|
||||
//- Calculate the time derivative of the field and return
|
||||
// true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ddt");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
ddt
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ddt();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ddtTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
50
src/functionObjects/field/ddt/ddtTemplates.C
Normal file
50
src/functionObjects/field/ddt/ddtTemplates.C
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 "fvcDdt.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::ddt::calcDdt()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::ddt(lookupObject<VolFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ddt2.H"
|
||||
|
||||
#include "stringListOps.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "wordRes.H"
|
||||
@ -134,7 +134,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
|
||||
return false;
|
||||
}
|
||||
|
||||
dict.lookup("fields") >> selectFields_;
|
||||
dict.readEntry("fields", selectFields_);
|
||||
selectFields_.uniq();
|
||||
|
||||
Info<< type() << " fields: " << selectFields_ << nl;
|
||||
@ -174,9 +174,9 @@ bool Foam::functionObjects::ddt2::execute()
|
||||
// Check exact matches first
|
||||
for (const wordRe& select : selectFields_)
|
||||
{
|
||||
if (!select.isPattern())
|
||||
if (select.isLiteral())
|
||||
{
|
||||
const word& fieldName = static_cast<const word&>(select);
|
||||
const word& fieldName = select;
|
||||
|
||||
if (!candidates.erase(fieldName))
|
||||
{
|
||||
|
||||
@ -56,28 +56,24 @@ int Foam::functionObjects::ddt2::apply(const word& inputName, int& state)
|
||||
: magSqr(input.dimensions()/dimTime)
|
||||
);
|
||||
|
||||
tmp<volScalarField> tddt2
|
||||
auto tddt2 = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
outputName,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
outputName,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dims, Zero)
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dims, Zero)
|
||||
);
|
||||
|
||||
store(outputName, tddt2);
|
||||
}
|
||||
|
||||
volScalarField& output =
|
||||
const_cast<volScalarField&>(lookupObject<volScalarField>(outputName));
|
||||
volScalarField& output = lookupObjectRef<volScalarField>(outputName);
|
||||
|
||||
if (mag_)
|
||||
{
|
||||
|
||||
@ -57,12 +57,8 @@ bool Foam::functionObjects::enstrophy::calc()
|
||||
0.5*magSqr(fvc::curl(lookupObject<volVectorField>(fieldName_)))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "externalCoupled.H"
|
||||
#include "stringListOps.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "OSspecific.H"
|
||||
#include "Fstream.H"
|
||||
@ -415,7 +416,7 @@ void Foam::functionObjects::externalCoupled::initCoupling()
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, regi)
|
||||
{
|
||||
meshes.set(regi, time_.lookupObjectPtr<fvMesh>(regionNames[regi]));
|
||||
meshes.set(regi, time_.findObject<fvMesh>(regionNames[regi]));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
@ -575,17 +576,17 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
wordList allRegionNames(time_.lookupClass<fvMesh>().sortedToc());
|
||||
|
||||
const dictionary& allRegionsDict = dict.subDict("regions");
|
||||
forAllConstIters(allRegionsDict, iter)
|
||||
for (const entry& dEntry : allRegionsDict)
|
||||
{
|
||||
if (!iter().isDict())
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
FatalIOErrorInFunction(allRegionsDict)
|
||||
<< "Regions must be specified in dictionary format"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
const wordRe regionGroupName(iter().keyword());
|
||||
const dictionary& regionDict = iter().dict();
|
||||
const wordRe regionGroupName(dEntry.keyword());
|
||||
const dictionary& regionDict = dEntry.dict();
|
||||
|
||||
labelList regionIDs = findStrings(regionGroupName, allRegionNames);
|
||||
|
||||
@ -594,20 +595,21 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
regionGroupNames_.append(compositeName(regionNames));
|
||||
regionGroupRegions_.append(regionNames);
|
||||
|
||||
forAllConstIters(regionDict, regionIter)
|
||||
for (const entry& dEntry : regionDict)
|
||||
{
|
||||
if (!regionIter().isDict())
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
FatalIOErrorInFunction(regionDict)
|
||||
<< "Regions must be specified in dictionary format"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
const wordRe groupName(regionIter().keyword());
|
||||
const dictionary& groupDict = regionIter().dict();
|
||||
|
||||
const wordRe groupName(dEntry.keyword());
|
||||
const dictionary& groupDict = dEntry.dict();
|
||||
|
||||
const label nGroups = groupNames_.size();
|
||||
const wordList readFields(groupDict.lookup("readFields"));
|
||||
const wordList writeFields(groupDict.lookup("writeFields"));
|
||||
const wordList readFields(groupDict.get<wordList>("readFields"));
|
||||
const wordList writeFields(groupDict.get<wordList>("writeFields"));
|
||||
|
||||
auto fnd = regionToGroups_.find(regionGroupNames_.last());
|
||||
if (fnd.found())
|
||||
@ -619,7 +621,7 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
regionToGroups_.insert
|
||||
(
|
||||
regionGroupNames_.last(),
|
||||
labelList{nGroups}
|
||||
labelList(one(), nGroups)
|
||||
);
|
||||
}
|
||||
groupNames_.append(groupName);
|
||||
@ -692,7 +694,7 @@ void Foam::functionObjects::externalCoupled::readDataMaster()
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, regi)
|
||||
{
|
||||
meshes.set(regi, time_.lookupObjectPtr<fvMesh>(regionNames[regi]));
|
||||
meshes.set(regi, time_.findObject<fvMesh>(regionNames[regi]));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
@ -736,7 +738,7 @@ void Foam::functionObjects::externalCoupled::writeDataMaster() const
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, regi)
|
||||
{
|
||||
meshes.set(regi, time_.lookupObjectPtr<fvMesh>(regionNames[regi]));
|
||||
meshes.set(regi, time_.findObject<fvMesh>(regionNames[regi]));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
|
||||
@ -95,14 +95,6 @@ externalCoupledMixedFvPatchField
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::externalCoupledMixedFvPatchField<Type>::
|
||||
~externalCoupledMixedFvPatchField()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
||||
@ -146,19 +146,19 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~externalCoupledMixedFvPatchField();
|
||||
virtual ~externalCoupledMixedFvPatchField() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Write header
|
||||
virtual void writeHeader(Ostream&) const;
|
||||
virtual void writeHeader(Ostream& os) const;
|
||||
|
||||
//- Write data
|
||||
virtual void writeData(Ostream&) const;
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
//- Read data
|
||||
virtual void readData(Istream&);
|
||||
virtual void readData(Istream& is);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,21 @@ License
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::externalCoupledTemperatureMixedFvPatchScalarField::
|
||||
outputTemperatureType
|
||||
>
|
||||
Foam::externalCoupledTemperatureMixedFvPatchScalarField::outputTemperatureNames
|
||||
({
|
||||
{ outputTemperatureType::FLUID, "fluid" },
|
||||
{ outputTemperatureType::WALL, "wall" },
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -36,7 +51,14 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "# Values: magSf T qDot htc" << endl;
|
||||
if (outputTemperature_ == outputTemperatureType::FLUID)
|
||||
{
|
||||
os << "# Values: area Tfluid qDot htc" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "# Values: area Twall qDot htc" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +71,8 @@ externalCoupledTemperatureMixedFvPatchScalarField
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
externalCoupledMixedFvPatchField<scalar>(p, iF)
|
||||
externalCoupledMixedFvPatchField<scalar>(p, iF),
|
||||
outputTemperature_(outputTemperatureType::WALL)
|
||||
{}
|
||||
|
||||
|
||||
@ -62,7 +85,8 @@ externalCoupledTemperatureMixedFvPatchScalarField
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
externalCoupledMixedFvPatchField<scalar>(ptf, p, iF, mapper)
|
||||
externalCoupledMixedFvPatchField<scalar>(ptf, p, iF, mapper),
|
||||
outputTemperature_(ptf.outputTemperature_)
|
||||
{}
|
||||
|
||||
|
||||
@ -75,8 +99,23 @@ externalCoupledTemperatureMixedFvPatchScalarField
|
||||
)
|
||||
:
|
||||
//externalCoupledMixedFvPatchField<scalar>(p, iF, dict)
|
||||
externalCoupledMixedFvPatchField<scalar>(p, iF)
|
||||
externalCoupledMixedFvPatchField<scalar>(p, iF),
|
||||
outputTemperature_(outputTemperatureType::WALL)
|
||||
{
|
||||
if (dict.found("outputTemperature"))
|
||||
{
|
||||
outputTemperature_ =
|
||||
outputTemperatureNames.get("outputTemperature", dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "outputTemperature not specified "
|
||||
<< flatOutput(outputTemperatureNames) << nl
|
||||
<< "using 'wall' as compatibility default" << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (dict.found("refValue"))
|
||||
{
|
||||
// Initialise same way as mixed
|
||||
@ -116,7 +155,8 @@ externalCoupledTemperatureMixedFvPatchScalarField
|
||||
const externalCoupledTemperatureMixedFvPatchScalarField& ecmpf
|
||||
)
|
||||
:
|
||||
externalCoupledMixedFvPatchField<scalar>(ecmpf)
|
||||
externalCoupledMixedFvPatchField<scalar>(ecmpf),
|
||||
outputTemperature_(ecmpf.outputTemperature_)
|
||||
{}
|
||||
|
||||
|
||||
@ -127,14 +167,8 @@ externalCoupledTemperatureMixedFvPatchScalarField
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
externalCoupledMixedFvPatchField<scalar>(ecmpf, iF)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::externalCoupledTemperatureMixedFvPatchScalarField::
|
||||
~externalCoupledTemperatureMixedFvPatchScalarField()
|
||||
externalCoupledMixedFvPatchField<scalar>(ecmpf, iF),
|
||||
outputTemperature_(ecmpf.outputTemperature_)
|
||||
{}
|
||||
|
||||
|
||||
@ -148,7 +182,7 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData
|
||||
const label patchi = patch().index();
|
||||
|
||||
// Heat flux [W/m2]
|
||||
scalarField qDot(this->patch().size(), 0.0);
|
||||
scalarField qDot(this->patch().size(), Zero);
|
||||
|
||||
typedef compressible::turbulenceModel cmpTurbModelType;
|
||||
|
||||
@ -189,10 +223,11 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData
|
||||
<< "thermo model to be available" << exit(FatalError);
|
||||
}
|
||||
|
||||
// Patch temperature [K]
|
||||
|
||||
// Patch (wall) temperature [K]
|
||||
const scalarField& Tp(*this);
|
||||
|
||||
// Near wall cell temperature [K]
|
||||
// Near wall cell (fluid) temperature [K]
|
||||
const scalarField Tc(patchInternalField());
|
||||
|
||||
// Heat transfer coefficient [W/m2/K]
|
||||
@ -200,13 +235,19 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData
|
||||
|
||||
const Field<scalar>& magSf(this->patch().magSf());
|
||||
|
||||
const UList<scalar>& Tout =
|
||||
(
|
||||
outputTemperature_ == outputTemperatureType::FLUID
|
||||
? Tc
|
||||
: Tp
|
||||
);
|
||||
|
||||
forAll(patch(), facei)
|
||||
{
|
||||
os << magSf[facei] << token::SPACE
|
||||
<< Tp[facei] << token::SPACE
|
||||
<< Tout[facei] << token::SPACE
|
||||
<< qDot[facei] << token::SPACE
|
||||
<< htc[facei] << token::SPACE
|
||||
<< nl;
|
||||
<< htc[facei] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,6 +276,20 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::readData
|
||||
}
|
||||
|
||||
|
||||
void Foam::externalCoupledTemperatureMixedFvPatchScalarField::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
externalCoupledMixedFvPatchField::write(os);
|
||||
os.writeEntry
|
||||
(
|
||||
"outputTemperature",
|
||||
outputTemperatureNames[outputTemperature_]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -87,6 +87,14 @@ Description
|
||||
To be used in combination with the functionObjects::externalCoupled
|
||||
functionObject.
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
outputTemperature | The output temperature: fluid/wall | yes |
|
||||
\endtable
|
||||
|
||||
Note the
|
||||
|
||||
SeeAlso
|
||||
externalCoupledFunctionObject
|
||||
mixedFvPatchField
|
||||
@ -101,6 +109,7 @@ SourceFiles
|
||||
#define externalCoupledTemperatureMixedFvPatchScalarField_H
|
||||
|
||||
#include "externalCoupledMixedFvPatchFields.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -115,6 +124,24 @@ class externalCoupledTemperatureMixedFvPatchScalarField
|
||||
:
|
||||
public externalCoupledMixedFvPatchField<scalar>
|
||||
{
|
||||
// Data Types
|
||||
|
||||
//- Location for the ouput temperature
|
||||
enum outputTemperatureType
|
||||
{
|
||||
FLUID, //!< Use fluid (cell) temperature
|
||||
WALL //!< Use wall (patch) temperature
|
||||
};
|
||||
|
||||
//- Names for outputTemperatureType
|
||||
static const Enum<outputTemperatureType> outputTemperatureNames;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Location for the ouput temperature
|
||||
enum outputTemperatureType outputTemperature_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -189,19 +216,22 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~externalCoupledTemperatureMixedFvPatchScalarField();
|
||||
virtual ~externalCoupledTemperatureMixedFvPatchScalarField() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Write header
|
||||
virtual void writeHeader(Ostream&) const;
|
||||
virtual void writeHeader(Ostream& os) const;
|
||||
|
||||
//- Write data
|
||||
virtual void writeData(Ostream&) const;
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
//- Read data
|
||||
virtual void readData(Istream&);
|
||||
virtual void readData(Istream& is);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -82,8 +82,7 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
label nFound = 0;
|
||||
for (const fvMesh& mesh : meshes)
|
||||
{
|
||||
const volFieldType* vfptr =
|
||||
mesh.lookupObjectPtr<volFieldType>(fieldName);
|
||||
const volFieldType* vfptr = mesh.findObject<volFieldType>(fieldName);
|
||||
|
||||
if (!vfptr)
|
||||
{
|
||||
@ -278,8 +277,8 @@ Foam::functionObjects::externalCoupled::gatherAndCombine
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
|
||||
tmp<Field<Type>> tresult(new Field<Type>(0));
|
||||
Field<Type>& result = tresult.ref();
|
||||
auto tresult = tmp<Field<Type>>::New();
|
||||
auto& result = tresult.ref();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
@ -358,8 +357,7 @@ bool Foam::functionObjects::externalCoupled::writeData
|
||||
|
||||
for (const fvMesh& mesh : meshes)
|
||||
{
|
||||
const volFieldType* vfptr =
|
||||
mesh.lookupObjectPtr<volFieldType>(fieldName);
|
||||
const volFieldType* vfptr = mesh.findObject<volFieldType>(fieldName);
|
||||
|
||||
if (!vfptr)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,26 +54,6 @@ namespace functionObjects
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName
|
||||
Foam::functionObjects::extractEulerianParticles::dictBaseFileDir() const
|
||||
{
|
||||
fileName baseDir(".."); // = mesh_.time().path();
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
baseDir = baseDir/".."/functionObject::outputPrefix;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseDir = baseDir/functionObject::outputPrefix;
|
||||
}
|
||||
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::extractEulerianParticles::checkFaceZone()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
@ -264,214 +244,163 @@ void Foam::functionObjects::extractEulerianParticles::setBlockedFaces
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::extractEulerianParticles::collectParticles
|
||||
void Foam::functionObjects::extractEulerianParticles::collectParticle
|
||||
(
|
||||
const scalar time,
|
||||
const boolList& collectParticle
|
||||
const label regioni
|
||||
)
|
||||
{
|
||||
DebugInFunction << "collectParticle: " << collectParticle << endl;
|
||||
DebugInFunction << "collectParticle: " << regioni << endl;
|
||||
|
||||
// Collect particles on local processors that have passed through faceZone
|
||||
forAll(collectParticle, regioni)
|
||||
const label particlei = regionToParticleMap_[regioni];
|
||||
eulerianParticle p = particles_[particlei];
|
||||
|
||||
if (p.faceIHit != -1 && nInjectorLocations_)
|
||||
{
|
||||
if (!collectParticle[regioni])
|
||||
// Use coarse face index for tag output
|
||||
label coarseFacei = fineToCoarseAddr_[p.faceIHit];
|
||||
p.faceIHit = globalCoarseFaces_.toGlobal(coarseFacei);
|
||||
}
|
||||
|
||||
reduce(p, sumParticleOp<eulerianParticle>());
|
||||
|
||||
const scalar pDiameter = cbrt(6.0*p.V/constant::mathematical::pi);
|
||||
|
||||
if ((pDiameter > minDiameter_) && (pDiameter < maxDiameter_))
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<label>::const_iterator iter = regionToParticleMap_.find(regioni);
|
||||
eulerianParticle p = particles_[iter()];
|
||||
|
||||
if (p.faceIHit != -1 && nInjectorLocations_)
|
||||
{
|
||||
// Use coarse face index for tag output
|
||||
label coarseFacei = fineToCoarseAddr_[p.faceIHit];
|
||||
p.faceIHit = globalCoarseFaces_.toGlobal(coarseFacei);
|
||||
}
|
||||
|
||||
reduce(p, sumParticleOp<eulerianParticle>());
|
||||
|
||||
const scalar pDiameter = cbrt(6.0*p.V/constant::mathematical::pi);
|
||||
|
||||
if ((pDiameter > minDiameter_) && (pDiameter < maxDiameter_))
|
||||
{
|
||||
if (Pstream::master())
|
||||
const scalar d = cbrt(6*p.V/constant::mathematical::pi);
|
||||
const point position = p.VC/(p.V + ROOTVSMALL);
|
||||
const vector U = p.VU/(p.V + ROOTVSMALL);
|
||||
label tag = -1;
|
||||
if (nInjectorLocations_)
|
||||
{
|
||||
const scalar d = cbrt(6*p.V/constant::mathematical::pi);
|
||||
const point position = p.VC/(p.V + ROOTVSMALL);
|
||||
const vector U = p.VU/(p.V + ROOTVSMALL);
|
||||
label tag = -1;
|
||||
if (nInjectorLocations_)
|
||||
{
|
||||
tag = p.faceIHit;
|
||||
}
|
||||
|
||||
injectedParticle* ip = new injectedParticle
|
||||
(
|
||||
mesh_,
|
||||
position,
|
||||
tag,
|
||||
time,
|
||||
d,
|
||||
U,
|
||||
false // not looking to set cell owner etc.
|
||||
);
|
||||
|
||||
cloud_.addParticle(ip);
|
||||
tag = p.faceIHit;
|
||||
}
|
||||
|
||||
nCollectedParticles_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Discard particles over/under diameter threshold
|
||||
nDiscardedParticles_++;
|
||||
discardedVolume_ += p.V;
|
||||
injectedParticle* ip = new injectedParticle
|
||||
(
|
||||
mesh_,
|
||||
position,
|
||||
tag,
|
||||
time,
|
||||
d,
|
||||
U,
|
||||
false // not looking to set cell owner etc.
|
||||
);
|
||||
|
||||
cloud_.addParticle(ip);
|
||||
|
||||
collectedVolume_ += p.V;
|
||||
}
|
||||
|
||||
++nCollectedParticles_;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Discard particles over/under diameter threshold
|
||||
++nDiscardedParticles_;
|
||||
discardedVolume_ += p.V;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::extractEulerianParticles::calculateAddressing
|
||||
(
|
||||
const label nRegionsOld,
|
||||
const label nRegionsNew,
|
||||
const label nNewRegions,
|
||||
const scalar time,
|
||||
labelList& regionFaceIDs
|
||||
)
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
// New region can only point to one old region
|
||||
// Old region can only point to one new region. If old region intersects
|
||||
// multiple new regions, select max of new region indices.
|
||||
|
||||
labelList oldToNewRegion(nRegionsOld, -1);
|
||||
labelList newToOldRegion(nRegionsNew, -1);
|
||||
// Determine mapping between old and new regions so that we can
|
||||
// accumulate particle info
|
||||
labelList oldToNewRegion(particles_.size(), -1);
|
||||
labelList newToNewRegion(identity(nNewRegions));
|
||||
|
||||
forAll(regionFaceIDs, facei)
|
||||
{
|
||||
label newRegioni = regionFaceIDs[facei];
|
||||
label oldRegioni = regions0_[facei];
|
||||
|
||||
if (newRegioni != -1)
|
||||
if (newRegioni != -1 && oldRegioni != -1)
|
||||
{
|
||||
newToOldRegion[newRegioni] = oldRegioni;
|
||||
|
||||
if (oldRegioni != -1)
|
||||
{
|
||||
// New region linked to old (so can accumulate particle data)
|
||||
// Old region might already be mapped to a new region
|
||||
oldToNewRegion[oldRegioni] =
|
||||
max(newRegioni, oldToNewRegion[oldRegioni]);
|
||||
}
|
||||
// If old region has split into multiple regions we need to
|
||||
// renumber new regions to maintain connectivity with old regions
|
||||
newToNewRegion[newRegioni] =
|
||||
max(newRegioni, oldToNewRegion[oldRegioni]);
|
||||
oldToNewRegion[oldRegioni] = newRegioni;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to re-number the new region indices based on knowledge of which
|
||||
// old region they intersect. After operations, there should be a
|
||||
// one-to-one match between the old and new regions.
|
||||
// Create map from new regions to slots in particles list
|
||||
// - filter through new-to-new addressing to identify new particles
|
||||
Pstream::listCombineGather(newToNewRegion, maxEqOp<label>());
|
||||
Pstream::listCombineScatter(newToNewRegion);
|
||||
|
||||
// Ensure all old regions point to the same new regions (if present)
|
||||
label nParticle = -1;
|
||||
labelHashSet newRegions;
|
||||
Map<label> newRegionToParticleMap;
|
||||
forAll(newToNewRegion, newRegioni0)
|
||||
{
|
||||
label newRegioni = newToNewRegion[newRegioni0];
|
||||
if (newRegions.insert(newRegioni))
|
||||
{
|
||||
++nParticle;
|
||||
}
|
||||
|
||||
// New particle slot
|
||||
newRegionToParticleMap.insert(newRegioni0, nParticle);
|
||||
}
|
||||
|
||||
// Accumulate old region data or create a new particle if there is no
|
||||
// mapping from the old-to-new region
|
||||
Pstream::listCombineGather(oldToNewRegion, maxEqOp<label>());
|
||||
Pstream::listCombineScatter(oldToNewRegion);
|
||||
|
||||
// Any new region that points to an old region should be renumbered to the
|
||||
// new region specified by the oldToNewRegion index
|
||||
|
||||
if (oldToNewRegion.size())
|
||||
List<eulerianParticle> newParticles(newRegionToParticleMap.size());
|
||||
forAll(oldToNewRegion, oldRegioni)
|
||||
{
|
||||
// Create corrected new to new addressing
|
||||
labelList newToNewRegionCorr(newToOldRegion.size(), -1);
|
||||
forAll(newToOldRegion, newRegioni)
|
||||
label newRegioni = oldToNewRegion[oldRegioni];
|
||||
if (newRegioni == -1)
|
||||
{
|
||||
label oldRegioni = newToOldRegion[newRegioni];
|
||||
if (oldRegioni != -1)
|
||||
{
|
||||
label newRegionICorr = oldToNewRegion[oldRegioni];
|
||||
newToNewRegionCorr[newRegioni] = newRegionICorr;
|
||||
newToOldRegion[newRegioni] = oldRegioni;
|
||||
}
|
||||
}
|
||||
// No mapping from old-to-new - collect new particle
|
||||
DebugInfo
|
||||
<< "Collecting particle from oldRegion:" << oldRegioni
|
||||
<< endl;
|
||||
|
||||
// Renumber the new (current) face region IDs
|
||||
forAll(regionFaceIDs, facei)
|
||||
{
|
||||
label newRegioni = regionFaceIDs[facei];
|
||||
|
||||
if (newRegioni != -1)
|
||||
{
|
||||
label newRegionICorr = newToNewRegionCorr[newRegioni];
|
||||
|
||||
// Note: newRegionICorr can be -1 if the region is new, since
|
||||
// the address corrections are based on inverting the
|
||||
// old-to-new addressing
|
||||
if (newRegionICorr != -1)
|
||||
{
|
||||
regionFaceIDs[facei] = newRegionICorr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolList collectParticleFlag(nRegionsOld, true);
|
||||
forAll(oldToNewRegion, oldRegioni)
|
||||
{
|
||||
label newRegioni = oldToNewRegion[oldRegioni];
|
||||
if (newRegioni != -1)
|
||||
{
|
||||
collectParticleFlag[oldRegioni] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Collect particles whose IDs are no longer active
|
||||
collectParticles(time, collectParticleFlag);
|
||||
}
|
||||
|
||||
|
||||
// Re-order collection bins
|
||||
|
||||
Map<label> newRegionToParticleMap(nRegionsNew);
|
||||
List<eulerianParticle> newParticles(nRegionsNew);
|
||||
label particlei = 0;
|
||||
|
||||
forAll(newToOldRegion, newRegioni)
|
||||
{
|
||||
label oldRegioni = newToOldRegion[newRegioni];
|
||||
if (oldRegioni == -1)
|
||||
{
|
||||
// No mapping from old to new - this is a new particle
|
||||
newRegionToParticleMap.insert(newRegioni, particlei);
|
||||
particlei++;
|
||||
collectParticle(time, oldRegioni);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update addressing for old to new regions
|
||||
// Combine existing particle into new particle
|
||||
label newParticlei = newRegionToParticleMap[newRegioni];
|
||||
label oldParticlei = regionToParticleMap_[oldRegioni];
|
||||
if (newRegionToParticleMap.insert(newRegioni, particlei))
|
||||
{
|
||||
// First time this particle has been seen
|
||||
newParticles[particlei] = particles_[oldParticlei];
|
||||
particlei++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Combine with existing contribution
|
||||
label newParticlei = newRegionToParticleMap[newRegioni];
|
||||
newParticles[newParticlei] =
|
||||
sumParticleOp<eulerianParticle>()
|
||||
(
|
||||
newParticles[newParticlei],
|
||||
particles_[oldParticlei]
|
||||
);
|
||||
}
|
||||
|
||||
DebugInfo
|
||||
<< "Combining newRegioni: " << newRegioni
|
||||
<< "(p:" << newParticlei << ") and "
|
||||
<< "oldRegioni: " << oldRegioni
|
||||
<< "(p:" << oldParticlei << ")"
|
||||
<< endl;
|
||||
|
||||
newParticles[newParticlei] =
|
||||
sumParticleOp<eulerianParticle>()
|
||||
(
|
||||
newParticles[newParticlei],
|
||||
particles_[oldParticlei]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the particles list and addressing for latest available info
|
||||
particles_.transfer(newParticles);
|
||||
regionToParticleMap_ = newRegionToParticleMap;
|
||||
|
||||
// Reset the region IDs for the next integration step
|
||||
// - these become the oldRegioni's
|
||||
regions0_ = regionFaceIDs;
|
||||
}
|
||||
|
||||
|
||||
@ -494,7 +423,6 @@ void Foam::functionObjects::extractEulerianParticles::accumulateParticleInfo
|
||||
forAll(regionFaceIDs, localFacei)
|
||||
{
|
||||
const label newRegioni = regionFaceIDs[localFacei];
|
||||
|
||||
if (newRegioni != -1)
|
||||
{
|
||||
const label particlei = regionToParticleMap_[newRegioni];
|
||||
@ -547,14 +475,14 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
||||
fineToCoarseAddr_(),
|
||||
globalCoarseFaces_(),
|
||||
regions0_(),
|
||||
nRegions0_(0),
|
||||
particles_(),
|
||||
regionToParticleMap_(),
|
||||
minDiameter_(ROOTVSMALL),
|
||||
maxDiameter_(GREAT),
|
||||
nCollectedParticles_(0),
|
||||
nDiscardedParticles_(0),
|
||||
discardedVolume_(0)
|
||||
nCollectedParticles_(getProperty<label>("nCollectedParticles", 0)),
|
||||
collectedVolume_(getProperty<scalar>("collectedVolume", 0)),
|
||||
nDiscardedParticles_(getProperty<label>("nDiscardedParticles", 0)),
|
||||
discardedVolume_(getProperty<scalar>("discardedVolume", 0))
|
||||
{
|
||||
if (mesh_.nSolutionD() != 3)
|
||||
{
|
||||
@ -567,12 +495,6 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::extractEulerianParticles::~extractEulerianParticles()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::extractEulerianParticles::read
|
||||
@ -584,8 +506,8 @@ bool Foam::functionObjects::extractEulerianParticles::read
|
||||
|
||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||
{
|
||||
dict.lookup("faceZone") >> faceZoneName_;
|
||||
dict.lookup("alpha") >> alphaName_;
|
||||
dict.readEntry("faceZone", faceZoneName_);
|
||||
dict.readEntry("alpha", alphaName_);
|
||||
|
||||
dict.readIfPresent("alphaThreshold", alphaThreshold_);
|
||||
dict.readIfPresent("U", UName_);
|
||||
@ -644,9 +566,9 @@ bool Foam::functionObjects::extractEulerianParticles::execute()
|
||||
|
||||
// Calculate the addressing between the old and new region information
|
||||
// Also collects particles that have traversed the faceZone
|
||||
// - Note: may also update regionFaceIDs
|
||||
calculateAddressing
|
||||
(
|
||||
nRegions0_,
|
||||
nRegionsNew,
|
||||
mesh_.time().value(),
|
||||
regionFaceIDs
|
||||
@ -656,13 +578,11 @@ bool Foam::functionObjects::extractEulerianParticles::execute()
|
||||
tmp<surfaceScalarField> tphi = phiU();
|
||||
accumulateParticleInfo(alphaf, tphi(), regionFaceIDs, fz);
|
||||
|
||||
// Reset the blocked faces for the next integration step
|
||||
nRegions0_ = nRegionsNew;
|
||||
regions0_ = regionFaceIDs;
|
||||
|
||||
Log << " Collected particles: " << nCollectedParticles_ << nl
|
||||
<< " Discarded particles: " << nDiscardedParticles_ << nl
|
||||
<< " Discarded volume: " << discardedVolume_ << nl
|
||||
Log << " Collected particles : " << nCollectedParticles_ << nl
|
||||
<< " Collected volume : " << collectedVolume_ << nl
|
||||
<< " Discarded particles : " << nDiscardedParticles_ << nl
|
||||
<< " Discarded volume : " << discardedVolume_ << nl
|
||||
<< " Particles in progress : " << particles_.size() << nl
|
||||
<< endl;
|
||||
|
||||
return true;
|
||||
@ -675,6 +595,11 @@ bool Foam::functionObjects::extractEulerianParticles::write()
|
||||
|
||||
cloud_.write();
|
||||
|
||||
setProperty("nCollectedParticles", nCollectedParticles_);
|
||||
setProperty("collectedVolume", collectedVolume_);
|
||||
setProperty("nDiscardedParticles", nDiscardedParticles_);
|
||||
setProperty("discardedVolume", discardedVolume_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,6 +23,7 @@ License
|
||||
|
||||
Class
|
||||
Foam::functionObjects::extractEulerianParticles
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
@ -73,10 +74,8 @@ SourceFiles
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "polyMesh.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "vectorList.H"
|
||||
#include "globalIndex.H"
|
||||
#include "eulerianParticle.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "injectedParticleCloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -153,9 +152,6 @@ protected:
|
||||
//- Region indices in faceZone faces from last iteration
|
||||
labelList regions0_;
|
||||
|
||||
//- Number of regions from last iteration
|
||||
label nRegions0_;
|
||||
|
||||
//- Particle properties (partial, being accumulated)
|
||||
List<eulerianParticle> particles_;
|
||||
|
||||
@ -176,6 +172,9 @@ protected:
|
||||
//- Total number of collected particles
|
||||
label nCollectedParticles_;
|
||||
|
||||
//- Total collected volume [m3]
|
||||
scalar collectedVolume_;
|
||||
|
||||
//- Total number of discarded particles
|
||||
label nDiscardedParticles_;
|
||||
|
||||
@ -185,9 +184,6 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return the base directory for dictionary output
|
||||
virtual fileName dictBaseFileDir() const;
|
||||
|
||||
//- Check that the faceZone is valid
|
||||
virtual void checkFaceZone();
|
||||
|
||||
@ -206,19 +202,19 @@ protected:
|
||||
);
|
||||
|
||||
//- Calculate the addressing between regions between iterations
|
||||
//- Returns the number of active regions (particles)
|
||||
virtual void calculateAddressing
|
||||
(
|
||||
const label nRegionsOld,
|
||||
const label nRegionsNew,
|
||||
const scalar time,
|
||||
labelList& regionFaceIDs
|
||||
);
|
||||
|
||||
//- Collect particles that have passed through the faceZone
|
||||
virtual void collectParticles
|
||||
virtual void collectParticle
|
||||
(
|
||||
const scalar time,
|
||||
const boolList& collectParticle
|
||||
const label regioni
|
||||
);
|
||||
|
||||
//- Process latest region information
|
||||
@ -265,7 +261,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~extractEulerianParticles();
|
||||
virtual ~extractEulerianParticles() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -305,13 +305,13 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
dict.readIfPresent("restartOnRestart", restartOnRestart_);
|
||||
dict.readIfPresent("restartOnOutput", restartOnOutput_);
|
||||
dict.readIfPresent("periodicRestart", periodicRestart_);
|
||||
dict.lookup("fields") >> faItems_;
|
||||
dict.readEntry("fields", faItems_);
|
||||
|
||||
const scalar currentTime = obr().time().value();
|
||||
|
||||
if (periodicRestart_)
|
||||
{
|
||||
scalar userRestartPeriod = readScalar(dict.lookup("restartPeriod"));
|
||||
scalar userRestartPeriod = dict.get<scalar>("restartPeriod");
|
||||
restartPeriod_ = obr().time().userTimeToTime(userRestartPeriod);
|
||||
|
||||
if (restartPeriod_ > 0)
|
||||
|
||||
@ -44,10 +44,10 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldAverageItem::baseType
|
||||
>
|
||||
Foam::functionObjects::fieldAverageItem::baseTypeNames_
|
||||
{
|
||||
({
|
||||
{ baseType::ITER, "iteration" },
|
||||
{ baseType::TIME, "time" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
@ -55,11 +55,11 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldAverageItem::windowType
|
||||
>
|
||||
Foam::functionObjects::fieldAverageItem::windowTypeNames_
|
||||
{
|
||||
({
|
||||
{ windowType::NONE, "none" },
|
||||
{ windowType::APPROXIMATE, "approximate" },
|
||||
{ windowType::EXACT, "exact" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -192,13 +192,13 @@ void Foam::functionObjects::fieldAverageItem::clear
|
||||
|
||||
bool Foam::functionObjects::fieldAverageItem::readState(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("totalIter") >> totalIter_;
|
||||
dict.lookup("totalTime") >> totalTime_;
|
||||
dict.readEntry("totalIter", totalIter_);
|
||||
dict.readEntry("totalTime", totalTime_);
|
||||
|
||||
if (window_ > 0)
|
||||
{
|
||||
dict.lookup("windowTimes") >> windowTimes_;
|
||||
dict.lookup("windowFieldNames") >> windowFieldNames_;
|
||||
dict.readEntry("windowTimes", windowTimes_);
|
||||
dict.readEntry("windowFieldNames", windowFieldNames_);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -62,19 +62,19 @@ Foam::Istream& Foam::functionObjects::operator>>
|
||||
{
|
||||
is.check(FUNCTION_NAME);
|
||||
|
||||
const dictionaryEntry entry(dictionary::null, is);
|
||||
const dictionaryEntry dictEntry(dictionary::null, is);
|
||||
const dictionary& dict = dictEntry.dict();
|
||||
|
||||
faItem.active_ = false;
|
||||
faItem.fieldName_ = entry.keyword();
|
||||
faItem.mean_ = readBool(entry.lookup("mean"));
|
||||
faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean"));
|
||||
faItem.base_ = faItem.baseTypeNames_.lookup("base", entry);
|
||||
faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
|
||||
faItem.fieldName_ = dictEntry.keyword();
|
||||
faItem.mean_ = dict.get<bool>("mean");
|
||||
faItem.prime2Mean_ = dict.get<bool>("prime2Mean");
|
||||
faItem.base_ = faItem.baseTypeNames_.get("base", dict);
|
||||
faItem.window_ = dict.lookupOrDefault<scalar>("window", -1.0);
|
||||
|
||||
if (faItem.window_ > 0)
|
||||
{
|
||||
faItem.windowType_ =
|
||||
faItem.windowTypeNames_.lookup("windowType", entry);
|
||||
faItem.windowType_ = faItem.windowTypeNames_.get("windowType", dict);
|
||||
|
||||
if (faItem.windowType_ != fieldAverageItem::windowType::NONE)
|
||||
{
|
||||
@ -84,17 +84,17 @@ Foam::Istream& Foam::functionObjects::operator>>
|
||||
&& label(faItem.window_) < 1
|
||||
)
|
||||
{
|
||||
FatalIOErrorInFunction(entry)
|
||||
FatalIOErrorInFunction(dictEntry)
|
||||
<< "Window must be 1 or more for base type "
|
||||
<< faItem.baseTypeNames_[fieldAverageItem::baseType::ITER]
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");
|
||||
faItem.windowName_ = dict.lookupOrDefault<word>("windowName", "");
|
||||
|
||||
if (faItem.windowType_ == fieldAverageItem::windowType::EXACT)
|
||||
{
|
||||
faItem.allowRestart_ = readBool(entry.lookup("allowRestart"));
|
||||
faItem.allowRestart_ = dict.get<bool>("allowRestart");
|
||||
|
||||
if (!faItem.allowRestart_)
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@ bool Foam::functionObjects::fieldAverageItem::calculateMeanField
|
||||
return false;
|
||||
}
|
||||
|
||||
const Type* baseFieldPtr = obr.lookupObjectPtr<Type>(fieldName_);
|
||||
const Type* baseFieldPtr = obr.findObject<Type>(fieldName_);
|
||||
|
||||
if (!baseFieldPtr)
|
||||
{
|
||||
@ -122,7 +122,7 @@ bool Foam::functionObjects::fieldAverageItem::calculateMeanField
|
||||
{
|
||||
const word& fieldName = nameIter();
|
||||
const scalar dt = timeIter();
|
||||
const Type* w = obr.lookupObjectPtr<Type>(fieldName);
|
||||
const Type* w = obr.findObject<Type>(fieldName);
|
||||
|
||||
meanField += dt*(*w);
|
||||
|
||||
@ -173,7 +173,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
|
||||
return false;
|
||||
}
|
||||
|
||||
const Type1* baseFieldPtr = obr.lookupObjectPtr<Type1>(fieldName_);
|
||||
const Type1* baseFieldPtr = obr.findObject<Type1>(fieldName_);
|
||||
|
||||
if (!baseFieldPtr)
|
||||
{
|
||||
@ -258,7 +258,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
|
||||
{
|
||||
const word& fieldName = nameIter();
|
||||
const scalar dt = timeIter();
|
||||
const Type1* w = obr.lookupObjectPtr<Type1>(fieldName);
|
||||
const Type1* w = obr.findObject<Type1>(fieldName);
|
||||
|
||||
prime2MeanField += dt*(sqr((*w) - meanField));
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ void Foam::functionObjects::fieldAverage::restoreWindowFieldsType
|
||||
|
||||
const word& fieldName = item.fieldName();
|
||||
|
||||
const Type* fieldPtr = lookupObjectPtr<Type>(fieldName);
|
||||
const Type* fieldPtr = findObject<Type>(fieldName);
|
||||
|
||||
if (!fieldPtr)
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,23 +56,20 @@ fieldCoordinateSystemTransform
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_(mesh_),
|
||||
coordSys_(mesh_, dict.subDict("coordinateSystem"))
|
||||
csysPtr_
|
||||
(
|
||||
coordinateSystem::New(mesh_, dict, coordinateSystem::typeName_())
|
||||
)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
Info<< type() << " " << name << ":" << nl
|
||||
<< " Applying transformation from global Cartesian to local "
|
||||
<< coordSys_ << nl << endl;
|
||||
<< " Applying " << (csysPtr_->uniform() ? "" : "non-")
|
||||
<< "uniform transformation from global Cartesian to local "
|
||||
<< *csysPtr_ << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::
|
||||
~fieldCoordinateSystemTransform()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word
|
||||
@ -85,6 +82,96 @@ Foam::functionObjects::fieldCoordinateSystemTransform::transformFieldName
|
||||
}
|
||||
|
||||
|
||||
const Foam::surfaceTensorField&
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor() const
|
||||
{
|
||||
typedef surfaceTensorField FieldType;
|
||||
typedef surfaceTensorField::Boundary BoundaryType;
|
||||
|
||||
if (!rotTensorSurface_.valid())
|
||||
{
|
||||
tensorField rotations(csysPtr_->R(mesh_.faceCentres()));
|
||||
|
||||
rotTensorSurface_.reset
|
||||
(
|
||||
new FieldType
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"surfRotation",
|
||||
mesh_.objectRegistry::instance(),
|
||||
mesh_.objectRegistry::db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false // no register
|
||||
),
|
||||
mesh_,
|
||||
dimless,
|
||||
std::move(rotations)
|
||||
// calculatedType
|
||||
)
|
||||
);
|
||||
|
||||
auto& rot = *rotTensorSurface_;
|
||||
|
||||
// Boundaries
|
||||
BoundaryType& bf = const_cast<BoundaryType&>(rot.boundaryField());
|
||||
|
||||
forAll(bf, patchi)
|
||||
{
|
||||
bf[patchi] = csysPtr_->R(bf[patchi].patch().patch().faceCentres());
|
||||
}
|
||||
}
|
||||
|
||||
return *rotTensorSurface_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::volTensorField&
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::vrotTensor() const
|
||||
{
|
||||
typedef volTensorField FieldType;
|
||||
typedef volTensorField::Boundary BoundaryType;
|
||||
|
||||
if (!rotTensorVolume_.valid())
|
||||
{
|
||||
tensorField rotations(csysPtr_->R(mesh_.cellCentres()));
|
||||
|
||||
rotTensorVolume_.reset
|
||||
(
|
||||
new FieldType
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"volRotation",
|
||||
mesh_.objectRegistry::instance(),
|
||||
mesh_.objectRegistry::db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false // no register
|
||||
),
|
||||
mesh_,
|
||||
dimless,
|
||||
std::move(rotations)
|
||||
// calculatedType
|
||||
)
|
||||
);
|
||||
|
||||
auto& rot = *rotTensorVolume_;
|
||||
|
||||
// Boundaries
|
||||
BoundaryType& bf = const_cast<BoundaryType&>(rot.boundaryField());
|
||||
|
||||
forAll(bf, patchi)
|
||||
{
|
||||
bf[patchi] = csysPtr_->R(bf[patchi].patch().patch().faceCentres());
|
||||
}
|
||||
}
|
||||
|
||||
return *rotTensorVolume_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::read
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -113,6 +200,10 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
||||
transform<tensor>(fieldName);
|
||||
}
|
||||
|
||||
// Finished with these
|
||||
rotTensorSurface_.clear();
|
||||
rotTensorVolume_.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,32 +29,27 @@ Group
|
||||
|
||||
Description
|
||||
Transforms a user-specified selection of fields from global Cartesian
|
||||
co-ordinates to a local co-ordinate system. The fields are run-time
|
||||
modifiable.
|
||||
coordinates to a local coordinate system.
|
||||
The fields are run-time modifiable.
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldCoordinateSystemTransform1
|
||||
{
|
||||
type fieldCoordinateSystemTransform;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
type fieldCoordinateSystemTransform;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
fields
|
||||
(
|
||||
U
|
||||
UMean
|
||||
UPrime2Mean
|
||||
);
|
||||
fields ( U UMean UPrime2Mean );
|
||||
|
||||
coordinateSystem
|
||||
{
|
||||
origin (0.001 0 0);
|
||||
coordinateRotation
|
||||
rotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0.15 0);
|
||||
e3 (0 0 -1);
|
||||
type axes;
|
||||
e1 (1 0.15 0);
|
||||
e3 (0 0 -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,10 +57,10 @@ Usage
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldCoordinateSystemTransform | yes |
|
||||
fields | list of fields to be transformed |yes |
|
||||
coordinateSystem | local co-ordinate system | yes |
|
||||
fields | list of fields to be transformed | yes |
|
||||
coordinateSystem | local coordinate system | yes |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
@ -102,13 +97,21 @@ class fieldCoordinateSystemTransform
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Fields to transform
|
||||
volFieldSelection fieldSet_;
|
||||
|
||||
//- Co-ordinate system to transform to
|
||||
coordinateSystem coordSys_;
|
||||
//- Coordinate system to transform to
|
||||
autoPtr<coordinateSystem> csysPtr_;
|
||||
|
||||
//- Demand-driven non-uniform rotation field (surface fields)
|
||||
// Eg, for cylindrical coordinates
|
||||
mutable autoPtr<surfaceTensorField> rotTensorSurface_;
|
||||
|
||||
//- Demand-driven non-uniform rotation field (volume fields)
|
||||
// Eg, for cylindrical coordinates
|
||||
mutable autoPtr<volTensorField> rotTensorVolume_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
@ -116,10 +119,25 @@ protected:
|
||||
//- Return the name of the transformed field
|
||||
word transformFieldName(const word& fieldName) const;
|
||||
|
||||
//- Demand-driven non-uniform rotation field for surface fields
|
||||
const surfaceTensorField& srotTensor() const;
|
||||
|
||||
//- Demand-driven non-uniform rotation field for volume fields
|
||||
const volTensorField& vrotTensor() const;
|
||||
|
||||
|
||||
//- Transform the given field
|
||||
template<class FieldType>
|
||||
void transformField(const FieldType& field);
|
||||
|
||||
//- Transform the given field
|
||||
template<class FieldType, class RotationFieldType>
|
||||
void transformField
|
||||
(
|
||||
const RotationFieldType& rot,
|
||||
const FieldType& field
|
||||
);
|
||||
|
||||
//- Transform the given field if has the specified element type
|
||||
template<class Type>
|
||||
void transform(const word& fieldName);
|
||||
@ -143,7 +161,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldCoordinateSystemTransform();
|
||||
virtual ~fieldCoordinateSystemTransform() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,7 +41,24 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
|
||||
store
|
||||
(
|
||||
transFieldName,
|
||||
Foam::transform(dimensionedTensor(coordSys_.R().R()), field)
|
||||
Foam::invTransform(dimensionedTensor(csysPtr_->R()), field)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class FieldType, class RotationFieldType>
|
||||
void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
|
||||
(
|
||||
const RotationFieldType& rot,
|
||||
const FieldType& field
|
||||
)
|
||||
{
|
||||
word transFieldName(transformFieldName(field.name()));
|
||||
|
||||
store
|
||||
(
|
||||
transFieldName,
|
||||
Foam::invTransform(rot, field)
|
||||
);
|
||||
}
|
||||
|
||||
@ -55,13 +72,31 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
// Scalar quantities (bool, label, scalar) and sphericalTensor quantities
|
||||
// are transform invariant. Use (pTraits<Type>::nComponents == 1) to avoid
|
||||
// avoid generating a tensor field for a non-uniform transformation.
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo
|
||||
<< type() << ": Field " << fieldName << " already in database"
|
||||
<< endl;
|
||||
|
||||
transformField<VolFieldType>(lookupObject<VolFieldType>(fieldName));
|
||||
if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
|
||||
{
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
vrotTensor(),
|
||||
lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
@ -69,10 +104,21 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< type() << ": Field " << fieldName << " already in database"
|
||||
<< endl;
|
||||
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
|
||||
{
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
srotTensor(),
|
||||
lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -91,10 +137,21 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< type() << ": Field " << fieldName << " read from file"
|
||||
<< endl;
|
||||
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
|
||||
{
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
vrotTensor(),
|
||||
lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (fieldHeader.typeHeaderOk<SurfaceFieldType>(true, true, false))
|
||||
{
|
||||
@ -102,10 +159,21 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< type() << ": Field " << fieldName << " read from file"
|
||||
<< endl;
|
||||
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
|
||||
{
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
srotTensor(),
|
||||
lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1806 |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -41,12 +41,8 @@ functions
|
||||
coordinateSystem
|
||||
{
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0.15 0);
|
||||
e3 (0 0 -1);
|
||||
}
|
||||
e1 (1 0.15 0);
|
||||
e3 (0 0 -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,12 +97,12 @@ bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
|
||||
|
||||
if (fieldName_.empty() || dict.found("field"))
|
||||
{
|
||||
dict.lookup("field") >> fieldName_;
|
||||
dict.readEntry("field", fieldName_);
|
||||
}
|
||||
|
||||
if (dict.found("result"))
|
||||
{
|
||||
dict.lookup("result") >> resultName_;
|
||||
dict.readEntry("result", resultName_);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
201
src/functionObjects/field/fieldExtents/fieldExtents.C
Normal file
201
src/functionObjects/field/fieldExtents/fieldExtents.C
Normal file
@ -0,0 +1,201 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "fieldExtents.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldExtents, 0);
|
||||
addToRunTimeSelectionTable(functionObject, fieldExtents, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldExtents::writeFileHeader(Ostream& os)
|
||||
{
|
||||
if (!fieldSet_.updateSelection())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (writtenHeader_)
|
||||
{
|
||||
writeBreak(os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeHeader(os, "Field extents");
|
||||
writeHeaderValue(os, "Reference position", C0_);
|
||||
writeHeaderValue(os, "Threshold", threshold_);
|
||||
}
|
||||
|
||||
writeCommented(os, "Time");
|
||||
|
||||
forAllConstIters(fieldSet_.selection(), iter)
|
||||
{
|
||||
const word& fieldName = iter();
|
||||
if (internalField_)
|
||||
{
|
||||
writeTabbed(os, fieldName + "_internal");
|
||||
}
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
const word& patchName = mesh_.boundaryMesh()[patchi].name();
|
||||
writeTabbed(os, fieldName + "_" + patchName);
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
|
||||
writtenHeader_ = true;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::fieldExtents::calcMask
|
||||
(
|
||||
const GeometricField<scalar, fvPatchField, volMesh>& field
|
||||
) const
|
||||
{
|
||||
return
|
||||
pos
|
||||
(
|
||||
field
|
||||
- dimensionedScalar("t", field.dimensions(), threshold_)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldExtents::fieldExtents
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(mesh_, name, typeName, dict),
|
||||
internalField_(true),
|
||||
threshold_(0),
|
||||
C0_(Zero),
|
||||
fieldSet_(mesh_),
|
||||
patchIDs_()
|
||||
{
|
||||
read(dict);
|
||||
|
||||
// Note: delay creating the output file header to handle field names
|
||||
// specified using regular expressions
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldExtents::read(const dictionary& dict)
|
||||
{
|
||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||
{
|
||||
threshold_ = dict.get<scalar>("threshold");
|
||||
|
||||
dict.readIfPresent<bool>("internalField", internalField_);
|
||||
|
||||
dict.readIfPresent<vector>("referencePosition", C0_);
|
||||
|
||||
patchIDs_.clear();
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
wordReList patchNames;
|
||||
if (dict.readIfPresent("patches", patchNames))
|
||||
{
|
||||
for (const wordRe& name : patchNames)
|
||||
{
|
||||
patchIDs_.insert(pbm.findIndices(name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add all non-processor and non-empty patches
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
const polyPatch& pp = pbm[patchi];
|
||||
if (!isA<processorPolyPatch>(pp) && !isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
patchIDs_.insert(patchi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!internalField_ && patchIDs_.empty())
|
||||
{
|
||||
IOWarningInFunction(dict)
|
||||
<< "No internal field or patches selected - no field extent "
|
||||
<< "information will be generated" << endl;
|
||||
}
|
||||
|
||||
fieldSet_.read(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExtents::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExtents::write()
|
||||
{
|
||||
writeFileHeader(file());
|
||||
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
for (const word& fieldName : fieldSet_.selection())
|
||||
{
|
||||
calcFieldExtents<scalar>(fieldName, true);
|
||||
calcFieldExtents<vector>(fieldName);
|
||||
calcFieldExtents<sphericalTensor>(fieldName);
|
||||
calcFieldExtents<symmTensor>(fieldName);
|
||||
calcFieldExtents<tensor>(fieldName);
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
207
src/functionObjects/field/fieldExtents/fieldExtents.H
Normal file
207
src/functionObjects/field/fieldExtents/fieldExtents.H
Normal file
@ -0,0 +1,207 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::fieldExtents
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the spatial minimum and maximum extents of a field
|
||||
|
||||
The extents are derived from the bound box limits after identifying the
|
||||
locations where field values exceed the user-supplied threshold value.
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldExtents1
|
||||
{
|
||||
type fieldExtents;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
writeToFile yes;
|
||||
log yes;
|
||||
fields (alpha);
|
||||
threshold 0.5;
|
||||
patches ();
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldExtents | yes |
|
||||
writeToFile | write extents data to file | no | yes
|
||||
log | write extents data to standard output | no | yes
|
||||
internalField | Process the internal field | no | yes
|
||||
threshold | Field value to identify extents boundary | yes |
|
||||
referencePosition | Reference position | no | (0 0 0)
|
||||
fields | list of fields to process | yes |
|
||||
patches | list of patches to process | no | \<all patches\>
|
||||
\endtable
|
||||
|
||||
Output data is written to the file \<timeDir\>/fieldExtents.dat
|
||||
|
||||
Note
|
||||
For non-scalar fields, the magnitude of the field is employed and compared
|
||||
to the threshold value.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
fieldExtents.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldExtents_H
|
||||
#define functionObjects_fieldExtents_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "volFieldSelection.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldExtents Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldExtents
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Flag to write the internal field extents
|
||||
bool internalField_;
|
||||
|
||||
//- Threshold value
|
||||
scalar threshold_;
|
||||
|
||||
//- Reference position; default = (0 0 0)
|
||||
point C0_;
|
||||
|
||||
//- Fields to assess
|
||||
volFieldSelection fieldSet_;
|
||||
|
||||
//- Patches to assess
|
||||
labelHashSet patchIDs_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os);
|
||||
|
||||
//- Return the field mask
|
||||
template<class Type>
|
||||
tmp<volScalarField> calcMask
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
) const;
|
||||
|
||||
//- Main calculation
|
||||
template<class Type>
|
||||
void calcFieldExtents
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool calcMag = false
|
||||
);
|
||||
|
||||
//- No copy construct
|
||||
fieldExtents(const fieldExtents&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const fieldExtents&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldExtents");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldExtents
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldExtents() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field extents data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the fieldExtents
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
tmp<volScalarField> fieldExtents::calcMask
|
||||
(
|
||||
const GeometricField<scalar, fvPatchField, volMesh>& field
|
||||
) const;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldExtentsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
120
src/functionObjects/field/fieldExtents/fieldExtentsTemplates.C
Normal file
120
src/functionObjects/field/fieldExtents/fieldExtentsTemplates.C
Normal file
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "fieldExtents.H"
|
||||
#include "volFields.H"
|
||||
#include "boundBox.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::fieldExtents::calcMask
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
) const
|
||||
{
|
||||
return
|
||||
pos
|
||||
(
|
||||
mag(field)
|
||||
- dimensionedScalar("t", field.dimensions(), threshold_)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldExtents::calcFieldExtents
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool calcMag
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
const VolFieldType* fieldPtr =
|
||||
obr_.findObject<VolFieldType>(fieldName);
|
||||
|
||||
if (!fieldPtr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto extents = [this](const scalarField& mask, const vectorField& C)
|
||||
{
|
||||
boundBox extents(boundBox::invertedBox);
|
||||
forAll(mask, i)
|
||||
{
|
||||
if (mask[i] > 0.5)
|
||||
{
|
||||
extents.add(C[i] - C0_);
|
||||
}
|
||||
};
|
||||
|
||||
extents.reduce();
|
||||
|
||||
if (extents.empty())
|
||||
{
|
||||
extents.add(point::zero);
|
||||
}
|
||||
|
||||
return extents;
|
||||
};
|
||||
|
||||
Log << "field: " << fieldName << nl;
|
||||
|
||||
writeTime(file());
|
||||
|
||||
tmp<volScalarField> tmask = calcMask<Type>(*fieldPtr);
|
||||
const volScalarField& mask = tmask();
|
||||
|
||||
// Internal field
|
||||
if (internalField_)
|
||||
{
|
||||
boundBox bb(extents(mask, mesh_.C()));
|
||||
Log << " internal field: " << bb << nl;
|
||||
file() << bb;
|
||||
|
||||
this->setResult(fieldName + "_internal_min" , bb.min());
|
||||
this->setResult(fieldName + "_internal_max", bb.max());
|
||||
}
|
||||
|
||||
// Patches
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
const fvPatchScalarField& maskp = mask.boundaryField()[patchi];
|
||||
boundBox bb(extents(maskp, maskp.patch().Cf()));
|
||||
const word& patchName = maskp.patch().name();
|
||||
Log << " patch " << patchName << ": " << bb << nl;
|
||||
file() << bb;
|
||||
this->setResult(fieldName + "_" + patchName + "_min", bb.min());
|
||||
this->setResult(fieldName + "_" + patchName + "_max", bb.max());
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -43,10 +43,10 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldMinMax::modeType
|
||||
>
|
||||
Foam::functionObjects::fieldMinMax::modeTypeNames_
|
||||
{
|
||||
({
|
||||
{ modeType::mdMag, "magnitude" },
|
||||
{ modeType::mdCmpt, "component" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -123,12 +123,6 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldMinMax::~fieldMinMax()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
||||
|
||||
@ -156,6 +156,14 @@ protected:
|
||||
//- No copy assignment
|
||||
void operator=(const fieldMinMax&) = delete;
|
||||
|
||||
//- Calculate the field min/max for a given field type
|
||||
template<class Type>
|
||||
void calcMinMaxFieldType
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const word& outputFieldName
|
||||
);
|
||||
|
||||
//- Calculate the field min/max
|
||||
template<class Type>
|
||||
void calcMinMaxFields
|
||||
@ -183,7 +191,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldMinMax();
|
||||
virtual ~fieldMinMax() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -110,6 +110,126 @@ void Foam::functionObjects::fieldMinMax::output
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const word& outputFieldName
|
||||
)
|
||||
{
|
||||
const label proci = Pstream::myProcNo();
|
||||
|
||||
// Find min internal field value info
|
||||
List<Type> minVs(Pstream::nProcs());
|
||||
labelList minCells(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
|
||||
label minProci = findMin(field);
|
||||
if (minProci != -1)
|
||||
{
|
||||
minVs[proci] = field[minProci];
|
||||
minCells[proci] = minProci;
|
||||
minCs[proci] = mesh_.C()[minProci];
|
||||
}
|
||||
else
|
||||
{
|
||||
minVs[proci] = pTraits<Type>::max;
|
||||
minCells[proci] = -1;
|
||||
minCs[proci] = vector::max;
|
||||
}
|
||||
|
||||
// Find max internal field value info
|
||||
List<Type> maxVs(Pstream::nProcs());
|
||||
labelList maxCells(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
|
||||
label maxProci = findMax(field);
|
||||
if (maxProci != -1)
|
||||
{
|
||||
maxVs[proci] = field[maxProci];
|
||||
maxCells[proci] = maxProci;
|
||||
maxCs[proci] = mesh_.C()[maxProci];
|
||||
}
|
||||
else
|
||||
{
|
||||
maxVs[proci] = pTraits<Type>::min;
|
||||
maxCells[proci] = -1;
|
||||
maxCs[proci] = vector::max;
|
||||
}
|
||||
|
||||
// Find min and max boundary field info
|
||||
const auto& fieldBoundary = field.boundaryField();
|
||||
const auto& CfBoundary = mesh_.C().boundaryField();
|
||||
|
||||
forAll(fieldBoundary, patchi)
|
||||
{
|
||||
const Field<Type>& fp = fieldBoundary[patchi];
|
||||
if (fp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
const labelList& faceCells =
|
||||
fieldBoundary[patchi].patch().faceCells();
|
||||
|
||||
label minPi = findMin(fp);
|
||||
if (fp[minPi] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = fp[minPi];
|
||||
minCells[proci] = faceCells[minPi];
|
||||
minCs[proci] = Cfp[minPi];
|
||||
}
|
||||
|
||||
label maxPi = findMax(fp);
|
||||
if (fp[maxPi] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = fp[maxPi];
|
||||
maxCells[proci] = faceCells[maxPi];
|
||||
maxCs[proci] = Cfp[maxPi];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collect info from all processors and output
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::scatterList(minVs);
|
||||
Pstream::gatherList(minCells);
|
||||
Pstream::scatterList(minCells);
|
||||
Pstream::gatherList(minCs);
|
||||
Pstream::scatterList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::scatterList(maxVs);
|
||||
Pstream::gatherList(maxCells);
|
||||
Pstream::scatterList(maxCells);
|
||||
Pstream::gatherList(maxCs);
|
||||
Pstream::scatterList(maxCs);
|
||||
|
||||
label mini = findMin(minVs);
|
||||
const Type& minValue = minVs[mini];
|
||||
const label minCell = minCells[mini];
|
||||
const vector& minC = minCs[mini];
|
||||
|
||||
label maxi = findMax(maxVs);
|
||||
const Type& maxValue = maxVs[maxi];
|
||||
const label maxCell = maxCells[maxi];
|
||||
const vector& maxC = maxCs[maxi];
|
||||
|
||||
output
|
||||
(
|
||||
field.name(),
|
||||
outputFieldName,
|
||||
minCell,
|
||||
maxCell,
|
||||
minC,
|
||||
maxC,
|
||||
mini,
|
||||
maxi,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldMinMax::calcMinMaxFields
|
||||
(
|
||||
@ -121,191 +241,22 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const label proci = Pstream::myProcNo();
|
||||
|
||||
const fieldType& field = lookupObject<fieldType>(fieldName);
|
||||
|
||||
const volVectorField::Boundary& CfBoundary =
|
||||
mesh_.C().boundaryField();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case mdMag:
|
||||
{
|
||||
const volScalarField magField(mag(field));
|
||||
const volScalarField::Boundary& magFieldBoundary =
|
||||
magField.boundaryField();
|
||||
|
||||
scalarList minVs(Pstream::nProcs());
|
||||
labelList minCells(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
label minProci = findMin(magField);
|
||||
minVs[proci] = magField[minProci];
|
||||
minCells[proci] = minProci;
|
||||
minCs[proci] = mesh_.C()[minProci];
|
||||
|
||||
scalarList maxVs(Pstream::nProcs());
|
||||
labelList maxCells(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
label maxProci = findMax(magField);
|
||||
maxVs[proci] = magField[maxProci];
|
||||
maxCells[proci] = maxProci;
|
||||
maxCs[proci] = mesh_.C()[maxProci];
|
||||
|
||||
forAll(magFieldBoundary, patchi)
|
||||
{
|
||||
const scalarField& mfp = magFieldBoundary[patchi];
|
||||
if (mfp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
const labelList& faceCells =
|
||||
magFieldBoundary[patchi].patch().faceCells();
|
||||
|
||||
label minPi = findMin(mfp);
|
||||
if (mfp[minPi] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = mfp[minPi];
|
||||
minCells[proci] = faceCells[minPi];
|
||||
minCs[proci] = Cfp[minPi];
|
||||
}
|
||||
|
||||
label maxPi = findMax(mfp);
|
||||
if (mfp[maxPi] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = mfp[maxPi];
|
||||
maxCells[proci] = faceCells[maxPi];
|
||||
maxCs[proci] = Cfp[maxPi];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::scatterList(minVs);
|
||||
Pstream::gatherList(minCells);
|
||||
Pstream::scatterList(minCells);
|
||||
Pstream::gatherList(minCs);
|
||||
Pstream::scatterList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::scatterList(maxVs);
|
||||
Pstream::gatherList(maxCells);
|
||||
Pstream::scatterList(maxCells);
|
||||
Pstream::gatherList(maxCs);
|
||||
Pstream::scatterList(maxCs);
|
||||
|
||||
label mini = findMin(minVs);
|
||||
scalar minValue = minVs[mini];
|
||||
const label minCell = minCells[mini];
|
||||
const vector& minC = minCs[mini];
|
||||
|
||||
label maxi = findMax(maxVs);
|
||||
scalar maxValue = maxVs[maxi];
|
||||
const label maxCell = maxCells[maxi];
|
||||
const vector& maxC = maxCs[maxi];
|
||||
|
||||
output
|
||||
calcMinMaxFieldType<scalar>
|
||||
(
|
||||
fieldName,
|
||||
word("mag(" + fieldName + ")"),
|
||||
minCell,
|
||||
maxCell,
|
||||
minC,
|
||||
maxC,
|
||||
mini,
|
||||
maxi,
|
||||
minValue,
|
||||
maxValue
|
||||
mag(field),
|
||||
word("mag(" + fieldName + ")")
|
||||
);
|
||||
break;
|
||||
}
|
||||
case mdCmpt:
|
||||
{
|
||||
const typename fieldType::Boundary&
|
||||
fieldBoundary = field.boundaryField();
|
||||
|
||||
List<Type> minVs(Pstream::nProcs());
|
||||
labelList minCells(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
label minProci = findMin(field);
|
||||
minVs[proci] = field[minProci];
|
||||
minCells[proci] = minProci;
|
||||
minCs[proci] = mesh_.C()[minProci];
|
||||
|
||||
List<Type> maxVs(Pstream::nProcs());
|
||||
labelList maxCells(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
label maxProci = findMax(field);
|
||||
maxVs[proci] = field[maxProci];
|
||||
maxCells[proci] = maxProci;
|
||||
maxCs[proci] = mesh_.C()[maxProci];
|
||||
|
||||
forAll(fieldBoundary, patchi)
|
||||
{
|
||||
const Field<Type>& fp = fieldBoundary[patchi];
|
||||
|
||||
if (fp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
const labelList& faceCells =
|
||||
fieldBoundary[patchi].patch().faceCells();
|
||||
|
||||
label minPi = findMin(fp);
|
||||
if (fp[minPi] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = fp[minPi];
|
||||
minCells[proci] = faceCells[minPi];
|
||||
minCs[proci] = Cfp[minPi];
|
||||
}
|
||||
|
||||
label maxPi = findMax(fp);
|
||||
if (fp[maxPi] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = fp[maxPi];
|
||||
maxCells[proci] = faceCells[maxPi];
|
||||
maxCs[proci] = Cfp[maxPi];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::scatterList(minVs);
|
||||
Pstream::gatherList(minCells);
|
||||
Pstream::scatterList(minCells);
|
||||
Pstream::gatherList(minCs);
|
||||
Pstream::scatterList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::scatterList(maxVs);
|
||||
Pstream::gatherList(maxCells);
|
||||
Pstream::scatterList(maxCells);
|
||||
Pstream::gatherList(maxCs);
|
||||
Pstream::scatterList(maxCs);
|
||||
|
||||
label mini = findMin(minVs);
|
||||
Type minValue = minVs[mini];
|
||||
const label minCell = minCells[mini];
|
||||
const vector& minC = minCs[mini];
|
||||
|
||||
label maxi = findMax(maxVs);
|
||||
Type maxValue = maxVs[maxi];
|
||||
const label maxCell = maxCells[maxi];
|
||||
const vector& maxC = maxCs[maxi];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
fieldName,
|
||||
minCell,
|
||||
maxCell,
|
||||
minC,
|
||||
maxC,
|
||||
mini,
|
||||
maxi,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
calcMinMaxFieldType(field, fieldName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -95,8 +95,8 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("writeFields") >> writeFields_;
|
||||
dict.readEntry("fields", fields_);
|
||||
dict.readEntry("writeFields", writeFields_);
|
||||
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
|
||||
|
||||
return true;
|
||||
|
||||
@ -36,7 +36,7 @@ Foam::functionObjects::fieldValue::New
|
||||
const bool output
|
||||
)
|
||||
{
|
||||
const word modelType(dict.lookup("type"));
|
||||
const word modelType(dict.get<word>("type"));
|
||||
|
||||
if (output)
|
||||
{
|
||||
|
||||
@ -46,13 +46,13 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_
|
||||
{
|
||||
({
|
||||
{ operationType::opAdd, "add" },
|
||||
{ operationType::opSubtract, "subtract" },
|
||||
{ operationType::opMin, "min" },
|
||||
{ operationType::opMax, "max" },
|
||||
{ operationType::opAverage, "average" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
@ -146,7 +146,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
|
||||
).ptr()
|
||||
);
|
||||
|
||||
operation_ = operationTypeNames_.lookup("operation", dict);
|
||||
operation_ = operationTypeNames_.get("operation", dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,12 +55,12 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes
|
||||
>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_
|
||||
{
|
||||
({
|
||||
{ regionTypes::stFaceZone, "faceZone" },
|
||||
{ regionTypes::stPatch, "patch" },
|
||||
{ regionTypes::stSurface, "surface" },
|
||||
{ regionTypes::stSampledSurface, "sampledSurface" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
@ -68,7 +68,7 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_
|
||||
{
|
||||
({
|
||||
// Normal operations
|
||||
{ operationType::opNone, "none" },
|
||||
{ operationType::opMin, "min" },
|
||||
@ -98,17 +98,17 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_
|
||||
{ operationType::opAbsWeightedAreaAverage, "absWeightedAreaAverage" },
|
||||
{ operationType::opAbsWeightedAreaIntegrate, "absWeightedAreaIntegrate" },
|
||||
{ operationType::opAbsWeightedUniformity, "absWeightedUniformity" },
|
||||
};
|
||||
});
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_
|
||||
{
|
||||
({
|
||||
{ postOperationType::postOpNone, "none" },
|
||||
{ postOperationType::postOpSqrt, "sqrt" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -484,7 +484,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
dict.lookup("name") >> regionName_;
|
||||
dict.readEntry("name", regionName_);
|
||||
|
||||
switch (regionType_)
|
||||
{
|
||||
@ -616,7 +616,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
surfaceWriterPtr_.clear();
|
||||
if (writeFields_)
|
||||
{
|
||||
const word surfaceFormat(dict.lookup("surfaceFormat"));
|
||||
const word surfaceFormat(dict.get<word>("surfaceFormat"));
|
||||
|
||||
if (surfaceFormat != "none")
|
||||
{
|
||||
@ -687,12 +687,12 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
|
||||
{
|
||||
case opSumDirection:
|
||||
{
|
||||
const vector n(dict_.lookup("direction"));
|
||||
const vector n(dict_.get<vector>("direction"));
|
||||
return gSum(pos0(values*(Sf & n))*mag(values));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
const vector n(dict_.lookup("direction"));
|
||||
const vector n(dict_.get<vector>("direction"));
|
||||
const scalarField nv(values*(Sf & n));
|
||||
|
||||
return gSum(pos0(nv)*mag(values) - neg(nv)*mag(values));
|
||||
@ -758,16 +758,14 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
|
||||
{
|
||||
case opSumDirection:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const vector n(dict_.get<vector>("direction").normalise());
|
||||
|
||||
const scalarField nv(n & values);
|
||||
return gSum(pos0(nv)*n*(nv));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const vector n(dict_.get<vector>("direction").normalise());
|
||||
|
||||
const scalarField nv(n & values);
|
||||
return gSum(pos0(nv)*n*(nv));
|
||||
@ -903,15 +901,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
)
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
regionType_(regionTypeNames_.lookup("regionType", dict)),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
regionType_(regionTypeNames_.get("regionType", dict)),
|
||||
operation_(operationTypeNames_.get("operation", dict)),
|
||||
postOperation_
|
||||
(
|
||||
postOperationTypeNames_.lookupOrDefault
|
||||
(
|
||||
"postOperation",
|
||||
dict,
|
||||
postOperationType::postOpNone
|
||||
postOperationType::postOpNone,
|
||||
true // Failsafe behaviour
|
||||
)
|
||||
),
|
||||
weightFieldName_("none"),
|
||||
@ -934,15 +933,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
regionType_(regionTypeNames_.lookup("regionType", dict)),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
regionType_(regionTypeNames_.get("regionType", dict)),
|
||||
operation_(operationTypeNames_.get("operation", dict)),
|
||||
postOperation_
|
||||
(
|
||||
postOperationTypeNames_.lookupOrDefault
|
||||
(
|
||||
"postOperation",
|
||||
dict,
|
||||
postOperationType::postOpNone
|
||||
postOperationType::postOpNone,
|
||||
true // Failsafe behaviour
|
||||
)
|
||||
),
|
||||
weightFieldName_("none"),
|
||||
|
||||
@ -178,7 +178,6 @@ processSameTypeValues
|
||||
if (canWeight(weightField))
|
||||
{
|
||||
tmp<scalarField> weight(weightingFactor(weightField));
|
||||
|
||||
result = gSum(weight*values);
|
||||
}
|
||||
else
|
||||
@ -466,8 +465,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(faceId_.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
forAll(values, i)
|
||||
{
|
||||
@ -501,8 +500,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(faceId_.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
forAll(values, i)
|
||||
{
|
||||
|
||||
@ -48,7 +48,7 @@ const Foam::Enum
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_
|
||||
{
|
||||
({
|
||||
// Normal operations
|
||||
{ operationType::opNone, "none" },
|
||||
{ operationType::opMin, "min" },
|
||||
@ -65,7 +65,7 @@ Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_
|
||||
{ operationType::opWeightedAverage, "weightedAverage" },
|
||||
{ operationType::opWeightedVolAverage, "weightedVolAverage" },
|
||||
{ operationType::opWeightedVolIntegrate, "weightedVolIntegrate" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -205,7 +205,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
operation_(operationTypeNames_.get("operation", dict)),
|
||||
weightFieldName_("none")
|
||||
{
|
||||
read(dict);
|
||||
@ -222,7 +222,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
operation_(operationTypeNames_.get("operation", dict)),
|
||||
weightFieldName_("none")
|
||||
{
|
||||
read(dict);
|
||||
|
||||
@ -111,12 +111,12 @@ bool Foam::functionObjects::fieldsExpression::read(const dictionary& dict)
|
||||
|
||||
if (fieldNames_.empty() || dict.found("fields"))
|
||||
{
|
||||
dict.lookup("fields") >> fieldNames_;
|
||||
dict.readEntry("fields", fieldNames_);
|
||||
}
|
||||
|
||||
if (dict.found("result"))
|
||||
{
|
||||
dict.lookup("result") >> resultName_;
|
||||
dict.readEntry("result", resultName_);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -59,13 +59,13 @@ const Foam::Enum
|
||||
Foam::functionObjects::fluxSummary::modeType
|
||||
>
|
||||
Foam::functionObjects::fluxSummary::modeTypeNames_
|
||||
{
|
||||
({
|
||||
{ modeType::mdFaceZone , "faceZone" },
|
||||
{ modeType::mdFaceZoneAndDirection, "faceZoneAndDirection" },
|
||||
{ modeType::mdCellZoneAndDirection, "cellZoneAndDirection" },
|
||||
{ modeType::mdSurface, "surface" },
|
||||
{ modeType::mdSurfaceAndDirection, "surfaceAndDirection" },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -129,7 +129,7 @@ void Foam::functionObjects::fluxSummary::initialiseSurface
|
||||
DynamicList<boolList>& faceFlip
|
||||
) const
|
||||
{
|
||||
const surfMesh* sPtr = mesh_.lookupObjectPtr<surfMesh>(surfName);
|
||||
const surfMesh* sPtr = mesh_.findObject<surfMesh>(surfName);
|
||||
if (!sPtr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -154,7 +154,7 @@ void Foam::functionObjects::fluxSummary::initialiseSurfaceAndDirection
|
||||
DynamicList<boolList>& faceFlip
|
||||
) const
|
||||
{
|
||||
const surfMesh* sPtr = mesh_.lookupObjectPtr<surfMesh>(surfName);
|
||||
const surfMesh* sPtr = mesh_.findObject<surfMesh>(surfName);
|
||||
if (!sPtr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -448,8 +448,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
|
||||
if (((own != -1) && (nbr == -1)) || ((own == -1) && (nbr != -1)))
|
||||
{
|
||||
vector n = mesh_.faces()[facei].normal(mesh_.points());
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
vector n = mesh_.faces()[facei].unitNormal(mesh_.points());
|
||||
|
||||
if ((n & refDir) > tolerance_)
|
||||
{
|
||||
@ -481,8 +480,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
|
||||
if ((own != -1) && (nbr == -1))
|
||||
{
|
||||
vector n = mesh_.faces()[facei].normal(mesh_.points());
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
vector n = mesh_.faces()[facei].unitNormal(mesh_.points());
|
||||
|
||||
if ((n & refDir) > tolerance_)
|
||||
{
|
||||
@ -819,7 +817,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
mode_ = modeTypeNames_.lookup("mode", dict);
|
||||
mode_ = modeTypeNames_.get("mode", dict);
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
|
||||
tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8);
|
||||
@ -835,7 +833,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
{
|
||||
case mdFaceZone:
|
||||
{
|
||||
List<word> zones(dict.lookup("faceZones"));
|
||||
wordList zones(dict.get<wordList>("faceZones"));
|
||||
|
||||
forAll(zones, i)
|
||||
{
|
||||
@ -853,8 +851,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
}
|
||||
case mdFaceZoneAndDirection:
|
||||
{
|
||||
List<Tuple2<word, vector>>
|
||||
zoneAndDirection(dict.lookup("faceZoneAndDirection"));
|
||||
List<Tuple2<word, vector>> zoneAndDirection;
|
||||
dict.readEntry("faceZoneAndDirection", zoneAndDirection);
|
||||
|
||||
forAll(zoneAndDirection, i)
|
||||
{
|
||||
@ -873,8 +871,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
}
|
||||
case mdCellZoneAndDirection:
|
||||
{
|
||||
List<Tuple2<word, vector>>
|
||||
zoneAndDirection(dict.lookup("cellZoneAndDirection"));
|
||||
List<Tuple2<word, vector>> zoneAndDirection;
|
||||
dict.readEntry("cellZoneAndDirection", zoneAndDirection);
|
||||
|
||||
forAll(zoneAndDirection, i)
|
||||
{
|
||||
@ -893,7 +891,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
}
|
||||
case mdSurface:
|
||||
{
|
||||
List<word> surfs(dict.lookup("surfaces"));
|
||||
wordList surfs(dict.get<wordList>("surfaces"));
|
||||
|
||||
forAll(surfs, i)
|
||||
{
|
||||
@ -909,8 +907,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
}
|
||||
case mdSurfaceAndDirection:
|
||||
{
|
||||
List<Tuple2<word, vector>>
|
||||
surfAndDirection(dict.lookup("surfaceAndDirection"));
|
||||
List<Tuple2<word, vector>> surfAndDirection;
|
||||
dict.readEntry("surfaceAndDirection", surfAndDirection);
|
||||
|
||||
forAll(surfAndDirection, i)
|
||||
{
|
||||
|
||||
@ -141,7 +141,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::devReff() const
|
||||
const dictionary& transportProperties =
|
||||
mesh_.lookupObject<dictionary>("transportProperties");
|
||||
|
||||
dimensionedScalar nu(transportProperties.lookup("nu"));
|
||||
dimensionedScalar nu("nu", dimViscosity, transportProperties);
|
||||
|
||||
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
@ -164,12 +164,8 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cf() const
|
||||
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
|
||||
const volVectorField::Boundary& Ubf = U.boundaryField();
|
||||
|
||||
tmp<FieldField<Field, scalar>> tCf
|
||||
(
|
||||
new FieldField<Field, scalar>(Ubf.size())
|
||||
);
|
||||
|
||||
FieldField<Field, scalar>& Cf = tCf.ref();
|
||||
auto tCf = tmp<FieldField<Field, scalar>>::New(Ubf.size());
|
||||
auto& Cf = tCf.ref();
|
||||
|
||||
forAll(Cf, patchi)
|
||||
{
|
||||
@ -179,7 +175,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cf() const
|
||||
const volSymmTensorField R(devReff());
|
||||
const volSymmTensorField::Boundary& Rbf = R.boundaryField();
|
||||
|
||||
for (label patchi : patchSet_)
|
||||
for (const label patchi : patchSet_)
|
||||
{
|
||||
const fvPatchVectorField& Up = Ubf[patchi];
|
||||
|
||||
@ -226,18 +222,18 @@ bool Foam::heatTransferCoeffModels::ReynoldsAnalogy::read
|
||||
{
|
||||
if (heatTransferCoeffModel::read(dict))
|
||||
{
|
||||
dict.lookup("UInf") >> URef_;
|
||||
dict.readEntry("UInf", URef_);
|
||||
|
||||
dict.readIfPresent("Cp", CpName_);
|
||||
if (CpName_ == "CpInf")
|
||||
{
|
||||
dict.lookup("CpInf") >> CpRef_;
|
||||
dict.readEntry("CpInf", CpRef_);
|
||||
}
|
||||
|
||||
dict.readIfPresent("rho", rhoName_);
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoRef_;
|
||||
dict.readEntry("rhoInf", rhoRef_);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -253,9 +249,9 @@ void Foam::heatTransferCoeffModels::ReynoldsAnalogy::htc(volScalarField& htc)
|
||||
const scalar magU = mag(URef_);
|
||||
|
||||
volScalarField::Boundary& htcBf = htc.boundaryFieldRef();
|
||||
forAllConstIters(patchSet_, iter)
|
||||
|
||||
for (const label patchi : patchSet_)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
const scalarField rhop(rho(patchi));
|
||||
const scalarField Cpp(Cp(patchi));
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ bool Foam::heatTransferCoeffModels::fixedReferenceTemperature::read
|
||||
{
|
||||
if (heatTransferCoeffModel::read(dict))
|
||||
{
|
||||
dict.lookup("TRef") >> TRef_;
|
||||
dict.readEntry("TRef", TRef_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -46,16 +46,12 @@ Foam::heatTransferCoeffModel::q() const
|
||||
const volScalarField& T = mesh_.lookupObject<volScalarField>(TName_);
|
||||
const volScalarField::Boundary& Tbf = T.boundaryField();
|
||||
|
||||
tmp<FieldField<Field, scalar>> tq
|
||||
(
|
||||
new FieldField<Field, scalar>(Tbf.size())
|
||||
);
|
||||
|
||||
FieldField<Field, scalar>& q = tq.ref();
|
||||
auto tq = tmp<FieldField<Field, scalar>>::New(Tbf.size());
|
||||
auto& q = tq.ref();
|
||||
|
||||
forAll(q, patchi)
|
||||
{
|
||||
q.set(patchi, new Field<scalar>(Tbf[patchi].size(), 0));
|
||||
q.set(patchi, new Field<scalar>(Tbf[patchi].size(), Zero));
|
||||
}
|
||||
|
||||
typedef compressible::turbulenceModel cmpTurbModel;
|
||||
@ -71,7 +67,7 @@ Foam::heatTransferCoeffModel::q() const
|
||||
const volScalarField alphaEff(turb.alphaEff());
|
||||
const volScalarField::Boundary& alphaEffbf = alphaEff.boundaryField();
|
||||
|
||||
for (label patchi : patchSet_)
|
||||
for (const label patchi : patchSet_)
|
||||
{
|
||||
q[patchi] = alphaEffbf[patchi]*hebf[patchi].snGrad();
|
||||
}
|
||||
@ -105,7 +101,7 @@ Foam::heatTransferCoeffModel::q() const
|
||||
const volScalarField& qr = mesh_.lookupObject<volScalarField>(qrName_);
|
||||
const volScalarField::Boundary& qrbf = qr.boundaryField();
|
||||
|
||||
for (label patchi : patchSet_)
|
||||
for (const label patchi : patchSet_)
|
||||
{
|
||||
q[patchi] += qrbf[patchi];
|
||||
}
|
||||
@ -135,8 +131,7 @@ Foam::heatTransferCoeffModel::heatTransferCoeffModel
|
||||
|
||||
bool Foam::heatTransferCoeffModel::read(const dictionary& dict)
|
||||
{
|
||||
patchSet_ =
|
||||
mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches")));
|
||||
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
|
||||
|
||||
dict.readIfPresent("qr", qrName_);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ Foam::autoPtr<Foam::heatTransferCoeffModel> Foam::heatTransferCoeffModel::New
|
||||
const word& TName
|
||||
)
|
||||
{
|
||||
const word modelType(dict.lookup("htcModel"));
|
||||
const word modelType(dict.get<word>("htcModel"));
|
||||
|
||||
Info<< "Selecting heat transfer coefficient model " << modelType << endl;
|
||||
|
||||
|
||||
@ -105,13 +105,13 @@ bool Foam::functionObjects::histogram::read(const dictionary& dict)
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
dict.lookup("field") >> fieldName_;
|
||||
dict.readEntry("field", fieldName_);
|
||||
|
||||
max_ = dict.lookupOrDefault<scalar>("max", -GREAT);
|
||||
min_ = dict.lookupOrDefault<scalar>("min", GREAT);
|
||||
dict.lookup("nBins") >> nBins_;
|
||||
dict.readEntry("nBins", nBins_);
|
||||
|
||||
word format(dict.lookup("setFormat"));
|
||||
const word format(dict.get<word>("setFormat"));
|
||||
formatterPtr_ = writer<scalar>::New(format);
|
||||
|
||||
return true;
|
||||
|
||||
@ -53,7 +53,7 @@ void Foam::functionObjects::mapFields::createInterpolation
|
||||
)
|
||||
{
|
||||
const fvMesh& meshTarget = mesh_;
|
||||
const word mapRegionName(dict.lookup("mapRegion"));
|
||||
const word mapRegionName(dict.get<word>("mapRegion"));
|
||||
|
||||
Info<< name() << ':' << nl
|
||||
<< " Reading mesh " << mapRegionName << endl;
|
||||
@ -71,7 +71,7 @@ void Foam::functionObjects::mapFields::createInterpolation
|
||||
)
|
||||
);
|
||||
const fvMesh& mapRegion = mapRegionPtr_();
|
||||
const word mapMethodName(dict.lookup("mapMethod"));
|
||||
const word mapMethodName(dict.get<word>("mapMethod"));
|
||||
if (!meshToMesh::interpolationMethodNames_.found(mapMethodName))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -100,11 +100,9 @@ void Foam::functionObjects::mapFields::createInterpolation
|
||||
Info<< " Patch mapping method: " << patchMapMethodName << endl;
|
||||
}
|
||||
|
||||
bool consistent = readBool(dict.lookup("consistent"));
|
||||
|
||||
Info<< " Creating mesh to mesh interpolation" << endl;
|
||||
|
||||
if (consistent)
|
||||
if (dict.get<bool>("consistent"))
|
||||
{
|
||||
interpPtr_.reset
|
||||
(
|
||||
@ -119,8 +117,11 @@ void Foam::functionObjects::mapFields::createInterpolation
|
||||
}
|
||||
else
|
||||
{
|
||||
HashTable<word> patchMap(dict.lookup("patchMap"));
|
||||
wordList cuttingPatches(dict.lookup("cuttingPatches"));
|
||||
HashTable<word> patchMap;
|
||||
wordList cuttingPatches;
|
||||
|
||||
dict.readEntry("patchMap", patchMap);
|
||||
dict.readEntry("cuttingPatches", cuttingPatches);
|
||||
|
||||
interpPtr_.reset
|
||||
(
|
||||
@ -162,7 +163,7 @@ bool Foam::functionObjects::mapFields::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldNames_;
|
||||
dict.readEntry("fields", fieldNames_);
|
||||
createInterpolation(dict);
|
||||
return true;
|
||||
}
|
||||
|
||||
573
src/functionObjects/field/momentum/momentum.C
Normal file
573
src/functionObjects/field/momentum/momentum.C
Normal file
@ -0,0 +1,573 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "momentum.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "cellSet.H"
|
||||
#include "cylindricalRotation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(momentum, 0);
|
||||
addToRunTimeSelectionTable(functionObject, momentum, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
Foam::autoPtr<GeoField>
|
||||
Foam::functionObjects::momentum::newField
|
||||
(
|
||||
const word& baseName,
|
||||
const dimensionSet& dims,
|
||||
bool registerObject
|
||||
) const
|
||||
{
|
||||
return
|
||||
autoPtr<GeoField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
scopedName(baseName),
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
registerObject
|
||||
),
|
||||
mesh_,
|
||||
dimensioned<typename GeoField::value_type>(dims, Zero)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::momentum::calc()
|
||||
{
|
||||
initialise();
|
||||
|
||||
// When field writing is not enabled we need our local storage
|
||||
// for the momentum and angular velocity fields
|
||||
autoPtr<volVectorField> tmomentum, tAngularMom, tAngularVel;
|
||||
|
||||
|
||||
// The base fields required
|
||||
const auto& U = lookupObject<volVectorField>(UName_);
|
||||
const auto* rhoPtr = findObject<volScalarField>(rhoName_);
|
||||
|
||||
const dimensionedScalar rhoRef("rho", dimDensity, rhoRef_);
|
||||
|
||||
// For quantities such as the mass-averaged angular velocity,
|
||||
// we would calculate the mass per-cell here.
|
||||
|
||||
// tmp<volScalarField::Internal> tmass =
|
||||
// (
|
||||
// rhoPtr
|
||||
// ? (mesh_.V() * (*rhoPtr))
|
||||
// : (mesh_.V() * rhoRef)
|
||||
// );
|
||||
|
||||
|
||||
// Linear momentum
|
||||
// ~~~~~~~~~~~~~~~
|
||||
|
||||
auto* pmomentum = getObjectPtr<volVectorField>(scopedName("momentum"));
|
||||
|
||||
if (!pmomentum)
|
||||
{
|
||||
tmomentum = newField<volVectorField>("momentum", dimVelocity*dimMass);
|
||||
pmomentum = tmomentum.get(); // get(), not release()
|
||||
}
|
||||
auto& momentum = *pmomentum;
|
||||
|
||||
if (rhoPtr)
|
||||
{
|
||||
momentum.ref() = (U * mesh_.V() * (*rhoPtr));
|
||||
}
|
||||
else
|
||||
{
|
||||
momentum.ref() = (U * mesh_.V() * rhoRef);
|
||||
}
|
||||
momentum.correctBoundaryConditions();
|
||||
|
||||
|
||||
// Angular momentum
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
|
||||
auto* pAngularMom =
|
||||
getObjectPtr<volVectorField>(scopedName("angularMomentum"));
|
||||
|
||||
if (hasCsys_ && !pAngularMom)
|
||||
{
|
||||
tAngularMom =
|
||||
newField<volVectorField>("angularMomentum", dimVelocity*dimMass);
|
||||
pAngularMom = tAngularMom.get(); // get(), not release()
|
||||
}
|
||||
else if (!pAngularMom)
|
||||
{
|
||||
// Angular momentum not requested, but alias to normal momentum
|
||||
// to simplify logic when calculating the summations
|
||||
pAngularMom = pmomentum;
|
||||
}
|
||||
auto& angularMom = *pAngularMom;
|
||||
|
||||
|
||||
// Angular velocity
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
|
||||
auto* pAngularVel =
|
||||
getObjectPtr<volVectorField>(scopedName("angularVelocity"));
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
if (!pAngularVel)
|
||||
{
|
||||
tAngularVel =
|
||||
newField<volVectorField>("angularVelocity", dimVelocity);
|
||||
pAngularVel = tAngularVel.get(); // get(), not release()
|
||||
}
|
||||
auto& angularVel = *pAngularVel;
|
||||
|
||||
|
||||
// Global to local
|
||||
|
||||
angularVel.primitiveFieldRef() =
|
||||
csys_.invTransform(mesh_.cellCentres(), U.internalField());
|
||||
|
||||
angularVel.correctBoundaryConditions();
|
||||
|
||||
if (rhoPtr)
|
||||
{
|
||||
angularMom.ref() = (angularVel * mesh_.V() * (*rhoPtr));
|
||||
}
|
||||
else
|
||||
{
|
||||
angularMom.ref() = (angularVel * mesh_.V() * rhoRef);
|
||||
}
|
||||
|
||||
angularMom.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
// Integrate the selection
|
||||
|
||||
sumMomentum_ = Zero;
|
||||
sumAngularMom_ = Zero;
|
||||
|
||||
switch (regionType_)
|
||||
{
|
||||
case vrtCellSet:
|
||||
case vrtCellZone:
|
||||
{
|
||||
for (const label celli : cellIDs())
|
||||
{
|
||||
sumMomentum_ += momentum[celli];
|
||||
sumAngularMom_ += angularMom[celli];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case vrtAll:
|
||||
{
|
||||
for (label celli=0; celli < mesh_.nCells(); ++celli)
|
||||
{
|
||||
sumMomentum_ += momentum[celli];
|
||||
sumAngularMom_ += angularMom[celli];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reduce(sumMomentum_, sumOp<vector>());
|
||||
reduce(sumAngularMom_, sumOp<vector>());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::momentum::writeFileHeader(Ostream& os)
|
||||
{
|
||||
if (!writeToFile() || writtenHeader_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
writeHeader(os, "Momentum, Angular Momentum");
|
||||
writeHeaderValue(os, "origin", csys_.origin());
|
||||
writeHeaderValue(os, "axis", csys_.e3());
|
||||
}
|
||||
else
|
||||
{
|
||||
writeHeader(os, "Momentum");
|
||||
}
|
||||
|
||||
if (regionType_ != vrtAll)
|
||||
{
|
||||
writeHeader
|
||||
(
|
||||
os,
|
||||
"Selection " + regionTypeNames_[regionType_]
|
||||
+ " = " + regionName_
|
||||
);
|
||||
}
|
||||
|
||||
writeHeader(os, "");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "(momentum_x momentum_y momentum_z)");
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
writeTabbed(os, "(momentum_r momentum_rtheta momentum_axis)");
|
||||
}
|
||||
os << endl;
|
||||
|
||||
|
||||
writtenHeader_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::momentum::initialise()
|
||||
{
|
||||
if (initialised_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!foundObject<volVectorField>(UName_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Could not find U: " << UName_ << " in database"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
const auto* pPtr = cfindObject<volScalarField>(pName_);
|
||||
|
||||
if (pPtr && pPtr->dimensions() == dimPressure)
|
||||
{
|
||||
// Compressible - rho is mandatory
|
||||
|
||||
if (!foundObject<volScalarField>(rhoName_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Could not find rho:" << rhoName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
initialised_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::momentum::writeValues(Ostream& os)
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
Log << " Sum of Momentum";
|
||||
|
||||
if (regionType_ != vrtAll)
|
||||
{
|
||||
Log << ' ' << regionTypeNames_[regionType_]
|
||||
<< ' ' << regionName_;
|
||||
}
|
||||
|
||||
Log << nl
|
||||
<< " linear : " << sumMomentum_ << nl;
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
Log << " angular : " << sumAngularMom_ << nl;
|
||||
}
|
||||
|
||||
if (writeToFile())
|
||||
{
|
||||
writeTime(os);
|
||||
|
||||
os << tab << sumMomentum_;
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
os << tab << sumAngularMom_;
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::momentum::momentum
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
bool readFields
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
volRegion(fvMeshFunctionObject::mesh_, dict),
|
||||
writeFile(mesh_, name, typeName, dict),
|
||||
sumMomentum_(Zero),
|
||||
sumAngularMom_(Zero),
|
||||
UName_(),
|
||||
pName_(),
|
||||
rhoName_(),
|
||||
rhoRef_(1.0),
|
||||
csys_(),
|
||||
hasCsys_(false),
|
||||
writeMomentum_(false),
|
||||
writeVelocity_(false),
|
||||
writePosition_(false),
|
||||
initialised_(false)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
read(dict);
|
||||
Log << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::functionObjects::momentum::momentum
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
bool readFields
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, obr, dict),
|
||||
volRegion(fvMeshFunctionObject::mesh_, dict),
|
||||
writeFile(mesh_, name, typeName, dict),
|
||||
sumMomentum_(Zero),
|
||||
sumAngularMom_(Zero),
|
||||
UName_(),
|
||||
pName_(),
|
||||
rhoName_(),
|
||||
rhoRef_(1.0),
|
||||
csys_(),
|
||||
hasCsys_(false),
|
||||
writeMomentum_(false),
|
||||
writeVelocity_(false),
|
||||
writePosition_(false),
|
||||
initialised_(false)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
read(dict);
|
||||
Log << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::momentum::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
volRegion::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
initialised_ = false;
|
||||
|
||||
Info<< type() << " " << name() << ":" << nl;
|
||||
|
||||
// Optional entries U and p
|
||||
UName_ = dict.lookupOrDefault<word>("U", "U");
|
||||
pName_ = dict.lookupOrDefault<word>("p", "p");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
rhoRef_ = dict.lookupOrDefault<scalar>("rhoRef", 1.0);
|
||||
|
||||
rhoRef_ = dict.lookupOrDefault<scalar>("rhoRef", 1.0);
|
||||
|
||||
hasCsys_ = dict.lookupOrDefault("cylindrical", false);
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
csys_ = coordSystem::cylindrical(dict);
|
||||
}
|
||||
|
||||
writeMomentum_ = dict.lookupOrDefault("writeMomentum", false);
|
||||
writeVelocity_ = dict.lookupOrDefault("writeVelocity", false);
|
||||
writePosition_ = dict.lookupOrDefault("writePosition", false);
|
||||
|
||||
Info<<"Integrating for selection: "
|
||||
<< regionTypeNames_[regionType_]
|
||||
<< " (" << regionName_ << ")" << nl;
|
||||
|
||||
if (writeMomentum_)
|
||||
{
|
||||
Info<< " Momentum fields will be written" << endl;
|
||||
|
||||
mesh_.objectRegistry::store
|
||||
(
|
||||
newField<volVectorField>("momentum", dimVelocity*dimMass)
|
||||
);
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
mesh_.objectRegistry::store
|
||||
(
|
||||
newField<volVectorField>("angularMomentum", dimVelocity*dimMass)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCsys_)
|
||||
{
|
||||
if (writeVelocity_)
|
||||
{
|
||||
Info<< " Angular velocity will be written" << endl;
|
||||
|
||||
mesh_.objectRegistry::store
|
||||
(
|
||||
newField<volVectorField>("angularVelocity", dimVelocity)
|
||||
);
|
||||
}
|
||||
|
||||
if (writePosition_)
|
||||
{
|
||||
Info<< " Angular position will be written" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::momentum::execute()
|
||||
{
|
||||
calc();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeFileHeader(file());
|
||||
|
||||
writeValues(file());
|
||||
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
// Write state/results information
|
||||
setResult("momentum_x", sumMomentum_[0]);
|
||||
setResult("momentum_y", sumMomentum_[1]);
|
||||
setResult("momentum_z", sumMomentum_[2]);
|
||||
|
||||
setResult("momentum_r", sumAngularMom_[0]);
|
||||
setResult("momentum_rtheta", sumAngularMom_[1]);
|
||||
setResult("momentum_axis", sumAngularMom_[2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::momentum::write()
|
||||
{
|
||||
if (writeMomentum_ || (hasCsys_ && (writeVelocity_ || writePosition_)))
|
||||
{
|
||||
Log <<"Writing fields" << nl;
|
||||
|
||||
const volVectorField* fieldPtr;
|
||||
|
||||
fieldPtr = findObject<volVectorField>(scopedName("momentum"));
|
||||
if (fieldPtr) fieldPtr->write();
|
||||
|
||||
fieldPtr = findObject<volVectorField>(scopedName("angularMomentum"));
|
||||
if (fieldPtr) fieldPtr->write();
|
||||
|
||||
fieldPtr = findObject<volVectorField>(scopedName("angularVelocity"));
|
||||
if (fieldPtr) fieldPtr->write();
|
||||
|
||||
if (hasCsys_ && writePosition_)
|
||||
{
|
||||
// Clunky, but currently no simple means of handling
|
||||
// component-wise conversion and output
|
||||
|
||||
auto cyl_r = newField<volScalarField>("cyl_r", dimLength);
|
||||
auto cyl_t = newField<volScalarField>("cyl_theta", dimless);
|
||||
auto cyl_z = newField<volScalarField>("cyl_z", dimLength);
|
||||
|
||||
// Internal
|
||||
{
|
||||
const auto& pts = mesh_.cellCentres();
|
||||
const label len = pts.size();
|
||||
|
||||
UList<scalar>& r = cyl_r->primitiveFieldRef(false);
|
||||
UList<scalar>& t = cyl_t->primitiveFieldRef(false);
|
||||
UList<scalar>& z = cyl_z->primitiveFieldRef(false);
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
point p(csys_.localPosition(pts[i]));
|
||||
|
||||
r[i] = p.x();
|
||||
t[i] = p.y();
|
||||
z[i] = p.z();
|
||||
}
|
||||
}
|
||||
|
||||
// Boundary
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
const auto& pts = pbm[patchi].faceCentres();
|
||||
const label len = pts.size();
|
||||
|
||||
UList<scalar>& r = cyl_r->boundaryFieldRef(false)[patchi];
|
||||
UList<scalar>& t = cyl_t->boundaryFieldRef(false)[patchi];
|
||||
UList<scalar>& z = cyl_z->boundaryFieldRef(false)[patchi];
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
point p(csys_.localPosition(pts[i]));
|
||||
|
||||
r[i] = p.x();
|
||||
t[i] = p.y();
|
||||
z[i] = p.z();
|
||||
}
|
||||
}
|
||||
|
||||
cyl_r->write();
|
||||
cyl_t->write();
|
||||
cyl_z->write();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
266
src/functionObjects/field/momentum/momentum.H
Normal file
266
src/functionObjects/field/momentum/momentum.H
Normal file
@ -0,0 +1,266 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::momentum
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates linear/angular momentum, reporting integral values
|
||||
and optionally writing the fields.
|
||||
|
||||
Data is written into momentum.dat in the
|
||||
postProcessing/\<functionObjectName\> directory.
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
momentum1
|
||||
{
|
||||
type momentum;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
log yes;
|
||||
|
||||
regionType all;
|
||||
writeMomentum yes;
|
||||
writePosition yes;
|
||||
writeVelocity yes;
|
||||
|
||||
cylindrical true;
|
||||
|
||||
origin (0 0 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | Type name: momentum | yes |
|
||||
log | Log information to standard output | no | no
|
||||
writeMomentum | Write (linear, angular) momentum fields | no | no
|
||||
writePosition | Write angular position component fields | no | no
|
||||
writeVelocity | Write angular velocity fields | no | no
|
||||
p | Pressure field name | no | p
|
||||
U | Velocity field name | no | U
|
||||
rho | Density field name | no | rho
|
||||
rhoRef | Reference density (incompressible) | no | 1.0
|
||||
cylindrical | Use cylindrical coordinates | no | false
|
||||
origin | Origin for cylindrical coordinates | no |
|
||||
regionType | Selection type: all/cellSet/cellZone | no | all
|
||||
name | Name of cellSet/cellZone if required | no |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
- For incompressible cases, the value of \c rhoRef is used.
|
||||
- When specifying the cylindrical coordinate system, the rotation
|
||||
can be specified directly with e1/e2/e3 axes, or via a \c rotation
|
||||
sub-dictionary
|
||||
For example,
|
||||
\verbatim
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
{
|
||||
type cylindrical;
|
||||
axis (0 0 1);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::volRegion
|
||||
Foam::functionObjects::writeFile
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
momentum.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_momentum_H
|
||||
#define functionObjects_momentum_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "cylindricalCS.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "volRegion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class dimensionSet;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class momentum Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class momentum
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public volRegion,
|
||||
public writeFile
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the fields and integral values
|
||||
void calc();
|
||||
|
||||
//- Allocate a new zero geometric field
|
||||
template<class GeoField>
|
||||
autoPtr<GeoField> newField
|
||||
(
|
||||
const word& baseName,
|
||||
const dimensionSet& dims,
|
||||
bool registerObject=true
|
||||
) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Integral (linear) momentum
|
||||
vector sumMomentum_;
|
||||
|
||||
//- Integral angular momentum
|
||||
vector sumAngularMom_;
|
||||
|
||||
|
||||
// Read from dictionary
|
||||
|
||||
//- The velocity field name (optional)
|
||||
word UName_;
|
||||
|
||||
//- The pressure field name (optional)
|
||||
// Only used to determine incompressible/compressible
|
||||
word pName_;
|
||||
|
||||
//- The density field name (optional)
|
||||
word rhoName_;
|
||||
|
||||
//- Reference density (for incompressible)
|
||||
scalar rhoRef_;
|
||||
|
||||
//- Coordinate system for evaluating angular momentum
|
||||
coordSystem::cylindrical csys_;
|
||||
|
||||
//- Are we using the cylindrical coordinate system?
|
||||
bool hasCsys_;
|
||||
|
||||
//- Write fields flag
|
||||
bool writeMomentum_;
|
||||
|
||||
//- Write fields flag
|
||||
bool writeVelocity_;
|
||||
|
||||
//- Write fields flag
|
||||
bool writePosition_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Initialise the fields
|
||||
void initialise();
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os);
|
||||
|
||||
//- Write momentum data
|
||||
void writeValues(Ostream& os);
|
||||
|
||||
//- No copy construct
|
||||
momentum(const momentum&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const momentum&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("momentum");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
momentum
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const bool readFields = true
|
||||
);
|
||||
|
||||
//- Construct from objectRegistry and dictionary
|
||||
momentum
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool readFields = true
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~momentum() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the momentum data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate and report the integral momentum
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the momentum, possibly angular momentum and velocity
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -260,10 +260,9 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
patchSet_ =
|
||||
mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches")));
|
||||
distance_ = readScalar(dict.lookup("distance"));
|
||||
dict.readEntry("fields", fieldSet_);
|
||||
dict.readEntry("distance", distance_);
|
||||
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
|
||||
|
||||
|
||||
// Clear out any previously loaded fields
|
||||
|
||||
@ -37,9 +37,9 @@ void Foam::functionObjects::nearWallFields::createFields
|
||||
|
||||
HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>());
|
||||
|
||||
forAllConstIter(typename HashTable<const VolFieldType*>, flds, iter)
|
||||
forAllConstIters(flds, iter)
|
||||
{
|
||||
const VolFieldType& fld = *iter();
|
||||
const VolFieldType& fld = *(iter.object());
|
||||
|
||||
if (fieldMap_.found(fld.name()))
|
||||
{
|
||||
|
||||
@ -80,10 +80,10 @@ bool Foam::functionObjects::particleDistribution::read(const dictionary& dict)
|
||||
{
|
||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||
{
|
||||
dict.lookup("cloud") >> cloudName_;
|
||||
dict.lookup("nameVsBinWidth") >> nameVsBinWidth_;
|
||||
dict.readEntry("cloud", cloudName_);
|
||||
dict.readEntry("nameVsBinWidth", nameVsBinWidth_);
|
||||
dict.readIfPresent("tagField", tagFieldName_);
|
||||
word format(dict.lookup("setFormat"));
|
||||
const word format(dict.get<word>("setFormat"));
|
||||
writerPtr_ = writer<scalar>::New(format);
|
||||
|
||||
Info<< type() << " " << name() << " output:" << nl
|
||||
|
||||
@ -70,22 +70,19 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
return tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rhoScale",
|
||||
p.mesh().time().timeName(),
|
||||
p.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
p,
|
||||
fvPatchField<scalar>::calculatedType()
|
||||
)
|
||||
"rhoScale",
|
||||
p.mesh().time().timeName(),
|
||||
p.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
p,
|
||||
fvPatchField<scalar>::calculatedType()
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -115,10 +112,8 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
|
||||
{
|
||||
return lookupObject<volScalarField>(rhoName_)*tsf;
|
||||
}
|
||||
else
|
||||
{
|
||||
return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*tsf;
|
||||
}
|
||||
|
||||
return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*tsf;
|
||||
}
|
||||
|
||||
|
||||
@ -192,28 +187,23 @@ bool Foam::functionObjects::pressure::calc()
|
||||
{
|
||||
const volScalarField& p = lookupObject<volScalarField>(fieldName_);
|
||||
|
||||
tmp<volScalarField> tp
|
||||
auto tp = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
p.mesh().time().timeName(),
|
||||
p.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
coeff(pRef(pDyn(p, rhoScale(p))))
|
||||
)
|
||||
resultName_,
|
||||
p.mesh().time().timeName(),
|
||||
p.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
coeff(pRef(pDyn(p, rhoScale(p))))
|
||||
);
|
||||
|
||||
return store(resultName_, tp);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -238,13 +228,6 @@ Foam::functionObjects::pressure::pressure
|
||||
rhoInfInitialised_(false)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
dimensionSet pDims(dimPressure);
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
pDims /= dimPressure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -265,22 +248,22 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
|
||||
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
dict.readEntry("rhoInf", rhoInf_);
|
||||
rhoInfInitialised_ = true;
|
||||
}
|
||||
|
||||
dict.lookup("calcTotal") >> calcTotal_;
|
||||
dict.readEntry("calcTotal", calcTotal_);
|
||||
if (calcTotal_)
|
||||
{
|
||||
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0.0);
|
||||
}
|
||||
|
||||
dict.lookup("calcCoeff") >> calcCoeff_;
|
||||
dict.readEntry("calcCoeff", calcCoeff_);
|
||||
if (calcCoeff_)
|
||||
{
|
||||
dict.lookup("pInf") >> pInf_;
|
||||
dict.lookup("UInf") >> UInf_;
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
dict.readEntry("pInf", pInf_);
|
||||
dict.readEntry("UInf", UInf_);
|
||||
dict.readEntry("rhoInf", rhoInf_);
|
||||
|
||||
scalar zeroCheck = 0.5*rhoInf_*magSqr(UInf_) + pInf_;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1806 |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -91,10 +91,10 @@ bool Foam::functionObjects::processorField::read(const dictionary& dict)
|
||||
|
||||
bool Foam::functionObjects::processorField::execute()
|
||||
{
|
||||
const volScalarField& procField =
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
volScalarField& procField =
|
||||
mesh_.lookupObjectRef<volScalarField>("processorID");
|
||||
|
||||
const_cast<volScalarField&>(procField) ==
|
||||
procField ==
|
||||
dimensionedScalar("proci", dimless, Pstream::myProcNo());
|
||||
|
||||
return true;
|
||||
|
||||
@ -81,7 +81,7 @@ bool Foam::functionObjects::randomise::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
dict.lookup("magPerturbation") >> magPerturbation_;
|
||||
dict.readEntry("magPerturbation", magPerturbation_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -39,26 +39,25 @@ bool Foam::functionObjects::randomise::calcRandomised()
|
||||
|
||||
resultName_ = fieldName_ & "Random";
|
||||
|
||||
tmp<VolFieldType> rfieldt(new VolFieldType(field));
|
||||
VolFieldType& rfield = rfieldt.ref();
|
||||
auto trfield = tmp<VolFieldType>::New(field);
|
||||
auto& rfield = trfield.ref();
|
||||
|
||||
Random rand(1234567);
|
||||
|
||||
forAll(field, celli)
|
||||
for (Type& cellval : rfield)
|
||||
{
|
||||
Type rndPert;
|
||||
rand.randomise01(rndPert);
|
||||
rndPert = 2.0*rndPert - pTraits<Type>::one;
|
||||
rndPert /= mag(rndPert);
|
||||
rfield[celli] += magPerturbation_*rndPert;
|
||||
|
||||
cellval += magPerturbation_*rndPert;
|
||||
}
|
||||
|
||||
return store(resultName_, rfieldt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return store(resultName_, trfield);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -78,24 +78,20 @@ calculateSpeciesRR
|
||||
const basicChemistryModel& basicChemistry
|
||||
)
|
||||
{
|
||||
tmp<DimensionedField<scalar, volMesh>> RRt
|
||||
auto RRt = tmp<DimensionedField<scalar, volMesh>>::New
|
||||
(
|
||||
new DimensionedField<scalar, volMesh>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"RR",
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
"RR",
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dimMass/dimVolume/dimTime, Zero)
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimMass/dimVolume/dimTime, Zero)
|
||||
);
|
||||
|
||||
DimensionedField<scalar, volMesh>& RR = RRt.ref();
|
||||
auto& RR = RRt.ref();
|
||||
|
||||
scalar dt = time_.deltaT().value();
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1806 |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -74,7 +74,7 @@ bool Foam::functionObjects::readFields::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
dict.readEntry("fields", fieldSet_);
|
||||
dict.readIfPresent("readOnStart", readOnStart_);
|
||||
|
||||
return true;
|
||||
|
||||
@ -47,13 +47,15 @@ bool Foam::functionObjects::readFields::loadField(const word& fieldName)
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo<< "readFields: " << SurfaceFieldType::typeName
|
||||
DebugInfo
|
||||
<< "readFields: " << SurfaceFieldType::typeName
|
||||
<< " " << fieldName << " already exists in database"
|
||||
<< " already in database" << endl;
|
||||
}
|
||||
else if (foundObject<SurfFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo<< "readFields: " << SurfFieldType::typeName
|
||||
DebugInfo
|
||||
<< "readFields: " << SurfFieldType::typeName
|
||||
<< " " << fieldName << " already exists in database"
|
||||
<< " already in database" << endl;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ bool Foam::functionObjects::reference::calcType()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
const VolFieldType* vfPtr = lookupObjectPtr<VolFieldType>(fieldName_);
|
||||
const VolFieldType* vfPtr = findObject<VolFieldType>(fieldName_);
|
||||
|
||||
if (vfPtr)
|
||||
{
|
||||
|
||||
@ -209,8 +209,8 @@ Foam::functionObjects::regionSizeDistribution::divide
|
||||
const scalarField& denom
|
||||
)
|
||||
{
|
||||
tmp<scalarField> tresult(new scalarField(num.size()));
|
||||
scalarField& result = tresult.ref();
|
||||
auto tresult = tmp<scalarField>::New(num.size());
|
||||
auto& result = tresult.ref();
|
||||
|
||||
forAll(denom, i)
|
||||
{
|
||||
@ -317,8 +317,8 @@ Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name),
|
||||
alphaName_(dict.lookup("field")),
|
||||
patchNames_(dict.lookup("patches")),
|
||||
alphaName_(dict.get<word>("field")),
|
||||
patchNames_(dict.get<wordRes>("patches")),
|
||||
isoPlanes_(dict.lookupOrDefault("isoPlanes", false))
|
||||
{
|
||||
read(dict);
|
||||
@ -338,34 +338,41 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
dict.lookup("field") >> alphaName_;
|
||||
dict.lookup("patches") >> patchNames_;
|
||||
dict.lookup("threshold") >> threshold_;
|
||||
dict.lookup("maxDiameter") >> maxDiam_;
|
||||
dict.readEntry("field", alphaName_);
|
||||
dict.readEntry("patches", patchNames_);
|
||||
dict.readEntry("threshold", threshold_);
|
||||
dict.readEntry("maxDiameter", maxDiam_);
|
||||
minDiam_ = 0.0;
|
||||
dict.readIfPresent("minDiameter", minDiam_);
|
||||
dict.lookup("nBins") >> nBins_;
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.readEntry("nBins", nBins_);
|
||||
dict.readEntry("fields", fields_);
|
||||
|
||||
word format(dict.lookup("setFormat"));
|
||||
const word format(dict.get<word>("setFormat"));
|
||||
formatterPtr_ = writer<scalar>::New(format);
|
||||
|
||||
if (dict.found("coordinateSystem"))
|
||||
if (dict.found(coordinateSystem::typeName_()))
|
||||
{
|
||||
coordSysPtr_.reset(new coordinateSystem(obr_, dict));
|
||||
csysPtr_.reset
|
||||
(
|
||||
coordinateSystem::New(obr_, dict, coordinateSystem::typeName_())
|
||||
);
|
||||
|
||||
Info<< "Transforming all vectorFields with coordinate system "
|
||||
<< coordSysPtr_().name() << endl;
|
||||
<< csysPtr_->name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
csysPtr_.clear();
|
||||
}
|
||||
|
||||
if (isoPlanes_)
|
||||
{
|
||||
dict.lookup("origin") >> origin_;
|
||||
dict.lookup("direction") >> direction_;
|
||||
dict.lookup("maxDiameter") >> maxDiameter_;
|
||||
dict.lookup("nDownstreamBins") >> nDownstreamBins_;
|
||||
dict.lookup("maxDownstream") >> maxDownstream_;
|
||||
direction_ /= mag(direction_);
|
||||
dict.readEntry("origin", origin_);
|
||||
dict.readEntry("direction", direction_);
|
||||
dict.readEntry("maxDiameter", maxDiameter_);
|
||||
dict.readEntry("nDownstreamBins", nDownstreamBins_);
|
||||
dict.readEntry("maxDownstream", maxDownstream_);
|
||||
direction_.normalise();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -458,6 +465,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
|
||||
{
|
||||
tmp<scalarField> townFld(fvp.patchInternalField());
|
||||
const scalarField& ownFld = townFld();
|
||||
|
||||
tmp<scalarField> tnbrFld(fvp.patchNeighbourField());
|
||||
const scalarField& nbrFld = tnbrFld();
|
||||
|
||||
@ -896,14 +904,14 @@ bool Foam::functionObjects::regionSizeDistribution::write()
|
||||
volVectorField
|
||||
>(fldName).primitiveField();
|
||||
|
||||
if (coordSysPtr_.valid())
|
||||
if (csysPtr_.valid())
|
||||
{
|
||||
Log << "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
<< coordSysPtr_().name()
|
||||
<< csysPtr_->name()
|
||||
<< endl;
|
||||
|
||||
fld = coordSysPtr_().localVector(fld);
|
||||
fld = csysPtr_->localVector(fld);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -113,8 +113,8 @@ Usage
|
||||
maxDiameter | maximum region equivalent diameter | yes |
|
||||
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
|
||||
origin | origin of local coordinate system | yes |
|
||||
coordinateRoation | orientation of local coordinate 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
|
||||
@ -198,7 +198,7 @@ class regionSizeDistribution
|
||||
autoPtr<writer<scalar>> formatterPtr_;
|
||||
|
||||
//- Optional coordinate system
|
||||
autoPtr<coordinateSystem> coordSysPtr_;
|
||||
autoPtr<coordinateSystem> csysPtr_;
|
||||
|
||||
// Optional extra definition of bins on planes downstream to the origin
|
||||
// point and maximum diameter
|
||||
|
||||
@ -53,12 +53,12 @@ const Foam::Enum
|
||||
Foam::functionObjects::setFlow::modeType
|
||||
>
|
||||
Foam::functionObjects::setFlow::modeTypeNames
|
||||
{
|
||||
({
|
||||
{ functionObjects::setFlow::modeType::FUNCTION, "function" },
|
||||
{ functionObjects::setFlow::modeType::ROTATION, "rotation" },
|
||||
{ functionObjects::setFlow::modeType::VORTEX2D, "vortex2D" },
|
||||
{ functionObjects::setFlow::modeType::VORTEX3D, "vortex3D" }
|
||||
};
|
||||
{ functionObjects::setFlow::modeType::VORTEX3D, "vortex3D" },
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -66,7 +66,7 @@ Foam::functionObjects::setFlow::modeTypeNames
|
||||
void Foam::functionObjects::setFlow::setPhi(const volVectorField& U)
|
||||
{
|
||||
surfaceScalarField* phiptr =
|
||||
mesh_.lookupObjectRefPtr<surfaceScalarField>(phiName_);
|
||||
mesh_.getObjectPtr<surfaceScalarField>(phiName_);
|
||||
|
||||
if (!phiptr)
|
||||
{
|
||||
@ -76,7 +76,7 @@ void Foam::functionObjects::setFlow::setPhi(const volVectorField& U)
|
||||
if (rhoName_ != "none")
|
||||
{
|
||||
const volScalarField* rhoptr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(rhoName_);
|
||||
mesh_.findObject<volScalarField>(rhoName_);
|
||||
|
||||
if (rhoptr)
|
||||
{
|
||||
@ -137,7 +137,8 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict)
|
||||
if (fvMeshFunctionObject::read(dict))
|
||||
{
|
||||
Info<< name() << ":" << endl;
|
||||
mode_ = modeTypeNames.read(dict.lookup("mode"));
|
||||
|
||||
modeTypeNames.readEntry("mode", dict, mode_);
|
||||
|
||||
Info<< " operating mode: " << modeTypeNames[mode_] << endl;
|
||||
|
||||
@ -176,22 +177,21 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict)
|
||||
case modeType::ROTATION:
|
||||
{
|
||||
omegaPtr_ = Function1<scalar>::New("omega", dict);
|
||||
dict.lookup("origin") >> origin_;
|
||||
vector refDir(dict.lookup("refDir"));
|
||||
refDir /= mag(refDir) + ROOTVSMALL;
|
||||
vector axis(dict.lookup("axis"));
|
||||
axis /= mag(axis) + ROOTVSMALL;
|
||||
|
||||
dict.readEntry("origin", origin_);
|
||||
const vector refDir(dict.get<vector>("refDir").normalise());
|
||||
const vector axis(dict.get<vector>("axis").normalise());
|
||||
|
||||
R_ = tensor(refDir, axis, refDir^axis);
|
||||
break;
|
||||
}
|
||||
case modeType::VORTEX2D:
|
||||
case modeType::VORTEX3D:
|
||||
{
|
||||
dict.lookup("origin") >> origin_;
|
||||
vector refDir(dict.lookup("refDir"));
|
||||
refDir /= mag(refDir) + ROOTVSMALL;
|
||||
vector axis(dict.lookup("axis"));
|
||||
axis /= mag(axis) + ROOTVSMALL;
|
||||
dict.readEntry("origin", origin_);
|
||||
const vector refDir(dict.get<vector>("refDir").normalise());
|
||||
const vector axis(dict.get<vector>("axis").normalise());
|
||||
|
||||
R_ = tensor(refDir, axis, refDir^axis);
|
||||
break;
|
||||
}
|
||||
@ -208,10 +208,11 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict)
|
||||
|
||||
bool Foam::functionObjects::setFlow::execute()
|
||||
{
|
||||
volVectorField* Uptr = mesh_.lookupObjectRefPtr<volVectorField>(UName_);
|
||||
volVectorField* Uptr =
|
||||
mesh_.getObjectPtr<volVectorField>(UName_);
|
||||
|
||||
surfaceScalarField* phiptr =
|
||||
mesh_.lookupObjectRefPtr<surfaceScalarField>(phiName_);
|
||||
mesh_.getObjectPtr<surfaceScalarField>(phiName_);
|
||||
|
||||
Log << nl << name() << ":" << nl;
|
||||
|
||||
@ -432,13 +433,13 @@ bool Foam::functionObjects::setFlow::execute()
|
||||
|
||||
bool Foam::functionObjects::setFlow::write()
|
||||
{
|
||||
const auto& Uptr = mesh_.lookupObjectRefPtr<volVectorField>(UName_);
|
||||
const auto* Uptr = mesh_.findObject<volVectorField>(UName_);
|
||||
if (Uptr)
|
||||
{
|
||||
Uptr->write();
|
||||
}
|
||||
|
||||
const auto& phiptr = mesh_.lookupObjectRefPtr<surfaceScalarField>(phiName_);
|
||||
const auto* phiptr = mesh_.findObject<surfaceScalarField>(phiName_);
|
||||
if (phiptr)
|
||||
{
|
||||
phiptr->write();
|
||||
|
||||
@ -102,8 +102,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::calc()
|
||||
|
||||
bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
{
|
||||
const IOField<scalar>* residualPtr =
|
||||
mesh_.lookupObjectPtr<IOField<scalar>>(residualName_);
|
||||
const auto* residualPtr = mesh_.findObject<IOField<scalar>>(residualName_);
|
||||
|
||||
if (residuals_)
|
||||
{
|
||||
@ -164,7 +163,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
}
|
||||
|
||||
const volScalarField* nonOrthPtr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(nonOrthogonalityName_);
|
||||
mesh_.findObject<volScalarField>(nonOrthogonalityName_);
|
||||
|
||||
if (nonOrthogonality_)
|
||||
{
|
||||
@ -200,7 +199,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
}
|
||||
|
||||
const volScalarField* skewnessPtr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(skewnessName_);
|
||||
mesh_.findObject<volScalarField>(skewnessName_);
|
||||
|
||||
if (skewness_)
|
||||
{
|
||||
@ -235,7 +234,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
}
|
||||
|
||||
const volScalarField* faceWeightsPtr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(faceWeightName_);
|
||||
mesh_.findObject<volScalarField>(faceWeightName_);
|
||||
|
||||
if (faceWeight_)
|
||||
{
|
||||
@ -279,23 +278,21 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
tmp<volScalarField> magGradCCPtr
|
||||
auto tmagGradCC = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"magGradCC",
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
"magGradCC",
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
auto& magGradCC = tmagGradCC.ref();
|
||||
|
||||
for (direction i=0; i<vector::nComponents; i++)
|
||||
{
|
||||
@ -316,12 +313,12 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
);
|
||||
cci = mesh_.C().component(i);
|
||||
cci.correctBoundaryConditions();
|
||||
magGradCCPtr.ref() += mag(fvc::grad(cci)).ref();
|
||||
magGradCC += mag(fvc::grad(cci)).ref();
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
Log << " Max magGradCc : " << max(magGradCCPtr.ref()).value()
|
||||
Log << " Max magGradCc : " << max(magGradCC.ref()).value()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -334,7 +331,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
max
|
||||
(
|
||||
scalar(0),
|
||||
(magGradCCPtr.ref() - maxGradCc_)
|
||||
(magGradCC - maxGradCc_)
|
||||
/ (minGradCc_ - maxGradCc_)
|
||||
),
|
||||
scalar(1)
|
||||
@ -344,7 +341,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
|
||||
|
||||
const volVectorField* UNamePtr =
|
||||
mesh_.lookupObjectPtr<volVectorField>(UName_);
|
||||
mesh_.findObject<volVectorField>(UName_);
|
||||
|
||||
if (Co_)
|
||||
{
|
||||
@ -355,25 +352,22 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
tmp<volScalarField> CoPtr
|
||||
auto CoPtr = tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Co",
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
"Co",
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
volScalarField& Co = CoPtr.ref();
|
||||
auto& Co = CoPtr.ref();
|
||||
|
||||
Co.primitiveFieldRef() =
|
||||
mesh_.time().deltaT()*mag(*UNamePtr)/pow(mesh_.V(), 1.0/3.0);
|
||||
@ -417,12 +411,10 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
|
||||
indicator_.max(0.0);
|
||||
|
||||
// Update the blended surface field
|
||||
surfaceScalarField* surBlendedPtr =
|
||||
(
|
||||
mesh_.lookupObjectRefPtr<surfaceScalarField>(resultName_)
|
||||
);
|
||||
surfaceScalarField& surBlended =
|
||||
mesh_.lookupObjectRef<surfaceScalarField>(resultName_);
|
||||
|
||||
*surBlendedPtr = fvc::interpolate(indicator_);
|
||||
surBlended = fvc::interpolate(indicator_);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -511,26 +503,23 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
|
||||
read(dict);
|
||||
setResultName(typeName, "");
|
||||
|
||||
tmp<surfaceScalarField> faceBlendedPtr
|
||||
auto faceBlendedPtr = tmp<surfaceScalarField>::New
|
||||
(
|
||||
new surfaceScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
resultName_,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
);
|
||||
store(resultName_, faceBlendedPtr);
|
||||
|
||||
const volScalarField* nonOrthPtr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(nonOrthogonalityName_);
|
||||
mesh_.findObject<volScalarField>(nonOrthogonalityName_);
|
||||
|
||||
if (nonOrthogonality_)
|
||||
{
|
||||
@ -562,7 +551,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
|
||||
|
||||
|
||||
const volScalarField* faceWeightsPtr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(faceWeightName_);
|
||||
mesh_.findObject<volScalarField>(faceWeightName_);
|
||||
|
||||
if (faceWeight_)
|
||||
{
|
||||
@ -593,7 +582,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
|
||||
}
|
||||
|
||||
const volScalarField* skewnessPtr =
|
||||
mesh_.lookupObjectPtr<volScalarField>(skewnessName_);
|
||||
mesh_.findObject<volScalarField>(skewnessName_);
|
||||
|
||||
if (skewness_)
|
||||
{
|
||||
@ -653,12 +642,12 @@ bool Foam::functionObjects::stabilityBlendingFactor::read
|
||||
{
|
||||
if (fieldExpression::read(dict) && writeFile::read(dict))
|
||||
{
|
||||
dict.lookup("switchNonOrtho") >> nonOrthogonality_;
|
||||
dict.lookup("switchGradCc") >> gradCc_;
|
||||
dict.lookup("switchResiduals") >> residuals_;
|
||||
dict.lookup("switchFaceWeight") >> faceWeight_;
|
||||
dict.lookup("switchSkewness") >> skewness_;
|
||||
dict.lookup("switchCo") >> Co_;
|
||||
dict.readEntry("switchNonOrtho", nonOrthogonality_);
|
||||
dict.readEntry("switchGradCc", gradCc_);
|
||||
dict.readEntry("switchResiduals", residuals_);
|
||||
dict.readEntry("switchFaceWeight", faceWeight_);
|
||||
dict.readEntry("switchSkewness", skewness_);
|
||||
dict.readEntry("switchCo", Co_);
|
||||
|
||||
dict.readIfPresent("maxNonOrthogonality", maxNonOrthogonality_);
|
||||
dict.readIfPresent("maxGradCc", maxGradCc_);
|
||||
|
||||
@ -71,27 +71,21 @@ Foam::tmp<Foam::pointScalarField> Foam::functionObjects::streamFunction::calc
|
||||
|
||||
const pointMesh& pMesh = pointMesh::New(mesh_);
|
||||
|
||||
tmp<pointScalarField> tstreamFunction
|
||||
auto tstreamFunction = tmp<pointScalarField>::New
|
||||
(
|
||||
new pointScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"streamFunction",
|
||||
time_.timeName(),
|
||||
mesh_
|
||||
),
|
||||
pMesh,
|
||||
dimensionedScalar(phi.dimensions(), Zero)
|
||||
)
|
||||
"streamFunction",
|
||||
time_.timeName(),
|
||||
mesh_
|
||||
),
|
||||
pMesh,
|
||||
dimensionedScalar(phi.dimensions(), Zero)
|
||||
);
|
||||
pointScalarField& streamFunction = tstreamFunction.ref();
|
||||
|
||||
labelList visitedPoint(mesh_.nPoints());
|
||||
forAll(visitedPoint, pointi)
|
||||
{
|
||||
visitedPoint[pointi] = 0;
|
||||
}
|
||||
labelList visitedPoint(mesh_.nPoints(), Zero);
|
||||
|
||||
label nVisited = 0;
|
||||
label nVisitedOld = 0;
|
||||
|
||||
@ -263,7 +257,7 @@ Foam::tmp<Foam::pointScalarField> Foam::functionObjects::streamFunction::calc
|
||||
points[curBPoints[pointi]]
|
||||
- currentBStreamPoint;
|
||||
edgeHat.replace(slabDir, 0);
|
||||
edgeHat /= mag(edgeHat);
|
||||
edgeHat.normalise();
|
||||
|
||||
vector nHat = unitAreas[facei];
|
||||
|
||||
@ -356,7 +350,7 @@ Foam::tmp<Foam::pointScalarField> Foam::functionObjects::streamFunction::calc
|
||||
points[curPoints[pointi]] - currentStreamPoint;
|
||||
|
||||
edgeHat.replace(slabDir, 0);
|
||||
edgeHat /= mag(edgeHat);
|
||||
edgeHat.normalise();
|
||||
|
||||
vector nHat = unitAreas[facei];
|
||||
|
||||
|
||||
@ -646,9 +646,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
||||
|
||||
fileName vtkPath
|
||||
(
|
||||
Pstream::parRun()
|
||||
? time_.path()/".."/functionObject::outputPrefix/"sets"/name()
|
||||
: time_.path()/functionObject::outputPrefix/"sets"/name()
|
||||
time_.globalPath()/functionObject::outputPrefix/"sets"/name()
|
||||
);
|
||||
if (mesh_.name() != fvMesh::defaultRegion)
|
||||
{
|
||||
@ -785,7 +783,11 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
||||
for (const word& fieldName : scalarNames_)
|
||||
{
|
||||
dictionary propsDict;
|
||||
propsDict.add("file", scalarVtkFile);
|
||||
propsDict.add
|
||||
(
|
||||
"file",
|
||||
time_.relativePath(scalarVtkFile, true)
|
||||
);
|
||||
setProperty(fieldName, propsDict);
|
||||
}
|
||||
|
||||
@ -793,7 +795,11 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
||||
for (const word& fieldName : vectorNames_)
|
||||
{
|
||||
dictionary propsDict;
|
||||
propsDict.add("file", vectorVtkFile);
|
||||
propsDict.add
|
||||
(
|
||||
"file",
|
||||
time_.relativePath(vectorVtkFile, true)
|
||||
);
|
||||
setProperty(fieldName, propsDict);
|
||||
}
|
||||
|
||||
@ -865,7 +871,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
|
||||
|
||||
if (fields_.empty())
|
||||
{
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.readEntry("fields", fields_);
|
||||
|
||||
if (!fields_.found(UName_))
|
||||
{
|
||||
@ -878,8 +884,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
|
||||
|
||||
Info<< " Employing velocity field " << UName_ << endl;
|
||||
|
||||
dict.lookup("trackForward") >> trackForward_;
|
||||
dict.lookup("lifeTime") >> lifeTime_;
|
||||
dict.readEntry("trackForward", trackForward_);
|
||||
dict.readEntry("lifeTime", lifeTime_);
|
||||
if (lifeTime_ < 1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -916,8 +922,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
|
||||
sampledSetPtr_.clear();
|
||||
sampledSetAxis_.clear();
|
||||
|
||||
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
|
||||
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
|
||||
scalarFormatterPtr_ = writer<scalar>::New(dict.get<word>("setFormat"));
|
||||
vectorFormatterPtr_ = writer<vector>::New(dict.get<word>("setFormat"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ bool Foam::functionObjects::surfaceInterpolate::read
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
dict.readEntry("fields", fieldSet_);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -107,14 +107,12 @@ bool Foam::functionObjects::surfaceInterpolate::write()
|
||||
{
|
||||
const word& fieldName = fieldSet_[i].second();
|
||||
|
||||
if (mesh_.foundObject<regIOobject>(fieldName))
|
||||
const regIOobject* ioptr = obr_.findObject<regIOobject>(fieldName);
|
||||
|
||||
if (ioptr)
|
||||
{
|
||||
Log << " " << fieldName << nl;
|
||||
|
||||
const regIOobject& field =
|
||||
obr_.lookupObject<regIOobject>(fieldName);
|
||||
|
||||
field.write();
|
||||
ioptr->write();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1806 |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -50,7 +50,7 @@ const Foam::Enum
|
||||
Foam::functionObjects::turbulenceFields::compressibleField
|
||||
>
|
||||
Foam::functionObjects::turbulenceFields::compressibleFieldNames_
|
||||
{
|
||||
({
|
||||
{ compressibleField::cfK, "k" },
|
||||
{ compressibleField::cfEpsilon, "epsilon" },
|
||||
{ compressibleField::cfOmega, "omega" },
|
||||
@ -62,8 +62,8 @@ Foam::functionObjects::turbulenceFields::compressibleFieldNames_
|
||||
{ compressibleField::cfR, "R" },
|
||||
{ compressibleField::cfDevRhoReff, "devRhoReff" },
|
||||
{ compressibleField::cfL, "L" },
|
||||
{ compressibleField::cfI, "I" }
|
||||
};
|
||||
{ compressibleField::cfI, "I" },
|
||||
});
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
@ -71,7 +71,7 @@ const Foam::Enum
|
||||
Foam::functionObjects::turbulenceFields::incompressibleField
|
||||
>
|
||||
Foam::functionObjects::turbulenceFields::incompressibleFieldNames_
|
||||
{
|
||||
({
|
||||
{ incompressibleField::ifK, "k" },
|
||||
{ incompressibleField::ifEpsilon, "epsilon" },
|
||||
{ incompressibleField::ifOmega, "omega" },
|
||||
@ -81,8 +81,8 @@ Foam::functionObjects::turbulenceFields::incompressibleFieldNames_
|
||||
{ incompressibleField::ifR, "R" },
|
||||
{ incompressibleField::ifDevReff, "devReff" },
|
||||
{ incompressibleField::ifL, "L" },
|
||||
{ incompressibleField::ifI, "I" }
|
||||
};
|
||||
{ incompressibleField::ifI, "I" },
|
||||
});
|
||||
|
||||
|
||||
const Foam::word Foam::functionObjects::turbulenceFields::modelName
|
||||
@ -103,12 +103,10 @@ bool Foam::functionObjects::turbulenceFields::compressible()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Turbulence model not found in database, deactivating"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Turbulence model not found in database, deactivating"
|
||||
<< exit(FatalError);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -144,11 +142,11 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||
|
||||
if (dict.found("field"))
|
||||
{
|
||||
fieldSet_.insert(word(dict.lookup("field")));
|
||||
fieldSet_.insert(dict.get<word>("field"));
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldSet_.insert(wordList(dict.lookup("fields")));
|
||||
fieldSet_.insert(dict.get<wordList>("fields"));
|
||||
}
|
||||
|
||||
Info<< type() << " " << name() << ": ";
|
||||
|
||||
@ -38,11 +38,11 @@ void Foam::functionObjects::turbulenceFields::processField
|
||||
|
||||
const word scopedName = modelName + ':' + fieldName;
|
||||
|
||||
if (obr_.foundObject<FieldType>(scopedName))
|
||||
FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName);
|
||||
|
||||
if (fldPtr)
|
||||
{
|
||||
FieldType& fld =
|
||||
const_cast<FieldType&>(obr_.lookupObject<FieldType>(scopedName));
|
||||
fld == tvalue();
|
||||
(*fldPtr) == tvalue();
|
||||
}
|
||||
else if (obr_.found(scopedName))
|
||||
{
|
||||
|
||||
@ -87,7 +87,7 @@ Foam::functionObjects::valueAverage::valueAverage
|
||||
if (dict.found(fieldName))
|
||||
{
|
||||
const dictionary& valueDict = dict.subDict(fieldName);
|
||||
totalTime_[fieldi] = readScalar(valueDict.lookup("totalTime"));
|
||||
valueDict.readEntry("totalTime", totalTime_[fieldi]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,8 +112,8 @@ bool Foam::functionObjects::valueAverage::read(const dictionary& dict)
|
||||
// Make certain that the values are consistent with the defaults:
|
||||
resetOnRestart_ = false;
|
||||
|
||||
dict.lookup("functionObject") >> functionObjectName_;
|
||||
dict.lookup("fields") >> fieldNames_;
|
||||
dict.readEntry("functionObject", functionObjectName_);
|
||||
dict.readEntry("fields", fieldNames_);
|
||||
if (dict.readIfPresent("window", window_))
|
||||
{
|
||||
window_ = obr().time().userTimeToTime(window_);
|
||||
|
||||
@ -57,12 +57,8 @@ bool Foam::functionObjects::vorticity::calc()
|
||||
fvc::curl(lookupObject<volVectorField>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -316,8 +316,7 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
|
||||
|
||||
// Outwards pointing normal
|
||||
vector edgeNormal = (pt1 - pt0)^n;
|
||||
|
||||
edgeNormal /= mag(edgeNormal) + VSMALL;
|
||||
edgeNormal.normalise();
|
||||
|
||||
// Determine whether position and end point on either side of edge.
|
||||
scalar sEnd = (endPosition - pt0)&edgeNormal;
|
||||
|
||||
@ -127,7 +127,7 @@ Foam::scalar Foam::wallBoundedParticle::trackToEdge
|
||||
const bool posVol = (nbrTi.tet(mesh()).mag() > 0);
|
||||
const vector path(endPosition - localPosition_);
|
||||
|
||||
if (posVol == ((nbrTi.faceTri(mesh()).normal() & path) < 0))
|
||||
if (posVol == ((nbrTi.faceTri(mesh()).areaNormal() & path) < 0))
|
||||
{
|
||||
// Change into nbrCell. No need to change tetFace, tetPt.
|
||||
//Pout<< " crossed from cell:" << celli_
|
||||
@ -166,8 +166,7 @@ Foam::scalar Foam::wallBoundedParticle::trackToEdge
|
||||
}
|
||||
|
||||
const triFace tri(currentTetIndices().faceTriIs(mesh(), false));
|
||||
vector n = tri.normal(mesh().points());
|
||||
n /= mag(n);
|
||||
const vector n = tri.unitNormal(mesh().points());
|
||||
|
||||
point projectedEndPosition = endPosition;
|
||||
|
||||
|
||||
@ -183,28 +183,39 @@ bool Foam::functionObjects::wallShearStress::execute()
|
||||
volVectorField& wallShearStress =
|
||||
mesh_.lookupObjectRef<volVectorField>(type());
|
||||
|
||||
const word& turbModelName = turbulenceModel::propertiesName;
|
||||
auto cmpModelPtr =
|
||||
mesh_.lookupObjectPtr<compressible::turbulenceModel>(turbModelName);
|
||||
auto icoModelPtr =
|
||||
mesh_.lookupObjectPtr<incompressible::turbulenceModel>(turbModelName);
|
||||
// Compressible
|
||||
{
|
||||
typedef compressible::turbulenceModel turbType;
|
||||
|
||||
if (cmpModelPtr)
|
||||
{
|
||||
calcShearStress(cmpModelPtr->devRhoReff(), wallShearStress);
|
||||
}
|
||||
else if (icoModelPtr)
|
||||
{
|
||||
calcShearStress(icoModelPtr->devReff(), wallShearStress);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
const turbType* modelPtr =
|
||||
findObject<turbType>(turbulenceModel::propertiesName);
|
||||
|
||||
if (modelPtr)
|
||||
{
|
||||
calcShearStress(modelPtr->devRhoReff(), wallShearStress);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// Incompressible
|
||||
{
|
||||
typedef incompressible::turbulenceModel turbType;
|
||||
|
||||
const turbType* modelPtr =
|
||||
findObject<turbType>(turbulenceModel::propertiesName);
|
||||
|
||||
if (modelPtr)
|
||||
{
|
||||
calcShearStress(modelPtr->devReff(), wallShearStress);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -120,10 +120,7 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::yPlus::execute()
|
||||
{
|
||||
volScalarField& yPlus =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupObject<volScalarField>(typeName)
|
||||
);
|
||||
lookupObjectRef<volScalarField>(typeName);
|
||||
|
||||
if (foundObject<turbulenceModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "zeroGradient.H"
|
||||
|
||||
#include "stringListOps.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "wordRes.H"
|
||||
@ -112,7 +112,7 @@ bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> selectFields_;
|
||||
dict.readEntry("fields", selectFields_);
|
||||
selectFields_.uniq();
|
||||
|
||||
Info<< type() << " fields: " << selectFields_ << nl;
|
||||
@ -133,9 +133,9 @@ bool Foam::functionObjects::zeroGradient::execute()
|
||||
// Check exact matches first
|
||||
for (const wordRe& select : selectFields_)
|
||||
{
|
||||
if (!select.isPattern())
|
||||
if (select.isLiteral())
|
||||
{
|
||||
const word& fieldName = static_cast<const word&>(select);
|
||||
const word& fieldName = select;
|
||||
|
||||
if (!candidates.erase(fieldName))
|
||||
{
|
||||
@ -176,16 +176,15 @@ bool Foam::functionObjects::zeroGradient::write()
|
||||
}
|
||||
|
||||
// Consistent output order
|
||||
const wordList outputList = results_.sortedToc();
|
||||
for (const word& fieldName : outputList)
|
||||
for (const word& fieldName : results_.sortedToc())
|
||||
{
|
||||
if (foundObject<regIOobject>(fieldName))
|
||||
{
|
||||
const regIOobject& io = lookupObject<regIOobject>(fieldName);
|
||||
const regIOobject* ioptr = findObject<regIOobject>(fieldName);
|
||||
|
||||
if (ioptr)
|
||||
{
|
||||
Log << " " << fieldName << endl;
|
||||
|
||||
io.write();
|
||||
ioptr->write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,29 +83,25 @@ int Foam::functionObjects::zeroGradient::apply
|
||||
|
||||
if (!foundObject<VolFieldType>(outputName))
|
||||
{
|
||||
tmp<VolFieldType> tzg
|
||||
auto tzeroGrad = tmp<VolFieldType>::New
|
||||
(
|
||||
new VolFieldType
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
outputName,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
outputName,
|
||||
time_.timeName(),
|
||||
mesh_,
|
||||
dimensioned<Type>(input.dimensions(), Zero),
|
||||
zeroGradientFvPatchField<Type>::typeName
|
||||
)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensioned<Type>(input.dimensions(), Zero),
|
||||
zeroGradientFvPatchField<Type>::typeName
|
||||
);
|
||||
|
||||
store(outputName, tzg);
|
||||
store(outputName, tzeroGrad);
|
||||
}
|
||||
|
||||
VolFieldType& output =
|
||||
const_cast<VolFieldType&>(lookupObject<VolFieldType>(outputName));
|
||||
VolFieldType& output = lookupObjectRef<VolFieldType>(outputName);
|
||||
|
||||
output = input;
|
||||
output.correctBoundaryConditions();
|
||||
|
||||
@ -243,24 +243,24 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
||||
forces::read(dict);
|
||||
|
||||
// Directions for lift and drag forces, and pitch moment
|
||||
dict.lookup("liftDir") >> liftDir_;
|
||||
dict.lookup("dragDir") >> dragDir_;
|
||||
dict.lookup("pitchAxis") >> pitchAxis_;
|
||||
dict.readEntry("liftDir", liftDir_);
|
||||
dict.readEntry("dragDir", dragDir_);
|
||||
dict.readEntry("pitchAxis", pitchAxis_);
|
||||
|
||||
// Free stream velocity magnitude
|
||||
dict.lookup("magUInf") >> magUInf_;
|
||||
dict.readEntry("magUInf", magUInf_);
|
||||
|
||||
// If case is compressible we must read rhoInf (store in rhoRef_) to
|
||||
// calculate the reference dynamic pressure
|
||||
// - note: for incompressible, rhoRef_ is already initialised
|
||||
if (rhoName_ != "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoRef_;
|
||||
dict.readEntry("rhoInf", rhoRef_);
|
||||
}
|
||||
|
||||
// Reference length and area scales
|
||||
dict.lookup("lRef") >> lRef_;
|
||||
dict.lookup("Aref") >> Aref_;
|
||||
dict.readEntry("lRef", lRef_);
|
||||
dict.readEntry("Aref", Aref_);
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
@ -402,16 +402,10 @@ bool Foam::functionObjects::forceCoeffs::execute()
|
||||
lookupObject<volVectorField>(fieldName("moment"));
|
||||
|
||||
volVectorField& forceCoeff =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("forceCoeff"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("forceCoeff"));
|
||||
|
||||
volVectorField& momentCoeff =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("momentCoeff"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("momentCoeff"));
|
||||
|
||||
dimensionedScalar f0("f0", dimForce, Aref_*pDyn);
|
||||
dimensionedScalar m0("m0", dimForce*dimLength, Aref_*lRef_*pDyn);
|
||||
|
||||
@ -29,6 +29,7 @@ License
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "cartesianCS.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -37,7 +38,6 @@ namespace Foam
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(forces, 0);
|
||||
|
||||
addToRunTimeSelectionTable(functionObject, forces, dictionary);
|
||||
}
|
||||
}
|
||||
@ -292,18 +292,12 @@ void Foam::functionObjects::forces::resetFields()
|
||||
if (writeFields_)
|
||||
{
|
||||
volVectorField& force =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("force"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("force"));
|
||||
|
||||
force == dimensionedVector(force.dimensions(), Zero);
|
||||
|
||||
volVectorField& moment =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("moment"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("moment"));
|
||||
|
||||
moment == dimensionedVector(moment.dimensions(), Zero);
|
||||
}
|
||||
@ -415,25 +409,20 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::rho() const
|
||||
{
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
return tmp<volScalarField>::New
|
||||
(
|
||||
new volScalarField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rho",
|
||||
mesh_.time().timeName(),
|
||||
mesh_
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("rho", dimDensity, rhoRef_)
|
||||
)
|
||||
"rho",
|
||||
mesh_.time().timeName(),
|
||||
mesh_
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("rho", dimDensity, rhoRef_)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(lookupObject<volScalarField>(rhoName_));
|
||||
}
|
||||
|
||||
return(lookupObject<volScalarField>(rhoName_));
|
||||
}
|
||||
|
||||
|
||||
@ -443,17 +432,15 @@ Foam::scalar Foam::functionObjects::forces::rho(const volScalarField& p) const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rhoName_ != "rhoInf")
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Dynamic pressure is expected but kinematic is provided."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return rhoRef_;
|
||||
if (rhoName_ != "rhoInf")
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Dynamic pressure is expected but kinematic is provided."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return rhoRef_;
|
||||
}
|
||||
|
||||
|
||||
@ -509,19 +496,13 @@ void Foam::functionObjects::forces::addToFields
|
||||
}
|
||||
|
||||
volVectorField& force =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("force"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("force"));
|
||||
|
||||
vectorField& pf = force.boundaryFieldRef()[patchi];
|
||||
pf += fN + fT + fP;
|
||||
|
||||
volVectorField& moment =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("moment"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("moment"));
|
||||
|
||||
vectorField& pm = moment.boundaryFieldRef()[patchi];
|
||||
pm += Md;
|
||||
@ -543,16 +524,10 @@ void Foam::functionObjects::forces::addToFields
|
||||
}
|
||||
|
||||
volVectorField& force =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("force"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("force"));
|
||||
|
||||
volVectorField& moment =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
lookupObject<volVectorField>(fieldName("moment"))
|
||||
);
|
||||
lookupObjectRef<volVectorField>(fieldName("moment"));
|
||||
|
||||
forAll(cellIDs, i)
|
||||
{
|
||||
@ -851,7 +826,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
patchSet_ = pbm.patchSet(wordReList(dict.lookup("patches")));
|
||||
patchSet_ = pbm.patchSet(dict.get<wordRes>("patches"));
|
||||
|
||||
if (directForceDensity_)
|
||||
{
|
||||
@ -868,7 +843,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
||||
// Reference density needed for incompressible calculations
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoRef_;
|
||||
dict.readEntry("rhoInf", rhoRef_);
|
||||
}
|
||||
|
||||
// Reference pressure, 0 by default
|
||||
@ -882,7 +857,23 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
||||
// specified directly, from coordinate system, or implicitly (0 0 0)
|
||||
if (!dict.readIfPresent<point>("CofR", coordSys_.origin()))
|
||||
{
|
||||
coordSys_ = coordinateSystem(obr_, dict);
|
||||
// The 'coordinateSystem' sub-dictionary is optional,
|
||||
// but enforce use of a cartesian system.
|
||||
|
||||
if (dict.found(coordinateSystem::typeName_()))
|
||||
{
|
||||
// New() for access to indirect (global) coordinate system
|
||||
coordSys_ =
|
||||
coordinateSystem::New
|
||||
(
|
||||
obr_, dict, coordinateSystem::typeName_()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
coordSys_ = coordSystem::cartesian(dict);
|
||||
}
|
||||
|
||||
localSystem_ = true;
|
||||
}
|
||||
|
||||
@ -899,7 +890,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
||||
if (dict.found("binData"))
|
||||
{
|
||||
const dictionary& binDict(dict.subDict("binData"));
|
||||
binDict.lookup("nBin") >> nBin_;
|
||||
binDict.readEntry("nBin", nBin_);
|
||||
|
||||
if (nBin_ < 0)
|
||||
{
|
||||
@ -914,9 +905,9 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
||||
}
|
||||
else
|
||||
{
|
||||
binDict.lookup("cumulative") >> binCumulative_;
|
||||
binDict.lookup("direction") >> binDir_;
|
||||
binDir_ /= mag(binDir_);
|
||||
binDict.readEntry("cumulative", binCumulative_);
|
||||
binDict.readEntry("direction", binDir_);
|
||||
binDir_.normalise();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1062,7 +1053,7 @@ void Foam::functionObjects::forces::calcForcesMoment()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
forAllConstIter(HashTable<const porosityModel*>, models, iter)
|
||||
forAllConstIters(models, iter)
|
||||
{
|
||||
// Non-const access required if mesh is changing
|
||||
porosityModel& pm = const_cast<porosityModel&>(*iter());
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,21 +32,21 @@ Description
|
||||
skin-friction forces over a given list of patches, and the resistance
|
||||
from porous zones.
|
||||
|
||||
Forces and moments are calculated, with optional co-ordinate system and
|
||||
Forces and moments are calculated, with optional coordinate system and
|
||||
writing of binned data, where force and moment contributions are collected
|
||||
into a user-defined number of bins that span the input geometries for a
|
||||
user-defined direction vector.
|
||||
|
||||
Data is written into multiple files in the
|
||||
postProcessing/\<functionObjectName\> directory:
|
||||
- force.dat : forces in global Cartesian co-ordinate system
|
||||
- moment.dat : moments in global Cartesian co-ordinate system
|
||||
- forceBin.dat : force bins in global Cartesian co-ordinate system
|
||||
- momentBin.dat : moment bins in global Cartesian co-ordinate system
|
||||
- localForce.dat : forces in local co-ordinate system
|
||||
- localMoment.dat : moments in local co-ordinate system
|
||||
- localForceBin.dat : force bins in local co-ordinate system
|
||||
- localMomentBin.dat : moment bins in local co-ordinate system
|
||||
- force.dat : forces in global Cartesian coordinate system
|
||||
- moment.dat : moments in global Cartesian coordinate system
|
||||
- forceBin.dat : force bins in global Cartesian coordinate system
|
||||
- momentBin.dat : moment bins in global Cartesian coordinate system
|
||||
- localForce.dat : forces in local Cartesian coordinate system
|
||||
- localMoment.dat : moments in local Cartesian coordinate system
|
||||
- localForceBin.dat : force bins in local Cartesian coordinate system
|
||||
- localMomentBin.dat : moment bins in local Cartesian coordinate system
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
@ -107,13 +107,19 @@ Note
|
||||
CofR (0 0 0);
|
||||
\endverbatim
|
||||
or
|
||||
\verbatim
|
||||
origin (0 0 0);
|
||||
e1 (0 1 0);
|
||||
e3 (0 0 1);
|
||||
\endverbatim
|
||||
or
|
||||
\verbatim
|
||||
coordinateSystem
|
||||
{
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
rotation
|
||||
{
|
||||
type axesRotation;
|
||||
type axes;
|
||||
e3 (0 0 1);
|
||||
e1 (1 0 0);
|
||||
}
|
||||
@ -136,7 +142,7 @@ SourceFiles
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "cartesianCS.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
#include "Tuple2.H"
|
||||
@ -224,9 +230,9 @@ protected:
|
||||
scalar pRef_;
|
||||
|
||||
//- Coordinate system used when evaluting forces/moments
|
||||
coordinateSystem coordSys_;
|
||||
coordSystem::cartesian coordSys_;
|
||||
|
||||
//- Flag to indicate whether we are using a local co-ordinate sys
|
||||
//- Flag to indicate whether we are using a local coordinates
|
||||
bool localSystem_;
|
||||
|
||||
//- Flag to include porosity effects
|
||||
|
||||
@ -3,6 +3,6 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
runTimePostProcessing/Allwmake
|
||||
runTimePostProcessing/Allwmake $*
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Source wmake functions
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
||||
# This cleanup handles both cmake runTimePostProcessing and the dummy version
|
||||
|
||||
# Cleanup library
|
||||
# Cleanup library files with .so version endings
|
||||
rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null
|
||||
|
||||
# Cleanup generated files - remove entire top-level
|
||||
removeObjectDir $PWD
|
||||
removeObjectDir "$PWD"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -6,9 +6,9 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
echo "======================================================================"
|
||||
echo "${PWD##*/} : $PWD"
|
||||
echo
|
||||
|
||||
unset depend
|
||||
|
||||
if [ -d "$VTK_DIR" ]
|
||||
then
|
||||
depend="VTK_DIR=$VTK_DIR"
|
||||
@ -17,25 +17,36 @@ then
|
||||
depend="ParaView_DIR=$ParaView_DIR"
|
||||
fi
|
||||
|
||||
if [ -n "$depend" ]
|
||||
# Or force use of dummy only
|
||||
# unset depend
|
||||
|
||||
if [ "$targetType" = objects ]
|
||||
then
|
||||
if [ "$targetType" != objects ]
|
||||
depend=ignore
|
||||
elif [ -n "$depend" ]
|
||||
then
|
||||
if command -v cmake > /dev/null 2>&1
|
||||
then
|
||||
if command -v cmake > /dev/null 2>&1
|
||||
then
|
||||
cmakeVersioned "$depend" $PWD || {
|
||||
echo
|
||||
echo " WARNING: incomplete build of VTK-based post-processing"
|
||||
echo
|
||||
}
|
||||
else
|
||||
echo "WARNING: skipped - needs cmake"
|
||||
fi
|
||||
cmakeVersioned "$depend" $PWD || {
|
||||
echo
|
||||
echo " WARNING: incomplete build of VTK-based post-processing"
|
||||
echo
|
||||
depend="dummy"
|
||||
}
|
||||
else
|
||||
echo "==> skip runTimePostProcessing (needs cmake)"
|
||||
depend="dummy"
|
||||
fi
|
||||
else
|
||||
echo "WARNING: skipped - needs a VTK or a ParaView installation"
|
||||
echo " - For ParaView : export the 'ParaView_DIR' variable"
|
||||
echo " - For VTK : export the 'VTK_DIR' variable"
|
||||
echo "WARNING: skip runTimePostProcessing (no VTK or ParaView)"
|
||||
echo " - ParaView : export the 'ParaView_DIR' variable"
|
||||
echo " - VTK : export the 'VTK_DIR' variable"
|
||||
fi
|
||||
|
||||
if [ "${depend:-dummy}" = dummy ]
|
||||
then
|
||||
echo "==> dummy runTimePostProcessing"
|
||||
wmakeVersioned "vtk=dummy" $PWD dummy
|
||||
fi
|
||||
|
||||
echo "======================================================================"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
project(runTimePostProcessing)
|
||||
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
@ -13,6 +14,7 @@ else()
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${LIB_SRC}/OpenFOAM/include
|
||||
${LIB_SRC}/OpenFOAM/lnInclude
|
||||
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
|
||||
${LIB_SRC}/finiteVolume/lnInclude
|
||||
@ -28,7 +30,8 @@ link_directories(
|
||||
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
# Build intermediate (library) directly into the OpenFOAM libdir
|
||||
# - implies CMAKE_INSTALL_PREFIX is ignored and there is no 'install' phase
|
||||
set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
|
||||
CACHE INTERNAL
|
||||
""
|
||||
@ -1,9 +1,15 @@
|
||||
#------------------------------------------------------------------------------
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3
|
||||
|
||||
project(runTimePostProcessing)
|
||||
# Fail if not building out-of-source
|
||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
message(FATAL_ERROR
|
||||
"In-source builds disallowed. Use a separate build directory")
|
||||
endif()
|
||||
|
||||
# Set policy for CMP0002 needed for cmake > 3
|
||||
cmake_policy(SET CMP0002 OLD)
|
||||
#-----------------------------------------------------------------------------
|
||||
# Simple discovery and sanity checks
|
||||
|
||||
if (EXISTS "$ENV{VTK_DIR}")
|
||||
message("Building with VTK from $ENV{VTK_DIR}")
|
||||
@ -11,17 +17,19 @@ if (EXISTS "$ENV{VTK_DIR}")
|
||||
include(${VTK_USE_FILE})
|
||||
elseif (EXISTS "$ENV{ParaView_DIR}")
|
||||
message("Building with Paraview from $ENV{ParaView_DIR}")
|
||||
find_package(ParaView REQUIRED)
|
||||
find_package(ParaView REQUIRED HINTS $ENV{ParaView_DIR})
|
||||
include(${VTK_USE_FILE})
|
||||
set(
|
||||
VTK_VERSION
|
||||
"${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}"
|
||||
)
|
||||
else()
|
||||
message (FATAL_ERROR "VTK not found using VTK_DIR or ParaView_DIR")
|
||||
message(FATAL_ERROR "VTK not found using VTK_DIR or ParaView_DIR")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
include(CMakeLists-OpenFOAM.txt)
|
||||
include(CMakeLists-Common.txt)
|
||||
include(CMakeLists-Project.txt)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
runTimePostProcessingDummy.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/librunTimePostProcessing
|
||||
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* LIB_LIBS = */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user