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 #include "KinematicLookupTableInjection.H"
00027 #include <OpenFOAM/scalarIOList.H>
00028
00029
00030
00031 template<class CloudType>
00032 Foam::label Foam::KinematicLookupTableInjection<CloudType>::parcelsToInject
00033 (
00034 const scalar time0,
00035 const scalar time1
00036 ) const
00037 {
00038 if ((time0 >= 0.0) && (time0 < duration_))
00039 {
00040 return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
00041 }
00042 else
00043 {
00044 return 0;
00045 }
00046 }
00047
00048
00049 template<class CloudType>
00050 Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::volumeToInject
00051 (
00052 const scalar time0,
00053 const scalar time1
00054 ) const
00055 {
00056 scalar volume = 0.0;
00057 if ((time0 >= 0.0) && (time0 < duration_))
00058 {
00059 forAll(injectors_, i)
00060 {
00061 volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
00062 }
00063 }
00064
00065 return volume;
00066 }
00067
00068
00069
00070
00071 template<class CloudType>
00072 Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
00073 (
00074 const dictionary& dict,
00075 CloudType& owner
00076 )
00077 :
00078 InjectionModel<CloudType>(dict, owner, typeName),
00079 inputFileName_(this->coeffDict().lookup("inputFile")),
00080 duration_(readScalar(this->coeffDict().lookup("duration"))),
00081 nParcelsPerSecond_
00082 (
00083 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
00084 ),
00085 injectors_
00086 (
00087 IOobject
00088 (
00089 inputFileName_,
00090 owner.db().time().constant(),
00091 owner.db(),
00092 IOobject::MUST_READ,
00093 IOobject::NO_WRITE
00094 )
00095 ),
00096 injectorCells_(0)
00097 {
00098
00099 injectorCells_.setSize(injectors_.size());
00100 forAll(injectors_, i)
00101 {
00102 this->findCellAtPosition(injectorCells_[i], injectors_[i].x());
00103 }
00104
00105
00106 this->volumeTotal_ = 0.0;
00107 forAll(injectors_, i)
00108 {
00109 this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
00110 }
00111 this->volumeTotal_ *= duration_;
00112 }
00113
00114
00115
00116
00117 template<class CloudType>
00118 Foam::KinematicLookupTableInjection<CloudType>::~KinematicLookupTableInjection()
00119 {}
00120
00121
00122
00123
00124 template<class CloudType>
00125 bool Foam::KinematicLookupTableInjection<CloudType>::active() const
00126 {
00127 return true;
00128 }
00129
00130
00131 template<class CloudType>
00132 Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::timeEnd() const
00133 {
00134 return this->SOI_ + duration_;
00135 }
00136
00137
00138 template<class CloudType>
00139 void Foam::KinematicLookupTableInjection<CloudType>::setPositionAndCell
00140 (
00141 const label parcelI,
00142 const label nParcels,
00143 const scalar time,
00144 vector& position,
00145 label& cellOwner
00146 )
00147 {
00148 label injectorI = parcelI*injectorCells_.size()/nParcels;
00149
00150 position = injectors_[injectorI].x();
00151 cellOwner = injectorCells_[injectorI];
00152 }
00153
00154
00155 template<class CloudType>
00156 void Foam::KinematicLookupTableInjection<CloudType>::setProperties
00157 (
00158 const label parcelI,
00159 const label nParcels,
00160 const scalar,
00161 typename CloudType::parcelType& parcel
00162 )
00163 {
00164 label injectorI = parcelI*injectorCells_.size()/nParcels;
00165
00166
00167 parcel.U() = injectors_[injectorI].U();
00168
00169
00170 parcel.d() = injectors_[injectorI].d();
00171
00172
00173 parcel.rho() = injectors_[injectorI].rho();
00174 }
00175
00176
00177 template<class CloudType>
00178 bool Foam::KinematicLookupTableInjection<CloudType>::fullyDescribed() const
00179 {
00180 return true;
00181 }
00182
00183
00184 template<class CloudType>
00185 bool Foam::KinematicLookupTableInjection<CloudType>::validInjection
00186 (
00187 const label
00188 )
00189 {
00190 return true;
00191 }
00192
00193
00194