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 "LocalInteraction.H"
00027
00028
00029
00030 template <class CloudType>
00031 Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
00032 (
00033 const label globalPatchI
00034 ) const
00035 {
00036 forAll(patchIds_, patchI)
00037 {
00038 if (patchIds_[patchI] == globalPatchI)
00039 {
00040 return patchI;
00041 }
00042 }
00043
00044 return -1;
00045 }
00046
00047
00048
00049
00050 template <class CloudType>
00051 Foam::LocalInteraction<CloudType>::LocalInteraction
00052 (
00053 const dictionary& dict,
00054 CloudType& cloud
00055 )
00056 :
00057 PatchInteractionModel<CloudType>(dict, cloud, typeName),
00058 patchData_(this->coeffDict().lookup("patches")),
00059 patchIds_(patchData_.size())
00060 {
00061 const polyMesh& mesh = cloud.mesh();
00062 const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
00063
00064
00065 forAll(patchData_, patchI)
00066 {
00067 const word& patchName = patchData_[patchI].patchName();
00068 patchIds_[patchI] = bMesh.findPatchID(patchName);
00069 if (patchIds_[patchI] < 0)
00070 {
00071 FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
00072 << "Patch " << patchName << " not found. Available patches "
00073 << "are: " << bMesh.names() << nl << exit(FatalError);
00074 }
00075 }
00076
00077
00078 DynamicList<word> badWalls;
00079 forAll(bMesh, patchI)
00080 {
00081 if
00082 (
00083 isA<wallPolyPatch>(bMesh[patchI])
00084 && applyToPatch(bMesh[patchI].index()) < 0
00085 )
00086 {
00087 badWalls.append(bMesh[patchI].name());
00088 }
00089 }
00090
00091 if (badWalls.size() > 0)
00092 {
00093 FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
00094 << "All wall patches must be specified when employing local patch "
00095 << "interaction. Please specify data for patches:" << nl
00096 << badWalls << nl << exit(FatalError);
00097 }
00098
00099
00100 forAll(patchData_, patchI)
00101 {
00102 const word& interactionTypeName =
00103 patchData_[patchI].interactionTypeName();
00104 const typename PatchInteractionModel<CloudType>::interactionType& it =
00105 this->wordToInteractionType(interactionTypeName);
00106
00107 if (it == PatchInteractionModel<CloudType>::itOther)
00108 {
00109 const word& patchName = patchData_[patchI].patchName();
00110 FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
00111 << "Unknown patch interaction type "
00112 << interactionTypeName << " for patch " << patchName
00113 << ". Valid selections are:"
00114 << this->PatchInteractionModel<CloudType>::interactionTypeNames_
00115 << nl << exit(FatalError);
00116 }
00117 }
00118 }
00119
00120
00121
00122
00123 template <class CloudType>
00124 Foam::LocalInteraction<CloudType>::~LocalInteraction()
00125 {}
00126
00127
00128
00129
00130 template<class CloudType>
00131 bool Foam::LocalInteraction<CloudType>::active() const
00132 {
00133 return true;
00134 }
00135
00136
00137 template <class CloudType>
00138 bool Foam::LocalInteraction<CloudType>::correct
00139 (
00140 const polyPatch& pp,
00141 const label faceId,
00142 bool& keepParticle,
00143 bool& active,
00144 vector& U
00145 ) const
00146 {
00147 label patchI = applyToPatch(pp.index());
00148
00149 if (patchI >= 0)
00150 {
00151 typename PatchInteractionModel<CloudType>::interactionType it =
00152 this->wordToInteractionType
00153 (
00154 patchData_[patchI].interactionTypeName()
00155 );
00156
00157 switch (it)
00158 {
00159 case PatchInteractionModel<CloudType>::itEscape:
00160 {
00161 keepParticle = false;
00162 active = false;
00163 U = vector::zero;
00164 break;
00165 }
00166 case PatchInteractionModel<CloudType>::itStick:
00167 {
00168 keepParticle = true;
00169 active = false;
00170 U = vector::zero;
00171 break;
00172 }
00173 case PatchInteractionModel<CloudType>::itRebound:
00174 {
00175 keepParticle = true;
00176 active = true;
00177
00178 vector nw = pp.faceAreas()[pp.whichFace(faceId)];
00179 nw /= mag(nw);
00180
00181 scalar Un = U & nw;
00182 vector Ut = U - Un*nw;
00183
00184 if (Un > 0)
00185 {
00186 U -= (1.0 + patchData_[patchI].e())*Un*nw;
00187 }
00188
00189 U -= patchData_[patchI].mu()*Ut;
00190
00191 break;
00192 }
00193 default:
00194 {
00195 FatalErrorIn
00196 (
00197 "bool LocalInteraction<CloudType>::correct"
00198 "("
00199 "const polyPatch&, "
00200 "const label, "
00201 "bool&, "
00202 "vector&"
00203 ") const"
00204 ) << "Unknown interaction type "
00205 << patchData_[patchI].interactionTypeName()
00206 << "(" << it << ") for patch "
00207 << patchData_[patchI].patchName()
00208 << ". Valid selections are:" << this->interactionTypeNames_
00209 << endl << abort(FatalError);
00210 }
00211 }
00212
00213 return true;
00214 }
00215
00216 return false;
00217 }
00218
00219
00220