/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 .
\*---------------------------------------------------------------------------*/
#include "InjectedParticleInjection.H"
#include "mathematicalConstants.H"
#include "bitSet.H"
#include "injectedParticleCloud.H"
using namespace Foam::constant;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template
void Foam::InjectedParticleInjection::initialise()
{
const injectedParticleCloud cloud(this->owner().mesh(), cloudName_);
label nParticles = cloud.size();
List time(nParticles);
List position(nParticles);
List diameter(nParticles);
List U(nParticles);
label particlei = 0;
for (const injectedParticle& p : cloud)
{
time[particlei] = p.soi();
position[particlei] = p.position() + positionOffset_;
diameter[particlei] = p.d();
U[particlei] = p.U();
++particlei;
}
// Combine all proc data
if (Pstream::parRun())
{
List> procTime(Pstream::nProcs());
procTime[Pstream::myProcNo()].transfer(time);
Pstream::allGatherList(procTime);
time =
ListListOps::combine>
(
procTime, accessOp>()
);
List> procPosition(Pstream::nProcs());
procPosition[Pstream::myProcNo()].transfer(position);
Pstream::allGatherList(procPosition);
position =
ListListOps::combine>
(
procPosition, accessOp>()
);
List> procD(Pstream::nProcs());
procD[Pstream::myProcNo()].transfer(diameter);
Pstream::allGatherList(procD);
diameter =
ListListOps::combine>
(
procD, accessOp>()
);
List> procU(Pstream::nProcs());
procU[Pstream::myProcNo()].transfer(U);
Pstream::allGatherList(procU);
U =
ListListOps::combine>
(
procU, accessOp>()
);
}
nParticles = time.size();
// Reset SOI according to user selection
scalar minTime = min(time);
forAll(time, i)
{
time[i] -= minTime;
}
// Sort and renumber to ensure lists in ascending time
labelList sortedIndices(Foam::sortedOrder(time));
time_ = UIndirectList(time, sortedIndices);
position_ = UIndirectList(position, sortedIndices);
diameter_ = UIndirectList(diameter, sortedIndices);
U_ = UIndirectList(U, sortedIndices);
// Pre-calculate injected particle volumes
List volume(nParticles);
scalar sumVolume = 0;
forAll(volume, i)
{
scalar vol = pow3(diameter_[i])*mathematical::pi/6.0;
volume[i] = vol;
sumVolume += vol;
}
volume_.transfer(volume);
// Set the volume of particles to inject
this->volumeTotal_ = sumVolume;
// Provide some feedback
Info<< " Read " << nParticles << " particles" << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::InjectedParticleInjection::InjectedParticleInjection
(
const dictionary& dict,
CloudType& owner,
const word& modelName
)
:
InjectionModel(dict, owner, modelName, typeName),
cloudName_(this->coeffDict().lookup("cloud")),
injectorCells_(),
injectorTetFaces_(),
injectorTetPts_(),
time_(this->template getModelProperty("time")),
position_(this->template getModelProperty("position")),
positionOffset_(this->coeffDict().lookup("positionOffset")),
diameter_(this->template getModelProperty("diameter")),
U_(this->template getModelProperty("U")),
volume_(this->template getModelProperty("volume")),
ignoreOutOfBounds_
(
this->coeffDict().getOrDefault("ignoreOutOfBounds", false)
),
currentParticlei_
(
this->template getModelProperty