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;
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),
291 topoChanging_(false),
293 oldPointsPtr_(nullptr)
325 boundary_.calcGeometry();
331 <<
"no points in mesh" <<
endl;
336 <<
"no cells in mesh" <<
endl;
344 Foam::polyMesh::polyMesh
408 clearedPrimitives_(
false),
423 bounds_(points_, syncPar),
427 tetBasePtIsPtr_(readTetBasePtIs()),
428 cellTreePtr_(
nullptr),
471 globalMeshDataPtr_(
nullptr),
473 topoChanging_(
false),
475 oldPointsPtr_(
nullptr)
480 const face& curFace = faces_[facei];
482 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
485 <<
"Face " << facei <<
"contains vertex labels out of range: " 486 << curFace <<
" Max point index = " << points_.
size()
496 Foam::polyMesh::polyMesh
559 clearedPrimitives_(
false),
574 bounds_(points_, syncPar),
578 tetBasePtIsPtr_(readTetBasePtIs()),
579 cellTreePtr_(
nullptr),
622 globalMeshDataPtr_(
nullptr),
624 topoChanging_(
false),
626 oldPointsPtr_(
nullptr)
631 const face& curFace = faces_[facei];
633 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
636 <<
"Face " << facei <<
"contains vertex labels out of range: " 637 << curFace <<
" Max point index = " << points_.
size()
648 const cell& curCell = cLst[celli];
650 if (
min(curCell) < 0 ||
max(curCell) > faces_.
size())
653 <<
"Cell " << celli <<
"contains face labels out of range: " 654 << curCell <<
" Max face index = " << faces_.
size()
672 const bool validBoundary
683 bounds_ =
boundBox(points_, validBoundary);
722 const face& curFace = faces_[facei];
724 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
727 <<
"Face " << facei <<
" contains vertex labels out of range: " 728 << curFace <<
" Max point index = " << points_.
size()
749 boundary_.calcGeometry();
759 <<
"no points or no cells in mesh" <<
endl;
809 if (geometricD_.
x() == 0)
826 if (solutionD_.
x() == 0)
843 if (tetBasePtIsPtr_.empty())
848 <<
"Forcing storage of base points." 852 tetBasePtIsPtr_.reset
870 return tetBasePtIsPtr_();
877 if (cellTreePtr_.empty())
897 return cellTreePtr_();
904 const bool validBoundary
910 <<
"boundary already exists" 923 boundary_.
set(pI, p[pI]);
930 globalMeshDataPtr_.clear();
938 boundary_.calcGeometry();
955 <<
"point, face or cell zone already exists" 967 pointZones_.
set(pI, pz[pI]);
981 faceZones_.
set(fI, fz[fI]);
995 cellZones_.
set(cI, cz[cI]);
1005 if (clearedPrimitives_)
1008 <<
"points deallocated" 1030 if (clearedPrimitives_)
1033 <<
"faces deallocated" 1055 if (oldPointsPtr_.empty())
1063 oldPointsPtr_.reset(
new pointField(points_));
1067 return oldPointsPtr_();
1079 <<
"Moving points for time " <<
time().
value()
1089 oldPointsPtr_.clear();
1090 oldPointsPtr_.reset(
new pointField(points_));
1094 points_ = newPoints;
1096 bool moveError =
false;
1105 <<
"Moving the mesh with given points will " 1106 <<
"invalidate the mesh." <<
nl 1107 <<
"Mesh motion should not be executed." <<
endl;
1115 if (tetBasePtIsPtr_.valid())
1119 tetBasePtIsPtr_().eventNo() =
getEvent();
1129 if (globalMeshDataPtr_.valid())
1131 globalMeshDataPtr_().movePoints(points_);
1144 cellTreePtr_.clear();
1150 meshObject::movePoints<polyMesh>(*this);
1151 meshObject::movePoints<pointMesh>(*this);
1153 const_cast<Time&
>(
time()).functionObjects().movePoints(*
this);
1156 if (debug && moveError)
1169 curMotionTimeIndex_ = 0;
1170 oldPointsPtr_.clear();
1176 if (globalMeshDataPtr_.empty())
1180 Pout<<
"polyMesh::globalData() const : " 1181 <<
"Constructing parallelData from processor topology" 1188 return globalMeshDataPtr_();
1208 rm(meshFilesPath/
"points");
1209 rm(meshFilesPath/
"faces");
1210 rm(meshFilesPath/
"owner");
1211 rm(meshFilesPath/
"neighbour");
1212 rm(meshFilesPath/
"cells");
1213 rm(meshFilesPath/
"boundary");
1214 rm(meshFilesPath/
"pointZones");
1215 rm(meshFilesPath/
"faceZones");
1216 rm(meshFilesPath/
"cellZones");
1217 rm(meshFilesPath/
"meshModifiers");
1218 rm(meshFilesPath/
"parallelData");
1221 if (
isDir(meshFilesPath/
"sets"))
1223 rmDir(meshFilesPath/
"sets");
1270 tetFacei = tet.
face();
1271 tetPti = tet.
tetPt();
1298 label facei = cFaces[cFacei];
1299 const face&
f = faces_[facei];
1301 bool isOwn = (owner_[facei] == celli);
1328 if ((faceTri.
area() & proj) > 0)
1346 label facei = cFaces[cFacei];
1347 const face&
f = faces_[facei];
1349 for (
label tetPti = 1; tetPti < f.
size() - 1; tetPti++)
1358 if ((faceTri.
area() & proj) > 0)
1376 return tetFacei != -1;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
A simple container for copying or transferring objects of type <T>.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
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.
fileName path() const
Return path.
A triangle primitive used to calculate face areas and swept volumes.
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 typeHeaderOk(const bool checkType=true)
Read header (uses typeFilePath to find file) and check header.
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.
const faceZoneMesh & faceZones() const
Return face zone mesh.
bool moving() const
Is mesh moving.
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
virtual 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)
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.
primitiveMesh()
Construct null.
A bounding box defined in terms of the points at its extremities.
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.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
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.
cellDecomposition
Enumeration defining the decomposition of the cell for.
void movePoints(const pointField &)
Correct zone mesh after moving points.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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)
virtual const pointField & points() const
Return raw points.
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.
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.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
void removeFiles() const
Remove all files from mesh instance()
void movePoints(const pointField &)
Correct polyBoundaryMesh after moving points.
void resetPrimitives(const Xfer< pointField > &points, const Xfer< faceList > &faces, const Xfer< labelList > &owner, const Xfer< labelList > &neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
const pointZoneMesh & pointZones() const
Return point zone mesh.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
const cellZoneMesh & cellZones() const
Return cell zone mesh.
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.
label getEvent() const
Return new event number.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
virtual const labelList & faceOwner() const
Return face owner.
const Type & value() const
Return const reference to value.
Point centre() const
Return centre (centroid)
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.
errorManip< error > abort(error &err)
void addPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches.
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.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
void updateMesh()
Correct polyBoundaryMesh after topology update.
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
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...
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
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.
virtual bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
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?
const fileName & instance() const
label timeIndex() const
Return current time index.
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
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 > &)
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.
Mesh consisting of general polyhedral cells.
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 bool write(const bool valid=true) const
Write using setting from DB.
readOption readOpt() const
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...
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
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.
#define InfoInFunction
Report an information message using Foam::Info.