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 "duplicatePoints.H"
00027 #include "localPointRegion.H"
00028 #include "polyTopoChange.H"
00029 #include <dynamicMesh/polyAddPoint.H>
00030 #include <dynamicMesh/polyModifyFace.H>
00031 #include <OpenFOAM/polyMesh.H>
00032 #include <OpenFOAM/OFstream.H>
00033 #include <meshTools/meshTools.H>
00034 #include <OpenFOAM/Time.H>
00035
00036
00037
00038 namespace Foam
00039 {
00040
00041 defineTypeNameAndDebug(duplicatePoints, 0);
00042
00043 }
00044
00045
00046
00047
00048
00049 Foam::duplicatePoints::duplicatePoints(const polyMesh& mesh)
00050 :
00051 mesh_(mesh),
00052 duplicates_(0)
00053 {}
00054
00055
00056
00057
00058 void Foam::duplicatePoints::setRefinement
00059 (
00060 const localPointRegion& regionSide,
00061 polyTopoChange& meshMod
00062 )
00063 {
00064 const Map<label>& meshPointMap = regionSide.meshPointMap();
00065 const labelListList& pointRegions = regionSide.pointRegions();
00066 const Map<label>& meshFaceMap = regionSide.meshFaceMap();
00067 const faceList& faceRegions = regionSide.faceRegions();
00068 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00069
00070
00071
00072
00073
00074 duplicates_.setSize(meshPointMap.size());
00075
00076 forAllConstIter(Map<label>, meshPointMap, iter)
00077 {
00078 label pointI = iter.key();
00079 label localI = iter();
00080 const labelList& regions = pointRegions[localI];
00081
00082 duplicates_[localI].setSize(regions.size());
00083 duplicates_[localI][0] = pointI;
00084 for (label i = 1; i < regions.size(); i++)
00085 {
00086 duplicates_[localI][i] = meshMod.addPoint
00087 (
00088 mesh_.points()[pointI],
00089 pointI,
00090 -1,
00091 true
00092 );
00093 }
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 }
00104
00105
00106
00107
00108
00109
00110 face newFace;
00111
00112 forAllConstIter(Map<label>, meshFaceMap, iter)
00113 {
00114 label faceI = iter.key();
00115 label localI = iter();
00116
00117
00118 const face& fRegion = faceRegions[localI];
00119 const face& f = mesh_.faces()[faceI];
00120
00121 newFace.setSize(f.size());
00122 forAll(f, fp)
00123 {
00124 label pointI = f[fp];
00125
00126 Map<label>::const_iterator iter = meshPointMap.find(pointI);
00127
00128 if (iter != meshPointMap.end())
00129 {
00130
00131
00132
00133
00134 const labelList& regions = pointRegions[iter()];
00135 const labelList& dupPoints = duplicates_[iter()];
00136
00137
00138 label index = findIndex(regions, fRegion[fp]);
00139
00140 newFace[fp] = dupPoints[index];
00141 }
00142 else
00143 {
00144 newFace[fp] = pointI;
00145 }
00146 }
00147
00148
00149 label zoneID = mesh_.faceZones().whichZone(faceI);
00150 bool zoneFlip = false;
00151 if (zoneID >= 0)
00152 {
00153 const faceZone& fZone = mesh_.faceZones()[zoneID];
00154 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
00155 }
00156
00157
00158 if (mesh_.isInternalFace(faceI))
00159 {
00160 meshMod.modifyFace
00161 (
00162 newFace,
00163 faceI,
00164 mesh_.faceOwner()[faceI],
00165 mesh_.faceNeighbour()[faceI],
00166 false,
00167 -1,
00168 zoneID,
00169 zoneFlip
00170 );
00171 }
00172 else
00173 {
00174 meshMod.modifyFace
00175 (
00176 newFace,
00177 faceI,
00178 mesh_.faceOwner()[faceI],
00179 -1,
00180 false,
00181 patches.whichPatch(faceI),
00182 zoneID,
00183 zoneFlip
00184 );
00185 }
00186 }
00187
00188
00189 if (debug)
00190 {
00191
00192 {
00193 OFstream str(mesh_.time().path()/"duplicatedPoints.obj");
00194 forAllConstIter(Map<label>, meshPointMap, iter)
00195 {
00196 label localI = iter();
00197 const labelList& dups = duplicates_[localI];
00198
00199 forAll(dups, i)
00200 {
00201 meshTools::writeOBJ(str, meshMod.points()[dups[i]]);
00202 }
00203 }
00204 }
00205 }
00206 }
00207
00208
00209 void Foam::duplicatePoints::updateMesh(const mapPolyMesh& map)
00210 {
00211 forAll(duplicates_, masterI)
00212 {
00213 inplaceRenumber(map.reversePointMap(), duplicates_[masterI]);
00214 }
00215 }
00216
00217
00218