reflectParcel.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 "reflectParcel.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "wallPolyPatch.H"
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038 defineTypeNameAndDebug(reflectParcel, 0);
00039
00040 addToRunTimeSelectionTable
00041 (
00042 wallModel,
00043 reflectParcel,
00044 dictionary
00045 );
00046
00047
00048
00049
00050
00051 reflectParcel::reflectParcel
00052 (
00053 const dictionary& dict,
00054 const volVectorField& U,
00055 spray& sm
00056 )
00057 :
00058 wallModel(dict, U, sm),
00059 U_(U),
00060 coeffsDict_(dict.subDict(typeName + "Coeffs")),
00061 elasticity_(readScalar(coeffsDict_.lookup("elasticity")))
00062 {}
00063
00064
00065
00066
00067 reflectParcel::~reflectParcel()
00068 {}
00069
00070
00071
00072
00073
00074 bool reflectParcel::wallTreatment
00075 (
00076 parcel& p,
00077 const label globalFacei
00078 ) const
00079 {
00080 label patchi = p.patch(globalFacei);
00081 label facei = p.patchFace(patchi, globalFacei);
00082
00083 const polyMesh& mesh = spray_.mesh();
00084
00085 if (isType<wallPolyPatch>(mesh_.boundaryMesh()[patchi]))
00086 {
00087
00088 vector Sf = mesh_.Sf().boundaryField()[patchi][facei];
00089 Sf /= mag(Sf);
00090
00091 if (!mesh.moving())
00092 {
00093
00094 scalar Un = p.U() & Sf;
00095
00096 if (Un > 0)
00097 {
00098 p.U() -= (1.0 + elasticity_)*Un*Sf;
00099 }
00100
00101 }
00102 else
00103 {
00104
00105 vector Ub1 = U_.boundaryField()[patchi][facei];
00106 vector Ub0 = U_.oldTime().boundaryField()[patchi][facei];
00107
00108 scalar dt = spray_.runTime().deltaT().value();
00109 const vectorField& oldPoints = mesh.oldPoints();
00110
00111 const vector& Cf1 = mesh.faceCentres()[globalFacei];
00112
00113 vector Cf0 = mesh.faces()[globalFacei].centre(oldPoints);
00114 vector Cf = Cf0 + p.stepFraction()*(Cf1 - Cf0);
00115 vector Sf0 = mesh.faces()[globalFacei].normal(oldPoints);
00116
00117
00118 if (mag(Sf0) > SMALL)
00119 {
00120 Sf0 /= mag(Sf0);
00121 }
00122 else
00123 {
00124 Sf0 = Sf;
00125 }
00126
00127 scalar magSfDiff = mag(Sf - Sf0);
00128
00129 vector Ub = Ub0 + p.stepFraction()*(Ub1 - Ub0);
00130
00131 if (magSfDiff > SMALL)
00132 {
00133
00134 vector Sfp = Sf0 + p.stepFraction()*(Sf - Sf0);
00135
00136 vector omega = Sf0 ^ Sf;
00137 scalar magOmega = mag(omega);
00138 omega /= magOmega+SMALL;
00139
00140 scalar phiVel = ::asin(magOmega)/dt;
00141
00142 scalar dist = (p.position() - Cf) & Sfp;
00143 vector pos = p.position() - dist*Sfp;
00144 vector vrot = phiVel*(omega ^ (pos - Cf));
00145
00146 vector v = Ub + vrot;
00147
00148 scalar Un = ((p.U() - v) & Sfp);
00149
00150 if (Un > 0.0)
00151 {
00152 p.U() -= (1.0 + elasticity_)*Un*Sfp;
00153 }
00154 }
00155 else
00156 {
00157
00158 vector Ur = p.U() - Ub;
00159 scalar Urn = Ur & Sf;
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 if (Urn > 0.0)
00173 {
00174 p.U() -= (1.0 + elasticity_)*Urn*Sf;
00175 }
00176 }
00177 }
00178
00179 }
00180 else
00181 {
00182 FatalError
00183 << "bool reflectParcel::wallTreatment(parcel& parcel) const "
00184 << " parcel has hit a boundary "
00185 << mesh_.boundary()[patchi].type()
00186 << " which not yet has been implemented."
00187 << abort(FatalError);
00188 }
00189 return true;
00190 }
00191
00192
00193
00194 }
00195
00196
Copyright © 2000-2009 OpenCFD Ltd