1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "PatchInjection.H"
28 #include "DataEntry.H"
31 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
33 template<class CloudType>
34 Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
40 if ((time0 >= 0.0) && (time0 < duration_))
42 return round(fraction_*(time1 - time0)*parcelsPerSecond_);
51 template<class CloudType>
52 Foam::scalar Foam::PatchInjection<CloudType>::volumeToInject
58 if ((time0 >= 0.0) && (time0 < duration_))
60 return fraction_*volumeFlowRate_().integrate(time0, time1);
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 template<class CloudType>
72 Foam::PatchInjection<CloudType>::PatchInjection
74 const dictionary& dict,
78 InjectionModel<CloudType>(dict, owner, typeName),
79 patchName_(this->coeffDict().lookup("patchName")),
80 duration_(readScalar(this->coeffDict().lookup("duration"))),
83 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
85 U0_(this->coeffDict().lookup("U0")),
88 DataEntry<scalar>::New
98 this->coeffDict().subDict("parcelPDF"),
105 label patchId = owner.mesh().boundaryMesh().findPatchID(patchName_);
111 "PatchInjection<CloudType>::PatchInjection"
113 "const dictionary&, "
116 ) << "Requested patch " << patchName_ << " not found" << nl
117 << "Available patches are: " << owner.mesh().boundaryMesh().names()
118 << nl << exit(FatalError);
121 const polyPatch& patch = owner.mesh().boundaryMesh()[patchId];
123 cellOwners_ = patch.faceCells();
125 label patchSize = cellOwners_.size();
126 label totalPatchSize = patchSize;
127 reduce(totalPatchSize, sumOp<label>());
128 fraction_ = scalar(patchSize)/totalPatchSize;
130 // Set total volume/mass to inject
131 this->volumeTotal_ = fraction_*volumeFlowRate_().integrate(0.0, duration_);
132 this->massTotal_ *= fraction_;
136 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 template<class CloudType>
139 Foam::PatchInjection<CloudType>::~PatchInjection()
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 template<class CloudType>
146 bool Foam::PatchInjection<CloudType>::active() const
152 template<class CloudType>
153 Foam::scalar Foam::PatchInjection<CloudType>::timeEnd() const
155 return this->SOI_ + duration_;
159 template<class CloudType>
160 void Foam::PatchInjection<CloudType>::setPositionAndCell
169 if (cellOwners_.size() > 0)
171 label cellI = this->owner().rndGen().integer(0, cellOwners_.size() - 1);
173 cellOwner = cellOwners_[cellI];
174 position = this->owner().mesh().C()[cellOwner];
180 position = pTraits<vector>::max;
185 template<class CloudType>
186 void Foam::PatchInjection<CloudType>::setProperties
191 typename CloudType::parcelType& parcel
194 // set particle velocity
197 // set particle diameter
198 parcel.d() = parcelPDF_->sample();
202 template<class CloudType>
203 bool Foam::PatchInjection<CloudType>::fullyDescribed() const
209 template<class CloudType>
210 bool Foam::PatchInjection<CloudType>::validInjection(const label)
216 // ************************************************************************* //