molecule.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 "moleculeCloud.H"
00028 #include "molecule.H"
00029 #include "Random.H"
00030 #include "Time.H"
00031
00032
00033
00034 Foam::tensor Foam::molecule::rotationTensorX(scalar phi) const
00035 {
00036 return tensor
00037 (
00038 1, 0, 0,
00039 0, Foam::cos(phi), -Foam::sin(phi),
00040 0, Foam::sin(phi), Foam::cos(phi)
00041 );
00042 }
00043
00044
00045 Foam::tensor Foam::molecule::rotationTensorY(scalar phi) const
00046 {
00047 return tensor
00048 (
00049 Foam::cos(phi), 0, Foam::sin(phi),
00050 0, 1, 0,
00051 -Foam::sin(phi), 0, Foam::cos(phi)
00052 );
00053 }
00054
00055
00056 Foam::tensor Foam::molecule::rotationTensorZ(scalar phi) const
00057 {
00058 return tensor
00059 (
00060 Foam::cos(phi), -Foam::sin(phi), 0,
00061 Foam::sin(phi), Foam::cos(phi), 0,
00062 0, 0, 1
00063 );
00064 }
00065
00066
00067
00068
00069 Foam::molecule::trackData::trackData
00070 (
00071 moleculeCloud& molCloud,
00072 label part
00073 )
00074 :
00075 Particle<molecule>::trackData(molCloud),
00076 molCloud_(molCloud),
00077 part_(part)
00078 {}
00079
00080
00081
00082
00083
00084 bool Foam::molecule::move(molecule::trackData& td)
00085 {
00086 td.switchProcessor = false;
00087 td.keepParticle = true;
00088
00089 const constantProperties& constProps(td.molCloud().constProps(id_));
00090
00091 scalar deltaT = cloud().pMesh().time().deltaT().value();
00092
00093 if (td.part() == 0)
00094 {
00095
00096
00097
00098 v_ += 0.5*deltaT*a_;
00099
00100 pi_ += 0.5*deltaT*tau_;
00101 }
00102 else if (td.part() == 1)
00103 {
00104
00105
00106 scalar tEnd = (1.0 - stepFraction())*deltaT;
00107 scalar dtMax = tEnd;
00108
00109 while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL)
00110 {
00111
00112 scalar dt = min(dtMax, tEnd);
00113
00114 dt *= trackToFace(position() + dt*v_, td);
00115
00116 tEnd -= dt;
00117 stepFraction() = 1.0 - tEnd/deltaT;
00118 }
00119 }
00120 else if (td.part() == 2)
00121 {
00122
00123
00124
00125
00126 if (!constProps.pointMolecule())
00127 {
00128 const diagTensor& momentOfInertia(constProps.momentOfInertia());
00129
00130 tensor R;
00131
00132 if (!constProps.linearMolecule())
00133 {
00134 R = rotationTensorX(0.5*deltaT*pi_.x()/momentOfInertia.xx());
00135 pi_ = pi_ & R;
00136 Q_ = Q_ & R;
00137 }
00138
00139 R = rotationTensorY(0.5*deltaT*pi_.y()/momentOfInertia.yy());
00140 pi_ = pi_ & R;
00141 Q_ = Q_ & R;
00142
00143 R = rotationTensorZ(deltaT*pi_.z()/momentOfInertia.zz());
00144 pi_ = pi_ & R;
00145 Q_ = Q_ & R;
00146
00147 R = rotationTensorY(0.5*deltaT*pi_.y()/momentOfInertia.yy());
00148 pi_ = pi_ & R;
00149 Q_ = Q_ & R;
00150
00151 if (!constProps.linearMolecule())
00152 {
00153 R = rotationTensorX(0.5*deltaT*pi_.x()/momentOfInertia.xx());
00154 pi_ = pi_ & R;
00155 Q_ = Q_ & R;
00156 }
00157 }
00158
00159 setSitePositions(constProps);
00160 }
00161 else if (td.part() == 3)
00162 {
00163
00164
00165
00166 scalar m = constProps.mass();
00167
00168 a_ = vector::zero;
00169
00170 tau_ = vector::zero;
00171
00172 forAll(siteForces_, s)
00173 {
00174 const vector& f = siteForces_[s];
00175
00176 a_ += f/m;
00177
00178 tau_ += (constProps.siteReferencePositions()[s] ^ (Q_.T() & f));
00179 }
00180
00181 v_ += 0.5*deltaT*a_;
00182
00183 pi_ += 0.5*deltaT*tau_;
00184
00185 if (constProps.pointMolecule())
00186 {
00187 tau_ = vector::zero;
00188
00189 pi_ = vector::zero;
00190 }
00191
00192 if (constProps.linearMolecule())
00193 {
00194 tau_.x() = 0.0;
00195
00196 pi_.x() = 0.0;
00197 }
00198 }
00199 else
00200 {
00201 FatalErrorIn("molecule::move(molecule::trackData& td)") << nl
00202 << td.part()
00203 << " is an invalid part of the integration method."
00204 << abort(FatalError);
00205 }
00206
00207 return td.keepParticle;
00208 }
00209
00210
00211 void Foam::molecule::transformProperties(const tensor& T)
00212 {
00213 Q_ = T & Q_;
00214
00215 sitePositions_ = position_ + (T & (sitePositions_ - position_));
00216
00217 siteForces_ = T & siteForces_;
00218 }
00219
00220
00221 void Foam::molecule::transformProperties(const vector& separation)
00222 {
00223 if (special_ == SPECIAL_TETHERED)
00224 {
00225 specialPosition_ += separation;
00226 }
00227 }
00228
00229
00230 void Foam::molecule::setSitePositions(const constantProperties& constProps)
00231 {
00232 sitePositions_ = position_ + (Q_ & constProps.siteReferencePositions());
00233 }
00234
00235
00236 void Foam::molecule::setSiteSizes(label size)
00237 {
00238 sitePositions_.setSize(size);
00239
00240 siteForces_.setSize(size);
00241 }
00242
00243
00244 bool Foam::molecule::hitPatch
00245 (
00246 const polyPatch&,
00247 molecule::trackData&,
00248 const label
00249 )
00250 {
00251 return false;
00252 }
00253
00254
00255 bool Foam::molecule::hitPatch
00256 (
00257 const polyPatch&,
00258 int&,
00259 const label
00260 )
00261 {
00262 return false;
00263 }
00264
00265
00266 void Foam::molecule::hitProcessorPatch
00267 (
00268 const processorPolyPatch&,
00269 molecule::trackData& td
00270 )
00271 {
00272 td.switchProcessor = true;
00273 }
00274
00275
00276 void Foam::molecule::hitProcessorPatch
00277 (
00278 const processorPolyPatch&,
00279 int&
00280 )
00281 {}
00282
00283
00284 void Foam::molecule::hitWallPatch
00285 (
00286 const wallPolyPatch& wpp,
00287 molecule::trackData& td
00288 )
00289 {
00290 vector nw = wpp.faceAreas()[wpp.whichFace(face())];
00291 nw /= mag(nw);
00292
00293 scalar vn = v_ & nw;
00294
00295
00296 if (vn > 0)
00297 {
00298 v_ -= 2*vn*nw;
00299 }
00300 }
00301
00302
00303 void Foam::molecule::hitWallPatch
00304 (
00305 const wallPolyPatch&,
00306 int&
00307 )
00308 {}
00309
00310
00311 void Foam::molecule::hitPatch
00312 (
00313 const polyPatch&,
00314 molecule::trackData& td
00315 )
00316 {
00317 td.keepParticle = false;
00318 }
00319
00320
00321 void Foam::molecule::hitPatch
00322 (
00323 const polyPatch&,
00324 int&
00325 )
00326 {}
00327
00328
00329
Copyright © 2000-2009 OpenCFD Ltd