mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: extractEulerianParticles FO - refactored to output a cloud of particles - distribution analysis to follow...
This commit is contained in:
@ -73,6 +73,10 @@ externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchFields.C
|
|||||||
externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C
|
externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C
|
||||||
|
|
||||||
extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C
|
extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C
|
||||||
|
extractEulerianParticles/eulerianParticle/eulerianParticle.C
|
||||||
|
extractEulerianParticles/injectedParticle/injectedParticleIO.C
|
||||||
|
extractEulerianParticles/injectedParticle/injectedParticleCloud.C
|
||||||
|
|
||||||
|
|
||||||
ddt2/ddt2.C
|
ddt2/ddt2.C
|
||||||
zeroGradient/zeroGradient.C
|
zeroGradient/zeroGradient.C
|
||||||
|
|||||||
@ -36,34 +36,39 @@ Foam::functionObjects::eulerianParticle::eulerianParticle()
|
|||||||
VC(vector::zero),
|
VC(vector::zero),
|
||||||
VU(vector::zero),
|
VU(vector::zero),
|
||||||
V(0),
|
V(0),
|
||||||
time(0),
|
time(0)
|
||||||
timeIndex(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const eulerianParticle& p)
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const functionObjects::eulerianParticle& p
|
||||||
|
)
|
||||||
{
|
{
|
||||||
os << p.globalFaceIHit << token::SPACE
|
os << p.globalFaceIHit << token::SPACE
|
||||||
<< p.VC << token::SPACE
|
<< p.VC << token::SPACE
|
||||||
<< p.VU << token::SPACE
|
<< p.VU << token::SPACE
|
||||||
<< p.V << token::SPACE
|
<< p.V << token::SPACE
|
||||||
<< p.time << token::SPACE
|
<< p.time;
|
||||||
<< p.timeIndex;
|
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, eulerianParticle& p)
|
Foam::Istream& Foam::operator>>
|
||||||
|
(
|
||||||
|
Istream& is,
|
||||||
|
functionObjects::eulerianParticle& p
|
||||||
|
)
|
||||||
{
|
{
|
||||||
is >> p.globalFaceIHit
|
is >> p.globalFaceIHit
|
||||||
>> p.VC
|
>> p.VC
|
||||||
>> p.VU
|
>> p.VU
|
||||||
>> p.V
|
>> p.V
|
||||||
>> p.time
|
>> p.time;
|
||||||
>> p.timeIndex;
|
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,9 +92,6 @@ public:
|
|||||||
//- Injection time - set at collection [s]
|
//- Injection time - set at collection [s]
|
||||||
scalar time;
|
scalar time;
|
||||||
|
|
||||||
//- Index of last output time
|
|
||||||
label timeIndex;
|
|
||||||
|
|
||||||
|
|
||||||
//- Constructor
|
//- Constructor
|
||||||
eulerianParticle();
|
eulerianParticle();
|
||||||
@ -122,8 +119,7 @@ public:
|
|||||||
&& a.VC == b.VC
|
&& a.VC == b.VC
|
||||||
&& a.VU == b.VU
|
&& a.VU == b.VU
|
||||||
&& a.V == b.V
|
&& a.V == b.V
|
||||||
&& a.time == b.time
|
&& a.time == b.time;
|
||||||
&& a.timeIndex == b.timeIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=
|
friend bool operator!=
|
||||||
|
|||||||
@ -101,7 +101,7 @@ void Foam::functionObjects::extractEulerianParticles::checkFaceZone()
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log << type() << " " << name() << " output:" << nl
|
Info<< type() << " " << name() << " output:" << nl
|
||||||
<< " faceZone : " << faceZoneName_ << nl
|
<< " faceZone : " << faceZoneName_ << nl
|
||||||
<< " faces : " << allFaces << nl
|
<< " faces : " << allFaces << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -154,27 +154,21 @@ void Foam::functionObjects::extractEulerianParticles::initialiseBins()
|
|||||||
{
|
{
|
||||||
fineToCoarseAddr_ = ppa.restrictTopBottomAddressing();
|
fineToCoarseAddr_ = ppa.restrictTopBottomAddressing();
|
||||||
nCoarseFaces = max(fineToCoarseAddr_) + 1;
|
nCoarseFaces = max(fineToCoarseAddr_) + 1;
|
||||||
coarseToFineAddr_ = invertOneToMany(nCoarseFaces, fineToCoarseAddr_);
|
|
||||||
|
|
||||||
// Set coarse face centres as area average of fine face centres
|
// Set coarse face centres as area average of fine face centres
|
||||||
const vectorField& faceCentres = mesh_.faceCentres();
|
const vectorField& faceCentres = mesh_.faceCentres();
|
||||||
const vectorField& faceAreas = mesh_.faceAreas();
|
const vectorField& faceAreas = mesh_.faceAreas();
|
||||||
coarsePosition_.setSize(coarseToFineAddr_.size());
|
coarsePosition_.setSize(nCoarseFaces);
|
||||||
forAll(coarseToFineAddr_, coarsei)
|
scalarField coarseArea(nCoarseFaces);
|
||||||
|
forAll(coarsePosition_, i)
|
||||||
{
|
{
|
||||||
const labelList& fineFaces = coarseToFineAddr_[coarsei];
|
const label facei = fz[i];
|
||||||
|
const label coarseFacei = fineToCoarseAddr_[i];
|
||||||
scalar sumArea = 0;
|
const scalar magSf = mag(faceAreas[facei]);
|
||||||
vector averagePosition(vector::zero);
|
coarseArea[coarseFacei] += magSf;
|
||||||
forAll(fineFaces, i)
|
coarsePosition_[coarseFacei] += magSf*faceCentres[facei];
|
||||||
{
|
|
||||||
label facei = fz[fineFaces[i]];
|
|
||||||
scalar magSf = mag(faceAreas[facei]);
|
|
||||||
sumArea += magSf;
|
|
||||||
averagePosition += magSf*faceCentres[facei];
|
|
||||||
}
|
|
||||||
coarsePosition_[coarsei] = averagePosition/sumArea;
|
|
||||||
}
|
}
|
||||||
|
coarsePosition_ /= coarseArea + ROOTVSMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create global addressing for coarse face addressing
|
// Create global addressing for coarse face addressing
|
||||||
@ -198,7 +192,7 @@ Foam::functionObjects::extractEulerianParticles::phiU() const
|
|||||||
if (phi.dimensions() == dimMass/dimTime)
|
if (phi.dimensions() == dimMass/dimTime)
|
||||||
{
|
{
|
||||||
const volScalarField& rho =
|
const volScalarField& rho =
|
||||||
obr_.lookupObject<volScalarField>(rhoName_);
|
mesh_.lookupObject<volScalarField>(rhoName_);
|
||||||
|
|
||||||
return phi/fvc::interpolate(rho);
|
return phi/fvc::interpolate(rho);
|
||||||
}
|
}
|
||||||
@ -297,6 +291,13 @@ void Foam::functionObjects::extractEulerianParticles::collectParticles
|
|||||||
{
|
{
|
||||||
// Particle on local processor
|
// Particle on local processor
|
||||||
p = particles_[iter()];
|
p = particles_[iter()];
|
||||||
|
|
||||||
|
if (nInjectorLocations_)
|
||||||
|
{
|
||||||
|
// Use coarse face index and position for output
|
||||||
|
p.globalFaceIHit = fineToCoarseAddr_[p.globalFaceIHit];
|
||||||
|
p.VC = p.V*coarsePosition_[p.globalFaceIHit];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reduce(p, sumParticleOp<eulerianParticle>());
|
reduce(p, sumParticleOp<eulerianParticle>());
|
||||||
|
|
||||||
@ -304,21 +305,22 @@ void Foam::functionObjects::extractEulerianParticles::collectParticles
|
|||||||
|
|
||||||
if ((pDiameter > minDiameter_) && (pDiameter < maxDiameter_))
|
if ((pDiameter > minDiameter_) && (pDiameter < maxDiameter_))
|
||||||
{
|
{
|
||||||
p.time = time;
|
if (Pstream::master())
|
||||||
p.timeIndex = outputTimes_.size() - 1;
|
|
||||||
|
|
||||||
if (Pstream::master() && writeRawData_)
|
|
||||||
{
|
{
|
||||||
rawParticlesDictPtr_->add
|
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);
|
||||||
|
|
||||||
|
injectedParticle* ip = new injectedParticle
|
||||||
(
|
(
|
||||||
word("particle" + Foam::name(nCollectedParticles_)),
|
mesh_,
|
||||||
p.writeDict()
|
position,
|
||||||
|
time,
|
||||||
|
d,
|
||||||
|
U
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (globalFaces_.isLocal(p.globalFaceIHit))
|
cloud_.addParticle(ip);
|
||||||
{
|
|
||||||
collectedParticles_.append(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nCollectedParticles_++;
|
nCollectedParticles_++;
|
||||||
@ -522,176 +524,6 @@ void Foam::functionObjects::extractEulerianParticles::accumulateParticleInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::extractEulerianParticles::writeBinnedParticleData()
|
|
||||||
{
|
|
||||||
DebugInFunction << endl;
|
|
||||||
|
|
||||||
if (!createDistribution_)
|
|
||||||
{
|
|
||||||
// No need to store collected particles if not creating a distribution
|
|
||||||
collectedParticles_.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 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 * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
||||||
@ -703,9 +535,7 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
|||||||
:
|
:
|
||||||
fvMeshFunctionObject(name, runTime, dict),
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
writeFile(runTime, name),
|
writeFile(runTime, name),
|
||||||
writeRawData_(false),
|
cloud_(mesh_, "eulerianParticleCloud"),
|
||||||
rawParticlesDictPtr_(NULL),
|
|
||||||
outputTimes_(100),
|
|
||||||
faceZoneName_(word::null),
|
faceZoneName_(word::null),
|
||||||
zoneID_(-1),
|
zoneID_(-1),
|
||||||
patchIDs_(),
|
patchIDs_(),
|
||||||
@ -715,21 +545,16 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
|||||||
UName_("U"),
|
UName_("U"),
|
||||||
rhoName_("rho"),
|
rhoName_("rho"),
|
||||||
phiName_("phi"),
|
phiName_("phi"),
|
||||||
nInjectorLocations_(0),
|
nInjectorLocations_(-1),
|
||||||
fineToCoarseAddr_(),
|
fineToCoarseAddr_(),
|
||||||
coarseToFineAddr_(),
|
|
||||||
coarsePosition_(),
|
coarsePosition_(),
|
||||||
globalCoarseFaces_(),
|
globalCoarseFaces_(),
|
||||||
regions0_(),
|
regions0_(),
|
||||||
nRegions0_(0),
|
nRegions0_(0),
|
||||||
particles_(),
|
particles_(),
|
||||||
regionToParticleMap_(),
|
regionToParticleMap_(),
|
||||||
collectedParticles_(),
|
|
||||||
minDiameter_(ROOTVSMALL),
|
minDiameter_(ROOTVSMALL),
|
||||||
maxDiameter_(GREAT),
|
maxDiameter_(GREAT),
|
||||||
createDistribution_(false),
|
|
||||||
resetDistributionOnWrite_(false),
|
|
||||||
distributionBinWidth_(0),
|
|
||||||
rndGen_(1234, -1),
|
rndGen_(1234, -1),
|
||||||
nCollectedParticles_(0),
|
nCollectedParticles_(0),
|
||||||
nDiscardedParticles_(0),
|
nDiscardedParticles_(0),
|
||||||
@ -743,32 +568,6 @@ Foam::functionObjects::extractEulerianParticles::extractEulerianParticles
|
|||||||
}
|
}
|
||||||
|
|
||||||
read(dict);
|
read(dict);
|
||||||
|
|
||||||
if (Pstream::master() && writeRawData_)
|
|
||||||
{
|
|
||||||
fileName baseDir(dictBaseFileDir()/name);
|
|
||||||
|
|
||||||
rawParticlesDictPtr_.reset
|
|
||||||
(
|
|
||||||
new IOdictionary
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"rawParticlesDict",
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
baseDir,
|
|
||||||
mesh_,
|
|
||||||
IOobject::NO_READ, // _IF_PRESENT,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
DebugVar(rawParticlesDictPtr_->objectPath());
|
|
||||||
DebugVar(rawParticlesDictPtr_->path());
|
|
||||||
}
|
|
||||||
|
|
||||||
outputTimes_.append(mesh_.time().value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -780,17 +579,17 @@ Foam::functionObjects::extractEulerianParticles::~extractEulerianParticles()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::extractEulerianParticles::read
|
||||||
bool Foam::functionObjects::extractEulerianParticles::read(const dictionary& dict)
|
(
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
{
|
{
|
||||||
DebugInFunction << endl;
|
DebugInFunction << endl;
|
||||||
|
|
||||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||||
{
|
{
|
||||||
dict.lookup("writeRawData") >> writeRawData_;
|
|
||||||
|
|
||||||
dict.lookup("faceZone") >> faceZoneName_;
|
dict.lookup("faceZone") >> faceZoneName_;
|
||||||
dict.lookup("nLocations") >> nInjectorLocations_;
|
dict.readIfPresent("nLocations", nInjectorLocations_);
|
||||||
dict.lookup("alphaName") >> alphaName_;
|
dict.lookup("alphaName") >> alphaName_;
|
||||||
dict.readIfPresent("alphaThreshold", alphaThreshold_);
|
dict.readIfPresent("alphaThreshold", alphaThreshold_);
|
||||||
dict.lookup("UName") >> UName_;
|
dict.lookup("UName") >> UName_;
|
||||||
@ -799,13 +598,13 @@ bool Foam::functionObjects::extractEulerianParticles::read(const dictionary& dic
|
|||||||
|
|
||||||
dict.readIfPresent("minDiameter", minDiameter_);
|
dict.readIfPresent("minDiameter", minDiameter_);
|
||||||
dict.readIfPresent("maxDiameter", maxDiameter_);
|
dict.readIfPresent("maxDiameter", maxDiameter_);
|
||||||
dict.lookup("createDistribution") >> createDistribution_;
|
|
||||||
dict.lookup("distributionBinWidth") >> distributionBinWidth_;
|
|
||||||
dict.lookup("resetDistributionOnWrite") >> resetDistributionOnWrite_;
|
|
||||||
|
|
||||||
checkFaceZone();
|
checkFaceZone();
|
||||||
|
|
||||||
initialiseBins();
|
if (nInjectorLocations_)
|
||||||
|
{
|
||||||
|
initialiseBins();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -859,7 +658,7 @@ bool Foam::functionObjects::extractEulerianParticles::execute()
|
|||||||
tmp<surfaceScalarField> tphi = phiU();
|
tmp<surfaceScalarField> tphi = phiU();
|
||||||
accumulateParticleInfo(alphaf, tphi(), regionFaceIDs, fz);
|
accumulateParticleInfo(alphaf, tphi(), regionFaceIDs, fz);
|
||||||
|
|
||||||
// Reset the blocked faces fot the next integration step
|
// Reset the blocked faces for the next integration step
|
||||||
nRegions0_ = nRegionsNew;
|
nRegions0_ = nRegionsNew;
|
||||||
regions0_ = regionFaceIDs;
|
regions0_ = regionFaceIDs;
|
||||||
|
|
||||||
@ -876,18 +675,13 @@ bool Foam::functionObjects::extractEulerianParticles::write()
|
|||||||
{
|
{
|
||||||
DebugInFunction << endl;
|
DebugInFunction << endl;
|
||||||
|
|
||||||
outputTimes_.append(obr_.time().value());
|
if (Pstream::master())
|
||||||
|
|
||||||
writeBinnedParticleData();
|
|
||||||
|
|
||||||
if (Pstream::master() && writeRawData_)
|
|
||||||
{
|
{
|
||||||
rawParticlesDictPtr_->regIOobject::write();
|
cloud_.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -29,13 +29,6 @@ Group
|
|||||||
Description
|
Description
|
||||||
Generates particle size information from Eulerian calculations, e.g. VoF.
|
Generates particle size information from Eulerian calculations, e.g. VoF.
|
||||||
|
|
||||||
Particle data is written to the directory:
|
|
||||||
|
|
||||||
\verbatim
|
|
||||||
$FOAM_CASE/postProcessing/<name>/rawParticlesDict
|
|
||||||
$FOAM_CASE/postProcessing/<name>/particleDistribution
|
|
||||||
\endverbatim
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
extractEulerianParticles1
|
extractEulerianParticles1
|
||||||
{
|
{
|
||||||
@ -48,12 +41,6 @@ Usage
|
|||||||
UName U;
|
UName U;
|
||||||
rhoName rho;
|
rhoName rho;
|
||||||
phiName phi;
|
phiName phi;
|
||||||
|
|
||||||
createDistribution yes;
|
|
||||||
distributionBinWidth 1e-4;
|
|
||||||
resetDistributionOnWrite no;
|
|
||||||
|
|
||||||
writeRawData yes;
|
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -66,9 +53,6 @@ Usage
|
|||||||
aplhaName | Name of phase indicator field | yes |
|
aplhaName | Name of phase indicator field | yes |
|
||||||
rhoName | Name of density field | yes |
|
rhoName | Name of density field | yes |
|
||||||
phiNane | Name of flux field | yes |
|
phiNane | Name of flux field | yes |
|
||||||
createDistribution | Flag to create a binned distribution | yes |
|
|
||||||
distributionBinWidth | Binned distribution bin width| yes |
|
|
||||||
writeRawData | Flag to write raw particle data | yes |
|
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -89,6 +73,7 @@ SourceFiles
|
|||||||
#include "cachedRandom.H"
|
#include "cachedRandom.H"
|
||||||
#include "eulerianParticle.H"
|
#include "eulerianParticle.H"
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
|
#include "injectedParticleCloud.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -97,7 +82,7 @@ namespace Foam
|
|||||||
namespace functionObjects
|
namespace functionObjects
|
||||||
{
|
{
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class extractEulerianParticlesFunctionObject Declaration
|
Class extractEulerianParticlesFunctionObject Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class extractEulerianParticles
|
class extractEulerianParticles
|
||||||
@ -110,14 +95,8 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Flag to write the raw collected particle data
|
//- Storage for collected particles
|
||||||
bool writeRawData_;
|
injectedParticleCloud cloud_;
|
||||||
|
|
||||||
//- Raw particle output dictionary
|
|
||||||
autoPtr<IOdictionary> rawParticlesDictPtr_;
|
|
||||||
|
|
||||||
//- List to keep track of output times
|
|
||||||
DynamicList<scalar> outputTimes_;
|
|
||||||
|
|
||||||
|
|
||||||
// faceZone info
|
// faceZone info
|
||||||
@ -149,7 +128,7 @@ protected:
|
|||||||
//- Name of the velocity field, default = U
|
//- Name of the velocity field, default = U
|
||||||
word UName_;
|
word UName_;
|
||||||
|
|
||||||
//- Name of the density field, defauls = rho
|
//- Name of the density field, default = rho
|
||||||
word rhoName_;
|
word rhoName_;
|
||||||
|
|
||||||
//- Name of the flux field, default ="rho"
|
//- Name of the flux field, default ="rho"
|
||||||
@ -164,11 +143,8 @@ protected:
|
|||||||
//- Agglomeration addressing from fine to coarse
|
//- Agglomeration addressing from fine to coarse
|
||||||
labelList fineToCoarseAddr_;
|
labelList fineToCoarseAddr_;
|
||||||
|
|
||||||
//- Agglomeration addressing from coarse to fine
|
|
||||||
labelListList coarseToFineAddr_;
|
|
||||||
|
|
||||||
//- Coarse face positions
|
//- Coarse face positions
|
||||||
vectorList coarsePosition_;
|
vectorField coarsePosition_;
|
||||||
|
|
||||||
//- Global coarse face addressing
|
//- Global coarse face addressing
|
||||||
globalIndex globalCoarseFaces_;
|
globalIndex globalCoarseFaces_;
|
||||||
@ -176,9 +152,6 @@ protected:
|
|||||||
|
|
||||||
// Particle collection info
|
// Particle collection info
|
||||||
|
|
||||||
//- Time of last write step
|
|
||||||
scalar lastOutputTime_;
|
|
||||||
|
|
||||||
//- Region indices in faceZone faces from last iteration
|
//- Region indices in faceZone faces from last iteration
|
||||||
labelList regions0_;
|
labelList regions0_;
|
||||||
|
|
||||||
@ -191,9 +164,6 @@ protected:
|
|||||||
//- Map from region to index in particles_ list
|
//- Map from region to index in particles_ list
|
||||||
Map<label> regionToParticleMap_;
|
Map<label> regionToParticleMap_;
|
||||||
|
|
||||||
// Collected particles
|
|
||||||
DynamicList<eulerianParticle> collectedParticles_;
|
|
||||||
|
|
||||||
//- Minimum diameter (optional)
|
//- Minimum diameter (optional)
|
||||||
// Can be used to filter out 'small' particles
|
// Can be used to filter out 'small' particles
|
||||||
scalar minDiameter_;
|
scalar minDiameter_;
|
||||||
@ -202,15 +172,6 @@ protected:
|
|||||||
// Can be used to filter out 'large' particles
|
// Can be used to filter out 'large' particles
|
||||||
scalar maxDiameter_;
|
scalar maxDiameter_;
|
||||||
|
|
||||||
//- Flag to create a distribution
|
|
||||||
bool createDistribution_;
|
|
||||||
|
|
||||||
//- Flag to reset the distribution on each write
|
|
||||||
bool resetDistributionOnWrite_;
|
|
||||||
|
|
||||||
//- Diameter distribution bin width
|
|
||||||
scalar distributionBinWidth_;
|
|
||||||
|
|
||||||
//- Random class needed by distribution models
|
//- Random class needed by distribution models
|
||||||
cachedRandom rndGen_;
|
cachedRandom rndGen_;
|
||||||
|
|
||||||
@ -274,9 +235,6 @@ protected:
|
|||||||
const faceZone& fz
|
const faceZone& fz
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write agglomerated particle data to stream
|
|
||||||
virtual void writeBinnedParticleData();
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline Type faceValue
|
inline Type faceValue
|
||||||
(
|
(
|
||||||
@ -296,7 +254,7 @@ public:
|
|||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
//- Static data staticData
|
//- Runtime type information
|
||||||
TypeName("extractEulerianParticles");
|
TypeName("extractEulerianParticles");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,231 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::injectedParticle
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
injectedParticle.C
|
||||||
|
injectedParticleIO.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef injectedParticle_H
|
||||||
|
#define injectedParticle_H
|
||||||
|
|
||||||
|
#include "particle.H"
|
||||||
|
#include "IOstream.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class injectedParticle;
|
||||||
|
|
||||||
|
// Forward declaration of friend functions
|
||||||
|
|
||||||
|
Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const injectedParticle&
|
||||||
|
);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class injectedParticle Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class injectedParticle
|
||||||
|
:
|
||||||
|
public particle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Size in bytes of the fields
|
||||||
|
static const std::size_t sizeofFields;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
// Particle properties
|
||||||
|
|
||||||
|
//- Start of injection [s]
|
||||||
|
scalar soi_;
|
||||||
|
|
||||||
|
//- Diameter [m]
|
||||||
|
scalar d_;
|
||||||
|
|
||||||
|
//- Velocity [m/s]
|
||||||
|
vector U_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("injectedParticle");
|
||||||
|
|
||||||
|
//- String representation of properties
|
||||||
|
AddToPropertyList
|
||||||
|
(
|
||||||
|
particle,
|
||||||
|
" soi"
|
||||||
|
+ " d"
|
||||||
|
+ " (Ux Uy Uz)";
|
||||||
|
);
|
||||||
|
|
||||||
|
//- String representation of property types
|
||||||
|
AddToPropertyTypes
|
||||||
|
(
|
||||||
|
particle,
|
||||||
|
"{scalar"
|
||||||
|
+ " scalar"
|
||||||
|
+ " vector}"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
inline injectedParticle
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& position,
|
||||||
|
const scalar soi,
|
||||||
|
const scalar d,
|
||||||
|
const vector& U
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
injectedParticle
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is,
|
||||||
|
bool readFields = true
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as a copy
|
||||||
|
injectedParticle(const injectedParticle& p);
|
||||||
|
|
||||||
|
//- Construct as a copy
|
||||||
|
injectedParticle(const injectedParticle& p, const polyMesh& mesh);
|
||||||
|
|
||||||
|
//- Construct and return a (basic particle) clone
|
||||||
|
virtual autoPtr<particle> clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<particle>(new injectedParticle(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct and return a (basic particle) clone
|
||||||
|
virtual autoPtr<particle> clone(const polyMesh& mesh) const
|
||||||
|
{
|
||||||
|
return autoPtr<particle>(new injectedParticle(*this, mesh));
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Factory class to read-construct particles used for
|
||||||
|
// parallel transfer
|
||||||
|
class iNew
|
||||||
|
{
|
||||||
|
const polyMesh& mesh_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
iNew(const polyMesh& mesh)
|
||||||
|
:
|
||||||
|
mesh_(mesh)
|
||||||
|
{}
|
||||||
|
|
||||||
|
autoPtr<injectedParticle> operator()(Istream& is) const
|
||||||
|
{
|
||||||
|
return autoPtr<injectedParticle>
|
||||||
|
(
|
||||||
|
new injectedParticle(mesh_, is, true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return const access to the start of injection
|
||||||
|
inline scalar soi() const;
|
||||||
|
|
||||||
|
//- Return const access to diameter
|
||||||
|
inline scalar d() const;
|
||||||
|
|
||||||
|
//- Return const access to velocity
|
||||||
|
inline const vector& U() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Return start of injection
|
||||||
|
inline scalar& soi();
|
||||||
|
|
||||||
|
//- Return access to diameter
|
||||||
|
inline scalar& d();
|
||||||
|
|
||||||
|
//- Return access to velocity
|
||||||
|
inline vector& U();
|
||||||
|
|
||||||
|
|
||||||
|
// I-O
|
||||||
|
|
||||||
|
//- Read
|
||||||
|
static void readFields(Cloud<injectedParticle>& c);
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
static void writeFields(const Cloud<injectedParticle>& c);
|
||||||
|
|
||||||
|
|
||||||
|
// Ostream Operator
|
||||||
|
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const injectedParticle&
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "injectedParticleI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "injectedParticleCloud.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::injectedParticleCloud::injectedParticleCloud
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& cloudName,
|
||||||
|
bool readFields
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Cloud<injectedParticle>(mesh, cloudName, false)
|
||||||
|
{
|
||||||
|
if (readFields)
|
||||||
|
{
|
||||||
|
injectedParticle::readFields(*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::injectedParticleCloud::~injectedParticleCloud()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::injectedParticleCloud
|
||||||
|
|
||||||
|
Group
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
injectedParticleCloud.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef injectedParticleCloud_H
|
||||||
|
#define injectedParticleCloud_H
|
||||||
|
|
||||||
|
#include "Cloud.H"
|
||||||
|
#include "injectedParticle.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class injectedParticleCloud Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class injectedParticleCloud
|
||||||
|
:
|
||||||
|
public Cloud<injectedParticle>
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
injectedParticleCloud(const injectedParticleCloud&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const injectedParticleCloud&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//-
|
||||||
|
injectedParticleCloud
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& name,
|
||||||
|
const bool readFields = true
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~injectedParticleCloud();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::injectedParticle::injectedParticle
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& position,
|
||||||
|
const scalar soi,
|
||||||
|
const scalar d,
|
||||||
|
const vector& U
|
||||||
|
)
|
||||||
|
:
|
||||||
|
particle(mesh, position, -1, false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::injectedParticle::soi() const
|
||||||
|
{
|
||||||
|
return soi_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::injectedParticle::d() const
|
||||||
|
{
|
||||||
|
return d_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::vector& Foam::injectedParticle::U() const
|
||||||
|
{
|
||||||
|
return U_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar& Foam::injectedParticle::soi()
|
||||||
|
{
|
||||||
|
return soi_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar& Foam::injectedParticle::d()
|
||||||
|
{
|
||||||
|
return d_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::vector& Foam::injectedParticle::U()
|
||||||
|
{
|
||||||
|
return U_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,179 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "IOField.H"
|
||||||
|
#include "Cloud.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::string Foam::injectedParticle::propertyList_ =
|
||||||
|
Foam::injectedParticle::propertyList();
|
||||||
|
|
||||||
|
Foam::string Foam::injectedParticle::propertyTypes_ =
|
||||||
|
Foam::injectedParticle::propertyTypes();
|
||||||
|
|
||||||
|
const std::size_t Foam::injectedParticle::sizeofFields
|
||||||
|
(
|
||||||
|
sizeof(scalar) + sizeof(scalar) + sizeof(vector)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::injectedParticle::injectedParticle
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is,
|
||||||
|
bool readFields
|
||||||
|
)
|
||||||
|
:
|
||||||
|
particle(mesh, is, readFields),
|
||||||
|
soi_(0.0),
|
||||||
|
d_(0.0),
|
||||||
|
U_(Zero)
|
||||||
|
{
|
||||||
|
if (readFields)
|
||||||
|
{
|
||||||
|
if (is.format() == IOstream::ASCII)
|
||||||
|
{
|
||||||
|
soi_ = readScalar(is);
|
||||||
|
d_ = readScalar(is);
|
||||||
|
is >> U_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
is.read(reinterpret_cast<char*>(&soi_), sizeofFields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check state of Istream
|
||||||
|
is.check
|
||||||
|
(
|
||||||
|
"injectedParticle::injectedParticle"
|
||||||
|
"(const polyMesh&, Istream&, bool)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::injectedParticle::readFields(Cloud<injectedParticle>& c)
|
||||||
|
{
|
||||||
|
if (!c.size())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
particle::readFields(c);
|
||||||
|
|
||||||
|
IOField<scalar> soi(c.fieldIOobject("soi", IOobject::MUST_READ));
|
||||||
|
c.checkFieldIOobject(c, soi);
|
||||||
|
|
||||||
|
IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
|
||||||
|
c.checkFieldIOobject(c, d);
|
||||||
|
|
||||||
|
IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
|
||||||
|
c.checkFieldIOobject(c, U);
|
||||||
|
|
||||||
|
label i = 0;
|
||||||
|
|
||||||
|
forAllIter(Cloud<injectedParticle>, c, iter)
|
||||||
|
{
|
||||||
|
injectedParticle& p = iter();
|
||||||
|
|
||||||
|
p.soi_ = soi[i];
|
||||||
|
p.d_ = d[i];
|
||||||
|
p.U_ = U[i];
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
|
||||||
|
{
|
||||||
|
particle::writeFields(c);
|
||||||
|
|
||||||
|
label np = c.size();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
label i = 0;
|
||||||
|
|
||||||
|
forAllConstIter(Cloud<injectedParticle>, c, iter)
|
||||||
|
{
|
||||||
|
const injectedParticle& p = iter();
|
||||||
|
|
||||||
|
soi[i] = p.soi();
|
||||||
|
d[i] = p.d();
|
||||||
|
U[i] = p.U();
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
soi.write();
|
||||||
|
d.write();
|
||||||
|
U.write();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const injectedParticle& p
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (os.format() == IOstream::ASCII)
|
||||||
|
{
|
||||||
|
os << static_cast<const particle&>(p)
|
||||||
|
<< token::SPACE << p.soi()
|
||||||
|
<< token::SPACE << p.d()
|
||||||
|
<< token::SPACE << p.U();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << static_cast<const particle&>(p);
|
||||||
|
os.write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(&p.soi_),
|
||||||
|
injectedParticle::sizeofFields
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check state of Ostream
|
||||||
|
os.check
|
||||||
|
(
|
||||||
|
"Ostream& operator<<(Ostream&, const injectedParticle&)"
|
||||||
|
);
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user