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 #include "SubList.H"
00031 #include "wedgePolyPatch.H"
00032 #include "emptyPolyPatch.H"
00033 #include "globalMeshData.H"
00034 #include "processorPolyPatch.H"
00035 #include "OSspecific.H"
00036 #include "demandDrivenData.H"
00037
00038 #include "pointMesh.H"
00039
00040
00041
00042 defineTypeNameAndDebug(Foam::polyMesh, 0);
00043
00044
00045 Foam::word Foam::polyMesh::defaultRegion = "region0";
00046 Foam::word Foam::polyMesh::meshSubDir = "polyMesh";
00047
00048
00049
00050
00051 void Foam::polyMesh::calcDirections() const
00052 {
00053 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
00054 {
00055 solutionD_[cmpt] = 1;
00056 }
00057
00058
00059
00060
00061 label nEmptyPatches = 0;
00062 label nWedgePatches = 0;
00063
00064 vector emptyDirVec = vector::zero;
00065 vector wedgeDirVec = vector::zero;
00066
00067 forAll(boundaryMesh(), patchi)
00068 {
00069 if (boundaryMesh()[patchi].size())
00070 {
00071 if (isA<emptyPolyPatch>(boundaryMesh()[patchi]))
00072 {
00073 nEmptyPatches++;
00074 emptyDirVec += sum(cmptMag(boundaryMesh()[patchi].faceAreas()));
00075 }
00076 else if (isA<wedgePolyPatch>(boundaryMesh()[patchi]))
00077 {
00078 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
00079 (
00080 boundaryMesh()[patchi]
00081 );
00082
00083 nWedgePatches++;
00084 wedgeDirVec += cmptMag(wpp.centreNormal());
00085 }
00086 }
00087 }
00088
00089 if (nEmptyPatches)
00090 {
00091 reduce(emptyDirVec, sumOp<vector>());
00092
00093 emptyDirVec /= mag(emptyDirVec);
00094
00095 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
00096 {
00097 if (emptyDirVec[cmpt] > 1e-6)
00098 {
00099 solutionD_[cmpt] = -1;
00100 }
00101 else
00102 {
00103 solutionD_[cmpt] = 1;
00104 }
00105 }
00106 }
00107
00108
00109
00110
00111 geometricD_ = solutionD_;
00112
00113 if (nWedgePatches)
00114 {
00115 reduce(wedgeDirVec, sumOp<vector>());
00116
00117 wedgeDirVec /= mag(wedgeDirVec);
00118
00119 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
00120 {
00121 if (wedgeDirVec[cmpt] > 1e-6)
00122 {
00123 geometricD_[cmpt] = -1;
00124 }
00125 else
00126 {
00127 geometricD_[cmpt] = 1;
00128 }
00129 }
00130 }
00131 }
00132
00133
00134
00135
00136 Foam::polyMesh::polyMesh(const IOobject& io)
00137 :
00138 objectRegistry(io),
00139 primitiveMesh(),
00140 points_
00141 (
00142 IOobject
00143 (
00144 "points",
00145 time().findInstance(meshDir(), "points"),
00146 meshSubDir,
00147 *this,
00148 IOobject::MUST_READ,
00149 IOobject::NO_WRITE
00150 )
00151 ),
00152 faces_
00153 (
00154 IOobject
00155 (
00156 "faces",
00157 time().findInstance(meshDir(), "faces"),
00158 meshSubDir,
00159 *this,
00160 IOobject::MUST_READ,
00161 IOobject::NO_WRITE
00162 )
00163 ),
00164 owner_
00165 (
00166 IOobject
00167 (
00168 "owner",
00169 time().findInstance(meshDir(), "faces"),
00170 meshSubDir,
00171 *this,
00172 IOobject::READ_IF_PRESENT,
00173 IOobject::NO_WRITE
00174 )
00175 ),
00176 neighbour_
00177 (
00178 IOobject
00179 (
00180 "neighbour",
00181 time().findInstance(meshDir(), "faces"),
00182 meshSubDir,
00183 *this,
00184 IOobject::READ_IF_PRESENT,
00185 IOobject::NO_WRITE
00186 )
00187 ),
00188 clearedPrimitives_(false),
00189 boundary_
00190 (
00191 IOobject
00192 (
00193 "boundary",
00194 time().findInstance(meshDir(), "boundary"),
00195 meshSubDir,
00196 *this,
00197 IOobject::MUST_READ,
00198 IOobject::NO_WRITE
00199 ),
00200 *this
00201 ),
00202 bounds_(points_),
00203 geometricD_(Vector<label>::zero),
00204 solutionD_(Vector<label>::zero),
00205 pointZones_
00206 (
00207 IOobject
00208 (
00209 "pointZones",
00210 time().findInstance
00211 (
00212 meshDir(),
00213 "pointZones",
00214 IOobject::READ_IF_PRESENT
00215 ),
00216 meshSubDir,
00217 *this,
00218 IOobject::READ_IF_PRESENT,
00219 IOobject::NO_WRITE
00220 ),
00221 *this
00222 ),
00223 faceZones_
00224 (
00225 IOobject
00226 (
00227 "faceZones",
00228 time().findInstance
00229 (
00230 meshDir(),
00231 "faceZones",
00232 IOobject::READ_IF_PRESENT
00233 ),
00234 meshSubDir,
00235 *this,
00236 IOobject::READ_IF_PRESENT,
00237 IOobject::NO_WRITE
00238 ),
00239 *this
00240 ),
00241 cellZones_
00242 (
00243 IOobject
00244 (
00245 "cellZones",
00246 time().findInstance
00247 (
00248 meshDir(),
00249 "cellZones",
00250 IOobject::READ_IF_PRESENT
00251 ),
00252 meshSubDir,
00253 *this,
00254 IOobject::READ_IF_PRESENT,
00255 IOobject::NO_WRITE
00256 ),
00257 *this
00258 ),
00259 globalMeshDataPtr_(NULL),
00260 moving_(false),
00261 changing_(false),
00262 curMotionTimeIndex_(time().timeIndex()),
00263 oldPointsPtr_(NULL)
00264 {
00265 if (exists(owner_.objectPath()))
00266 {
00267 initMesh();
00268 }
00269 else
00270 {
00271 cellIOList cLst
00272 (
00273 IOobject
00274 (
00275 "cells",
00276 time().findInstance(meshDir(), "cells"),
00277 meshSubDir,
00278 *this,
00279 IOobject::MUST_READ,
00280 IOobject::NO_WRITE
00281 )
00282 );
00283
00284
00285 initMesh(cLst);
00286
00287 owner_.write();
00288 neighbour_.write();
00289 }
00290
00291
00292 boundary_.updateMesh();
00293
00294
00295 boundary_.calcGeometry();
00296
00297
00298 if (globalData().nTotalPoints() == 0)
00299 {
00300 WarningIn("polyMesh(const IOobject&)")
00301 << "no points in mesh" << endl;
00302 }
00303 if (globalData().nTotalCells() == 0)
00304 {
00305 WarningIn("polyMesh(const IOobject&)")
00306 << "no cells in mesh" << endl;
00307 }
00308 }
00309
00310
00311 Foam::polyMesh::polyMesh
00312 (
00313 const IOobject& io,
00314 const Xfer<pointField>& points,
00315 const Xfer<faceList>& faces,
00316 const Xfer<labelList>& owner,
00317 const Xfer<labelList>& neighbour,
00318 const bool syncPar
00319 )
00320 :
00321 objectRegistry(io),
00322 primitiveMesh(),
00323 points_
00324 (
00325 IOobject
00326 (
00327 "points",
00328 instance(),
00329 meshSubDir,
00330 *this,
00331 IOobject::NO_READ,
00332 IOobject::AUTO_WRITE
00333 ),
00334 points
00335 ),
00336 faces_
00337 (
00338 IOobject
00339 (
00340 "faces",
00341 instance(),
00342 meshSubDir,
00343 *this,
00344 IOobject::NO_READ,
00345 IOobject::AUTO_WRITE
00346 ),
00347 faces
00348 ),
00349 owner_
00350 (
00351 IOobject
00352 (
00353 "owner",
00354 instance(),
00355 meshSubDir,
00356 *this,
00357 IOobject::NO_READ,
00358 IOobject::AUTO_WRITE
00359 ),
00360 owner
00361 ),
00362 neighbour_
00363 (
00364 IOobject
00365 (
00366 "neighbour",
00367 instance(),
00368 meshSubDir,
00369 *this,
00370 IOobject::NO_READ,
00371 IOobject::AUTO_WRITE
00372 ),
00373 neighbour
00374 ),
00375 clearedPrimitives_(false),
00376 boundary_
00377 (
00378 IOobject
00379 (
00380 "boundary",
00381 instance(),
00382 meshSubDir,
00383 *this,
00384 IOobject::NO_READ,
00385 IOobject::AUTO_WRITE
00386 ),
00387 *this,
00388 0
00389 ),
00390 bounds_(points_, syncPar),
00391 geometricD_(Vector<label>::zero),
00392 solutionD_(Vector<label>::zero),
00393 pointZones_
00394 (
00395 IOobject
00396 (
00397 "pointZones",
00398 instance(),
00399 meshSubDir,
00400 *this,
00401 IOobject::NO_READ,
00402 IOobject::NO_WRITE
00403 ),
00404 *this,
00405 0
00406 ),
00407 faceZones_
00408 (
00409 IOobject
00410 (
00411 "faceZones",
00412 instance(),
00413 meshSubDir,
00414 *this,
00415 IOobject::NO_READ,
00416 IOobject::NO_WRITE
00417 ),
00418 *this,
00419 0
00420 ),
00421 cellZones_
00422 (
00423 IOobject
00424 (
00425 "cellZones",
00426 instance(),
00427 meshSubDir,
00428 *this,
00429 IOobject::NO_READ,
00430 IOobject::NO_WRITE
00431 ),
00432 *this,
00433 0
00434 ),
00435 globalMeshDataPtr_(NULL),
00436 moving_(false),
00437 changing_(false),
00438 curMotionTimeIndex_(time().timeIndex()),
00439 oldPointsPtr_(NULL)
00440 {
00441
00442 forAll (faces_, faceI)
00443 {
00444 const face& curFace = faces_[faceI];
00445
00446 if (min(curFace) < 0 || max(curFace) > points_.size())
00447 {
00448 FatalErrorIn
00449 (
00450 "polyMesh::polyMesh\n"
00451 "(\n"
00452 " const IOobject& io,\n"
00453 " const pointField& points,\n"
00454 " const faceList& faces,\n"
00455 " const cellList& cells\n"
00456 ")\n"
00457 ) << "Face " << faceI << "contains vertex labels out of range: "
00458 << curFace << " Max point index = " << points_.size()
00459 << abort(FatalError);
00460 }
00461 }
00462
00463
00464 initMesh();
00465 }
00466
00467
00468 Foam::polyMesh::polyMesh
00469 (
00470 const IOobject& io,
00471 const Xfer<pointField>& points,
00472 const Xfer<faceList>& faces,
00473 const Xfer<cellList>& cells,
00474 const bool syncPar
00475 )
00476 :
00477 objectRegistry(io),
00478 primitiveMesh(),
00479 points_
00480 (
00481 IOobject
00482 (
00483 "points",
00484 instance(),
00485 meshSubDir,
00486 *this,
00487 IOobject::NO_READ,
00488 IOobject::AUTO_WRITE
00489 ),
00490 points
00491 ),
00492 faces_
00493 (
00494 IOobject
00495 (
00496 "faces",
00497 instance(),
00498 meshSubDir,
00499 *this,
00500 IOobject::NO_READ,
00501 IOobject::AUTO_WRITE
00502 ),
00503 faces
00504 ),
00505 owner_
00506 (
00507 IOobject
00508 (
00509 "owner",
00510 instance(),
00511 meshSubDir,
00512 *this,
00513 IOobject::NO_READ,
00514 IOobject::AUTO_WRITE
00515 ),
00516 0
00517 ),
00518 neighbour_
00519 (
00520 IOobject
00521 (
00522 "neighbour",
00523 instance(),
00524 meshSubDir,
00525 *this,
00526 IOobject::NO_READ,
00527 IOobject::AUTO_WRITE
00528 ),
00529 0
00530 ),
00531 clearedPrimitives_(false),
00532 boundary_
00533 (
00534 IOobject
00535 (
00536 "boundary",
00537 instance(),
00538 meshSubDir,
00539 *this,
00540 IOobject::NO_READ,
00541 IOobject::AUTO_WRITE
00542 ),
00543 *this,
00544 0
00545 ),
00546 bounds_(points_, syncPar),
00547 geometricD_(Vector<label>::zero),
00548 solutionD_(Vector<label>::zero),
00549 pointZones_
00550 (
00551 IOobject
00552 (
00553 "pointZones",
00554 instance(),
00555 meshSubDir,
00556 *this,
00557 IOobject::NO_READ,
00558 IOobject::NO_WRITE
00559 ),
00560 *this,
00561 0
00562 ),
00563 faceZones_
00564 (
00565 IOobject
00566 (
00567 "faceZones",
00568 instance(),
00569 meshSubDir,
00570 *this,
00571 IOobject::NO_READ,
00572 IOobject::NO_WRITE
00573 ),
00574 *this,
00575 0
00576 ),
00577 cellZones_
00578 (
00579 IOobject
00580 (
00581 "cellZones",
00582 instance(),
00583 meshSubDir,
00584 *this,
00585 IOobject::NO_READ,
00586 IOobject::NO_WRITE
00587 ),
00588 *this,
00589 0
00590 ),
00591 globalMeshDataPtr_(NULL),
00592 moving_(false),
00593 changing_(false),
00594 curMotionTimeIndex_(time().timeIndex()),
00595 oldPointsPtr_(NULL)
00596 {
00597
00598 forAll (faces_, faceI)
00599 {
00600 const face& curFace = faces_[faceI];
00601
00602 if (min(curFace) < 0 || max(curFace) > points_.size())
00603 {
00604 FatalErrorIn
00605 (
00606 "polyMesh::polyMesh\n"
00607 "(\n"
00608 " const IOobject&,\n"
00609 " const Xfer<pointField>&,\n"
00610 " const Xfer<faceList>&,\n"
00611 " const Xfer<cellList>&\n"
00612 ")\n"
00613 ) << "Face " << faceI << "contains vertex labels out of range: "
00614 << curFace << " Max point index = " << points_.size()
00615 << abort(FatalError);
00616 }
00617 }
00618
00619
00620 cellList cLst(cells);
00621
00622
00623 forAll (cLst, cellI)
00624 {
00625 const cell& curCell = cLst[cellI];
00626
00627 if (min(curCell) < 0 || max(curCell) > faces_.size())
00628 {
00629 FatalErrorIn
00630 (
00631 "polyMesh::polyMesh\n"
00632 "(\n"
00633 " const IOobject&,\n"
00634 " const Xfer<pointField>&,\n"
00635 " const Xfer<faceList>&,\n"
00636 " const Xfer<cellList>&\n"
00637 ")\n"
00638 ) << "Cell " << cellI << "contains face labels out of range: "
00639 << curCell << " Max face index = " << faces_.size()
00640 << abort(FatalError);
00641 }
00642 }
00643
00644
00645 initMesh(cLst);
00646 }
00647
00648
00649 void Foam::polyMesh::resetPrimitives
00650 (
00651 const Xfer<pointField>& points,
00652 const Xfer<faceList>& faces,
00653 const Xfer<labelList>& owner,
00654 const Xfer<labelList>& neighbour,
00655 const labelList& patchSizes,
00656 const labelList& patchStarts,
00657 const bool validBoundary
00658 )
00659 {
00660
00661 clearAddressing();
00662
00663
00664
00665 if (&points)
00666 {
00667 points_.transfer(points());
00668 bounds_ = boundBox(points_, validBoundary);
00669 }
00670
00671 if (&faces)
00672 {
00673 faces_.transfer(faces());
00674 }
00675
00676 if (&owner)
00677 {
00678 owner_.transfer(owner());
00679 }
00680
00681 if (&neighbour)
00682 {
00683 neighbour_.transfer(neighbour());
00684 }
00685
00686
00687
00688 forAll(boundary_, patchI)
00689 {
00690 boundary_[patchI] = polyPatch
00691 (
00692 boundary_[patchI].name(),
00693 patchSizes[patchI],
00694 patchStarts[patchI],
00695 patchI,
00696 boundary_
00697 );
00698 }
00699
00700
00701
00702 setInstance(time().timeName());
00703
00704
00705 forAll (faces_, faceI)
00706 {
00707 const face& curFace = faces_[faceI];
00708
00709 if (min(curFace) < 0 || max(curFace) > points_.size())
00710 {
00711 FatalErrorIn
00712 (
00713 "polyMesh::polyMesh::resetPrimitives\n"
00714 "(\n"
00715 " const Xfer<pointField>&,\n"
00716 " const Xfer<faceList>&,\n"
00717 " const Xfer<labelList>& owner,\n"
00718 " const Xfer<labelList>& neighbour,\n"
00719 " const labelList& patchSizes,\n"
00720 " const labelList& patchStarts\n"
00721 ")\n"
00722 ) << "Face " << faceI << " contains vertex labels out of range: "
00723 << curFace << " Max point index = " << points_.size()
00724 << abort(FatalError);
00725 }
00726 }
00727
00728
00729
00730
00731 initMesh();
00732
00733
00734 if (validBoundary)
00735 {
00736
00737
00738
00739
00740
00741 boundary_.updateMesh();
00742
00743
00744 boundary_.calcGeometry();
00745
00746
00747 if (globalData().nTotalPoints() == 0 || globalData().nTotalCells() == 0)
00748 {
00749 FatalErrorIn
00750 (
00751 "polyMesh::polyMesh::resetPrimitives\n"
00752 "(\n"
00753 " const Xfer<pointField>&,\n"
00754 " const Xfer<faceList>&,\n"
00755 " const Xfer<labelList>& owner,\n"
00756 " const Xfer<labelList>& neighbour,\n"
00757 " const labelList& patchSizes,\n"
00758 " const labelList& patchStarts\n"
00759 ")\n"
00760 )
00761 << "no points or no cells in mesh" << endl;
00762 }
00763 }
00764 }
00765
00766
00767
00768
00769 Foam::polyMesh::~polyMesh()
00770 {
00771 clearOut();
00772 resetMotion();
00773 }
00774
00775
00776
00777
00778 const Foam::fileName& Foam::polyMesh::dbDir() const
00779 {
00780 if (objectRegistry::dbDir() == defaultRegion)
00781 {
00782 return parent().dbDir();
00783 }
00784 else
00785 {
00786 return objectRegistry::dbDir();
00787 }
00788 }
00789
00790
00791 Foam::fileName Foam::polyMesh::meshDir() const
00792 {
00793 return dbDir()/meshSubDir;
00794 }
00795
00796
00797 const Foam::fileName& Foam::polyMesh::pointsInstance() const
00798 {
00799 return points_.instance();
00800 }
00801
00802
00803 const Foam::fileName& Foam::polyMesh::facesInstance() const
00804 {
00805 return faces_.instance();
00806 }
00807
00808
00809 const Foam::Vector<Foam::label>& Foam::polyMesh::geometricD() const
00810 {
00811 if (geometricD_.x() == 0)
00812 {
00813 calcDirections();
00814 }
00815
00816 return geometricD_;
00817 }
00818
00819
00820 Foam::label Foam::polyMesh::nGeometricD() const
00821 {
00822 return cmptSum(geometricD() + Vector<label>::one)/2;
00823 }
00824
00825
00826 const Foam::Vector<Foam::label>& Foam::polyMesh::solutionD() const
00827 {
00828 if (solutionD_.x() == 0)
00829 {
00830 calcDirections();
00831 }
00832
00833 return solutionD_;
00834 }
00835
00836
00837 Foam::label Foam::polyMesh::nSolutionD() const
00838 {
00839 return cmptSum(solutionD() + Vector<label>::one)/2;
00840 }
00841
00842
00843
00844 void Foam::polyMesh::addPatches
00845 (
00846 const List<polyPatch*>& p,
00847 const bool validBoundary
00848 )
00849 {
00850 if (boundaryMesh().size())
00851 {
00852 FatalErrorIn
00853 (
00854 "void polyMesh::addPatches(const List<polyPatch*>&, const bool)"
00855 ) << "boundary already exists"
00856 << abort(FatalError);
00857 }
00858
00859
00860 geometricD_ = Vector<label>::zero;
00861 solutionD_ = Vector<label>::zero;
00862
00863 boundary_.setSize(p.size());
00864
00865
00866 forAll (p, pI)
00867 {
00868 boundary_.set(pI, p[pI]);
00869 }
00870
00871
00872
00873
00874
00875 deleteDemandDrivenData(globalMeshDataPtr_);
00876
00877 if (validBoundary)
00878 {
00879
00880 boundary_.updateMesh();
00881
00882
00883 boundary_.calcGeometry();
00884
00885 boundary_.checkDefinition();
00886 }
00887 }
00888
00889
00890
00891 void Foam::polyMesh::addZones
00892 (
00893 const List<pointZone*>& pz,
00894 const List<faceZone*>& fz,
00895 const List<cellZone*>& cz
00896 )
00897 {
00898 if (pointZones().size() || faceZones().size() || cellZones().size())
00899 {
00900 FatalErrorIn
00901 (
00902 "void addZones\n"
00903 "(\n"
00904 " const List<pointZone*>&,\n"
00905 " const List<faceZone*>&,\n"
00906 " const List<cellZone*>&\n"
00907 ")"
00908 ) << "point, face or cell zone already exists"
00909 << abort(FatalError);
00910 }
00911
00912
00913 if (pz.size())
00914 {
00915 pointZones_.setSize(pz.size());
00916
00917
00918 forAll (pz, pI)
00919 {
00920 pointZones_.set(pI, pz[pI]);
00921 }
00922
00923 pointZones_.writeOpt() = IOobject::AUTO_WRITE;
00924 }
00925
00926
00927 if (fz.size())
00928 {
00929 faceZones_.setSize(fz.size());
00930
00931
00932 forAll (fz, fI)
00933 {
00934 faceZones_.set(fI, fz[fI]);
00935 }
00936
00937 faceZones_.writeOpt() = IOobject::AUTO_WRITE;
00938 }
00939
00940
00941 if (cz.size())
00942 {
00943 cellZones_.setSize(cz.size());
00944
00945
00946 forAll (cz, cI)
00947 {
00948 cellZones_.set(cI, cz[cI]);
00949 }
00950
00951 cellZones_.writeOpt() = IOobject::AUTO_WRITE;
00952 }
00953 }
00954
00955
00956 const Foam::pointField& Foam::polyMesh::points() const
00957 {
00958 if (clearedPrimitives_)
00959 {
00960 FatalErrorIn("const pointField& polyMesh::points() const")
00961 << "points deallocated"
00962 << abort(FatalError);
00963 }
00964
00965 return points_;
00966 }
00967
00968
00969 const Foam::faceList& Foam::polyMesh::faces() const
00970 {
00971 if (clearedPrimitives_)
00972 {
00973 FatalErrorIn("const faceList& polyMesh::faces() const")
00974 << "faces deallocated"
00975 << abort(FatalError);
00976 }
00977
00978 return faces_;
00979 }
00980
00981
00982 const Foam::labelList& Foam::polyMesh::faceOwner() const
00983 {
00984 return owner_;
00985 }
00986
00987
00988 const Foam::labelList& Foam::polyMesh::faceNeighbour() const
00989 {
00990 return neighbour_;
00991 }
00992
00993
00994
00995 const Foam::pointField& Foam::polyMesh::oldPoints() const
00996 {
00997 if (!oldPointsPtr_)
00998 {
00999 if (debug)
01000 {
01001 WarningIn("const pointField& polyMesh::oldPoints() const")
01002 << "Old points not available. Forcing storage of old points"
01003 << endl;
01004 }
01005
01006 oldPointsPtr_ = new pointField(points_);
01007 curMotionTimeIndex_ = time().timeIndex();
01008 }
01009
01010 return *oldPointsPtr_;
01011 }
01012
01013
01014 Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
01015 (
01016 const pointField& newPoints
01017 )
01018 {
01019 if (debug)
01020 {
01021 Info<< "tmp<scalarField> polyMesh::movePoints(const pointField&) : "
01022 << " Moving points for time " << time().value()
01023 << " index " << time().timeIndex() << endl;
01024 }
01025
01026 moving(true);
01027
01028
01029 if (curMotionTimeIndex_ != time().timeIndex())
01030 {
01031
01032 deleteDemandDrivenData(oldPointsPtr_);
01033 oldPointsPtr_ = new pointField(points_);
01034 curMotionTimeIndex_ = time().timeIndex();
01035 }
01036
01037 points_ = newPoints;
01038
01039 if (debug)
01040 {
01041
01042 if (primitiveMesh::checkMeshMotion(points_, true))
01043 {
01044 Info<< "tmp<scalarField> polyMesh::movePoints"
01045 << "(const pointField&) : "
01046 << "Moving the mesh with given points will "
01047 << "invalidate the mesh." << nl
01048 << "Mesh motion should not be executed." << endl;
01049 }
01050 }
01051
01052 points_.writeOpt() = IOobject::AUTO_WRITE;
01053 points_.instance() = time().timeName();
01054
01055
01056 tmp<scalarField> sweptVols = primitiveMesh::movePoints
01057 (
01058 points_,
01059 oldPoints()
01060 );
01061
01062
01063 if (globalMeshDataPtr_)
01064 {
01065 globalMeshDataPtr_->movePoints(points_);
01066 }
01067
01068
01069
01070 bounds_ = boundBox(points_);
01071 boundary_.movePoints(points_);
01072
01073 pointZones_.movePoints(points_);
01074 faceZones_.movePoints(points_);
01075 cellZones_.movePoints(points_);
01076
01077
01078 geometricD_ = Vector<label>::zero;
01079 solutionD_ = Vector<label>::zero;
01080
01081
01082
01083
01084
01085
01086 if (thisDb().foundObject<pointMesh>(pointMesh::typeName))
01087 {
01088 const_cast<pointMesh&>
01089 (
01090 thisDb().lookupObject<pointMesh>
01091 (
01092 pointMesh::typeName
01093 )
01094 ).movePoints(points_);
01095 }
01096
01097 return sweptVols;
01098 }
01099
01100
01101
01102 void Foam::polyMesh::resetMotion() const
01103 {
01104 curMotionTimeIndex_ = 0;
01105 deleteDemandDrivenData(oldPointsPtr_);
01106 }
01107
01108
01109
01110 const Foam::globalMeshData& Foam::polyMesh::globalData() const
01111 {
01112 if (!globalMeshDataPtr_)
01113 {
01114 if (debug)
01115 {
01116 Pout<< "polyMesh::globalData() const : "
01117 << "Constructing parallelData from processor topology" << nl
01118 << "This needs the patch faces to be correctly matched"
01119 << endl;
01120 }
01121
01122 globalMeshDataPtr_ = new globalMeshData(*this);
01123 }
01124
01125 return *globalMeshDataPtr_;
01126 }
01127
01128
01129
01130 void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
01131 {
01132 fileName meshFilesPath = thisDb().path()/instanceDir/meshDir();
01133
01134 rm(meshFilesPath/"points");
01135 rm(meshFilesPath/"faces");
01136 rm(meshFilesPath/"owner");
01137 rm(meshFilesPath/"neighbour");
01138 rm(meshFilesPath/"cells");
01139 rm(meshFilesPath/"boundary");
01140 rm(meshFilesPath/"pointZones");
01141 rm(meshFilesPath/"faceZones");
01142 rm(meshFilesPath/"cellZones");
01143 rm(meshFilesPath/"meshModifiers");
01144 rm(meshFilesPath/"parallelData");
01145
01146
01147 if (isDir(meshFilesPath/"sets"))
01148 {
01149 rmDir(meshFilesPath/"sets");
01150 }
01151 }
01152
01153 void Foam::polyMesh::removeFiles() const
01154 {
01155 removeFiles(instance());
01156 }
01157
01158
01159