mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: extractEulerianParticles FO updates
This commit is contained in:
@ -0,0 +1,370 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 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 "extractEulerianParticleDistribution.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(extractEulerianParticleDistribution, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
extractEulerianParticleDistribution,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::functionObjects::extractEulerianParticleDistribution::initialiseBins()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
const faceZone& fz = mesh_.faceZones()[zoneID_];
|
||||
|
||||
// Agglomerate faceZone faces into nInjectorLocations_ global locations
|
||||
const indirectPrimitivePatch patch
|
||||
(
|
||||
IndirectList<face>(mesh_.faces(), fz),
|
||||
mesh_.points()
|
||||
);
|
||||
|
||||
const label nFaces = fz.size();
|
||||
label nLocations = nInjectorLocations_;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
label nGlobalFaces = returnReduce(nFaces, sumOp<label>());
|
||||
scalar fraction = scalar(nFaces)/scalar(nGlobalFaces);
|
||||
nLocations = ceil(fraction*nInjectorLocations_);
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "nFaces:" << nFaces
|
||||
<< ", nGlobalFaces:" << nGlobalFaces
|
||||
<< ", fraction:" << fraction
|
||||
<< ", nLocations:" << nLocations
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
pairPatchAgglomeration ppa(patch, 10, 50, nLocations, labelMax, 180);
|
||||
ppa.agglomerate();
|
||||
|
||||
label nCoarseFaces = 0;
|
||||
if (nFaces != 0)
|
||||
{
|
||||
fineToCoarseAddr_ = ppa.restrictTopBottomAddressing();
|
||||
nCoarseFaces = max(fineToCoarseAddr_) + 1;
|
||||
coarseToFineAddr_ = invertOneToMany(nCoarseFaces, fineToCoarseAddr_);
|
||||
|
||||
// Set coarse face centres as area average of fine face centres
|
||||
const vectorField& faceCentres = mesh_.faceCentres();
|
||||
const vectorField& faceAreas = mesh_.faceAreas();
|
||||
coarsePosition_.setSize(coarseToFineAddr_.size());
|
||||
forAll(coarseToFineAddr_, coarsei)
|
||||
{
|
||||
const labelList& fineFaces = coarseToFineAddr_[coarsei];
|
||||
|
||||
scalar sumArea = 0;
|
||||
vector averagePosition(vector::zero);
|
||||
forAll(fineFaces, i)
|
||||
{
|
||||
label facei = fz[fineFaces[i]];
|
||||
scalar magSf = mag(faceAreas[facei]);
|
||||
sumArea += magSf;
|
||||
averagePosition += magSf*faceCentres[facei];
|
||||
}
|
||||
coarsePosition_[coarsei] = averagePosition/sumArea;
|
||||
}
|
||||
}
|
||||
|
||||
// Create global addressing for coarse face addressing
|
||||
globalCoarseFaces_ = globalIndex(nCoarseFaces);
|
||||
|
||||
Info<< "Created " << returnReduce(nCoarseFaces, sumOp<label>())
|
||||
<< " coarse faces" << endl;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Foam::functionObjects::extractEulerianParticleDistribution::
|
||||
writeBinnedParticleData()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
// Gather particles ready for collection from all procs
|
||||
List<List<eulerianParticle> > allProcParticles(Pstream::nProcs());
|
||||
allProcParticles[Pstream::myProcNo()] = collectedParticles_;
|
||||
Pstream::gatherList(allProcParticles);
|
||||
Pstream::scatterList(allProcParticles);
|
||||
List<eulerianParticle> allParticles =
|
||||
ListListOps::combine<List<eulerianParticle> >
|
||||
(
|
||||
allProcParticles,
|
||||
accessOp<List<eulerianParticle> >()
|
||||
);
|
||||
|
||||
|
||||
// Determine coarse face index (global) and position for each particle
|
||||
label nCoarseFaces = globalCoarseFaces_.size();
|
||||
List<label> particleCoarseFacei(allParticles.size(), -1);
|
||||
List<point> particleCoarseFacePosition(nCoarseFaces, point::min);
|
||||
|
||||
forAll(allParticles, particlei)
|
||||
{
|
||||
const eulerianParticle& p = allParticles[particlei];
|
||||
label globalFaceHiti = p.globalFaceIHit;
|
||||
|
||||
if (globalFaces_.isLocal(globalFaceHiti))
|
||||
{
|
||||
label localFacei = globalFaces_.toLocal(globalFaceHiti);
|
||||
label coarseFacei = fineToCoarseAddr_[localFacei];
|
||||
label globalCoarseFacei = globalCoarseFaces_.toGlobal(coarseFacei);
|
||||
|
||||
particleCoarseFacei[particlei] = globalCoarseFacei;
|
||||
particleCoarseFacePosition[globalCoarseFacei] =
|
||||
coarsePosition_[coarseFacei];
|
||||
}
|
||||
}
|
||||
Pstream::listCombineGather(particleCoarseFacei, maxEqOp<label>());
|
||||
Pstream::listCombineGather(particleCoarseFacePosition, maxEqOp<point>());
|
||||
|
||||
// Write the agglomerated particle data to file
|
||||
DynamicList<label> processedCoarseFaces;
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName baseDir(dictBaseFileDir()/name());
|
||||
|
||||
IOdictionary dict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"particleDistribution",
|
||||
obr_.time().timeName(),
|
||||
baseDir,
|
||||
obr_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
labelListList coarseFaceToParticle =
|
||||
invertOneToMany(nCoarseFaces, particleCoarseFacei);
|
||||
|
||||
// Process the allParticles per coarse face
|
||||
forAll(coarseFaceToParticle, globalCoarseFacei)
|
||||
{
|
||||
const List<label>& particleIDs =
|
||||
coarseFaceToParticle[globalCoarseFacei];
|
||||
|
||||
const label nParticle = particleIDs.size();
|
||||
|
||||
if (nParticle == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Field<scalar> pd(particleIDs.size());
|
||||
scalar sumV = 0;
|
||||
vector sumVU = vector::zero;
|
||||
scalar startTime = GREAT;
|
||||
scalar endTime = -GREAT;
|
||||
forAll(particleIDs, i)
|
||||
{
|
||||
const label particlei = particleIDs[i];
|
||||
const eulerianParticle& p = allParticles[particlei];
|
||||
scalar pDiameter = cbrt(6*p.V/constant::mathematical::pi);
|
||||
pd[i] = pDiameter;
|
||||
sumV += p.V;
|
||||
sumVU += p.VU;
|
||||
|
||||
startTime = min(startTime, outputTimes_[p.timeIndex]);
|
||||
endTime = max(endTime, outputTimes_[p.timeIndex + 1]);
|
||||
}
|
||||
|
||||
if (sumV < ROOTVSMALL)
|
||||
{
|
||||
// Started collecting particle info, but not accumulated any
|
||||
// volume yet
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
distributionModels::binned binnedDiameters
|
||||
(
|
||||
pd,
|
||||
distributionBinWidth_,
|
||||
rndGen_
|
||||
);
|
||||
|
||||
// Velocity info hard-coded to volume average
|
||||
vector Uave = sumVU/sumV;
|
||||
|
||||
dictionary particleDict;
|
||||
particleDict.add("startTime", startTime);
|
||||
particleDict.add("endTime", endTime);
|
||||
particleDict.add("nParticle", nParticle);
|
||||
particleDict.add
|
||||
(
|
||||
"position",
|
||||
particleCoarseFacePosition[globalCoarseFacei]
|
||||
);
|
||||
particleDict.add("volume", sumV);
|
||||
particleDict.add("U", Uave);
|
||||
particleDict.add
|
||||
(
|
||||
"binnedDistribution",
|
||||
binnedDiameters.writeDict("distribution")
|
||||
);
|
||||
dict.add
|
||||
(
|
||||
word("sample" + Foam::name(globalCoarseFacei)),
|
||||
particleDict
|
||||
);
|
||||
|
||||
processedCoarseFaces.append(globalCoarseFacei);
|
||||
}
|
||||
|
||||
dict.regIOobject::write();
|
||||
}
|
||||
|
||||
|
||||
if (resetDistributionOnWrite_)
|
||||
{
|
||||
// Remove particles from processed coarse faces from collectedParticles_
|
||||
Pstream::scatter(processedCoarseFaces);
|
||||
labelHashSet processedFaces(processedCoarseFaces);
|
||||
DynamicList<eulerianParticle> nonProcessedParticles;
|
||||
forAll(collectedParticles_, particlei)
|
||||
{
|
||||
const eulerianParticle& p = collectedParticles_[particlei];
|
||||
label localFacei = globalFaces_.toLocal(p.globalFaceIHit);
|
||||
label coarseFacei = fineToCoarseAddr_[localFacei];
|
||||
label globalCoarseFacei = globalCoarseFaces_.toGlobal(coarseFacei);
|
||||
if (!processedFaces.found(globalCoarseFacei))
|
||||
{
|
||||
nonProcessedParticles.append(p);
|
||||
}
|
||||
}
|
||||
collectedParticles_.transfer(nonProcessedParticles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::extractEulerianParticleDistribution::
|
||||
extractEulerianParticleDistribution
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const bool readFields
|
||||
)
|
||||
:
|
||||
extractEulerianParticleDistribution(name, runTime, dict, false),
|
||||
nInjectorLocations_(0),
|
||||
resetDistributionOnWrite_(false),
|
||||
distributionBinWidth_(0)
|
||||
fineToCoarseAddr_(),
|
||||
coarseToFineAddr_(),
|
||||
coarsePosition_(),
|
||||
globalCoarseFaces_(),
|
||||
rndGen_(1234, -1)
|
||||
{
|
||||
// We need to cache the collected particles in order to determine the
|
||||
// distributions
|
||||
cacheCollectedParticles_ = true;
|
||||
|
||||
if (readFields)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::extractEulerianParticleDistribution::
|
||||
~extractEulerianParticleDistribution()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
bool Foam::functionObjects::extractEulerianParticleDistribution::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
if (extractEulerianParticles::read(dict))
|
||||
{
|
||||
dict.lookup("nLocations") >> nInjectorLocations_;
|
||||
dict.lookup("distributionBinWidth") >> distributionBinWidth_;
|
||||
dict.lookup("resetDistributionOnWrite") >> resetDistributionOnWrite_;
|
||||
|
||||
initialiseBins();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::extractEulerianParticleDistribution::execute()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
return extractEulerianParticles::execute();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::extractEulerianParticleDistribution::write()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
if (extractEulerianParticles::write())
|
||||
{
|
||||
writeBinnedParticleData();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,197 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 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::extractEulerianParticleDistribution
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Generates particle size information from Eulerian calculations, e.g. VoF.
|
||||
|
||||
Particle data is written to the directory:
|
||||
|
||||
\verbatim
|
||||
$FOAM_CASE/postProcessing/<name>/particleDistribution
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
extractEulerianParticleDistribution1
|
||||
{
|
||||
type extractEulerianParticleDistribution;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
faceZone f0;
|
||||
nLocations 10;
|
||||
alphaName alpha.water;
|
||||
UName U;
|
||||
rhoName rho;
|
||||
phiName phi;
|
||||
|
||||
writeRawData yes;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: extractEulerianParticleDistribution | yes |
|
||||
faceZone | Name of faceZone used as collection surface | yes |
|
||||
nLocations | Number of injection bins to generate | yes |
|
||||
aplhaName | Name of phase indicator field | yes |
|
||||
rhoName | Name of density field | yes |
|
||||
phiName | Name of flux field | yes |
|
||||
distributionBinWidth | Binned distribution bin width| yes |
|
||||
writeRawData | Flag to write raw particle data | yes |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
extractEulerianParticleDistribution.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_extractEulerianParticleDistribution_H
|
||||
#define functionObjects_extractEulerianParticleDistribution_H
|
||||
|
||||
#include "extractEulerianParticles.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class extractEulerianParticleDistributionFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class extractEulerianParticleDistribution
|
||||
:
|
||||
public extractEulerianParticles
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
// Agglomeration
|
||||
|
||||
//- Number of sample locations to generate
|
||||
label nInjectorLocations_;
|
||||
|
||||
//- Agglomeration addressing from fine to coarse
|
||||
labelList fineToCoarseAddr_;
|
||||
|
||||
//- Agglomeration addressing from coarse to fine
|
||||
labelListList coarseToFineAddr_;
|
||||
|
||||
//- Coarse face positions
|
||||
vectorList coarsePosition_;
|
||||
|
||||
//- Global coarse face addressing
|
||||
globalIndex globalCoarseFaces_;
|
||||
|
||||
|
||||
// Particle collection info
|
||||
|
||||
//- Flag to reset the distribution on each write
|
||||
bool resetDistributionOnWrite_;
|
||||
|
||||
//- Diameter distribution bin width
|
||||
scalar distributionBinWidth_;
|
||||
|
||||
//- Random class needed by distribution models
|
||||
cachedRandom rndGen_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Initialise the particle collection bins
|
||||
virtual void initialiseBins();
|
||||
|
||||
//- Write agglomerated particle data to stream
|
||||
virtual void writeBinnedParticleData();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
extractEulerianParticleDistribution
|
||||
(
|
||||
const extractEulerianParticleDistribution&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const extractEulerianParticleDistribution&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Static data staticData
|
||||
TypeName("extractEulerianParticleDistribution");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
extractEulerianParticleDistribution
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const bool readFields = true
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~extractEulerianParticleDistribution();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
virtual bool execute();
|
||||
|
||||
//- Write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "extractEulerianParticleDistributionTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -119,6 +119,11 @@ void Foam::functionObjects::extractEulerianParticles::initialiseBins()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
if (!nInjectorLocations_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const faceZone& fz = mesh_.faceZones()[zoneID_];
|
||||
|
||||
// Agglomerate faceZone faces into nInjectorLocations_ global locations
|
||||
@ -159,8 +164,9 @@ void Foam::functionObjects::extractEulerianParticles::initialiseBins()
|
||||
const vectorField& faceCentres = mesh_.faceCentres();
|
||||
const vectorField& faceAreas = mesh_.faceAreas();
|
||||
coarsePosition_.setSize(nCoarseFaces);
|
||||
scalarField coarseArea(nCoarseFaces);
|
||||
forAll(coarsePosition_, i)
|
||||
coarsePosition_ = vector::zero;
|
||||
scalarField coarseArea(nCoarseFaces, 0);
|
||||
forAll(fz, i)
|
||||
{
|
||||
const label facei = fz[i];
|
||||
const label coarseFacei = fineToCoarseAddr_[i];
|
||||
@ -168,6 +174,7 @@ void Foam::functionObjects::extractEulerianParticles::initialiseBins()
|
||||
coarseArea[coarseFacei] += magSf;
|
||||
coarsePosition_[coarseFacei] += magSf*faceCentres[facei];
|
||||
}
|
||||
|
||||
coarsePosition_ /= coarseArea + ROOTVSMALL;
|
||||
}
|
||||
|
||||
@ -310,11 +317,16 @@ void Foam::functionObjects::extractEulerianParticles::collectParticles
|
||||
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.globalFaceIHit;
|
||||
}
|
||||
injectedParticle* ip = new injectedParticle
|
||||
(
|
||||
mesh_,
|
||||
position,
|
||||
tag,
|
||||
time,
|
||||
d,
|
||||
U
|
||||
@ -545,7 +557,7 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
phiName_("phi"),
|
||||
nInjectorLocations_(-1),
|
||||
nInjectorLocations_(0),
|
||||
fineToCoarseAddr_(),
|
||||
coarsePosition_(),
|
||||
globalCoarseFaces_(),
|
||||
@ -555,7 +567,6 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
||||
regionToParticleMap_(),
|
||||
minDiameter_(ROOTVSMALL),
|
||||
maxDiameter_(GREAT),
|
||||
rndGen_(1234, -1),
|
||||
nCollectedParticles_(0),
|
||||
nDiscardedParticles_(0),
|
||||
discardedVolume_(0)
|
||||
@ -675,10 +686,7 @@ bool Foam::functionObjects::extractEulerianParticles::write()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
cloud_.write();
|
||||
}
|
||||
cloud_.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -172,9 +172,6 @@ protected:
|
||||
// Can be used to filter out 'large' particles
|
||||
scalar maxDiameter_;
|
||||
|
||||
//- Random class needed by distribution models
|
||||
cachedRandom rndGen_;
|
||||
|
||||
|
||||
// Statistics
|
||||
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 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 "injectedParticle.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(injectedParticle, 0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -74,6 +74,9 @@ protected:
|
||||
|
||||
// Particle properties
|
||||
|
||||
//- Tag
|
||||
label tag_;
|
||||
|
||||
//- Start of injection [s]
|
||||
scalar soi_;
|
||||
|
||||
@ -95,7 +98,8 @@ public:
|
||||
AddToPropertyList
|
||||
(
|
||||
particle,
|
||||
" soi"
|
||||
" tag"
|
||||
+ " soi"
|
||||
+ " d"
|
||||
+ " (Ux Uy Uz)";
|
||||
);
|
||||
@ -104,7 +108,8 @@ public:
|
||||
AddToPropertyTypes
|
||||
(
|
||||
particle,
|
||||
"{scalar"
|
||||
"{label"
|
||||
+ " scalar"
|
||||
+ " scalar"
|
||||
+ " vector}"
|
||||
);
|
||||
@ -117,6 +122,7 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label tag,
|
||||
const scalar soi,
|
||||
const scalar d,
|
||||
const vector& U
|
||||
@ -175,6 +181,9 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to the tag
|
||||
inline label tag() const;
|
||||
|
||||
//- Return const access to the start of injection
|
||||
inline scalar soi() const;
|
||||
|
||||
@ -187,7 +196,10 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return start of injection
|
||||
//- Return the tag
|
||||
inline label& tag();
|
||||
|
||||
//- Return the start of injection
|
||||
inline scalar& soi();
|
||||
|
||||
//- Return access to diameter
|
||||
@ -205,6 +217,13 @@ public:
|
||||
//- Write
|
||||
static void writeFields(const Cloud<injectedParticle>& c);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
static void writeObjects
|
||||
(
|
||||
const Cloud<injectedParticle>& c,
|
||||
objectRegistry& obr
|
||||
);
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
|
||||
@ -25,6 +25,11 @@ License
|
||||
|
||||
#include "injectedParticleCloud.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(Cloud<injectedParticle>, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::injectedParticleCloud::injectedParticleCloud
|
||||
@ -49,4 +54,12 @@ Foam::injectedParticleCloud::~injectedParticleCloud()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::injectedParticleCloud::writeObjects(objectRegistry& obr) const
|
||||
{
|
||||
injectedParticle::writeObjects(*this, obr);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -80,6 +80,14 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~injectedParticleCloud();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
virtual void writeObjects(objectRegistry& obr) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -30,15 +30,26 @@ inline Foam::injectedParticle::injectedParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label tag,
|
||||
const scalar soi,
|
||||
const scalar d,
|
||||
const vector& U
|
||||
)
|
||||
:
|
||||
particle(mesh, position, -1, false)
|
||||
particle(mesh, position, -1, false),
|
||||
tag_(tag),
|
||||
soi_(soi),
|
||||
d_(d),
|
||||
U_(U)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::label Foam::injectedParticle::tag() const
|
||||
{
|
||||
return tag_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::injectedParticle::soi() const
|
||||
{
|
||||
return soi_;
|
||||
@ -57,6 +68,12 @@ inline const Foam::vector& Foam::injectedParticle::U() const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label& Foam::injectedParticle::tag()
|
||||
{
|
||||
return tag_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar& Foam::injectedParticle::soi()
|
||||
{
|
||||
return soi_;
|
||||
|
||||
@ -38,7 +38,7 @@ Foam::string Foam::injectedParticle::propertyTypes_ =
|
||||
|
||||
const std::size_t Foam::injectedParticle::sizeofFields
|
||||
(
|
||||
sizeof(scalar) + sizeof(scalar) + sizeof(vector)
|
||||
sizeof(label) + sizeof(scalar) + sizeof(scalar) + sizeof(vector)
|
||||
);
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ Foam::injectedParticle::injectedParticle
|
||||
)
|
||||
:
|
||||
particle(mesh, is, readFields),
|
||||
tag_(-1),
|
||||
soi_(0.0),
|
||||
d_(0.0),
|
||||
U_(Zero)
|
||||
@ -60,6 +61,7 @@ Foam::injectedParticle::injectedParticle
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
tag_ = readLabel(is);
|
||||
soi_ = readScalar(is);
|
||||
d_ = readScalar(is);
|
||||
is >> U_;
|
||||
@ -88,6 +90,9 @@ void Foam::injectedParticle::readFields(Cloud<injectedParticle>& c)
|
||||
|
||||
particle::readFields(c);
|
||||
|
||||
IOField<label> tag(c.fieldIOobject("tag", IOobject::MUST_READ));
|
||||
c.checkFieldIOobject(c, tag);
|
||||
|
||||
IOField<scalar> soi(c.fieldIOobject("soi", IOobject::MUST_READ));
|
||||
c.checkFieldIOobject(c, soi);
|
||||
|
||||
@ -103,6 +108,7 @@ void Foam::injectedParticle::readFields(Cloud<injectedParticle>& c)
|
||||
{
|
||||
injectedParticle& p = iter();
|
||||
|
||||
p.tag_ = tag[i];
|
||||
p.soi_ = soi[i];
|
||||
p.d_ = d[i];
|
||||
p.U_ = U[i];
|
||||
@ -118,6 +124,7 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
|
||||
|
||||
label np = c.size();
|
||||
|
||||
IOField<label> tag(c.fieldIOobject("tag", IOobject::NO_READ), np);
|
||||
IOField<scalar> soi(c.fieldIOobject("soi", IOobject::NO_READ), np);
|
||||
IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
|
||||
IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
|
||||
@ -128,6 +135,7 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
|
||||
{
|
||||
const injectedParticle& p = iter();
|
||||
|
||||
tag[i] = p.tag();
|
||||
soi[i] = p.soi();
|
||||
d[i] = p.d();
|
||||
U[i] = p.U();
|
||||
@ -135,12 +143,44 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
|
||||
i++;
|
||||
}
|
||||
|
||||
tag.write();
|
||||
soi.write();
|
||||
d.write();
|
||||
U.write();
|
||||
}
|
||||
|
||||
|
||||
void Foam::injectedParticle::writeObjects
|
||||
(
|
||||
const Cloud<injectedParticle>& c,
|
||||
objectRegistry& obr
|
||||
)
|
||||
{
|
||||
particle::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
|
||||
IOField<label>& tag(cloud::createIOField<label>("tag", np, obr));
|
||||
IOField<scalar>& soi(cloud::createIOField<scalar>("soi", np, obr));
|
||||
IOField<scalar>& d(cloud::createIOField<scalar>("d", np, obr));
|
||||
IOField<vector>& U(cloud::createIOField<vector>("U", np, obr));
|
||||
|
||||
label i = 0;
|
||||
|
||||
forAllConstIter(Cloud<injectedParticle>, c, iter)
|
||||
{
|
||||
const injectedParticle& p = iter();
|
||||
|
||||
tag[i] = p.tag();
|
||||
soi[i] = p.soi();
|
||||
d[i] = p.d();
|
||||
U[i] = p.U();
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
@ -152,6 +192,7 @@ Foam::Ostream& Foam::operator<<
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << static_cast<const particle&>(p)
|
||||
<< token::SPACE << p.tag()
|
||||
<< token::SPACE << p.soi()
|
||||
<< token::SPACE << p.d()
|
||||
<< token::SPACE << p.U();
|
||||
|
||||
Reference in New Issue
Block a user