56 return io.db().dbDir()/io.local();
60 return io.db().dbDir()/io.local()/io.
name();
65 void Foam::polyMesh::calcDirections()
const
75 label nEmptyPatches = 0;
76 label nWedgePatches = 0;
83 if (boundaryMesh()[
patchi].size())
85 if (isA<emptyPolyPatch>(boundaryMesh()[
patchi]))
90 else if (isA<wedgePolyPatch>(boundaryMesh()[
patchi]))
92 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
98 wedgeDirVec +=
cmptMag(wpp.centreNormal());
103 reduce(nEmptyPatches, maxOp<label>());
104 reduce(nWedgePatches, maxOp<label>());
108 reduce(emptyDirVec, sumOp<vector>());
110 emptyDirVec /=
mag(emptyDirVec);
114 if (emptyDirVec[cmpt] > 1
e-6)
116 solutionD_[cmpt] = -1;
120 solutionD_[cmpt] = 1;
128 geometricD_ = solutionD_;
132 reduce(wedgeDirVec, sumOp<vector>());
134 wedgeDirVec /=
mag(wedgeDirVec);
138 if (wedgeDirVec[cmpt] > 1
e-6)
140 geometricD_[cmpt] = -1;
144 geometricD_[cmpt] = 1;
153 typeIOobject<labelIOList> io
169 return autoPtr<labelIOList>(
nullptr);
185 time().findInstance(meshDir(),
"points"),
197 time().findInstance(meshDir(),
"faces"),
228 clearedPrimitives_(false),
246 tetBasePtIsPtr_(readTetBasePtIs()),
247 cellTreePtr_(nullptr),
305 globalMeshDataPtr_(nullptr),
306 curMotionTimeIndex_(-1),
307 oldPointsPtr_(nullptr),
308 oldCellCentresPtr_(nullptr),
309 storeOldCellCentres_(false),
343 boundary_.calcGeometry();
350 <<
"no points in mesh" <<
endl;
355 <<
"no cells in mesh" <<
endl;
432 clearedPrimitives_(false),
447 bounds_(points_, syncPar),
451 tetBasePtIsPtr_(readTetBasePtIs()),
452 cellTreePtr_(nullptr),
492 globalMeshDataPtr_(nullptr),
493 curMotionTimeIndex_(-1),
494 oldPointsPtr_(nullptr),
495 oldCellCentresPtr_(nullptr),
496 storeOldCellCentres_(false),
503 const face& curFace = faces_[facei];
505 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
508 <<
"Face " << facei <<
"contains vertex labels out of range: "
509 << curFace <<
" Max point index = " << points_.
size()
582 clearedPrimitives_(false),
597 bounds_(points_, syncPar),
601 tetBasePtIsPtr_(readTetBasePtIs()),
602 cellTreePtr_(nullptr),
642 globalMeshDataPtr_(nullptr),
643 curMotionTimeIndex_(-1),
644 oldPointsPtr_(nullptr),
645 oldCellCentresPtr_(nullptr),
646 storeOldCellCentres_(false),
653 const face& curFace = faces_[facei];
655 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
658 <<
"Face " << facei <<
"contains vertex labels out of range: "
659 << curFace <<
" Max point index = " << points_.
size()
670 const cell& curCell = cLst[celli];
672 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
675 <<
"Cell " << celli <<
"contains face labels out of range: "
676 << curCell <<
" Max face index = " << faces_.size()
690 points_(move(
mesh.points_)),
691 faces_(move(
mesh.faces_)),
692 owner_(move(
mesh.owner_)),
693 neighbour_(move(
mesh.neighbour_)),
694 clearedPrimitives_(
mesh.clearedPrimitives_),
695 boundary_(move(
mesh.boundary_)),
696 bounds_(move(
mesh.bounds_)),
698 geometricD_(
mesh.geometricD_),
699 solutionD_(
mesh.solutionD_),
700 tetBasePtIsPtr_(move(
mesh.tetBasePtIsPtr_)),
701 cellTreePtr_(move(
mesh.cellTreePtr_)),
702 pointZones_(move(
mesh.pointZones_)),
703 faceZones_(move(
mesh.faceZones_)),
704 cellZones_(move(
mesh.cellZones_)),
705 globalMeshDataPtr_(move(
mesh.globalMeshDataPtr_)),
706 curMotionTimeIndex_(
mesh.curMotionTimeIndex_),
707 oldPointsPtr_(move(
mesh.oldPointsPtr_)),
708 oldCellCentresPtr_(move(
mesh.oldCellCentresPtr_)),
709 storeOldCellCentres_(
mesh.storeOldCellCentres_),
710 moving_(
mesh.moving_),
711 topoChanged_(
mesh.topoChanged_)
723 const bool validBoundary
727 clearAddressing(
true);
734 bounds_ =
boundBox(points_, validBoundary);
739 faces_ = move(faces);
744 owner_ = move(owner);
749 neighbour_ = move(neighbour);
768 setInstance(time().
name());
773 const face& curFace = faces_[facei];
775 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
778 <<
"Face " << facei <<
" contains vertex labels out of range: "
779 << curFace <<
" Max point index = " << points_.
size()
797 boundary_.topoChange();
800 boundary_.calcGeometry();
810 <<
"no points or no cells in mesh"
820 clearAddressing(
true);
824 points_.swap(otherMesh.points_);
826 faces_.swap(otherMesh.faces_);
827 owner_.swap(otherMesh.owner_);
828 neighbour_.swap(otherMesh.neighbour_);
831 boundary_.clearGeom();
832 boundary_.clearAddressing();
837 auto updatePatches = []
843 boundaryMesh.resize(otherPatches.
size());
845 forAll(otherPatches, otherPatchi)
851 if (isA<processorPolyPatch>(otherPatches[otherPatchi]))
856 otherPatches[otherPatchi].
clone(boundaryMesh)
863 boundaryMesh[otherPatchi],
866 otherPatches[otherPatchi].size(),
867 otherPatches[otherPatchi].start()
885 updatePatches(otherPatches, boundary_);
886 updatePatches(
patches, otherMesh.boundary_);
890 globalMeshDataPtr_.clear();
891 otherMesh.globalMeshDataPtr_.clear();
894 setInstance(time().
name());
902 const face& curFace =
mesh.faces_[facei];
907 <<
"Face " << facei <<
" contains vertex labels out of "
908 <<
"range: " << curFace <<
" Max point index = "
915 checkFaces(otherMesh);
920 otherMesh.initMesh();
923 boundary_.topoChange();
927 boundary_.calcGeometry();
928 otherMesh.boundary_.calcGeometry();
931 if (foundObject<pointMesh>(pointMesh::typeName))
942 pointZones_.swap(otherMesh.pointZones_);
943 faceZones_.swap(otherMesh.faceZones_);
944 cellZones_.swap(otherMesh.cellZones_);
984 return dbDir()/meshSubDir;
990 return points_.instance();
996 return faces_.instance();
1002 return points_.writeOpt();
1008 return faces_.writeOpt();
1014 if (geometricD_.x() == 0)
1031 if (solutionD_.x() == 0)
1048 if (tetBasePtIsPtr_.empty())
1053 <<
"Forcing storage of base points."
1057 tetBasePtIsPtr_.reset
1075 return tetBasePtIsPtr_();
1082 if (cellTreePtr_.empty())
1102 return cellTreePtr_();
1109 const bool validBoundary
1112 if (boundaryMesh().size())
1115 <<
"boundary already exists"
1123 boundary_.setSize(
p.size());
1128 boundary_.set(pI,
p[pI]);
1135 globalMeshDataPtr_.clear();
1151 if (pointZones().size() || faceZones().size() || cellZones().size())
1154 <<
"point, face or cell zone already exists"
1161 pointZones_.setSize(pz.
size());
1166 pointZones_.set(pI, pz[pI]->
name(), pz[pI]);
1175 faceZones_.setSize(fz.
size());
1180 faceZones_.set(fI, fz[fI]->
name(), fz[fI]);
1189 cellZones_.setSize(cz.
size());
1194 cellZones_.set(cI, cz[cI]->
name(), cz[cI]);
1205 const bool validBoundary
1209 boundary_.clearGeom();
1210 clearAddressing(
true);
1235 setInstance(time().
name());
1237 boundary_.reorderPatches(newToOld, validBoundary);
1240 meshObjects::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1241 meshObjects::reorderPatches<pointMesh>(*
this, newToOld, validBoundary);
1247 const label insertPatchi,
1251 const label sz = boundary_.size();
1253 label startFacei = nFaces();
1254 if (insertPatchi < sz)
1256 startFacei = boundary_[insertPatchi].start();
1263 for (
label i = 0; i < insertPatchi; i++)
1267 for (
label i = insertPatchi; i < sz; i++)
1271 newToOld[insertPatchi] = -1;
1274 reorderPatches(newToOld,
false);
1277 boundary_.clearGeom();
1278 clearAddressing(
true);
1314 meshObjects::addPatch<polyMesh>(*
this, insertPatchi);
1315 meshObjects::addPatch<pointMesh>(*
this, insertPatchi);
1322 boundary_.topoChange();
1325 boundary_.calcGeometry();
1327 boundary_.checkDefinition();
1333 if (clearedPrimitives_)
1336 <<
"points deallocated"
1346 if (clearedPrimitives_)
1349 <<
"faces deallocated"
1376 if (oldPointsPtr_.empty())
1379 <<
"Old points have not been stored"
1383 return oldPointsPtr_();
1389 storeOldCellCentres_ =
true;
1393 return cellCentres();
1396 if (oldCellCentresPtr_.empty())
1399 <<
"Old cell centres have not been stored"
1403 return oldCellCentresPtr_();
1412 <<
"Set points for time " << time().value()
1413 <<
" index " << time().timeIndex() <<
endl;
1418 points_ = newPoints;
1420 setPointsInstance(time().
name());
1423 if (globalMeshDataPtr_.valid())
1425 globalMeshDataPtr_().movePoints(points_);
1431 boundary_.movePoints(points_);
1433 pointZones_.movePoints(points_);
1434 faceZones_.movePoints(points_);
1435 cellZones_.movePoints(points_);
1438 cellTreePtr_.clear();
1444 meshObjects::movePoints<polyMesh>(*
this);
1445 meshObjects::movePoints<pointMesh>(*
this);
1457 <<
"Moving points for time " << time().value()
1458 <<
" index " << time().timeIndex() <<
endl;
1462 if (curMotionTimeIndex_ != time().
timeIndex())
1464 oldPointsPtr_.clear();
1465 oldPointsPtr_.reset(
new pointField(points_));
1466 if (storeOldCellCentres_)
1468 oldCellCentresPtr_.clear();
1469 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1471 curMotionTimeIndex_ = time().timeIndex();
1474 points_ = newPoints;
1476 setPointsInstance(time().
name());
1485 if (globalMeshDataPtr_.valid())
1487 globalMeshDataPtr_().movePoints(points_);
1493 boundary_.movePoints(points_);
1495 pointZones_.movePoints(points_);
1496 faceZones_.movePoints(points_);
1497 cellZones_.movePoints(points_);
1500 cellTreePtr_.clear();
1506 meshObjects::movePoints<polyMesh>(*
this);
1507 meshObjects::movePoints<pointMesh>(*
this);
1515 curMotionTimeIndex_ = -1;
1516 oldPointsPtr_.clear();
1517 oldCellCentresPtr_.clear();
1523 if (globalMeshDataPtr_.empty())
1527 Pout<<
"polyMesh::globalData() const : "
1528 <<
"Constructing parallelData from processor topology"
1535 return globalMeshDataPtr_();
1553 fileName meshFilesPath = thisDb().time().
path()/instanceDir/meshDir();
1555 rm(meshFilesPath/
"points");
1556 rm(meshFilesPath/
"faces");
1557 rm(meshFilesPath/
"owner");
1558 rm(meshFilesPath/
"neighbour");
1559 rm(meshFilesPath/
"cells");
1560 rm(meshFilesPath/
"boundary");
1561 rm(meshFilesPath/
"pointZones");
1562 rm(meshFilesPath/
"faceZones");
1563 rm(meshFilesPath/
"cellZones");
1564 rm(meshFilesPath/
"meshModifiers");
1565 rm(meshFilesPath/
"parallelData");
1568 if (
isDir(meshFilesPath/
"sets"))
1570 rmDir(meshFilesPath/
"sets");
1577 removeFiles(instance());
1601 findTetFacePt(celli,
p, tetFacei, tetPti);
1617 tetFacei = tet.
face();
1618 tetPti = tet.
tetPt();
1637 case FACE_CENTRE_TRIS:
1645 label facei = cFaces[cFacei];
1646 const face&
f = faces_[facei];
1647 const point& fc = faceCentres()[facei];
1648 bool isOwn = (owner_[facei] == celli);
1658 nextPointi =
f.nextLabel(fp);
1662 pointi =
f.nextLabel(fp);
1675 if ((faceTri.
area() & proj) > 0)
1685 case FACE_DIAG_TRIS:
1693 label facei = cFaces[cFacei];
1694 const face&
f = faces_[facei];
1696 for (
label tetPti = 1; tetPti <
f.
size() - 1; tetPti++)
1705 if ((faceTri.
area() & proj) > 0)
1721 findTetFacePt(celli,
p, tetFacei, tetPti);
1723 return tetFacei != -1;
1741 && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS)
1750 (void)tetBasePtIs();
1758 if (decompMode == CELL_TETS)
1767 findCellFacePt(
p, celli, tetFacei, tetPti);
1777 label celli = findNearestCell(
p);
1780 if (pointInCell(
p, celli, decompMode))
1788 for (
label celli = 0; celli < nCells(); celli++)
1790 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...
const fileName & local() const
const Time & time() const
Return time.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const word & headerClassName() const
Return name of the class name read from header.
const word & name() const
Return name.
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.
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.
const Type & value() const
Return const reference to value.
const word & name() const
Return const reference to name.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
word name() const
Return file name (part beyond last /)
fileName path() const
Return directory path name (part before last /)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a directory in the file system?
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.
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.
cellDecomposition
Enumeration defining the decomposition of the cell for.
IOobject::writeOption facesWriteOpt() const
Return the points write option.
static bool found(const IOobject &io)
Return whether the given IOobject relates to a mesh on disk.
virtual const faceList & faces() const
Return raw faces.
void addedPatches()
Complete addition of single patches.
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.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
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.
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 addPatch(const label insertPatchi, const polyPatch &patch)
Add/insert single patch.
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 cellList & cells() const
virtual bool write(const bool write=true) const
Write using setting from DB.
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 pointField &meshPoints) 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.
static const word null
An empty word.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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.
const fileOperation & fileHandler()
Get current file handler.
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.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
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)
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?
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void cmptMag(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)