/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2019-2020 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 "ReactingMultiphaseLookupTableInjection.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::ReactingMultiphaseLookupTableInjection:: ReactingMultiphaseLookupTableInjection ( const dictionary& dict, CloudType& owner, const word& modelName ) : InjectionModel(dict, owner, modelName, typeName), inputFileName_(this->coeffDict().lookup("inputFile")), duration_(this->coeffDict().getScalar("duration")), parcelsPerSecond_(this->coeffDict().getScalar("parcelsPerSecond")), randomise_(this->coeffDict().getBool("randomise")), injectors_ ( IOobject ( inputFileName_, owner.db().time().constant(), owner.db(), IOobject::MUST_READ, IOobject::NO_WRITE ) ), injectorCells_(injectors_.size()), injectorTetFaces_(injectors_.size()), injectorTetPts_(injectors_.size()) { updateMesh(); duration_ = owner.db().time().userTimeToTime(duration_); // Determine volume of particles to inject this->volumeTotal_ = 0.0; forAll(injectors_, i) { this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho(); } this->volumeTotal_ *= duration_; } template Foam::ReactingMultiphaseLookupTableInjection:: ReactingMultiphaseLookupTableInjection ( const ReactingMultiphaseLookupTableInjection& im ) : InjectionModel(im), inputFileName_(im.inputFileName_), duration_(im.duration_), parcelsPerSecond_(im.parcelsPerSecond_), randomise_(im.randomise_), injectors_(im.injectors_), injectorCells_(im.injectorCells_), injectorTetFaces_(im.injectorTetFaces_), injectorTetPts_(im.injectorTetPts_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::ReactingMultiphaseLookupTableInjection::updateMesh() { // Set/cache the injector cells bitSet reject(injectors_.size()); // Set/cache the injector cells forAll(injectors_, i) { if ( !this->findCellAtPosition ( injectorCells_[i], injectorTetFaces_[i], injectorTetPts_[i], injectors_[i].x(), !this->ignoreOutOfBounds_ ) ) { reject.set(i); } } label nRejected = reject.count(); if (nRejected) { reject.flip(); inplaceSubset(reject, injectorCells_); inplaceSubset(reject, injectorTetFaces_); inplaceSubset(reject, injectorTetPts_); inplaceSubset(reject, injectors_); Info<< " " << nRejected << " positions rejected, out of bounds" << endl; } } template Foam::scalar Foam::ReactingMultiphaseLookupTableInjection::timeEnd() const { return this->SOI_ + duration_; } template Foam::label Foam::ReactingMultiphaseLookupTableInjection::parcelsToInject ( const scalar time0, const scalar time1 ) { if ((time0 >= 0.0) && (time0 < duration_)) { return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_); } return 0; } template Foam::scalar Foam::ReactingMultiphaseLookupTableInjection::volumeToInject ( const scalar time0, const scalar time1 ) { scalar volume = 0.0; if ((time0 >= 0.0) && (time0 < duration_)) { forAll(injectors_, i) { volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0); } } return volume; } template void Foam::ReactingMultiphaseLookupTableInjection::setPositionAndCell ( const label parcelI, const label nParcels, const scalar time, vector& position, label& cellOwner, label& tetFacei, label& tetPti ) { label injectorI = 0; if (randomise_) { Random& rnd = this->owner().rndGen(); injectorI = rnd.position