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