repatchPolyTopoChanger.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
00028
00029
00030
00031
00032
00033
00034 #include "repatchPolyTopoChanger.H"
00035 #include "polyTopoChanger.H"
00036 #include "mapPolyMesh.H"
00037 #include "polyModifyFace.H"
00038
00039
00040
00041 Foam::polyTopoChange& Foam::repatchPolyTopoChanger::meshMod()
00042 {
00043 if (meshModPtr_.empty())
00044 {
00045 meshModPtr_.reset(new polyTopoChange(mesh_));
00046 }
00047 return meshModPtr_();
00048 }
00049
00050
00051
00052
00053 Foam::repatchPolyTopoChanger::repatchPolyTopoChanger(polyMesh& mesh)
00054 :
00055 mesh_(mesh),
00056 meshModPtr_(NULL)
00057 {}
00058
00059
00060
00061
00062 void Foam::repatchPolyTopoChanger::changePatches
00063 (
00064 const List<polyPatch*>& patches
00065 )
00066 {
00067 if (meshModPtr_.valid())
00068 {
00069 FatalErrorIn
00070 (
00071 "repatchPolyTopoChanger::changePatches(const List<polyPatch*>&)"
00072 ) << "Cannot change patches after having changed faces. " << nl
00073 << "Please call changePatches first."
00074 << exit(FatalError);
00075 }
00076 meshModPtr_.clear();
00077 mesh_.removeBoundary();
00078 mesh_.addPatches(patches);
00079 }
00080
00081
00082 void Foam::repatchPolyTopoChanger::changePatchID
00083 (
00084 const label faceID,
00085 const label patchID
00086 )
00087 {
00088 if (polyTopoChanger::debug)
00089 {
00090
00091 if
00092 (
00093 faceID >= mesh_.faces().size()
00094 || patchID >= mesh_.boundaryMesh().size()
00095 || mesh_.isInternalFace(faceID)
00096 )
00097 {
00098 FatalErrorIn
00099 (
00100 "void Foam::repatchPolyTopoChanger::changePatchID\n"
00101 "(\n"
00102 " const label faceID,\n"
00103 " const label patchID\n"
00104 ")\n"
00105 ) << "Error in definition. faceID: " << faceID
00106 << " patchID: " << patchID << ". "
00107 << "Labels out of range or internal face."
00108 << abort(FatalError);
00109 }
00110 }
00111
00112 const label zoneID = mesh_.faceZones().whichZone(faceID);
00113
00114 bool zoneFlip = false;
00115
00116 if (zoneID >= 0)
00117 {
00118 const faceZone& fZone = mesh_.faceZones()[zoneID];
00119
00120 zoneFlip = fZone.flipMap()[fZone.whichFace(faceID)];
00121 }
00122
00123 meshMod().setAction
00124 (
00125 polyModifyFace
00126 (
00127 mesh_.faces()[faceID],
00128 faceID,
00129 mesh_.faceOwner()[faceID],
00130 -1,
00131 false,
00132 patchID,
00133 false,
00134 zoneID,
00135 zoneFlip
00136 )
00137 );
00138 }
00139
00140
00141 void Foam::repatchPolyTopoChanger::setFaceZone
00142 (
00143 const label faceID,
00144 const label zoneID,
00145 const bool zoneFlip
00146 )
00147 {
00148 if (polyTopoChanger::debug)
00149 {
00150
00151 if (faceID > mesh_.faces().size())
00152 {
00153 FatalErrorIn
00154 (
00155 "void Foam::repatchPolyTopoChanger::setFaceZone"
00156 "(\n"
00157 " const label faceID,\n"
00158 " const label zoneID,\n"
00159 " const bool flip\n"
00160 ")\n"
00161 ) << "Error in definition. faceID: " << faceID
00162 << "out of range."
00163 << abort(FatalError);
00164 }
00165 }
00166
00167 meshMod().setAction
00168 (
00169 polyModifyFace
00170 (
00171 mesh_.faces()[faceID],
00172 faceID,
00173 mesh_.faceOwner()[faceID],
00174 mesh_.faceNeighbour()[faceID],
00175 false,
00176 mesh_.boundaryMesh().whichPatch(faceID),
00177 true,
00178 zoneID,
00179 zoneFlip
00180 )
00181 );
00182 }
00183
00184
00185 void Foam::repatchPolyTopoChanger::changeAnchorPoint
00186 (
00187 const label faceID,
00188 const label fp
00189 )
00190 {
00191 if (polyTopoChanger::debug)
00192 {
00193
00194 if (faceID > mesh_.faces().size())
00195 {
00196 FatalErrorIn
00197 (
00198 "void Foam::repatchPolyTopoChanger::setFaceZone"
00199 "(\n"
00200 " const label faceID,\n"
00201 " const label zoneID,\n"
00202 " const bool flip\n"
00203 ")\n"
00204 ) << "Error in definition. faceID: " << faceID
00205 << "out of range."
00206 << abort(FatalError);
00207 }
00208 }
00209
00210 const face& f = mesh_.faces()[faceID];
00211
00212 if ((fp < 0) || (fp >= f.size()))
00213 {
00214 FatalErrorIn
00215 (
00216 "void Foam::repatchPolyTopoChanger::changeAnchorPoint"
00217 "(\n"
00218 " const label faceID,\n"
00219 " const label fp\n"
00220 ")\n"
00221 ) << "Error in definition. Face point: " << fp
00222 << "indexes out of face " << f
00223 << abort(FatalError);
00224 }
00225
00226 label patchID = mesh_.boundaryMesh().whichPatch(faceID);
00227
00228 const label zoneID = mesh_.faceZones().whichZone(faceID);
00229
00230 bool zoneFlip = false;
00231
00232 if (zoneID >= 0)
00233 {
00234 const faceZone& fZone = mesh_.faceZones()[zoneID];
00235
00236 zoneFlip = fZone.flipMap()[fZone.whichFace(faceID)];
00237 }
00238
00239 if (fp == 0)
00240 {
00241
00242 meshMod().setAction
00243 (
00244 polyModifyFace
00245 (
00246 f,
00247 faceID,
00248 mesh_.faceOwner()[faceID],
00249 -1,
00250 false,
00251 patchID,
00252 false,
00253 zoneID,
00254 zoneFlip
00255 )
00256 );
00257 }
00258 else
00259 {
00260
00261
00262 face newFace(f.size());
00263
00264 label fVert = fp;
00265
00266 for (label i = 0; i < f.size(); i++)
00267 {
00268 newFace[i] = f[fVert++];
00269
00270 if (fVert == f.size())
00271 {
00272 fVert = 0;
00273 }
00274 }
00275
00276
00277 meshMod().setAction
00278 (
00279 polyModifyFace
00280 (
00281 newFace,
00282 faceID,
00283 mesh_.faceOwner()[faceID],
00284 -1,
00285 false,
00286 patchID,
00287 false,
00288 zoneID,
00289 zoneFlip
00290 )
00291 );
00292 }
00293 }
00294
00295
00296 void Foam::repatchPolyTopoChanger::repatch()
00297 {
00298
00299 meshMod().changeMesh(mesh_, false);
00300
00301
00302 meshModPtr_.clear();
00303 }
00304
00305
00306
Copyright © 2000-2009 OpenCFD Ltd