52 void Foam::polyMesh::calcDirections()
const
62 label nEmptyPatches = 0;
63 label nWedgePatches = 0;
79 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
85 wedgeDirVec +=
cmptMag(wpp.centreNormal());
90 reduce(nEmptyPatches, maxOp<label>());
91 reduce(nWedgePatches, maxOp<label>());
95 reduce(emptyDirVec, sumOp<vector>());
97 emptyDirVec /=
mag(emptyDirVec);
101 if (emptyDirVec[cmpt] > 1
e-6)
103 solutionD_[cmpt] = -1;
107 solutionD_[cmpt] = 1;
115 geometricD_ = solutionD_;
119 reduce(wedgeDirVec, sumOp<vector>());
121 wedgeDirVec /=
mag(wedgeDirVec);
125 if (wedgeDirVec[cmpt] > 1
e-6)
127 geometricD_[cmpt] = -1;
131 geometricD_[cmpt] = 1;
140 typeIOobject<labelIOList> io
156 return autoPtr<labelIOList>(
nullptr);
172 time().findInstance(meshDir(),
"points"),
184 time().findInstance(meshDir(),
"faces"),
215 clearedPrimitives_(false),
221 time().findInstance(meshDir(),
"boundary"),
233 tetBasePtIsPtr_(readTetBasePtIs()),
234 cellTreePtr_(nullptr),
289 globalMeshDataPtr_(nullptr),
290 curMotionTimeIndex_(-1),
291 oldPointsPtr_(nullptr),
292 oldCellCentresPtr_(nullptr),
293 storeOldCellCentres_(false),
327 boundary_.calcGeometry();
333 <<
"no points in mesh" <<
endl;
338 <<
"no cells in mesh" <<
endl;
410 clearedPrimitives_(false),
425 bounds_(points_, syncPar),
429 tetBasePtIsPtr_(readTetBasePtIs()),
430 cellTreePtr_(nullptr),
473 globalMeshDataPtr_(nullptr),
474 curMotionTimeIndex_(-1),
475 oldPointsPtr_(nullptr),
476 oldCellCentresPtr_(nullptr),
477 storeOldCellCentres_(false),
484 const face& curFace = faces_[facei];
486 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
489 <<
"Face " << facei <<
"contains vertex labels out of range: "
490 << curFace <<
" Max point index = " << points_.
size()
564 clearedPrimitives_(false),
579 bounds_(points_, syncPar),
583 tetBasePtIsPtr_(readTetBasePtIs()),
584 cellTreePtr_(nullptr),
627 globalMeshDataPtr_(nullptr),
628 curMotionTimeIndex_(-1),
629 oldPointsPtr_(nullptr),
630 oldCellCentresPtr_(nullptr),
631 storeOldCellCentres_(false),
638 const face& curFace = faces_[facei];
640 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
643 <<
"Face " << facei <<
"contains vertex labels out of range: "
644 << curFace <<
" Max point index = " << points_.
size()
655 const cell& curCell = cLst[celli];
657 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
660 <<
"Cell " << celli <<
"contains face labels out of range: "
661 << curCell <<
" Max face index = " << faces_.size()
675 points_(move(mesh.points_)),
676 faces_(move(mesh.faces_)),
677 owner_(move(mesh.owner_)),
678 neighbour_(move(mesh.neighbour_)),
679 clearedPrimitives_(mesh.clearedPrimitives_),
680 boundary_(move(mesh.boundary_)),
681 bounds_(move(mesh.bounds_)),
683 geometricD_(mesh.geometricD_),
684 solutionD_(mesh.solutionD_),
685 tetBasePtIsPtr_(move(mesh.tetBasePtIsPtr_)),
686 cellTreePtr_(move(mesh.cellTreePtr_)),
687 pointZones_(move(mesh.pointZones_)),
688 faceZones_(move(mesh.faceZones_)),
689 cellZones_(move(mesh.cellZones_)),
690 globalMeshDataPtr_(move(mesh.globalMeshDataPtr_)),
691 curMotionTimeIndex_(mesh.curMotionTimeIndex_),
692 oldPointsPtr_(move(mesh.oldPointsPtr_)),
693 oldCellCentresPtr_(move(mesh.oldCellCentresPtr_)),
694 storeOldCellCentres_(mesh.storeOldCellCentres_),
695 moving_(mesh.moving_),
696 topoChanged_(mesh.topoChanged_)
708 const bool validBoundary
712 clearAddressing(
true);
719 bounds_ =
boundBox(points_, validBoundary);
724 faces_ = move(faces);
729 owner_ = move(owner);
734 neighbour_ = move(neighbour);
753 setInstance(time().
name());
758 const face& curFace = faces_[facei];
760 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
763 <<
"Face " << facei <<
" contains vertex labels out of range: "
764 << curFace <<
" Max point index = " << points_.
size()
782 boundary_.topoChange();
785 boundary_.calcGeometry();
795 <<
"no points or no cells in mesh"
805 clearAddressing(
true);
809 points_.swap(otherMesh.points_);
811 faces_.swap(otherMesh.faces_);
812 owner_.swap(otherMesh.owner_);
813 neighbour_.swap(otherMesh.neighbour_);
816 boundary_.clearGeom();
817 boundary_.clearAddressing();
822 auto updatePatches = []
828 boundaryMesh.resize(otherPatches.
size());
830 forAll(otherPatches, otherPatchi)
836 if (isA<processorPolyPatch>(otherPatches[otherPatchi]))
841 otherPatches[otherPatchi].
clone(boundaryMesh)
848 boundaryMesh[otherPatchi],
851 otherPatches[otherPatchi].size(),
852 otherPatches[otherPatchi].start()
870 updatePatches(otherPatches, boundary_);
871 updatePatches(
patches, otherMesh.boundary_);
875 globalMeshDataPtr_.clear();
876 otherMesh.globalMeshDataPtr_.clear();
879 setInstance(time().
name());
883 auto checkFaces = [](
const polyMesh& mesh)
885 forAll(mesh.faces_, facei)
887 const face& curFace = mesh.faces_[facei];
889 if (
min(curFace) < 0 ||
max(curFace) > mesh.points_.size())
892 <<
"Face " << facei <<
" contains vertex labels out of "
893 <<
"range: " << curFace <<
" Max point index = "
900 checkFaces(otherMesh);
905 otherMesh.initMesh();
908 boundary_.topoChange();
912 boundary_.calcGeometry();
913 otherMesh.boundary_.calcGeometry();
916 if (foundObject<pointMesh>(pointMesh::typeName))
926 if (pointZones_.size() == otherMesh.pointZones_.
size())
928 pointZones_.clearAddressing();
933 pointZones_[i].swap(otherMesh.pointZones_[i]);
939 <<
"Number of pointZones in other mesh = "
940 << otherMesh.pointZones_.
size()
941 <<
" is not the same as in the mesh = "
942 << pointZones_.size()
947 if (faceZones_.size() == otherMesh.faceZones_.
size())
949 faceZones_.clearAddressing();
954 faceZones_[i].swap(otherMesh.faceZones_[i]);
960 <<
"Number of faceZones in other mesh = "
961 << otherMesh.faceZones_.
size()
962 <<
" is not the same as in the mesh = "
968 if (cellZones_.size() == otherMesh.cellZones_.
size())
970 cellZones_.clearAddressing();
975 cellZones_[i].swap(otherMesh.cellZones_[i]);
981 <<
"Number of cellZones in other mesh = "
982 << otherMesh.cellZones_.
size()
983 <<
" is not the same as in the mesh = "
1005 return parent().dbDir();
1016 return dbDir()/meshSubDir;
1022 return points_.instance();
1028 return faces_.instance();
1034 return points_.writeOpt();
1040 return faces_.writeOpt();
1046 if (geometricD_.x() == 0)
1063 if (solutionD_.x() == 0)
1080 if (tetBasePtIsPtr_.empty())
1085 <<
"Forcing storage of base points."
1089 tetBasePtIsPtr_.reset
1107 return tetBasePtIsPtr_();
1114 if (cellTreePtr_.empty())
1134 return cellTreePtr_();
1141 const bool validBoundary
1144 if (boundaryMesh().size())
1147 <<
"boundary already exists"
1155 boundary_.setSize(
p.
size());
1160 boundary_.set(pI,
p[pI]);
1167 globalMeshDataPtr_.clear();
1172 boundary_.topoChange();
1175 boundary_.calcGeometry();
1177 boundary_.checkDefinition();
1189 if (pointZones().size() || faceZones().size() || cellZones().size())
1192 <<
"point, face or cell zone already exists"
1199 pointZones_.setSize(pz.
size());
1204 pointZones_.set(pI, pz[pI]);
1213 faceZones_.setSize(fz.
size());
1218 faceZones_.set(fI, fz[fI]);
1227 cellZones_.setSize(cz.
size());
1232 cellZones_.set(cI, cz[cI]);
1243 const bool validBoundary
1248 boundary_.clearGeom();
1249 clearAddressing(
true);
1273 meshObjects::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1274 meshObjects::reorderPatches<pointMesh>(*
this, newToOld, validBoundary);
1280 const label insertPatchi,
1283 const word& defaultPatchFieldType,
1284 const bool validBoundary
1287 const label sz = boundary_.size();
1289 label startFacei = nFaces();
1290 if (insertPatchi < sz)
1292 startFacei = boundary_[insertPatchi].start();
1299 for (
label i = 0; i < insertPatchi; i++)
1303 for (
label i = insertPatchi; i < sz; i++)
1307 newToOld[insertPatchi] = -1;
1309 reorderPatches(newToOld,
false);
1313 boundary_.clearGeom();
1314 clearAddressing(
true);
1356 meshObjects::addPatch<polyMesh>(*
this, insertPatchi);
1357 meshObjects::addPatch<pointMesh>(*
this, insertPatchi);
1363 if (clearedPrimitives_)
1366 <<
"points deallocated"
1376 if (clearedPrimitives_)
1379 <<
"faces deallocated"
1406 if (oldPointsPtr_.empty())
1409 <<
"Old points have not been stored"
1413 return oldPointsPtr_();
1419 storeOldCellCentres_ =
true;
1423 return cellCentres();
1426 if (oldCellCentresPtr_.empty())
1429 <<
"Old cell centres have not been stored"
1433 return oldCellCentresPtr_();
1445 io.
eventNo() = points_.eventNo()+1;
1454 <<
"Set points for time " << time().value()
1455 <<
" index " << time().timeIndex() <<
endl;
1460 points_ = newPoints;
1462 setPointsInstance(time().
name());
1465 if (globalMeshDataPtr_.valid())
1467 globalMeshDataPtr_().movePoints(points_);
1473 boundary_.movePoints(points_);
1475 pointZones_.movePoints(points_);
1476 faceZones_.movePoints(points_);
1477 cellZones_.movePoints(points_);
1480 cellTreePtr_.clear();
1486 meshObjects::movePoints<polyMesh>(*
this);
1487 meshObjects::movePoints<pointMesh>(*
this);
1499 <<
"Moving points for time " << time().value()
1500 <<
" index " << time().timeIndex() <<
endl;
1504 if (curMotionTimeIndex_ != time().
timeIndex())
1506 oldPointsPtr_.clear();
1507 oldPointsPtr_.reset(
new pointField(points_));
1508 if (storeOldCellCentres_)
1510 oldCellCentresPtr_.clear();
1511 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1513 curMotionTimeIndex_ = time().timeIndex();
1516 points_ = newPoints;
1518 setPointsInstance(time().
name());
1527 if (globalMeshDataPtr_.valid())
1529 globalMeshDataPtr_().movePoints(points_);
1535 boundary_.movePoints(points_);
1537 pointZones_.movePoints(points_);
1538 faceZones_.movePoints(points_);
1539 cellZones_.movePoints(points_);
1542 cellTreePtr_.clear();
1548 meshObjects::movePoints<polyMesh>(*
this);
1549 meshObjects::movePoints<pointMesh>(*
this);
1557 curMotionTimeIndex_ = -1;
1558 oldPointsPtr_.clear();
1559 oldCellCentresPtr_.clear();
1565 if (globalMeshDataPtr_.empty())
1569 Pout<<
"polyMesh::globalData() const : "
1570 <<
"Constructing parallelData from processor topology"
1577 return globalMeshDataPtr_();
1595 fileName meshFilesPath = thisDb().time().
path()/instanceDir/meshDir();
1597 rm(meshFilesPath/
"points");
1598 rm(meshFilesPath/
"faces");
1599 rm(meshFilesPath/
"owner");
1600 rm(meshFilesPath/
"neighbour");
1601 rm(meshFilesPath/
"cells");
1602 rm(meshFilesPath/
"boundary");
1603 rm(meshFilesPath/
"pointZones");
1604 rm(meshFilesPath/
"faceZones");
1605 rm(meshFilesPath/
"cellZones");
1606 rm(meshFilesPath/
"meshModifiers");
1607 rm(meshFilesPath/
"parallelData");
1610 if (
isDir(meshFilesPath/
"sets"))
1612 rmDir(meshFilesPath/
"sets");
1619 removeFiles(instance());
1643 findTetFacePt(celli,
p, tetFacei, tetPti);
1659 tetFacei = tet.
face();
1660 tetPti = tet.
tetPt();
1679 case FACE_CENTRE_TRIS:
1687 label facei = cFaces[cFacei];
1688 const face&
f = faces_[facei];
1689 const point& fc = faceCentres()[facei];
1690 bool isOwn = (owner_[facei] == celli);
1700 nextPointi =
f.nextLabel(fp);
1704 pointi =
f.nextLabel(fp);
1717 if ((faceTri.
area() & proj) > 0)
1727 case FACE_DIAG_TRIS:
1735 label facei = cFaces[cFacei];
1736 const face&
f = faces_[facei];
1738 for (
label tetPti = 1; tetPti <
f.
size() - 1; tetPti++)
1747 if ((faceTri.
area() & proj) > 0)
1763 findTetFacePt(celli,
p, tetFacei, tetPti);
1765 return tetFacei != -1;
1783 && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS)
1792 (void)tetBasePtIs();
1800 if (decompMode == CELL_TETS)
1809 findCellFacePt(
p, celli, tetFacei, tetPti);
1819 label celli = findNearestCell(
p);
1822 if (pointInCell(
p, celli, decompMode))
1830 for (
label celli = 0; celli < nCells(); celli++)
1832 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 polyMesh &mesh)
label size() const
Return number of elements in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
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.
void clearAddressing()
Clear addressing.
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)=0
Reordered/removed trailing patches. If validBoundary call is parallel.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Inter-processor communications stream.
static bool & parRun()
Is this a parallel run?
label size() const
Return the number of elements in the UPtrList.
virtual void topoChange(const polyTopoChangeMap &map)=0
Update topology using the given map.
static const direction nComponents
Number of components in this vector space.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
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 subset of mesh faces organised as a primitive patch.
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.
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list.
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 meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
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.
static word defaultRegion
Return the default region name.
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.
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.
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)
word name(const complex &)
Return a string representation of a complex.