attachInterface.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 "attachDetach.H"
00028 #include "polyMesh.H"
00029 #include "primitiveMesh.H"
00030 #include "polyTopoChange.H"
00031 #include "polyTopoChanger.H"
00032 #include "polyRemovePoint.H"
00033 #include "polyRemoveFace.H"
00034 #include "polyModifyFace.H"
00035
00036
00037
00038 const Foam::scalar Foam::attachDetach::positionDifference_ = 1e-8;
00039
00040
00041
00042 void Foam::attachDetach::attachInterface
00043 (
00044 polyTopoChange& ref
00045 ) const
00046 {
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 if (debug)
00061 {
00062 Pout<< "void attachDetach::attachInterface("
00063 << "polyTopoChange& ref) const "
00064 << " for object " << name() << " : "
00065 << "Attaching interface" << endl;
00066 }
00067
00068 const polyMesh& mesh = topoChanger().mesh();
00069 const faceList& faces = mesh.faces();
00070 const labelList& own = mesh.faceOwner();
00071 const labelList& nei = mesh.faceNeighbour();
00072
00073 const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchID_.index()];
00074 const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchID_.index()];
00075
00076 const label masterPatchStart = masterPatch.start();
00077 const label slavePatchStart = slavePatch.start();
00078
00079 const labelList& slaveMeshPoints = slavePatch.meshPoints();
00080
00081 const Map<label>& removedPointMap = pointMatchMap();
00082
00083 const labelList removedPoints = removedPointMap.toc();
00084
00085 forAll (removedPoints, pointI)
00086 {
00087 ref.setAction(polyRemovePoint(removedPoints[pointI]));
00088 }
00089
00090
00091
00092 for (label i = 0; i < slavePatch.size(); i++)
00093 {
00094 ref.setAction(polyRemoveFace(i + slavePatchStart));
00095
00096 }
00097
00098
00099 const labelList& masterFaceCells = masterPatch.faceCells();
00100 const labelList& slaveFaceCells = slavePatch.faceCells();
00101
00102 const boolList& mfFlip = mesh.faceZones()[faceZoneID_.index()].flipMap();
00103
00104 forAll (masterFaceCells, faceI)
00105 {
00106
00107
00108 if (masterFaceCells[faceI] < slaveFaceCells[faceI])
00109 {
00110 ref.setAction
00111 (
00112 polyModifyFace
00113 (
00114 faces[masterPatchStart + faceI],
00115 masterPatchStart + faceI,
00116 masterFaceCells[faceI],
00117 slaveFaceCells[faceI],
00118 false,
00119 -1,
00120 false,
00121 faceZoneID_.index(),
00122 mfFlip[faceI]
00123 )
00124 );
00125 }
00126 else
00127 {
00128
00129 ref.setAction
00130 (
00131 polyModifyFace
00132 (
00133 faces[masterPatchStart + faceI].reverseFace(),
00134 masterPatchStart + faceI,
00135 slaveFaceCells[faceI],
00136 masterFaceCells[faceI],
00137 true,
00138 -1,
00139 false,
00140 faceZoneID_.index(),
00141 !mfFlip[faceI]
00142 )
00143 );
00144 }
00145 }
00146
00147
00148
00149
00150 labelHashSet facesToModifyMap
00151 (
00152 slaveMeshPoints.size()*primitiveMesh::facesPerPoint_
00153 );
00154
00155 const labelListList& pf = mesh.pointFaces();
00156
00157
00158
00159 forAll (slaveMeshPoints, pointI)
00160 {
00161 const labelList& curFaces = pf[slaveMeshPoints[pointI]];
00162
00163 forAll (curFaces, faceI)
00164 {
00165 if (!ref.faceRemoved(curFaces[faceI]))
00166 {
00167 facesToModifyMap.insert(curFaces[faceI]);
00168 }
00169 }
00170 }
00171
00172
00173 const labelList ftm = facesToModifyMap.toc();
00174
00175 forAll (ftm, faceI)
00176 {
00177
00178
00179
00180 label curFaceID = ftm[faceI];
00181
00182 face newFace(faces[curFaceID]);
00183
00184 forAll (newFace, pointI)
00185 {
00186 Map<label>::const_iterator rpmIter =
00187 removedPointMap.find(newFace[pointI]);
00188
00189 if (rpmIter != removedPointMap.end())
00190 {
00191
00192 newFace[pointI] = rpmIter();
00193 }
00194 }
00195
00196
00197
00198
00199 label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID);
00200 bool modifiedFaceZoneFlip = false;
00201
00202 if (modifiedFaceZone >= 0)
00203 {
00204 modifiedFaceZoneFlip =
00205 mesh.faceZones()[modifiedFaceZone].flipMap()
00206 [
00207 mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID)
00208 ];
00209 }
00210
00211
00212 label patchID = mesh.boundaryMesh().whichPatch(curFaceID);
00213 label neiCell;
00214 if (patchID == -1)
00215 {
00216 neiCell = nei[curFaceID];
00217 }
00218 else
00219 {
00220 neiCell = -1;
00221 }
00222
00223
00224
00225 ref.setAction
00226 (
00227 polyModifyFace
00228 (
00229 newFace,
00230 curFaceID,
00231 own[curFaceID],
00232 neiCell,
00233 false,
00234 patchID,
00235 false,
00236 modifiedFaceZone,
00237 modifiedFaceZoneFlip
00238 )
00239 );
00240 }
00241
00242 if (debug)
00243 {
00244 Pout<< "void attachDetach::attachInterface("
00245 << "polyTopoChange& ref) const "
00246 << " for object " << name() << " : "
00247 << "Finished attaching interface" << endl;
00248 }
00249 }
00250
00251
00252 void Foam::attachDetach::modifyMotionPoints
00253 (
00254 pointField& motionPoints
00255 ) const
00256 {
00257 const Map<label>& removedPointMap = pointMatchMap();
00258
00259 const labelList removedPoints = removedPointMap.toc();
00260
00261 if (debug)
00262 {
00263 Pout<< "void attachDetach::modifyMotionPoints("
00264 << "pointField& motionPoints) const "
00265 << " for object " << name() << " : "
00266 << "Adjusting motion points." << endl;
00267
00268
00269 scalar pointDiff = 0;
00270
00271 forAll (removedPoints, pointI)
00272 {
00273 pointDiff +=
00274 mag
00275 (
00276 motionPoints[removedPoints[pointI]]
00277 - motionPoints[removedPointMap.find(removedPoints[pointI])()]
00278 );
00279 }
00280
00281 if (pointDiff > removedPoints.size()*positionDifference_)
00282 {
00283 Pout<< "Point motion difference = " << pointDiff << endl;
00284 }
00285 }
00286
00287
00288 forAll (removedPoints, pointI)
00289 {
00290 motionPoints[removedPoints[pointI]] =
00291 motionPoints[removedPointMap.find(removedPoints[pointI])()];
00292 }
00293
00294 }
00295
00296
00297
Copyright © 2000-2009 OpenCFD Ltd