50 void Foam::polyMesh::calcDirections()
const
60 label nEmptyPatches = 0;
61 label nWedgePatches = 0;
77 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
83 wedgeDirVec +=
cmptMag(wpp.centreNormal());
88 reduce(nEmptyPatches, maxOp<label>());
89 reduce(nWedgePatches, maxOp<label>());
93 reduce(emptyDirVec, sumOp<vector>());
95 emptyDirVec /=
mag(emptyDirVec);
97 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
99 if (emptyDirVec[cmpt] > 1
e-6)
101 solutionD_[cmpt] = -1;
105 solutionD_[cmpt] = 1;
113 geometricD_ = solutionD_;
117 reduce(wedgeDirVec, sumOp<vector>());
119 wedgeDirVec /=
mag(wedgeDirVec);
121 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
123 if (wedgeDirVec[cmpt] > 1
e-6)
125 geometricD_[cmpt] = -1;
129 geometricD_[cmpt] = 1;
147 time().findInstance(meshDir(),
"points"),
159 time().findInstance(meshDir(),
"faces"),
171 time().findInstance(meshDir(),
"faces"),
183 time().findInstance(meshDir(),
"faces"),
190 clearedPrimitives_(false),
196 time().findInstance(meshDir(),
"boundary"),
261 globalMeshDataPtr_(NULL),
297 boundary_.calcGeometry();
303 <<
"no points in mesh" <<
endl;
308 <<
"no cells in mesh" <<
endl;
313 Foam::polyMesh::polyMesh
377 clearedPrimitives_(
false),
392 bounds_(points_, syncPar),
437 globalMeshDataPtr_(NULL),
446 const face& curFace = faces_[faceI];
448 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
452 "polyMesh::polyMesh\n"
454 " const IOobject& io,\n"
455 " const pointField& points,\n"
456 " const faceList& faces,\n"
457 " const cellList& cells\n"
459 ) <<
"Face " << faceI <<
"contains vertex labels out of range: "
460 << curFace <<
" Max point index = " << points_.
size()
470 Foam::polyMesh::polyMesh
533 clearedPrimitives_(
false),
548 bounds_(points_, syncPar),
593 globalMeshDataPtr_(NULL),
602 const face& curFace = faces_[faceI];
604 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
608 "polyMesh::polyMesh\n"
610 " const IOobject&,\n"
611 " const Xfer<pointField>&,\n"
612 " const Xfer<faceList>&,\n"
613 " const Xfer<cellList>&\n"
615 ) <<
"Face " << faceI <<
"contains vertex labels out of range: "
616 << curFace <<
" Max point index = " << points_.
size()
627 const cell& curCell = cLst[cellI];
629 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
633 "polyMesh::polyMesh\n"
635 " const IOobject&,\n"
636 " const Xfer<pointField>&,\n"
637 " const Xfer<faceList>&,\n"
638 " const Xfer<cellList>&\n"
640 ) <<
"Cell " << cellI <<
"contains face labels out of range: "
641 << curCell <<
" Max face index = " << faces_.
size()
659 const bool validBoundary
669 points_.transfer(
points());
670 bounds_ =
boundBox(points_, validBoundary);
675 faces_.transfer(faces());
680 owner_.transfer(owner());
685 neighbour_.transfer(neighbour());
694 boundary_[patchI].
name(),
709 const face& curFace = faces_[faceI];
711 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
715 "polyMesh::polyMesh::resetPrimitives\n"
717 " const Xfer<pointField>&,\n"
718 " const Xfer<faceList>&,\n"
719 " const Xfer<labelList>& owner,\n"
720 " const Xfer<labelList>& neighbour,\n"
721 " const labelList& patchSizes,\n"
722 " const labelList& patchStarts\n"
724 ) <<
"Face " << faceI <<
" contains vertex labels out of range: "
725 << curFace <<
" Max point index = " << points_.
size()
743 boundary_.updateMesh();
746 boundary_.calcGeometry();
757 "polyMesh::polyMesh::resetPrimitives\n"
759 " const Xfer<pointField>&,\n"
760 " const Xfer<faceList>&,\n"
761 " const Xfer<labelList>& owner,\n"
762 " const Xfer<labelList>& neighbour,\n"
763 " const labelList& patchSizes,\n"
764 " const labelList& patchStarts\n"
765 " const bool validBoundary\n"
767 ) <<
"no points or no cells in mesh" <<
endl;
788 return parent().dbDir();
799 return dbDir()/meshSubDir;
805 return points_.instance();
811 return faces_.instance();
817 if (geometricD_.x() == 0)
834 if (solutionD_.x() == 0)
853 const bool validBoundary
860 "void polyMesh::addPatches(const List<polyPatch*>&, const bool)"
861 ) <<
"boundary already exists"
869 boundary_.setSize(p.
size());
874 boundary_.set(pI, p[pI]);
886 boundary_.updateMesh();
889 boundary_.calcGeometry();
891 boundary_.checkDefinition();
904 if (pointZones().size() || faceZones().size() || cellZones().size())
910 " const List<pointZone*>&,\n"
911 " const List<faceZone*>&,\n"
912 " const List<cellZone*>&\n"
914 ) <<
"point, face or cell zone already exists"
921 pointZones_.setSize(pz.
size());
926 pointZones_.set(pI, pz[pI]);
935 faceZones_.setSize(fz.
size());
940 faceZones_.set(fI, fz[fI]);
949 cellZones_.setSize(cz.
size());
954 cellZones_.set(cI, cz[cI]);
964 if (clearedPrimitives_)
966 FatalErrorIn(
"const pointField& polyMesh::points() const")
967 <<
"points deallocated"
977 if (clearedPrimitives_)
980 <<
"faces deallocated"
1007 WarningIn(
"const pointField& polyMesh::oldPoints() const")
1008 <<
"Old points not available. Forcing storage of old points"
1013 curMotionTimeIndex_ = time().timeIndex();
1016 return *oldPointsPtr_;
1027 Info<<
"tmp<scalarField> polyMesh::movePoints(const pointField&) : "
1028 <<
" Moving points for time " << time().value()
1029 <<
" index " << time().timeIndex() <<
endl;
1035 if (curMotionTimeIndex_ != time().
timeIndex())
1040 curMotionTimeIndex_ = time().timeIndex();
1043 points_ = newPoints;
1050 Info<<
"tmp<scalarField> polyMesh::movePoints"
1051 <<
"(const pointField&) : "
1052 <<
"Moving the mesh with given points will "
1053 <<
"invalidate the mesh." <<
nl
1054 <<
"Mesh motion should not be executed." <<
endl;
1059 points_.instance() = time().timeName();
1069 if (globalMeshDataPtr_)
1071 globalMeshDataPtr_->movePoints(points_);
1077 boundary_.movePoints(points_);
1079 pointZones_.movePoints(points_);
1080 faceZones_.movePoints(points_);
1081 cellZones_.movePoints(points_);
1092 if (thisDb().foundObject<pointMesh>(pointMesh::typeName))
1110 curMotionTimeIndex_ = 0;
1118 if (!globalMeshDataPtr_)
1122 Pout<<
"polyMesh::globalData() const : "
1123 <<
"Constructing parallelData from processor topology" <<
nl
1124 <<
"This needs the patch faces to be correctly matched"
1131 return *globalMeshDataPtr_;
1138 fileName meshFilesPath = thisDb().
path()/instanceDir/meshDir();
1140 rm(meshFilesPath/
"points");
1141 rm(meshFilesPath/
"faces");
1142 rm(meshFilesPath/
"owner");
1143 rm(meshFilesPath/
"neighbour");
1144 rm(meshFilesPath/
"cells");
1145 rm(meshFilesPath/
"boundary");
1146 rm(meshFilesPath/
"pointZones");
1147 rm(meshFilesPath/
"faceZones");
1148 rm(meshFilesPath/
"cellZones");
1149 rm(meshFilesPath/
"meshModifiers");
1150 rm(meshFilesPath/
"parallelData");
1153 if (
isDir(meshFilesPath/
"sets"))
1155 rmDir(meshFilesPath/
"sets");
1161 removeFiles(instance());