meshRefinementMerge.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 "meshRefinement.H"
00028 #include "combineFaces.H"
00029 #include "polyTopoChange.H"
00030 #include "removePoints.H"
00031
00032
00033
00034
00035 Foam::label Foam::meshRefinement::mergePatchFaces
00036 (
00037 const scalar minCos,
00038 const scalar concaveCos,
00039 const labelList& patchIDs
00040 )
00041 {
00042
00043 combineFaces faceCombiner(mesh_);
00044
00045 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00046
00047
00048 labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
00049
00050 forAll(patchIDs, i)
00051 {
00052 label patchI = patchIDs[i];
00053
00054 const polyPatch& patch = patches[patchI];
00055
00056 if (!patch.coupled())
00057 {
00058 forAll(patch, i)
00059 {
00060 boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
00061 }
00062 }
00063 }
00064
00065
00066 labelListList mergeSets
00067 (
00068 faceCombiner.getMergeSets
00069 (
00070 minCos,
00071 concaveCos,
00072 boundaryCells
00073 )
00074 );
00075
00076 label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
00077
00078 Info<< "mergePatchFaces : Merging " << nFaceSets
00079 << " sets of faces." << endl;
00080
00081 if (nFaceSets > 0)
00082 {
00083
00084 polyTopoChange meshMod(mesh_);
00085
00086
00087
00088 faceCombiner.setRefinement(mergeSets, meshMod);
00089
00090
00091 autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
00092
00093
00094 mesh_.updateMesh(map);
00095
00096
00097 if (map().hasMotionPoints())
00098 {
00099 mesh_.movePoints(map().preMotionPoints());
00100 }
00101 else
00102 {
00103
00104 mesh_.clearOut();
00105 }
00106
00107 if (overwrite())
00108 {
00109 mesh_.setInstance(oldInstance());
00110 }
00111
00112 faceCombiner.updateMesh(map);
00113
00114
00115
00116
00117 labelHashSet retestFaces(6*mergeSets.size());
00118
00119 forAll(mergeSets, setI)
00120 {
00121 label oldMasterI = mergeSets[setI][0];
00122
00123 label faceI = map().reverseFaceMap()[oldMasterI];
00124
00125
00126 const cell& cFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
00127
00128 forAll(cFaces, i)
00129 {
00130 retestFaces.insert(cFaces[i]);
00131 }
00132 }
00133 updateMesh(map, retestFaces.toc());
00134 }
00135
00136
00137 return nFaceSets;
00138 }
00139
00140
00141
00142
00143 Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
00144 (
00145 const scalar minCos
00146 )
00147 {
00148
00149 removePoints pointRemover(mesh_);
00150
00151
00152 boolList pointCanBeDeleted;
00153 label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
00154
00155 Info<< "Removing " << nRemove
00156 << " straight edge points." << endl;
00157
00158 autoPtr<mapPolyMesh> map;
00159
00160 if (nRemove > 0)
00161 {
00162
00163
00164
00165 labelHashSet retestOldFaces(nRemove / Pstream::nProcs());
00166
00167 {
00168 const faceList& faces = mesh_.faces();
00169
00170 forAll(faces, faceI)
00171 {
00172 const face& f = faces[faceI];
00173
00174 forAll(f, fp)
00175 {
00176 if (pointCanBeDeleted[f[fp]])
00177 {
00178 retestOldFaces.insert(faceI);
00179 break;
00180 }
00181 }
00182 }
00183 }
00184
00185
00186 polyTopoChange meshMod(mesh_);
00187
00188 pointRemover.setRefinement(pointCanBeDeleted, meshMod);
00189
00190
00191 map = meshMod.changeMesh(mesh_, false, true);
00192
00193
00194 mesh_.updateMesh(map);
00195
00196
00197 if (map().hasMotionPoints())
00198 {
00199 mesh_.movePoints(map().preMotionPoints());
00200 }
00201 else
00202 {
00203
00204 mesh_.clearOut();
00205 }
00206
00207 if (overwrite())
00208 {
00209 mesh_.setInstance(oldInstance());
00210 }
00211
00212 pointRemover.updateMesh(map);
00213
00214
00215 labelHashSet retestFaces(6*retestOldFaces.size());
00216
00217 const cellList& cells = mesh_.cells();
00218
00219 forAllConstIter(labelHashSet, retestOldFaces, iter)
00220 {
00221 label faceI = map().reverseFaceMap()[iter.key()];
00222
00223 const cell& ownFaces = cells[mesh_.faceOwner()[faceI]];
00224
00225 forAll(ownFaces, i)
00226 {
00227 retestFaces.insert(ownFaces[i]);
00228 }
00229
00230 if (mesh_.isInternalFace(faceI))
00231 {
00232 const cell& neiFaces = cells[mesh_.faceNeighbour()[faceI]];
00233
00234 forAll(neiFaces, i)
00235 {
00236 retestFaces.insert(neiFaces[i]);
00237 }
00238 }
00239 }
00240 updateMesh(map, retestFaces.toc());
00241 }
00242
00243 return map;
00244 }
00245
00246
00247
Copyright © 2000-2009 OpenCFD Ltd