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 "polyMesh.H"
00028 #include "Time.H"
00029 #include "cellIOList.H"
00030
00031
00032
00033 void Foam::polyMesh::setInstance(const fileName& inst)
00034 {
00035 if (debug)
00036 {
00037 Info<< "void polyMesh::setInstance(const fileName& inst) : "
00038 << "Resetting file instance to " << inst << endl;
00039 }
00040
00041 points_.writeOpt() = IOobject::AUTO_WRITE;
00042 points_.instance() = inst;
00043
00044 faces_.writeOpt() = IOobject::AUTO_WRITE;
00045 faces_.instance() = inst;
00046
00047 owner_.writeOpt() = IOobject::AUTO_WRITE;
00048 owner_.instance() = inst;
00049
00050 neighbour_.writeOpt() = IOobject::AUTO_WRITE;
00051 neighbour_.instance() = inst;
00052
00053 boundary_.writeOpt() = IOobject::AUTO_WRITE;
00054 boundary_.instance() = inst;
00055
00056 pointZones_.writeOpt() = IOobject::AUTO_WRITE;
00057 pointZones_.instance() = inst;
00058
00059 faceZones_.writeOpt() = IOobject::AUTO_WRITE;
00060 faceZones_.instance() = inst;
00061
00062 cellZones_.writeOpt() = IOobject::AUTO_WRITE;
00063 cellZones_.instance() = inst;
00064 }
00065
00066
00067 Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
00068 {
00069 if (debug)
00070 {
00071 Info<< "polyMesh::readUpdateState polyMesh::readUpdate() : "
00072 << "Updating mesh based on saved data." << endl;
00073 }
00074
00075
00076 fileName pointsInst(time().findInstance(meshDir(), "points"));
00077 fileName facesInst(time().findInstance(meshDir(), "faces"));
00078
00079 if (debug)
00080 {
00081 Info<< "Faces instance: old = " << facesInstance()
00082 << " new = " << facesInst << nl
00083 << "Points instance: old = " << pointsInstance()
00084 << " new = " << pointsInst << endl;
00085 }
00086
00087 if (facesInst != facesInstance())
00088 {
00089
00090 if (debug)
00091 {
00092 Info << "Topological change" << endl;
00093 }
00094
00095 clearOut();
00096
00097
00098
00099 setInstance(facesInst);
00100 points_.instance() = pointsInst;
00101
00102 points_ = pointIOField
00103 (
00104 IOobject
00105 (
00106 "points",
00107 pointsInst,
00108 meshSubDir,
00109 *this,
00110 IOobject::MUST_READ,
00111 IOobject::NO_WRITE,
00112 false
00113 )
00114 );
00115
00116 faces_ = faceIOList
00117 (
00118 IOobject
00119 (
00120 "faces",
00121 facesInst,
00122 meshSubDir,
00123 *this,
00124 IOobject::MUST_READ,
00125 IOobject::NO_WRITE,
00126 false
00127 )
00128 );
00129
00130 owner_ = labelIOList
00131 (
00132 IOobject
00133 (
00134 "owner",
00135 facesInst,
00136 meshSubDir,
00137 *this,
00138 IOobject::READ_IF_PRESENT,
00139 IOobject::NO_WRITE,
00140 false
00141 )
00142 );
00143
00144 neighbour_ = labelIOList
00145 (
00146 IOobject
00147 (
00148 "neighbour",
00149 facesInst,
00150 meshSubDir,
00151 *this,
00152 IOobject::READ_IF_PRESENT,
00153 IOobject::NO_WRITE,
00154 false
00155 )
00156 );
00157
00158
00159 polyBoundaryMesh newBoundary
00160 (
00161 IOobject
00162 (
00163 "boundary",
00164 facesInst,
00165 meshSubDir,
00166 *this,
00167 IOobject::MUST_READ,
00168 IOobject::NO_WRITE,
00169 false
00170 ),
00171 *this
00172 );
00173
00174
00175 bool boundaryChanged = false;
00176
00177 if (newBoundary.size() != boundary_.size())
00178 {
00179 boundaryChanged = true;
00180 }
00181 else
00182 {
00183 wordList newTypes = newBoundary.types();
00184 wordList newNames = newBoundary.names();
00185
00186 wordList oldTypes = boundary_.types();
00187 wordList oldNames = boundary_.names();
00188
00189 forAll (oldTypes, patchI)
00190 {
00191 if
00192 (
00193 oldTypes[patchI] != newTypes[patchI]
00194 || oldNames[patchI] != newNames[patchI]
00195 )
00196 {
00197 boundaryChanged = true;
00198 break;
00199 }
00200 }
00201 }
00202
00203 if (boundaryChanged)
00204 {
00205 WarningIn("polyMesh::readUpdateState polyMesh::readUpdate()")
00206 << "Number of patches has changed. This may have "
00207 << "unexpected consequences. Proceed with care." << endl;
00208
00209 boundary_.clear();
00210 boundary_.setSize(newBoundary.size());
00211
00212 forAll (newBoundary, patchI)
00213 {
00214 boundary_.set(patchI, newBoundary[patchI].clone(boundary_));
00215 }
00216 }
00217 else
00218 {
00219 forAll (boundary_, patchI)
00220 {
00221 boundary_[patchI] = polyPatch
00222 (
00223 newBoundary[patchI].name(),
00224 newBoundary[patchI].size(),
00225 newBoundary[patchI].start(),
00226 patchI,
00227 boundary_
00228 );
00229 }
00230 }
00231
00232
00233
00234
00235
00236 if (exists(owner_.objectPath()))
00237 {
00238 initMesh();
00239 }
00240 else
00241 {
00242 cellIOList cells
00243 (
00244 IOobject
00245 (
00246 "cells",
00247 facesInst,
00248 meshSubDir,
00249 *this,
00250 IOobject::MUST_READ,
00251 IOobject::NO_WRITE,
00252 false
00253 )
00254 );
00255
00256
00257
00258 initMesh(cells);
00259 }
00260
00261
00262
00263
00264
00265
00266 boundary_.updateMesh();
00267
00268
00269 boundary_.calcGeometry();
00270
00271
00272 bounds_ = boundBox(points_);
00273 geometricD_ = Vector<label>::zero;
00274 solutionD_ = Vector<label>::zero;
00275
00276
00277 pointZoneMesh newPointZones
00278 (
00279 IOobject
00280 (
00281 "pointZones",
00282 facesInst,
00283 meshSubDir,
00284 *this,
00285 IOobject::READ_IF_PRESENT,
00286 IOobject::NO_WRITE,
00287 false
00288 ),
00289 *this
00290 );
00291
00292 label oldSize = pointZones_.size();
00293
00294 if (newPointZones.size() <= pointZones_.size())
00295 {
00296 pointZones_.setSize(newPointZones.size());
00297 }
00298
00299
00300 forAll (pointZones_, czI)
00301 {
00302 pointZones_[czI] = newPointZones[czI];
00303 }
00304
00305
00306 pointZones_.setSize(newPointZones.size());
00307
00308 for (label czI = oldSize; czI < newPointZones.size(); czI++)
00309 {
00310 pointZones_.set(czI, newPointZones[czI].clone(pointZones_));
00311 }
00312
00313
00314 faceZoneMesh newFaceZones
00315 (
00316 IOobject
00317 (
00318 "faceZones",
00319 facesInst,
00320 meshSubDir,
00321 *this,
00322 IOobject::READ_IF_PRESENT,
00323 IOobject::NO_WRITE,
00324 false
00325 ),
00326 *this
00327 );
00328
00329 oldSize = faceZones_.size();
00330
00331 if (newFaceZones.size() <= faceZones_.size())
00332 {
00333 faceZones_.setSize(newFaceZones.size());
00334 }
00335
00336
00337 forAll (faceZones_, fzI)
00338 {
00339 faceZones_[fzI].resetAddressing
00340 (
00341 newFaceZones[fzI],
00342 newFaceZones[fzI].flipMap()
00343 );
00344 }
00345
00346
00347 faceZones_.setSize(newFaceZones.size());
00348
00349 for (label fzI = oldSize; fzI < newFaceZones.size(); fzI++)
00350 {
00351 faceZones_.set(fzI, newFaceZones[fzI].clone(faceZones_));
00352 }
00353
00354
00355 cellZoneMesh newCellZones
00356 (
00357 IOobject
00358 (
00359 "cellZones",
00360 facesInst,
00361 meshSubDir,
00362 *this,
00363 IOobject::READ_IF_PRESENT,
00364 IOobject::NO_WRITE,
00365 false
00366 ),
00367 *this
00368 );
00369
00370 oldSize = cellZones_.size();
00371
00372 if (newCellZones.size() <= cellZones_.size())
00373 {
00374 cellZones_.setSize(newCellZones.size());
00375 }
00376
00377
00378 forAll (cellZones_, czI)
00379 {
00380 cellZones_[czI] = newCellZones[czI];
00381 }
00382
00383
00384 cellZones_.setSize(newCellZones.size());
00385
00386 for (label czI = oldSize; czI < newCellZones.size(); czI++)
00387 {
00388 cellZones_.set(czI, newCellZones[czI].clone(cellZones_));
00389 }
00390
00391
00392 if (boundaryChanged)
00393 {
00394 return polyMesh::TOPO_PATCH_CHANGE;
00395 }
00396 else
00397 {
00398 return polyMesh::TOPO_CHANGE;
00399 }
00400 }
00401 else if (pointsInst != pointsInstance())
00402 {
00403
00404 if (debug)
00405 {
00406 Info << "Point motion" << endl;
00407 }
00408
00409 clearGeom();
00410
00411 points_.instance() = pointsInst;
00412
00413 points_ = pointIOField
00414 (
00415 IOobject
00416 (
00417 "points",
00418 pointsInst,
00419 meshSubDir,
00420 *this,
00421 IOobject::MUST_READ,
00422 IOobject::NO_WRITE,
00423 false
00424 )
00425 );
00426
00427
00428 bounds_ = boundBox(points_);
00429
00430
00431 geometricD_ = Vector<label>::zero;
00432 solutionD_ = Vector<label>::zero;
00433
00434 return polyMesh::POINTS_MOVED;
00435 }
00436 else
00437 {
00438 if (debug)
00439 {
00440 Info << "No change" << endl;
00441 }
00442
00443 return polyMesh::UNCHANGED;
00444 }
00445 }
00446
00447
00448