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