diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C new file mode 100644 index 0000000000..75a24d704d --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C @@ -0,0 +1,395 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#include "InjectedParticleInjection.H" +#include "mathematicalConstants.H" +#include "PackedBoolList.H" +#include "SortableList.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; + + forAllConstIter(injectedParticleCloud, cloud, iter) + { + const injectedParticle& p = iter(); + + 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::gatherList(procTime); + Pstream::scatterList(procTime); + time = + ListListOps::combine> + ( + procTime, accessOp>() + ); + + List> procPosition(Pstream::nProcs()); + procPosition[Pstream::myProcNo()].transfer(position); + Pstream::gatherList(procPosition); + Pstream::scatterList(procPosition); + position = + ListListOps::combine> + ( + procPosition, accessOp>() + ); + + List> procD(Pstream::nProcs()); + procD[Pstream::myProcNo()].transfer(diameter); + Pstream::gatherList(procD); + Pstream::scatterList(procD); + diameter = + ListListOps::combine> + ( + procD, accessOp>() + ); + + List> procU(Pstream::nProcs()); + procU[Pstream::myProcNo()].transfer(U); + Pstream::gatherList(procU); + Pstream::scatterList(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, sortedIndices); + 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/16.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().lookupOrDefault("ignoreOutOfBounds", false) + ), + currentParticlei_ + ( + this->template getModelProperty