PatchInjection.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "PatchInjection.H"
00028 #include "DataEntry.H"
00029 #include "pdf.H"
00030
00031
00032
00033 template<class CloudType>
00034 Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
00035 (
00036 const scalar time0,
00037 const scalar time1
00038 ) const
00039 {
00040 if ((time0 >= 0.0) && (time0 < duration_))
00041 {
00042 return round(fraction_*(time1 - time0)*parcelsPerSecond_);
00043 }
00044 else
00045 {
00046 return 0;
00047 }
00048 }
00049
00050
00051 template<class CloudType>
00052 Foam::scalar Foam::PatchInjection<CloudType>::volumeToInject
00053 (
00054 const scalar time0,
00055 const scalar time1
00056 ) const
00057 {
00058 if ((time0 >= 0.0) && (time0 < duration_))
00059 {
00060 return fraction_*volumeFlowRate_().integrate(time0, time1);
00061 }
00062 else
00063 {
00064 return 0.0;
00065 }
00066 }
00067
00068
00069
00070
00071 template<class CloudType>
00072 Foam::PatchInjection<CloudType>::PatchInjection
00073 (
00074 const dictionary& dict,
00075 CloudType& owner
00076 )
00077 :
00078 InjectionModel<CloudType>(dict, owner, typeName),
00079 patchName_(this->coeffDict().lookup("patchName")),
00080 duration_(readScalar(this->coeffDict().lookup("duration"))),
00081 parcelsPerSecond_
00082 (
00083 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
00084 ),
00085 U0_(this->coeffDict().lookup("U0")),
00086 volumeFlowRate_
00087 (
00088 DataEntry<scalar>::New
00089 (
00090 "volumeFlowRate",
00091 this->coeffDict()
00092 )
00093 ),
00094 parcelPDF_
00095 (
00096 pdf::New
00097 (
00098 this->coeffDict().subDict("parcelPDF"),
00099 owner.rndGen()
00100 )
00101 ),
00102 cellOwners_(),
00103 fraction_(1.0)
00104 {
00105 label patchId = owner.mesh().boundaryMesh().findPatchID(patchName_);
00106
00107 if (patchId < 0)
00108 {
00109 FatalErrorIn
00110 (
00111 "PatchInjection<CloudType>::PatchInjection"
00112 "("
00113 "const dictionary&, "
00114 "CloudType&"
00115 ")"
00116 ) << "Requested patch " << patchName_ << " not found" << nl
00117 << "Available patches are: " << owner.mesh().boundaryMesh().names()
00118 << nl << exit(FatalError);
00119 }
00120
00121 const polyPatch& patch = owner.mesh().boundaryMesh()[patchId];
00122
00123 cellOwners_ = patch.faceCells();
00124
00125 label patchSize = cellOwners_.size();
00126 label totalPatchSize = patchSize;
00127 reduce(totalPatchSize, sumOp<scalar>());
00128 fraction_ = patchSize/totalPatchSize;
00129
00130
00131 this->volumeTotal_ = fraction_*volumeFlowRate_().integrate(0.0, duration_);
00132 }
00133
00134
00135
00136
00137 template<class CloudType>
00138 Foam::PatchInjection<CloudType>::~PatchInjection()
00139 {}
00140
00141
00142
00143
00144 template<class CloudType>
00145 bool Foam::PatchInjection<CloudType>::active() const
00146 {
00147 return true;
00148 }
00149
00150
00151 template<class CloudType>
00152 Foam::scalar Foam::PatchInjection<CloudType>::timeEnd() const
00153 {
00154 return this->SOI_ + duration_;
00155 }
00156
00157
00158 template<class CloudType>
00159 void Foam::PatchInjection<CloudType>::setPositionAndCell
00160 (
00161 const label,
00162 const label,
00163 const scalar,
00164 vector& position,
00165 label& cellOwner
00166 )
00167 {
00168 label cellI = this->owner().rndGen().integer(0, cellOwners_.size() - 1);
00169
00170 cellOwner = cellOwners_[cellI];
00171 position = this->owner().mesh().C()[cellOwner];
00172 }
00173
00174
00175 template<class CloudType>
00176 void Foam::PatchInjection<CloudType>::setProperties
00177 (
00178 const label,
00179 const label,
00180 const scalar,
00181 typename CloudType::parcelType& parcel
00182 )
00183 {
00184
00185 parcel.U() = U0_;
00186
00187
00188 parcel.d() = parcelPDF_->sample();
00189 }
00190
00191
00192 template<class CloudType>
00193 bool Foam::PatchInjection<CloudType>::fullyDescribed() const
00194 {
00195 return false;
00196 }
00197
00198
00199 template<class CloudType>
00200 bool Foam::PatchInjection<CloudType>::validInjection(const label)
00201 {
00202 return true;
00203 }
00204
00205
00206
Copyright © 2000-2009 OpenCFD Ltd