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