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 "slidingInterface.H"
00028 #include "polyMesh.H"
00029 #include "primitiveMesh.H"
00030 #include "polyTopoChange.H"
00031 #include "polyTopoChanger.H"
00032 #include "polyModifyFace.H"
00033 #include "polyModifyPoint.H"
00034
00035
00036
00037 void Foam::slidingInterface::decoupleInterface
00038 (
00039 polyTopoChange& ref
00040 ) const
00041 {
00042 if (debug)
00043 {
00044 Pout<< "void slidingInterface::decoupleInterface("
00045 << "polyTopoChange& ref) const : "
00046 << "Decoupling sliding interface " << name() << endl;
00047 }
00048
00049 if (!attached_)
00050 {
00051 if (debug)
00052 {
00053 Pout<< "void slidingInterface::decoupleInterface("
00054 << "polyTopoChange& ref) const : "
00055 << "Interface already decoupled." << endl;
00056 }
00057
00058 return;
00059 }
00060
00061
00062 clearCouple(ref);
00063
00064 const polyMesh& mesh = topoChanger().mesh();
00065 const faceList& faces = mesh.faces();
00066 const cellList& cells = mesh.cells();
00067
00068 const labelList& own = mesh.faceOwner();
00069 const labelList& nei = mesh.faceNeighbour();
00070
00071
00072
00073 const primitiveFacePatch& masterPatch =
00074 mesh.faceZones()[masterFaceZoneID_.index()]();
00075
00076 const labelList& masterPatchAddr =
00077 mesh.faceZones()[masterFaceZoneID_.index()];
00078
00079 const boolList& masterPatchFlip =
00080 mesh.faceZones()[masterFaceZoneID_.index()].flipMap();
00081
00082 const labelList& masterFc = masterFaceCells();
00083
00084
00085
00086 forAll (masterPatchAddr, faceI)
00087 {
00088
00089 face newFace = faces[masterPatchAddr[faceI]];
00090
00091 if (masterPatchFlip[faceI])
00092 {
00093 newFace = newFace.reverseFace();
00094 }
00095
00096 ref.setAction
00097 (
00098 polyModifyFace
00099 (
00100 newFace,
00101 masterPatchAddr[faceI],
00102 masterFc[faceI],
00103 -1,
00104 false,
00105 masterPatchID_.index(),
00106 false,
00107 masterFaceZoneID_.index(),
00108 false
00109 )
00110 );
00111
00112 }
00113
00114
00115
00116 const primitiveFacePatch& slavePatch =
00117 mesh.faceZones()[slaveFaceZoneID_.index()]();
00118
00119 const labelList& slavePatchAddr =
00120 mesh.faceZones()[slaveFaceZoneID_.index()];
00121
00122 const boolList& slavePatchFlip =
00123 mesh.faceZones()[slaveFaceZoneID_.index()].flipMap();
00124
00125 const labelList& slaveFc = slaveFaceCells();
00126
00127
00128 const Map<label>& rpm = retiredPointMap();
00129
00130
00131
00132 forAll (slavePatchAddr, faceI)
00133 {
00134
00135 face newFace = faces[slavePatchAddr[faceI]];
00136
00137 if (slavePatchFlip[faceI])
00138 {
00139 newFace = newFace.reverseFace();
00140 }
00141
00142
00143 forAll (newFace, pointI)
00144 {
00145 Map<label>::const_iterator rpmIter = rpm.find(newFace[pointI]);
00146 if (rpmIter != rpm.end())
00147 {
00148
00149
00150 newFace[pointI] = rpmIter();
00151 }
00152 }
00153
00154 ref.setAction
00155 (
00156 polyModifyFace
00157 (
00158 newFace,
00159 slavePatchAddr[faceI],
00160 slaveFc[faceI],
00161 -1,
00162 false,
00163 slavePatchID_.index(),
00164 false,
00165 slaveFaceZoneID_.index(),
00166 false
00167 )
00168 );
00169 }
00170
00171
00172
00173
00174 const labelList& masterStickOuts = masterStickOutFaces();
00175
00176 forAll (masterStickOuts, faceI)
00177 {
00178
00179
00180 const label curFaceID = masterStickOuts[faceI];
00181
00182 const face& oldFace = faces[curFaceID];
00183
00184 DynamicList<label> newFaceLabels(oldFace.size());
00185
00186 bool changed = false;
00187
00188 forAll (oldFace, pointI)
00189 {
00190
00191 if (ref.pointRemoved(oldFace[pointI]))
00192 {
00193
00194 changed = true;
00195 }
00196 else
00197 {
00198 newFaceLabels.append(oldFace[pointI]);
00199 }
00200 }
00201
00202 if (changed)
00203 {
00204 if (newFaceLabels.size() < 3)
00205 {
00206 FatalErrorIn
00207 (
00208 "void slidingInterface::decoupleInterface("
00209 "polyTopoChange& ref) const"
00210 ) << "Face " << curFaceID << " reduced to less than "
00211 << "3 points. Topological/cutting error." << nl
00212 << "Old face: " << oldFace << " new face: " << newFaceLabels
00213 << abort(FatalError);
00214 }
00215
00216
00217 label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID);
00218 bool modifiedFaceZoneFlip = false;
00219
00220 if (modifiedFaceZone >= 0)
00221 {
00222 modifiedFaceZoneFlip =
00223 mesh.faceZones()[modifiedFaceZone].flipMap()
00224 [
00225 mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID)
00226 ];
00227 }
00228
00229 face newFace;
00230 newFace.transfer(newFaceLabels);
00231
00232
00233
00234
00235 ref.setAction
00236 (
00237 polyModifyFace
00238 (
00239 newFace,
00240 curFaceID,
00241 own[curFaceID],
00242 nei[curFaceID],
00243 false,
00244 mesh.boundaryMesh().whichPatch(curFaceID),
00245 false,
00246 modifiedFaceZone,
00247 modifiedFaceZoneFlip
00248 )
00249 );
00250 }
00251 }
00252
00253
00254
00255 labelHashSet slaveLayerCellFaceMap
00256 (
00257 primitiveMesh::facesPerCell_*(masterPatch.size() + slavePatch.size())
00258 );
00259
00260 forAll (slaveFc, faceI)
00261 {
00262 const labelList& curFaces = cells[slaveFc[faceI]];
00263
00264 forAll (curFaces, faceI)
00265 {
00266
00267
00268 if
00269 (
00270 mesh.faceZones().whichZone(curFaces[faceI])
00271 != slaveFaceZoneID_.index()
00272 && !ref.faceRemoved(curFaces[faceI])
00273
00274 )
00275 {
00276 slaveLayerCellFaceMap.insert(curFaces[faceI]);
00277 }
00278 }
00279 }
00280
00281
00282 const labelList& slaveStickOuts = slaveStickOutFaces();
00283
00284
00285 const Map<label>& masterPm = masterPatch.meshPointMap();
00286
00287 forAll (slaveStickOuts, faceI)
00288 {
00289
00290
00291 const label curFaceID = slaveStickOuts[faceI];
00292
00293 const face& oldFace = faces[curFaceID];
00294
00295 DynamicList<label> newFaceLabels(oldFace.size());
00296
00297 bool changed = false;
00298
00299 forAll (oldFace, pointI)
00300 {
00301
00302 if (rpm.found(oldFace[pointI]))
00303 {
00304
00305 changed = true;
00306
00307 newFaceLabels.append(rpm.find(oldFace[pointI])());
00308 }
00309 else if (ref.pointRemoved(oldFace[pointI]))
00310 {
00311
00312 changed = true;
00313 }
00314 else if (masterPm.found(oldFace[pointI]))
00315 {
00316
00317 changed = true;
00318 }
00319 else
00320 {
00321 newFaceLabels.append(oldFace[pointI]);
00322 }
00323 }
00324
00325 if (changed)
00326 {
00327 if (newFaceLabels.size() < 3)
00328 {
00329 FatalErrorIn
00330 (
00331 "void slidingInterface::decoupleInterface("
00332 "polyTopoChange& ref) const"
00333 ) << "Face " << curFaceID << " reduced to less than "
00334 << "3 points. Topological/cutting error." << nl
00335 << "Old face: " << oldFace << " new face: " << newFaceLabels
00336 << abort(FatalError);
00337 }
00338
00339
00340 label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID);
00341 bool modifiedFaceZoneFlip = false;
00342
00343 if (modifiedFaceZone >= 0)
00344 {
00345 modifiedFaceZoneFlip =
00346 mesh.faceZones()[modifiedFaceZone].flipMap()
00347 [
00348 mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID)
00349 ];
00350 }
00351
00352 face newFace;
00353 newFace.transfer(newFaceLabels);
00354
00355
00356
00357
00358 ref.setAction
00359 (
00360 polyModifyFace
00361 (
00362 newFace,
00363 curFaceID,
00364 own[curFaceID],
00365 nei[curFaceID],
00366 false,
00367 mesh.boundaryMesh().whichPatch(curFaceID),
00368 false,
00369 modifiedFaceZone,
00370 modifiedFaceZoneFlip
00371 )
00372 );
00373 }
00374 }
00375
00376
00377 const pointField& points = mesh.points();
00378
00379 const labelList& slaveMeshPoints =
00380 mesh.faceZones()[slaveFaceZoneID_.index()]().meshPoints();
00381
00382 forAll (slaveMeshPoints, pointI)
00383 {
00384 ref.setAction
00385 (
00386 polyModifyPoint
00387 (
00388 slaveMeshPoints[pointI],
00389 points[slaveMeshPoints[pointI]],
00390 false,
00391 mesh.pointZones().whichZone(slaveMeshPoints[pointI]),
00392 true
00393 )
00394 );
00395 }
00396
00397
00398 retiredPointMapPtr_->clear();
00399
00400
00401 attached_ = false;
00402
00403 if (debug)
00404 {
00405 Pout<< "void slidingInterface::coupleInterface("
00406 << "polyTopoChange& ref) const : "
00407 << "Finished decoupling sliding interface " << name() << endl;
00408 }
00409 }
00410
00411
00412