51 void Foam::polyMesh::calcDirections()
const
61 label nEmptyPatches = 0;
62 label nWedgePatches = 0;
78 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
84 wedgeDirVec +=
cmptMag(wpp.centreNormal());
89 reduce(nEmptyPatches, maxOp<label>());
90 reduce(nWedgePatches, maxOp<label>());
94 reduce(emptyDirVec, sumOp<vector>());
96 emptyDirVec /=
mag(emptyDirVec);
100 if (emptyDirVec[cmpt] > 1
e-6)
102 solutionD_[cmpt] = -1;
106 solutionD_[cmpt] = 1;
114 geometricD_ = solutionD_;
118 reduce(wedgeDirVec, sumOp<vector>());
120 wedgeDirVec /=
mag(wedgeDirVec);
124 if (wedgeDirVec[cmpt] > 1
e-6)
126 geometricD_[cmpt] = -1;
130 geometricD_[cmpt] = 1;
139 typeIOobject<labelIOList> io
155 return autoPtr<labelIOList>(
nullptr);
171 time().findInstance(meshDir(),
"points"),
183 time().findInstance(meshDir(),
"faces"),
214 clearedPrimitives_(false),
232 tetBasePtIsPtr_(readTetBasePtIs()),
233 cellTreePtr_(nullptr),
291 globalMeshDataPtr_(nullptr),
292 curMotionTimeIndex_(-1),
293 oldPointsPtr_(nullptr),
294 oldCellCentresPtr_(nullptr),
295 storeOldCellCentres_(false),
329 boundary_.calcGeometry();
336 <<
"no points in mesh" <<
endl;
341 <<
"no cells in mesh" <<
endl;
418 clearedPrimitives_(false),
433 bounds_(points_, syncPar),
437 tetBasePtIsPtr_(readTetBasePtIs()),
438 cellTreePtr_(nullptr),
478 globalMeshDataPtr_(nullptr),
479 curMotionTimeIndex_(-1),
480 oldPointsPtr_(nullptr),
481 oldCellCentresPtr_(nullptr),
482 storeOldCellCentres_(false),
489 const face& curFace = faces_[facei];
491 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
494 <<
"Face " << facei <<
"contains vertex labels out of range: "
495 << curFace <<
" Max point index = " << points_.
size()
569 clearedPrimitives_(false),
584 bounds_(points_, syncPar),
588 tetBasePtIsPtr_(readTetBasePtIs()),
589 cellTreePtr_(nullptr),
629 globalMeshDataPtr_(nullptr),
630 curMotionTimeIndex_(-1),
631 oldPointsPtr_(nullptr),
632 oldCellCentresPtr_(nullptr),
633 storeOldCellCentres_(false),
640 const face& curFace = faces_[facei];
642 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
645 <<
"Face " << facei <<
"contains vertex labels out of range: "
646 << curFace <<
" Max point index = " << points_.
size()
657 const cell& curCell = cLst[celli];
659 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
662 <<
"Cell " << celli <<
"contains face labels out of range: "
663 << curCell <<
" Max face index = " << faces_.size()
677 points_(move(mesh.points_)),
678 faces_(move(mesh.faces_)),
679 owner_(move(mesh.owner_)),
680 neighbour_(move(mesh.neighbour_)),
681 clearedPrimitives_(mesh.clearedPrimitives_),
682 boundary_(move(mesh.boundary_)),
683 bounds_(move(mesh.bounds_)),
685 geometricD_(mesh.geometricD_),
686 solutionD_(mesh.solutionD_),
687 tetBasePtIsPtr_(move(mesh.tetBasePtIsPtr_)),
688 cellTreePtr_(move(mesh.cellTreePtr_)),
689 pointZones_(move(mesh.pointZones_)),
690 faceZones_(move(mesh.faceZones_)),
691 cellZones_(move(mesh.cellZones_)),
692 globalMeshDataPtr_(move(mesh.globalMeshDataPtr_)),
693 curMotionTimeIndex_(mesh.curMotionTimeIndex_),
694 oldPointsPtr_(move(mesh.oldPointsPtr_)),
695 oldCellCentresPtr_(move(mesh.oldCellCentresPtr_)),
696 storeOldCellCentres_(mesh.storeOldCellCentres_),
697 moving_(mesh.moving_),
698 topoChanged_(mesh.topoChanged_)
710 const bool validBoundary
714 clearAddressing(
true);
721 bounds_ =
boundBox(points_, validBoundary);
726 faces_ = move(faces);
731 owner_ = move(owner);
736 neighbour_ = move(neighbour);
755 setInstance(time().
name());
760 const face& curFace = faces_[facei];
762 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
765 <<
"Face " << facei <<
" contains vertex labels out of range: "
766 << curFace <<
" Max point index = " << points_.
size()
784 boundary_.topoChange();
787 boundary_.calcGeometry();
797 <<
"no points or no cells in mesh"
807 clearAddressing(
true);
811 points_.swap(otherMesh.points_);
813 faces_.swap(otherMesh.faces_);
814 owner_.swap(otherMesh.owner_);
815 neighbour_.swap(otherMesh.neighbour_);
818 boundary_.clearGeom();
819 boundary_.clearAddressing();
824 auto updatePatches = []
830 boundaryMesh.resize(otherPatches.
size());
832 forAll(otherPatches, otherPatchi)
838 if (isA<processorPolyPatch>(otherPatches[otherPatchi]))
843 otherPatches[otherPatchi].
clone(boundaryMesh)
850 boundaryMesh[otherPatchi],
853 otherPatches[otherPatchi].size(),
854 otherPatches[otherPatchi].start()
872 updatePatches(otherPatches, boundary_);
873 updatePatches(
patches, otherMesh.boundary_);
877 globalMeshDataPtr_.clear();
878 otherMesh.globalMeshDataPtr_.clear();
881 setInstance(time().
name());
885 auto checkFaces = [](
const polyMesh& mesh)
887 forAll(mesh.faces_, facei)
889 const face& curFace = mesh.faces_[facei];
891 if (
min(curFace) < 0 ||
max(curFace) > mesh.points_.size())
894 <<
"Face " << facei <<
" contains vertex labels out of "
895 <<
"range: " << curFace <<
" Max point index = "
902 checkFaces(otherMesh);
907 otherMesh.initMesh();
910 boundary_.topoChange();
914 boundary_.calcGeometry();
915 otherMesh.boundary_.calcGeometry();
918 if (foundObject<pointMesh>(pointMesh::typeName))
929 pointZones_.swap(otherMesh.pointZones_);
930 faceZones_.swap(otherMesh.faceZones_);
931 cellZones_.swap(otherMesh.cellZones_);
950 return parent().dbDir();
961 return dbDir()/meshSubDir;
967 return points_.instance();
973 return faces_.instance();
979 return points_.writeOpt();
985 return faces_.writeOpt();
991 if (geometricD_.x() == 0)
1008 if (solutionD_.x() == 0)
1025 if (tetBasePtIsPtr_.empty())
1030 <<
"Forcing storage of base points."
1034 tetBasePtIsPtr_.reset
1052 return tetBasePtIsPtr_();
1059 if (cellTreePtr_.empty())
1079 return cellTreePtr_();
1086 const bool validBoundary
1089 if (boundaryMesh().size())
1092 <<
"boundary already exists"
1100 boundary_.setSize(
p.
size());
1105 boundary_.set(pI,
p[pI]);
1112 globalMeshDataPtr_.clear();
1117 boundary_.topoChange();
1120 boundary_.calcGeometry();
1122 boundary_.checkDefinition();
1134 if (pointZones().size() || faceZones().size() || cellZones().size())
1137 <<
"point, face or cell zone already exists"
1144 pointZones_.setSize(pz.
size());
1149 pointZones_.set(pI, pz[pI]->
name(), pz[pI]);
1158 faceZones_.setSize(fz.
size());
1163 faceZones_.set(fI, fz[fI]->
name(), fz[fI]);
1172 cellZones_.setSize(cz.
size());
1177 cellZones_.set(cI, cz[cI]->
name(), cz[cI]);
1188 const bool validBoundary
1193 boundary_.clearGeom();
1195 clearAddressing(
true);
1220 setInstance(time().
name());
1222 boundary_.reorderPatches(newToOld, validBoundary);
1225 meshObjects::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1226 meshObjects::reorderPatches<pointMesh>(*
this, newToOld, validBoundary);
1232 const label insertPatchi,
1235 const word& defaultPatchFieldType,
1236 const bool validBoundary
1239 const label sz = boundary_.size();
1241 label startFacei = nFaces();
1242 if (insertPatchi < sz)
1244 startFacei = boundary_[insertPatchi].start();
1251 for (
label i = 0; i < insertPatchi; i++)
1255 for (
label i = insertPatchi; i < sz; i++)
1259 newToOld[insertPatchi] = -1;
1261 reorderPatches(newToOld,
false);
1265 boundary_.clearGeom();
1266 clearAddressing(
true);
1308 meshObjects::addPatch<polyMesh>(*
this, insertPatchi);
1309 meshObjects::addPatch<pointMesh>(*
this, insertPatchi);
1315 if (clearedPrimitives_)
1318 <<
"points deallocated"
1328 if (clearedPrimitives_)
1331 <<
"faces deallocated"
1358 if (oldPointsPtr_.empty())
1361 <<
"Old points have not been stored"
1365 return oldPointsPtr_();
1371 storeOldCellCentres_ =
true;
1375 return cellCentres();
1378 if (oldCellCentresPtr_.empty())
1381 <<
"Old cell centres have not been stored"
1385 return oldCellCentresPtr_();
1397 io.
eventNo() = points_.eventNo()+1;
1406 <<
"Set points for time " << time().value()
1407 <<
" index " << time().timeIndex() <<
endl;
1412 points_ = newPoints;
1414 setPointsInstance(time().
name());
1417 if (globalMeshDataPtr_.valid())
1419 globalMeshDataPtr_().movePoints(points_);
1425 boundary_.movePoints(points_);
1427 pointZones_.movePoints(points_);
1428 faceZones_.movePoints(points_);
1429 cellZones_.movePoints(points_);
1432 cellTreePtr_.clear();
1438 meshObjects::movePoints<polyMesh>(*
this);
1439 meshObjects::movePoints<pointMesh>(*
this);
1451 <<
"Moving points for time " << time().value()
1452 <<
" index " << time().timeIndex() <<
endl;
1456 if (curMotionTimeIndex_ != time().
timeIndex())
1458 oldPointsPtr_.clear();
1459 oldPointsPtr_.reset(
new pointField(points_));
1460 if (storeOldCellCentres_)
1462 oldCellCentresPtr_.clear();
1463 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1465 curMotionTimeIndex_ = time().timeIndex();
1468 points_ = newPoints;
1470 setPointsInstance(time().
name());
1479 if (globalMeshDataPtr_.valid())
1481 globalMeshDataPtr_().movePoints(points_);
1487 boundary_.movePoints(points_);
1489 pointZones_.movePoints(points_);
1490 faceZones_.movePoints(points_);
1491 cellZones_.movePoints(points_);
1494 cellTreePtr_.clear();
1500 meshObjects::movePoints<polyMesh>(*
this);
1501 meshObjects::movePoints<pointMesh>(*
this);
1509 curMotionTimeIndex_ = -1;
1510 oldPointsPtr_.clear();
1511 oldCellCentresPtr_.clear();
1517 if (globalMeshDataPtr_.empty())
1521 Pout<<
"polyMesh::globalData() const : "
1522 <<
"Constructing parallelData from processor topology"
1529 return globalMeshDataPtr_();
1547 fileName meshFilesPath = thisDb().time().
path()/instanceDir/meshDir();
1549 rm(meshFilesPath/
"points");
1550 rm(meshFilesPath/
"faces");
1551 rm(meshFilesPath/
"owner");
1552 rm(meshFilesPath/
"neighbour");
1553 rm(meshFilesPath/
"cells");
1554 rm(meshFilesPath/
"boundary");
1555 rm(meshFilesPath/
"pointZones");
1556 rm(meshFilesPath/
"faceZones");
1557 rm(meshFilesPath/
"cellZones");
1558 rm(meshFilesPath/
"meshModifiers");
1559 rm(meshFilesPath/
"parallelData");
1562 if (
isDir(meshFilesPath/
"sets"))
1564 rmDir(meshFilesPath/
"sets");
1571 removeFiles(instance());
1595 findTetFacePt(celli,
p, tetFacei, tetPti);
1611 tetFacei = tet.
face();
1612 tetPti = tet.
tetPt();
1631 case FACE_CENTRE_TRIS:
1639 label facei = cFaces[cFacei];
1640 const face&
f = faces_[facei];
1641 const point& fc = faceCentres()[facei];
1642 bool isOwn = (owner_[facei] == celli);
1652 nextPointi =
f.nextLabel(fp);
1656 pointi =
f.nextLabel(fp);
1669 if ((faceTri.
area() & proj) > 0)
1679 case FACE_DIAG_TRIS:
1687 label facei = cFaces[cFacei];
1688 const face&
f = faces_[facei];
1690 for (
label tetPti = 1; tetPti <
f.
size() - 1; tetPti++)
1699 if ((faceTri.
area() & proj) > 0)
1715 findTetFacePt(celli,
p, tetFacei, tetPti);
1717 return tetFacei != -1;
1735 && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS)
1744 (void)tetBasePtIs();
1752 if (decompMode == CELL_TETS)
1761 findCellFacePt(
p, celli, tetFacei, tetPti);
1771 label celli = findNearestCell(
p);
1774 if (pointInCell(
p, celli, decompMode))
1782 for (
label celli = 0; celli < nCells(); celli++)
1784 if (pointInCell(
p, celli, decompMode))
#define forAll(list, i)
Loop across all elements in list.
A List of objects of type <Type> with automated input and output using a compact storage....
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
label size() const
Return number of elements in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const word & headerClassName() const
Return name of the class name read from header.
writeOption
Enumeration defining the write options.
void size(const label)
Override size to be inconsistent with allocated storage.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool processorCase() const
Return true if this is a processor case.
virtual void topoChange(const polyTopoChangeMap &map)=0
Update topology using the given map.
Inter-processor communications stream.
static bool & parRun()
Is this a parallel run?
label size() const
Return the number of elements in the UPtrList.
static const direction nComponents
Number of components in this vector space.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
bool readIfPresent()
Read zones if the zones file is present.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A bounding box defined in terms of the points at its extremities.
A cell is defined as a list of faces with extra functionality.
A list of keyword definitions, which are a keyword followed by any number of values (e....
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
fileName path() const
Return directory path name (part before last /)
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
static void clearUpto(objectRegistry &)
Clear all meshObjects derived from FromType up to (but not including)
Registry of regIOobjects.
const Time & time() const
Return time.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
bool foundObject(const word &name) const
Is the named Type in registry.
Mesh representing a set of points created from polyMesh.
void reset()
Reset pointMesh with respect to the updated polyMesh.
void topoChange()
Correct polyBoundaryMesh after topology update.
void clearGeom()
Clear geometry at this level and at patches.
void clearAddressing()
Clear addressing at this level and at patches.
static labelList findFaceBasePts(const polyMesh &mesh, scalar tol=minTetQuality, bool report=false)
Find a suitable base point for each face for decomposition.
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
Mesh consisting of general polyhedral cells.
virtual ~polyMesh()
Destructor.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
const fileName & facesInstance() const
Return the current instance directory for faces.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
static word defaultRegion
Return the default region name.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
virtual void addPatch(const label insertPatchi, const polyPatch &patch, const dictionary &patchFieldDict, const word &defaultPatchFieldType, const bool validBoundary)
Add/insert single patch. If validBoundary the new situation.
cellDecomposition
Enumeration defining the decomposition of the cell for.
IOobject::writeOption facesWriteOpt() const
Return the points write option.
virtual const faceList & faces() const
Return raw faces.
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
void resetPrimitives(pointField &&points, faceList &&faces, labelList &&owner, labelList &&neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
virtual const labelList & faceOwner() const
Return face owner.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
const globalMeshData & globalData() const
Return parallel info.
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
void swap(polyMesh &)
Swap mesh.
const fileName & pointsInstance() const
Return the current instance directory for points.
label comm() const
Return communicator used for parallel communication.
polyMesh(const IOobject &io)
Construct from IOobject.
void clearAddressing(const bool isMeshUpdate=false)
Clear addressing.
void resetMotion() const
Reset motion.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
virtual const pointField & points() const
Return raw points.
void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
IOobject::writeOption pointsWriteOpt() const
Return the points write option.
void removeFiles() const
Remove all files from mesh instance()
virtual const pointField & oldCellCentres() const
Return old cell centres for mesh motion.
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorder and trim existing patches. If validBoundary the new.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void setInstance(const fileName &)
Set the instance for mesh files.
virtual void setPoints(const pointField &)
Reset the points.
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Cell-face mesh analysis engine.
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
void clearGeom()
Clear geometry.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
const vectorField & faceAreas() const
const cellList & cells() const
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
virtual bool write(const bool write=true) const
Write using setting from DB.
label eventNo() const
Event number at last update.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
label face() const
Return the face.
label tetPt() const
Return the characterising tetPtI.
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the face for.
A class for managing temporary objects.
Standard boundBox + extra functionality for use in octree.
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
A triangle primitive used to calculate face areas and swept volumes.
vector area() const
Return vector area.
Point centre() const
Return centre (centroid)
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > mag(const dimensioned< Type > &)
bool rmDir(const fileName &)
Remove a directory and its contents.
defineTypeNameAndDebug(combustionModel, 0)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
dimensionSet cmptMag(const dimensionSet &)
prefixOSstream Pout(cout, "Pout")
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)