LocalInteraction.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 "LocalInteraction.H"
00028
00029
00030
00031 template <class CloudType>
00032 Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
00033 (
00034 const label globalPatchI
00035 ) const
00036 {
00037 forAll(patchIds_, patchI)
00038 {
00039 if (patchIds_[patchI] == globalPatchI)
00040 {
00041 return patchI;
00042 }
00043 }
00044
00045 return -1;
00046 }
00047
00048
00049
00050
00051 template <class CloudType>
00052 Foam::LocalInteraction<CloudType>::LocalInteraction
00053 (
00054 const dictionary& dict,
00055 CloudType& cloud
00056 )
00057 :
00058 PatchInteractionModel<CloudType>(dict, cloud, typeName),
00059 patchData_(this->coeffDict().lookup("patches")),
00060 patchIds_(patchData_.size())
00061 {
00062 const polyMesh& mesh = cloud.mesh();
00063 const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
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() << 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
00101
00102
00103 template <class CloudType>
00104 Foam::LocalInteraction<CloudType>::~LocalInteraction()
00105 {}
00106
00107
00108
00109
00110 template<class CloudType>
00111 bool Foam::LocalInteraction<CloudType>::active() const
00112 {
00113 return true;
00114 }
00115
00116
00117 template <class CloudType>
00118 bool Foam::LocalInteraction<CloudType>::correct
00119 (
00120 const polyPatch& pp,
00121 const label faceId,
00122 vector& U
00123 ) const
00124 {
00125 label patchI = applyToPatch(pp.index());
00126
00127 if (patchI >= 0)
00128 {
00129 vector nw = pp.faceAreas()[pp.whichFace(faceId)];
00130 nw /= mag(nw);
00131
00132 scalar Un = U & nw;
00133 vector Ut = U - Un*nw;
00134
00135 if (Un > 0)
00136 {
00137 U -= (1.0 + patchData_[patchI].e())*Un*nw;
00138 }
00139
00140 U -= patchData_[patchI].mu()*Ut;
00141
00142 return true;
00143 }
00144
00145 return false;
00146 }
00147
00148
00149
Copyright © 2000-2009 OpenCFD Ltd