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;
149 time().findInstance(meshDir(),
"points"),
161 time().findInstance(meshDir(),
"faces"),
192 clearedPrimitives_(false),
198 time().findInstance(meshDir(),
"boundary"),
210 tetBasePtIsPtr_(NULL),
266 globalMeshDataPtr_(NULL),
268 topoChanging_(false),
302 boundary_.calcGeometry();
308 <<
"no points in mesh" <<
endl;
313 <<
"no cells in mesh" <<
endl;
321 Foam::polyMesh::polyMesh
385 clearedPrimitives_(
false),
400 bounds_(points_, syncPar),
404 tetBasePtIsPtr_(NULL),
448 globalMeshDataPtr_(NULL),
450 topoChanging_(
false),
457 const face& curFace = faces_[facei];
459 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
463 "polyMesh::polyMesh\n" 465 " const IOobject& io,\n" 466 " const pointField& points,\n" 467 " const faceList& faces,\n" 468 " const cellList& cells\n" 470 ) <<
"Face " << facei <<
"contains vertex labels out of range: " 471 << curFace <<
" Max point index = " << points_.
size()
481 Foam::polyMesh::polyMesh
544 clearedPrimitives_(
false),
559 bounds_(points_, syncPar),
563 tetBasePtIsPtr_(NULL),
607 globalMeshDataPtr_(NULL),
609 topoChanging_(
false),
616 const face& curFace = faces_[facei];
618 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
622 "polyMesh::polyMesh\n" 624 " const IOobject&,\n" 625 " const Xfer<pointField>&,\n" 626 " const Xfer<faceList>&,\n" 627 " const Xfer<cellList>&\n" 629 ) <<
"Face " << facei <<
"contains vertex labels out of range: " 630 << curFace <<
" Max point index = " << points_.
size()
641 const cell& curCell = cLst[celli];
643 if (
min(curCell) < 0 ||
max(curCell) > faces_.
size())
647 "polyMesh::polyMesh\n" 649 " const IOobject&,\n" 650 " const Xfer<pointField>&,\n" 651 " const Xfer<faceList>&,\n" 652 " const Xfer<cellList>&\n" 654 ) <<
"Cell " << celli <<
"contains face labels out of range: " 655 << curCell <<
" Max face index = " << faces_.
size()
673 const bool validBoundary
684 bounds_ =
boundBox(points_, validBoundary);
723 const face& curFace = faces_[facei];
725 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
729 "polyMesh::polyMesh::resetPrimitives\n" 731 " const Xfer<pointField>&,\n" 732 " const Xfer<faceList>&,\n" 733 " const Xfer<labelList>& owner,\n" 734 " const Xfer<labelList>& neighbour,\n" 735 " const labelList& patchSizes,\n" 736 " const labelList& patchStarts\n" 737 " const bool validBoundary\n" 739 ) <<
"Face " << facei <<
" contains vertex labels out of range: " 740 << curFace <<
" Max point index = " << points_.
size()
761 boundary_.calcGeometry();
772 "polyMesh::polyMesh::resetPrimitives\n" 774 " const Xfer<pointField>&,\n" 775 " const Xfer<faceList>&,\n" 776 " const Xfer<labelList>& owner,\n" 777 " const Xfer<labelList>& neighbour,\n" 778 " const labelList& patchSizes,\n" 779 " const labelList& patchStarts\n" 780 " const bool validBoundary\n" 782 ) <<
"no points or no cells in mesh" <<
endl;
832 if (geometricD_.
x() == 0)
849 if (solutionD_.
x() == 0)
866 if (tetBasePtIsPtr_.empty())
870 WarningIn(
"const labelList& polyMesh::tetBasePtIs() const")
871 <<
"Tet base point indices not available. " 872 <<
"Forcing storage of base points." 876 tetBasePtIsPtr_.reset
885 return tetBasePtIsPtr_();
892 if (cellTreePtr_.empty())
898 overallBb = overallBb.
extend(rndGen, 1
e-4);
899 overallBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
900 overallBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
920 return cellTreePtr_();
927 const bool validBoundary
934 "void polyMesh::addPatches(const List<polyPatch*>&, const bool)" 935 ) <<
"boundary already exists" 948 boundary_.
set(pI, p[pI]);
955 globalMeshDataPtr_.clear();
963 boundary_.calcGeometry();
983 " const List<pointZone*>&,\n" 984 " const List<faceZone*>&,\n" 985 " const List<cellZone*>&\n" 987 ) <<
"point, face or cell zone already exists" 999 pointZones_.
set(pI, pz[pI]);
1013 faceZones_.
set(fI, fz[fI]);
1027 cellZones_.
set(cI, cz[cI]);
1037 if (clearedPrimitives_)
1039 FatalErrorIn(
"const pointField& polyMesh::points() const")
1040 <<
"points deallocated" 1062 if (clearedPrimitives_)
1064 FatalErrorIn(
"const faceList& polyMesh::faces() const")
1065 <<
"faces deallocated" 1087 if (oldPointsPtr_.empty())
1091 WarningIn(
"const pointField& polyMesh::oldPoints() const")
1092 <<
"Old points not available. Forcing storage of old points" 1096 oldPointsPtr_.reset(
new pointField(points_));
1100 return oldPointsPtr_();
1111 Info<<
"tmp<scalarField> polyMesh::movePoints(const pointField&) : " 1112 <<
" Moving points for time " <<
time().
value()
1122 oldPointsPtr_.clear();
1123 oldPointsPtr_.reset(
new pointField(points_));
1127 points_ = newPoints;
1129 bool moveError =
false;
1137 Info<<
"tmp<scalarField> polyMesh::movePoints" 1138 <<
"(const pointField&) : " 1139 <<
"Moving the mesh with given points will " 1140 <<
"invalidate the mesh." <<
nl 1141 <<
"Mesh motion should not be executed." <<
endl;
1156 if (globalMeshDataPtr_.valid())
1158 globalMeshDataPtr_().movePoints(points_);
1174 meshObject::movePoints<polyMesh>(*this);
1175 meshObject::movePoints<pointMesh>(*this);
1177 const_cast<Time&
>(
time()).functionObjects().movePoints(*
this);
1180 if (debug && moveError)
1194 curMotionTimeIndex_ = 0;
1195 oldPointsPtr_.clear();
1202 if (globalMeshDataPtr_.empty())
1206 Pout<<
"polyMesh::globalData() const : " 1207 <<
"Constructing parallelData from processor topology" 1214 return globalMeshDataPtr_();
1234 rm(meshFilesPath/
"points");
1235 rm(meshFilesPath/
"faces");
1236 rm(meshFilesPath/
"owner");
1237 rm(meshFilesPath/
"neighbour");
1238 rm(meshFilesPath/
"cells");
1239 rm(meshFilesPath/
"boundary");
1240 rm(meshFilesPath/
"pointZones");
1241 rm(meshFilesPath/
"faceZones");
1242 rm(meshFilesPath/
"cellZones");
1243 rm(meshFilesPath/
"meshModifiers");
1244 rm(meshFilesPath/
"parallelData");
1247 if (
isDir(meshFilesPath/
"sets"))
1249 rmDir(meshFilesPath/
"sets");
1288 celli = nearestCellI;
1300 label testCellI = tree.
shapes().cellLabels()[testCells[pCI]];
1302 if (testCellI == nearestCellI)
1327 "void Foam::polyMesh::findCellFacePt" 1334 ) <<
"Did not find nearest cell in search tree." 1351 tetFacei = tet.
face();
1352 tetPti = tet.
tetPt();
1379 label facei = cFaces[cFacei];
1380 const face&
f = faces_[facei];
1382 bool isOwn = (owner_[facei] == celli);
1409 if ((faceTri.
normal() & proj) > 0)
1427 label facei = cFaces[cFacei];
1428 const face&
f = faces_[facei];
1430 for (
label tetPti = 1; tetPti < f.
size() - 1; tetPti++)
1448 if ((faceTri.
normal() & proj) > 0)
1466 return tetFacei != -1;
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
const cellZoneMesh & cellZones() const
Return cell zone mesh.
static bool & parRun()
Is this a parallel run?
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.
void resetMotion() const
Reset motion.
Simple random number generator.
const faceZoneMesh & faceZones() const
Return face zone mesh.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
cachedRandom rndGen(label(0),-1)
const point & min() const
Minimum describing the bounding box.
Inter-processor communications stream.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
label eventNo() const
Event number at last update.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
bool rmDir(const fileName &)
Remove a dirctory and its contents.
readOption readOpt() const
static tetIndices triangleTetIndices(const polyMesh &mesh, label fI, label cI, const label tetPtI)
Return the tet decomposition of the given triangle of the given face.
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
bool set(const label) const
Is element set.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
void setInstance(const fileName &)
Set the instance for mesh files.
fileName path() const
Return path.
void clearAddressing()
Clear topological data.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
dimensioned< scalar > mag(const dimensioned< Type > &)
label getEvent() const
Return new event number.
A cell is defined as a list of faces with extra functionality.
static labelList findFaceBasePts(const polyMesh &mesh, scalar tol=minTetQuality, bool report=false)
Find a suitable base point for each face for decomposition.
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
const Type & shapes() const
Reference to shape.
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
A simple container for copying or transferring objects of type <T>.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Standard boundBox + extra functionality for use in octree.
void size(const label)
Override size to be inconsistent with allocated storage.
const fileName & instance() const
void updateMesh()
Correct polyBoundaryMesh after topology update.
const cellList & cells() const
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
const pointZoneMesh & pointZones() const
Return point zone mesh.
bool checkDefinition(const bool report=false) const
Check boundary definition. Return true if in error.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
bool hit() const
Is there a hit.
label nextLabel(const label i) const
Next vertex on face.
const fileName & pointsInstance() const
Return the current instance directory for points.
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.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
label index() const
Return index.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
vectorField pointField
pointField is a vectorField.
A triangle primitive used to calculate face normals and swept volumes.
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
A patch is a list of labels that address the faces in the global face list.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
label findNearestCell(const point &location) const
Find the cell with the nearest cell centre to location.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
virtual bool write() const
Write using setting from DB.
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.
A face is a list of labels corresponding to mesh vertices.
Number of components in this vector space.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Cell-face mesh analysis engine.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
#define WarningIn(functionName)
Report a warning using Foam::Warning.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
virtual const pointField & points() const
Return raw points.
label timeIndex() const
Return current time index.
vector normal() const
Return vector normal.
primitiveMesh()
Construct null.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
writeOption writeOpt() const
virtual bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
fileName objectPath() const
Return complete path + object name.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const point & max() const
Maximum describing the bounding box.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
label size() const
Return number of elements in table.
const objectRegistry & thisDb() const
Return the object registry.
errorManip< error > abort(error &err)
virtual const labelList & faceOwner() const
Return face owner.
Point centre() const
Return centre (centroid)
label comm() const
Return communicator used for parallel communication.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
InfoProxy< IOobject > info() const
Return info proxy.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A bounding box defined in terms of the points at its extremities.
bool isDir(const fileName &)
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...
const fileName & facesInstance() const
Return the current instance directory for faces.
void movePoints(const pointField &)
Correct polyBoundaryMesh after moving points.
virtual void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
static word defaultRegion
Return the default region name.
Cmpt cmptSum(const VectorSpace< Form, Cmpt, nCmpt > &vs)
Mesh consisting of general polyhedral cells.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const objectRegistry & parent() const
Return the parent objectRegistry.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
Registry of regIOobjects.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
A class for handling file names.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
Vector< scalar > vector
A scalar version of the templated Vector.
void removeFiles() const
Remove all files from mesh instance()
const Time & time() const
Return time.
virtual const faceList & faces() const
Return raw faces.
label tetPt() const
Return the characterising tetPtI.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
virtual const labelList & faceNeighbour() const
Return face neighbour.
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
virtual ~polyMesh()
Destructor.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
void movePoints(const pointField &)
Correct zone mesh after moving points.
static label worldComm
Default communicator (all processors)
cellDecomposition
Enumeration defining the decomposition of the cell for.
bool moving() const
Is mesh moving.
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
A class for managing temporary objects.
const globalMeshData & globalData() const
Return parallel info.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
const Type & value() const
Return const reference to value.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
const vectorField & faceCentres() const
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
label face() const
Return the face.