52 void Foam::polyMesh::calcDirections()
const 62 label nEmptyPatches = 0;
63 label nWedgePatches = 0;
70 if (boundaryMesh()[
patchi].size())
72 if (isA<emptyPolyPatch>(boundaryMesh()[
patchi]))
77 else if (isA<wedgePolyPatch>(boundaryMesh()[
patchi]))
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()
679 const bool validBoundary
690 bounds_ =
boundBox(points_, validBoundary);
695 faces_ = move(
faces);
700 owner_ = move(owner);
705 neighbour_ = move(neighbour);
729 const face& curFace = faces_[facei];
731 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
734 <<
"Face " << facei <<
" contains vertex labels out of range: " 735 << curFace <<
" Max point index = " << points_.
size()
756 boundary_.calcGeometry();
766 <<
"no points or no cells in mesh" <<
endl;
777 points_ = newMesh.
points();
779 faces_ = newMesh.
faces();
815 globalMeshDataPtr_.clear();
823 const face& curFace = faces_[facei];
825 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
828 <<
"Face " << facei <<
" contains vertex labels out of range: " 829 << curFace <<
" Max point index = " << points_.
size()
842 boundary_.calcGeometry();
845 if (foundObject<pointMesh>(pointMesh::typeName))
896 if (geometricD_.x() == 0)
913 if (solutionD_.x() == 0)
930 if (tetBasePtIsPtr_.empty())
935 <<
"Forcing storage of base points." 939 tetBasePtIsPtr_.reset
957 return tetBasePtIsPtr_();
964 if (cellTreePtr_.empty())
984 return cellTreePtr_();
991 const bool validBoundary
997 <<
"boundary already exists" 1010 boundary_.
set(pI, p[pI]);
1017 globalMeshDataPtr_.clear();
1025 boundary_.calcGeometry();
1042 <<
"point, face or cell zone already exists" 1054 pointZones_.
set(pI, pz[pI]);
1068 faceZones_.
set(fI, fz[fI]);
1082 cellZones_.
set(cI, cz[cI]);
1093 const bool validBoundary
1113 TopologicalMeshObject,
1123 meshObject::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1124 meshObject::reorderPatches<pointMesh>(*
this, newToOld, validBoundary);
1130 const label insertPatchi,
1133 const word& defaultPatchFieldType,
1134 const bool validBoundary
1140 if (insertPatchi < sz)
1142 startFacei = boundary_[insertPatchi].start();
1149 for (
label i = 0; i < insertPatchi; i++)
1153 for (
label i = insertPatchi; i < sz; i++)
1157 newToOld[insertPatchi] = -1;
1179 TopologicalMeshObject,
1206 meshObject::addPatch<polyMesh>(*
this, insertPatchi);
1207 meshObject::addPatch<pointMesh>(*
this, insertPatchi);
1213 if (clearedPrimitives_)
1216 <<
"points deallocated" 1226 if (clearedPrimitives_)
1229 <<
"faces deallocated" 1256 if (oldPointsPtr_.empty())
1259 <<
"Old points have not been stored" 1263 return oldPointsPtr_();
1269 storeOldCellCentres_ =
true;
1276 if (oldCellCentresPtr_.empty())
1279 <<
"Old cell centres have not been stored" 1283 return oldCellCentresPtr_();
1304 <<
"Set points for time " <<
time().
value()
1310 points_ = newPoints;
1315 if (globalMeshDataPtr_.valid())
1317 globalMeshDataPtr_().movePoints(points_);
1330 cellTreePtr_.clear();
1336 meshObject::movePoints<polyMesh>(*this);
1337 meshObject::movePoints<pointMesh>(*this);
1349 <<
"Moving points for time " <<
time().
value()
1356 oldPointsPtr_.clear();
1357 oldPointsPtr_.reset(
new pointField(points_));
1358 if (storeOldCellCentres_)
1360 oldCellCentresPtr_.clear();
1366 points_ = newPoints;
1368 bool moveError =
false;
1377 <<
"Moving the mesh with given points will " 1378 <<
"invalidate the mesh." <<
nl 1379 <<
"Mesh motion should not be executed." <<
endl;
1392 if (globalMeshDataPtr_.valid())
1394 globalMeshDataPtr_().movePoints(points_);
1407 cellTreePtr_.clear();
1413 meshObject::movePoints<polyMesh>(*this);
1414 meshObject::movePoints<pointMesh>(*this);
1416 if (debug && moveError)
1429 curMotionTimeIndex_ = -1;
1430 oldPointsPtr_.clear();
1431 oldCellCentresPtr_.clear();
1437 if (globalMeshDataPtr_.empty())
1441 Pout<<
"polyMesh::globalData() const : " 1442 <<
"Constructing parallelData from processor topology" 1449 return globalMeshDataPtr_();
1469 rm(meshFilesPath/
"points");
1470 rm(meshFilesPath/
"faces");
1471 rm(meshFilesPath/
"owner");
1472 rm(meshFilesPath/
"neighbour");
1473 rm(meshFilesPath/
"cells");
1474 rm(meshFilesPath/
"boundary");
1475 rm(meshFilesPath/
"pointZones");
1476 rm(meshFilesPath/
"faceZones");
1477 rm(meshFilesPath/
"cellZones");
1478 rm(meshFilesPath/
"meshModifiers");
1479 rm(meshFilesPath/
"parallelData");
1482 if (
isDir(meshFilesPath/
"sets"))
1484 rmDir(meshFilesPath/
"sets");
1531 tetFacei = tet.
face();
1532 tetPti = tet.
tetPt();
1559 label facei = cFaces[cFacei];
1560 const face&
f = faces_[facei];
1562 bool isOwn = (owner_[facei] == celli);
1589 if ((faceTri.
area() & proj) > 0)
1607 label facei = cFaces[cFacei];
1608 const face&
f = faces_[facei];
1610 for (
label tetPti = 1; tetPti < f.
size() - 1; tetPti++)
1619 if ((faceTri.
area() & proj) > 0)
1637 return tetFacei != -1;
const fvPatchList & patches
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
bool moving_
Member data pending transfer to fvMesh.
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorder and trim existing patches. If validBoundary the new.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
autoPtr< IOobject > clone() const
Clone.
label tetPt() const
Return the characterising tetPtI.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
#define forAll(list, i)
Loop across all elements in list.
void clearAddressing()
Clear topological data.
A triangle primitive used to calculate face areas and swept volumes.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
static labelList findFaceBasePts(const polyMesh &mesh, scalar tol=minTetQuality, bool report=false)
Find a suitable base point for each face for decomposition.
bool set(const label) const
Is element set.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
const meshCellZones & cellZones() const
Return cell zones.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
Cell-face mesh analysis engine.
void resetMotion() const
Reset motion.
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the face for.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
void size(const label)
Override size to be inconsistent with allocated storage.
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void reset(const polyMesh &)
Reset mesh.
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label nextLabel(const label i) const
Next vertex on face.
void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorders the patches. Ordering does not have to be done in.
primitiveMesh()
Construct null.
void clearGeom()
Clear geometry at this level and at patches.
A bounding box defined in terms of the points at its extremities.
void setPointsInstance(const fileName &)
Set the instance for the points files.
const cellList & cells() const
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
const objectRegistry & parent() const
Return the parent objectRegistry.
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
Vector< scalar > vector
A scalar version of the templated Vector.
static label worldComm
Default communicator (all processors)
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
void movePoints(const pointField &)
Correct zones after moving points.
cellDecomposition
Enumeration defining the decomposition of the cell for.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
label size() const
Return number of elements in table.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const meshPointZones & pointZones() const
Return point zones.
virtual const pointField & points() const
Return raw points.
Mesh representing a set of points created from polyMesh.
vector area() const
Return vector area.
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
objectRegistry(const Time &db, const label nIoObjects=128)
Construct the time objectRegistry given an initial estimate.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
void reset()
Reset pointMesh with respect to the updated polyMesh.
bool topoChanged_
Is the mesh topology changing.
static const direction nComponents
Number of components in this vector space.
vectorField pointField
pointField is a vectorField.
const fileName & pointsInstance() const
Return the current instance directory for points.
void clearGeom()
Clear geometry.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
void topoChange()
Correct polyBoundaryMesh after topology update.
void removeFiles() const
Remove all files from mesh instance()
void movePoints(const pointField &)
Correct polyBoundaryMesh after moving points.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
bool checkDefinition(const bool report=false) const
Check boundary definition. Return true if in error.
static void clearUpto(objectRegistry &)
Clear all meshObject derived from FromType up to (but not including)
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.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
dimensionSet cmptMag(const dimensionSet &)
virtual const labelList & faceOwner() const
Return face owner.
const Type & value() const
Return const reference to value.
Point centre() const
Return centre (centroid)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
label eventNo() const
Event number at last update.
const globalMeshData & globalData() const
Return parallel info.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
virtual const faceList & faces() const
Return raw faces.
label comm() const
Return communicator used for parallel communication.
void addZones(const List< pointZone *> &pz, const List< faceZone *> &fz, const List< cellZone *> &cz)
Add mesh zones.
const vectorField & cellCentres() const
errorManip< error > abort(error &err)
void addPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label face() const
Return the face.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
bool rmDir(const fileName &)
Remove a directory and its contents.
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
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.
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
static pointMesh & New(polyMesh &mesh)
A List of objects of type <T> with automated input and output using a compact storage. Behaves like IOList except when binary output in case it writes a CompactListList.
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void setInstance(const fileName &)
Set the instance for mesh files.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
label size() const
Return the number of elements in the UPtrList.
const vectorField & faceCentres() const
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
writeOption writeOpt() const
static bool & parRun()
Is this a parallel run?
label timeIndex() const
Return current time index.
virtual const pointField & oldCellCentres() const
Return old cell centres for mesh motion.
#define WarningInFunction
Report a warning using Foam::Warning.
void clearAddressing()
Clear addressing at this level and at patches.
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
label findNearestCell(const point &location) const
Find the cell with the nearest cell centre to location.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
virtual ~polyMesh()
Destructor.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Standard boundBox + extra functionality for use in octree.
dimensioned< scalar > mag(const dimensioned< Type > &)
bool headerOk()
Read header of local object without type-checking.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const objectRegistry & thisDb() const
Return the object registry.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const doubleScalar e
Elementary charge.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
Mesh consisting of general polyhedral cells.
virtual bool write(const bool write=true) const
Write using setting from DB.
A class for managing temporary objects.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
virtual void setPoints(const pointField &)
Reset the points.
readOption readOpt() const
fileName path() const
Return path.
const word & headerClassName() const
Return name of the class name read from header.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Inter-processor communications stream.
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
IOList< label > labelIOList
Label container classes.
polyMesh(const IOobject &io)
Construct from IOobject.
#define InfoInFunction
Report an information message using Foam::Info.