enrichedPatch.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
00028
00029 #include "enrichedPatch.H"
00030 #include "demandDrivenData.H"
00031 #include "OFstream.H"
00032 #include "meshTools.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038 defineTypeNameAndDebug(enrichedPatch, 0);
00039 }
00040
00041
00042
00043
00044 void Foam::enrichedPatch::calcMeshPoints() const
00045 {
00046 if (meshPointsPtr_)
00047 {
00048 FatalErrorIn("void enrichedPatch::calcMeshPoints() const")
00049 << "Mesh points already calculated."
00050 << abort(FatalError);
00051 }
00052
00053 meshPointsPtr_ = new labelList(pointMap().toc());
00054 labelList& mp = *meshPointsPtr_;
00055
00056 sort(mp);
00057 }
00058
00059
00060 void Foam::enrichedPatch::calcLocalFaces() const
00061 {
00062 if (localFacesPtr_)
00063 {
00064 FatalErrorIn("void enrichedPatch::calcLocalFaces() const")
00065 << "Local faces already calculated."
00066 << abort(FatalError);
00067 }
00068
00069
00070 const labelList& mp = meshPoints();
00071
00072 Map<label> mpLookup(2*mp.size());
00073
00074 forAll (mp, mpI)
00075 {
00076 mpLookup.insert(mp[mpI], mpI);
00077 }
00078
00079 const faceList& faces = enrichedFaces();
00080
00081 localFacesPtr_ = new faceList(faces.size());
00082 faceList& lf = *localFacesPtr_;
00083
00084 forAll (faces, faceI)
00085 {
00086 const face& f = faces[faceI];
00087
00088 face& curlf = lf[faceI];
00089
00090 curlf.setSize(f.size());
00091
00092 forAll (f, pointI)
00093 {
00094 curlf[pointI] = mpLookup.find(f[pointI])();
00095 }
00096 }
00097 }
00098
00099
00100 void Foam::enrichedPatch::calcLocalPoints() const
00101 {
00102 if (localPointsPtr_)
00103 {
00104 FatalErrorIn("void enrichedPatch::calcLocalPoints() const")
00105 << "Local points already calculated."
00106 << abort(FatalError);
00107 }
00108
00109 const labelList& mp = meshPoints();
00110
00111 localPointsPtr_ = new pointField(mp.size());
00112 pointField& lp = *localPointsPtr_;
00113
00114 forAll (lp, i)
00115 {
00116 lp[i] = pointMap().find(mp[i])();
00117 }
00118 }
00119
00120
00121 void Foam::enrichedPatch::clearOut()
00122 {
00123 deleteDemandDrivenData(enrichedFacesPtr_);
00124
00125 deleteDemandDrivenData(meshPointsPtr_);
00126 deleteDemandDrivenData(localFacesPtr_);
00127 deleteDemandDrivenData(localPointsPtr_);
00128 deleteDemandDrivenData(pointPointsPtr_);
00129 deleteDemandDrivenData(masterPointFacesPtr_);
00130
00131 clearCutFaces();
00132 }
00133
00134
00135
00136
00137
00138 Foam::enrichedPatch::enrichedPatch
00139 (
00140 const primitiveFacePatch& masterPatch,
00141 const primitiveFacePatch& slavePatch,
00142 const labelList& slavePointPointHits,
00143 const labelList& slavePointEdgeHits,
00144 const List<objectHit>& slavePointFaceHits
00145 )
00146 :
00147 masterPatch_(masterPatch),
00148 slavePatch_(slavePatch),
00149 pointMap_
00150 (
00151 masterPatch_.meshPoints().size()
00152 + slavePatch_.meshPoints().size()
00153 ),
00154 pointMapComplete_(false),
00155 pointMergeMap_(2*slavePatch_.meshPoints().size()),
00156 slavePointPointHits_(slavePointPointHits),
00157 slavePointEdgeHits_(slavePointEdgeHits),
00158 slavePointFaceHits_(slavePointFaceHits),
00159 enrichedFacesPtr_(NULL),
00160 meshPointsPtr_(NULL),
00161 localFacesPtr_(NULL),
00162 localPointsPtr_(NULL),
00163 pointPointsPtr_(NULL),
00164 masterPointFacesPtr_(NULL),
00165 cutFacesPtr_(NULL),
00166 cutFaceMasterPtr_(NULL),
00167 cutFaceSlavePtr_(NULL)
00168 {}
00169
00170
00171
00172
00173 Foam::enrichedPatch::~enrichedPatch()
00174 {
00175 clearOut();
00176 }
00177
00178
00179
00180
00181 const Foam::labelList& Foam::enrichedPatch::meshPoints() const
00182 {
00183 if (!meshPointsPtr_)
00184 {
00185 calcMeshPoints();
00186 }
00187
00188 return *meshPointsPtr_;
00189 }
00190
00191
00192 const Foam::faceList& Foam::enrichedPatch::localFaces() const
00193 {
00194 if (!localFacesPtr_)
00195 {
00196 calcLocalFaces();
00197 }
00198
00199 return *localFacesPtr_;
00200 }
00201
00202
00203 const Foam::pointField& Foam::enrichedPatch::localPoints() const
00204 {
00205 if (!localPointsPtr_)
00206 {
00207 calcLocalPoints();
00208 }
00209
00210 return *localPointsPtr_;
00211 }
00212
00213
00214 const Foam::labelListList& Foam::enrichedPatch::pointPoints() const
00215 {
00216 if (!pointPointsPtr_)
00217 {
00218 calcPointPoints();
00219 }
00220
00221 return *pointPointsPtr_;
00222 }
00223
00224
00225 bool Foam::enrichedPatch::checkSupport() const
00226 {
00227 const faceList& faces = enrichedFaces();
00228
00229 bool error = false;
00230
00231 forAll (faces, faceI)
00232 {
00233 const face& curFace = faces[faceI];
00234
00235 forAll (curFace, pointI)
00236 {
00237 if (!pointMap().found(curFace[pointI]))
00238 {
00239 WarningIn("void enrichedPatch::checkSupport()")
00240 << "Point " << pointI << " of face " << faceI
00241 << " global point index: " << curFace[pointI]
00242 << " not supported in point map. This is not allowed."
00243 << endl;
00244
00245 error = true;
00246 }
00247 }
00248 }
00249
00250 return error;
00251 }
00252
00253
00254 void Foam::enrichedPatch::writeOBJ(const fileName& fName) const
00255 {
00256 OFstream str(fName);
00257
00258 const pointField& lp = localPoints();
00259
00260 forAll(lp, pointI)
00261 {
00262 meshTools::writeOBJ(str, lp[pointI]);
00263 }
00264
00265 const faceList& faces = localFaces();
00266
00267 forAll(faces, faceI)
00268 {
00269 const face& f = faces[faceI];
00270
00271 str << 'f';
00272 forAll(f, fp)
00273 {
00274 str << ' ' << f[fp]+1;
00275 }
00276 str << nl;
00277 }
00278 }
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
Copyright © 2000-2009 OpenCFD Ltd