diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H b/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H index 3bd86d1f215f81dea3b1bbf880bd9ccb3e82fa0e..800854763c1cc7752ae190180b14a7280fc9f1b3 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H @@ -32,6 +32,7 @@ License #include "KinematicCloud.H" #include "ConeInjection.H" +#include "ConeInjectionMP.H" #include "FieldActivatedInjection.H" #include "KinematicLookupTableInjection.H" #include "ManualInjection.H" @@ -50,6 +51,12 @@ License ParcelType \ ); \ makeInjectionModelType \ + ( \ + ConeInjectionMP, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeInjectionModelType \ ( \ FieldActivatedInjection, \ KinematicCloud, \ diff --git a/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H b/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H index 2c705ec989c7c85ca241c2e269f1b9ff87d4ae37..0bae6f13b64859b9b99602195bf729ce9b72dab8 100644 --- a/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeReactingMultiphaseParcelInjectionModels.H @@ -33,6 +33,7 @@ License #include "KinematicCloud.H" #include "ConeInjection.H" +#include "ConeInjectionMP.H" #include "FieldActivatedInjection.H" #include "ManualInjection.H" #include "NoInjection.H" @@ -66,6 +67,13 @@ License ThermoType \ ); \ makeInjectionModelThermoType \ + ( \ + ConeInjectionMP, \ + KinematicCloud, \ + ParcelType, \ + ThermoType \ + ); \ + makeInjectionModelThermoType \ ( \ FieldActivatedInjection, \ KinematicCloud, \ diff --git a/src/lagrangian/intermediate/parcels/include/makeReactingParcelInjectionModels.H b/src/lagrangian/intermediate/parcels/include/makeReactingParcelInjectionModels.H index 71ab8fbba567b657a2e9f0744ddb3b55466c4b44..5d70cb1e6887f27f9efe6dc7541f0a8f5e3b8daf 100644 --- a/src/lagrangian/intermediate/parcels/include/makeReactingParcelInjectionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeReactingParcelInjectionModels.H @@ -33,6 +33,7 @@ License #include "KinematicCloud.H" #include "ConeInjection.H" +#include "ConeInjectionMP.H" #include "FieldActivatedInjection.H" #include "ManualInjection.H" #include "NoInjection.H" @@ -67,6 +68,13 @@ License ThermoType \ ); \ makeInjectionModelThermoType \ + ( \ + ConeInjectionMP, \ + KinematicCloud, \ + ParcelType, \ + ThermoType \ + ); \ + makeInjectionModelThermoType \ ( \ FieldActivatedInjection, \ KinematicCloud, \ diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C new file mode 100644 index 0000000000000000000000000000000000000000..6e1fa412be0c7f165091f8cb86616cdabb50e4c7 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C @@ -0,0 +1,282 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "ConeInjectionMP.H" +#include "DataEntry.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template<class CloudType> +Foam::label Foam::ConeInjectionMP<CloudType>::parcelsToInject +( + const scalar time0, + const scalar time1 +) const +{ + if ((time0 >= 0.0) && (time0 < duration_)) + { + const scalar targetVolume = volumeFlowRate_().integrate(0, time1); + + const label targetParcels = + parcelsPerInjector_*targetVolume/this->volumeTotal_; + + const label nToInject = targetParcels - nInjected_; + + nInjected_ += nToInject; + + return positions_.size()*nToInject; + } + else + { + return 0; + } +} + + +template<class CloudType> +Foam::scalar Foam::ConeInjectionMP<CloudType>::volumeToInject +( + const scalar time0, + const scalar time1 +) const +{ + if ((time0 >= 0.0) && (time0 < duration_)) + { + return volumeFlowRate_().integrate(time0, time1); + } + else + { + return 0.0; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ConeInjectionMP<CloudType>::ConeInjectionMP +( + const dictionary& dict, + CloudType& owner +) +: + InjectionModel<CloudType>(dict, owner, typeName), + positionsFile_(this->coeffDict().lookup("positionsFile")), + positions_ + ( + IOobject + ( + positionsFile_, + owner.db().time().constant(), + owner.mesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + injectorCells_(positions_.size()), + axesFile_(this->coeffDict().lookup("axesFile")), + axes_ + ( + IOobject + ( + axesFile_, + owner.db().time().constant(), + owner.mesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + duration_(readScalar(this->coeffDict().lookup("duration"))), + parcelsPerInjector_ + ( + readScalar(this->coeffDict().lookup("parcelsPerInjector")) + ), + volumeFlowRate_ + ( + DataEntry<scalar>::New + ( + "volumeFlowRate", + this->coeffDict() + ) + ), + Umag_ + ( + DataEntry<scalar>::New + ( + "Umag", + this->coeffDict() + ) + ), + thetaInner_ + ( + DataEntry<scalar>::New + ( + "thetaInner", + this->coeffDict() + ) + ), + thetaOuter_ + ( + DataEntry<scalar>::New + ( + "thetaOuter", + this->coeffDict() + ) + ), + parcelPDF_ + ( + pdf::New + ( + this->coeffDict().subDict("parcelPDF"), + owner.rndGen() + ) + ), + nInjected_(this->parcelsAddedTotal()), + tanVec1_(positions_.size()), + tanVec2_(positions_.size()) +{ + // Normalise direction vector and determine direction vectors + // tangential to direction + forAll(axes_, i) + { + axes_[i] /= mag(axes_[i]); + + vector tangent = vector::zero; + scalar magTangent = 0.0; + + while (magTangent < SMALL) + { + vector v = this->owner().rndGen().vector01(); + + tangent = v - (v & axes_[i])*axes_[i]; + magTangent = mag(tangent); + } + + tanVec1_[i] = tangent/magTangent; + tanVec2_[i] = axes_[i]^tanVec1_[i]; + } + + // Set total volume to inject + this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_); + + // Set/cache the injector cells + forAll(positions_, i) + { + this->findCellAtPosition + ( + injectorCells_[i], + positions_[i] + ); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ConeInjectionMP<CloudType>::~ConeInjectionMP() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +bool Foam::ConeInjectionMP<CloudType>::active() const +{ + return true; +} + + +template<class CloudType> +Foam::scalar Foam::ConeInjectionMP<CloudType>::timeEnd() const +{ + return this->SOI_ + duration_; +} + + +template<class CloudType> +void Foam::ConeInjectionMP<CloudType>::setPositionAndCell +( + const label parcelI, + const label, + const scalar, + vector& position, + label& cellOwner +) +{ + const label i = parcelI%positions_.size(); + + position = positions_[i]; + cellOwner = injectorCells_[i]; +} + + +template<class CloudType> +void Foam::ConeInjectionMP<CloudType>::setProperties +( + const label parcelI, + const label, + const scalar time, + typename CloudType::parcelType* pPtr +) +{ + // set particle velocity + const label i = parcelI%positions_.size(); + + const scalar deg2Rad = mathematicalConstant::pi/180.0; + + scalar t = time - this->SOI_; + scalar ti = thetaInner_().value(t); + scalar to = thetaOuter_().value(t); + scalar coneAngle = this->owner().rndGen().scalar01()*(to - ti) + ti; + + coneAngle *= deg2Rad; + scalar alpha = sin(coneAngle); + scalar dcorr = cos(coneAngle); + scalar beta = + 2.0*mathematicalConstant::pi*this->owner().rndGen().scalar01(); + + vector normal = alpha*(tanVec1_[i]*cos(beta) + tanVec2_[i]*sin(beta)); + vector dirVec = dcorr*axes_[i]; + dirVec += normal; + + dirVec /= mag(dirVec); + + pPtr->U() = Umag_().value(t)*dirVec; + + // set particle diameter + pPtr->d() = parcelPDF_().sample(); +} + + +template<class CloudType> +bool Foam::ConeInjectionMP<CloudType>::validInjection(const label parcelI) +{ + return true; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H new file mode 100644 index 0000000000000000000000000000000000000000..489b9d4d95d84d9c993ae6f3c3e317d176021e52 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::ConeInjectionMP + +Description + Cone injection multi-point + + - User specifies + - time of start of injection + - injector positions + - directions (along injection axes) + - parcel flow rate + - parcel velocities + - inner and outer cone angles + - Parcel diameters obtained by PDF model + +SourceFiles + ConeInjectionMP.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ConeInjectionMP_H +#define ConeInjectionMP_H + +#include "InjectionModel.H" +#include "pdf.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes + +template<class Type> +class DataEntry; + +/*---------------------------------------------------------------------------*\ + Class ConeInjectionMP Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class ConeInjectionMP +: + public InjectionModel<CloudType> +{ + // Private data + + //- Coefficients dictionary + dictionary coeffDict_; + + //- Name of file containing positions data + const word positionsFile_; + + //- Field of injector positions + vectorIOField positions_; + + //- Field of cell labels corresoponding to injector positions + labelField injectorCells_; + + //- Name of file containing axes data + const word axesFile_; + + //- Field of injector positions + vectorIOField axes_; + + //- Injection duration [s] + const scalar duration_; + + //- Number of parcels to introduce per injector + const label parcelsPerInjector_; + + //- Volume flow rate of parcels to introduce relative to SOI [m^3] + const autoPtr<DataEntry<scalar> > volumeFlowRate_; + + //- Parcel velocity magnitude relative to SOI [m/s] + const autoPtr<DataEntry<scalar> > Umag_; + + //- Inner cone angle relative to SOI [deg] + const autoPtr<DataEntry<scalar> > thetaInner_; + + //- Outer cone angle relative to SOI [deg] + const autoPtr<DataEntry<scalar> > thetaOuter_; + + //- Parcel size PDF model + const autoPtr<pdf> parcelPDF_; + + //- Number of parcels per injector already injected + mutable label nInjected_; + + + // Tangential vectors to the direction vector + + //- First tangential vector + vectorField tanVec1_; + + //- Second tangential vector + vectorField tanVec2_; + + +protected: + + // Protected member functions + + //- Number of parcels to introduce over the time step + label parcelsToInject + ( + const scalar time0, + const scalar time1 + ) const; + + //- Number of parcels to introduce over the time step + scalar volumeToInject + ( + const scalar time0, + const scalar time1 + ) const; + + +public: + + //- Runtime type information + TypeName("ConeInjectionMP"); + + + // Constructors + + //- Construct from dictionary + ConeInjectionMP + ( + const dictionary& dict, + CloudType& owner + ); + + + //- Destructor + virtual ~ConeInjectionMP(); + + + // Member Functions + + //- Flag to indicate whether model activates injection model + bool active() const; + + //- Return the end-of-injection time + scalar timeEnd() const; + + + // Injection geometry + + //- Set the injection position and owner cell + virtual void setPositionAndCell + ( + const label parcelI, + const label nParcels, + const scalar time, + vector& position, + label& cellOwner + ); + + virtual void setProperties + ( + const label parcelI, + const label nParcels, + const scalar time, + typename CloudType::parcelType* pPtr + ); + + virtual bool fullyDescribed() const + { + return false; + } + + //- Return flag to identify whether or not injection in cellI is + // permitted + virtual bool validInjection(const label parcelI); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "ConeInjectionMP.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //