Go to the documentation of this file.
62 label nEmptyPatches = 0;
63 label nWedgePatches = 0;
97 emptyDirVec /=
mag(emptyDirVec);
101 if (emptyDirVec[cmpt] > 1
e-6)
121 wedgeDirVec /=
mag(wedgeDirVec);
125 if (wedgeDirVec[cmpt] > 1
e-6)
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),
308 <<
"no points in mesh" <<
endl;
313 <<
"no cells in mesh" <<
endl;
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())
462 <<
"Face " << facei <<
"contains vertex labels out of range: "
463 << curFace <<
" Max point index = " << points_.
size()
536 clearedPrimitives_(
false),
551 bounds_(points_, syncPar),
555 tetBasePtIsPtr_(NULL),
599 globalMeshDataPtr_(NULL),
601 topoChanging_(
false),
608 const face& curFace = faces_[facei];
610 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
613 <<
"Face " << facei <<
"contains vertex labels out of range: "
614 << curFace <<
" Max point index = " << points_.
size()
625 const cell& curCell = cLst[celli];
627 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
630 <<
"Cell " << celli <<
"contains face labels out of range: "
631 << curCell <<
" Max face index = " << faces_.
size()
649 const bool validBoundary
653 clearAddressing(
true);
659 points_.transfer(
points());
660 bounds_ =
boundBox(points_, validBoundary);
665 faces_.transfer(faces());
670 owner_.transfer(owner());
675 neighbour_.transfer(neighbour());
699 const face& curFace = faces_[facei];
701 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
704 <<
"Face " << facei <<
" contains vertex labels out of range: "
705 << curFace <<
" Max point index = " << points_.
size()
723 boundary_.updateMesh();
726 boundary_.calcGeometry();
736 <<
"no points or no cells in mesh" <<
endl;
757 return parent().dbDir();
768 return dbDir()/meshSubDir;
774 return points_.instance();
780 return faces_.instance();
786 if (geometricD_.x() == 0)
803 if (solutionD_.x() == 0)
820 if (tetBasePtIsPtr_.empty())
825 <<
"Forcing storage of base points."
829 tetBasePtIsPtr_.reset
838 return tetBasePtIsPtr_();
845 if (cellTreePtr_.empty())
852 overallBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
853 overallBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
873 return cellTreePtr_();
880 const bool validBoundary
886 <<
"boundary already exists"
894 boundary_.setSize(
p.size());
899 boundary_.set(pI,
p[pI]);
906 globalMeshDataPtr_.clear();
911 boundary_.updateMesh();
914 boundary_.calcGeometry();
916 boundary_.checkDefinition();
928 if (pointZones().size() || faceZones().size() || cellZones().size())
931 <<
"point, face or cell zone already exists"
938 pointZones_.setSize(pz.
size());
943 pointZones_.set(pI, pz[pI]);
952 faceZones_.setSize(fz.
size());
957 faceZones_.set(fI, fz[fI]);
966 cellZones_.setSize(cz.
size());
971 cellZones_.set(cI, cz[cI]);
981 if (clearedPrimitives_)
984 <<
"points deallocated"
1000 io.
eventNo() = points_.eventNo()+1;
1006 if (clearedPrimitives_)
1009 <<
"faces deallocated"
1031 if (oldPointsPtr_.empty())
1039 oldPointsPtr_.reset(
new pointField(points_));
1040 curMotionTimeIndex_ = time().timeIndex();
1043 return oldPointsPtr_();
1054 Info<<
"tmp<scalarField> polyMesh::movePoints(const pointField&) : "
1055 <<
" Moving points for time " << time().value()
1056 <<
" index " << time().timeIndex() <<
endl;
1062 if (curMotionTimeIndex_ != time().
timeIndex())
1065 oldPointsPtr_.clear();
1066 oldPointsPtr_.reset(
new pointField(points_));
1067 curMotionTimeIndex_ = time().timeIndex();
1070 points_ = newPoints;
1072 bool moveError =
false;
1076 if (checkMeshMotion(points_,
true))
1080 Info<<
"tmp<scalarField> polyMesh::movePoints"
1081 <<
"(const pointField&) : "
1082 <<
"Moving the mesh with given points will "
1083 <<
"invalidate the mesh." <<
nl
1084 <<
"Mesh motion should not be executed." <<
endl;
1089 points_.instance() = time().timeName();
1090 points_.eventNo() = getEvent();
1099 if (globalMeshDataPtr_.valid())
1101 globalMeshDataPtr_().movePoints(points_);
1107 boundary_.movePoints(points_);
1109 pointZones_.movePoints(points_);
1110 faceZones_.movePoints(points_);
1111 cellZones_.movePoints(points_);
1117 meshObject::movePoints<polyMesh>(*
this);
1118 meshObject::movePoints<pointMesh>(*
this);
1120 const_cast<Time&
>(time()).functionObjects().movePoints(*
this);
1123 if (debug && moveError)
1137 curMotionTimeIndex_ = 0;
1138 oldPointsPtr_.clear();
1145 if (globalMeshDataPtr_.empty())
1149 Pout<<
"polyMesh::globalData() const : "
1150 <<
"Constructing parallelData from processor topology"
1157 return globalMeshDataPtr_();
1175 fileName meshFilesPath = thisDb().time().
path()/instanceDir/meshDir();
1177 rm(meshFilesPath/
"points");
1178 rm(meshFilesPath/
"faces");
1179 rm(meshFilesPath/
"owner");
1180 rm(meshFilesPath/
"neighbour");
1181 rm(meshFilesPath/
"cells");
1182 rm(meshFilesPath/
"boundary");
1183 rm(meshFilesPath/
"pointZones");
1184 rm(meshFilesPath/
"faceZones");
1185 rm(meshFilesPath/
"cellZones");
1186 rm(meshFilesPath/
"meshModifiers");
1187 rm(meshFilesPath/
"parallelData");
1190 if (
isDir(meshFilesPath/
"sets"))
1192 rmDir(meshFilesPath/
"sets");
1199 removeFiles(instance());
1225 findTetFacePt(nearestCellI,
p, tetFacei, tetPti);
1231 celli = nearestCellI;
1243 label testCellI = tree.
shapes().cellLabels()[testCells[pCI]];
1245 if (testCellI == nearestCellI)
1253 findTetFacePt(testCellI,
p, tetFacei, tetPti);
1269 <<
"Did not find nearest cell in search tree."
1286 tetFacei = tet.
face();
1287 tetPti = tet.
tetPt();
1306 case FACE_CENTRE_TRIS:
1314 label facei = cFaces[cFacei];
1315 const face&
f = faces_[facei];
1316 const point& fc = faceCentres()[facei];
1317 bool isOwn = (owner_[facei] == celli);
1327 nextPointI =
f.nextLabel(fp);
1331 pointI =
f.nextLabel(fp);
1344 if ((faceTri.
normal() & proj) > 0)
1354 case FACE_DIAG_TRIS:
1362 label facei = cFaces[cFacei];
1363 const face&
f = faces_[facei];
1365 for (
label tetPti = 1; tetPti <
f.
size() - 1; tetPti++)
1383 if ((faceTri.
normal() & proj) > 0)
1399 findTetFacePt(celli,
p, tetFacei, tetPti);
1401 return tetFacei != -1;
1419 && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS)
1428 (void)tetBasePtIs();
1436 if (decompMode == CELL_TETS)
1445 findCellFacePt(
p, celli, tetFacei, tetPti);
1455 label celli = findNearestCell(
p);
1458 if (pointInCell(
p, celli, decompMode))
1466 for (
label celli = 0; celli < nCells(); celli++)
1468 if (pointInCell(
p, celli, decompMode))
vectorField pointField
pointField is a vectorField.
Simple random number generator.
virtual const pointField & points() const
Return raw points.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
label index() const
Return index.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void resetMotion() const
Reset motion.
cellDecomposition
Enumeration defining the decomposition of the cell for.
A class for handling file names.
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
const point & max() const
Maximum describing the bounding box.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Wedge front and back plane patch.
static word defaultRegion
Return the default region name.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
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 fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
Standard boundBox + extra functionality for use in octree.
const Time & time() const
Return time.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static bool & parRun()
Is this a parallel run?
bool pointInCell(const point &p, label celli) const
Is the point in the cell.
fileName path() const
Return directory path name (part before last /)
bool hit() const
Is there a hit.
labelIOList neighbour_
Face neighbour.
const fileName & facesInstance() const
Return the current instance directory for faces.
@ nComponents
Number of components in this vector space.
virtual bool write() const
Write using setting from DB.
const Type & shapes() const
Reference to shape.
label comm() const
Return communicator used for parallel communication.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
dimensioned< scalar > mag(const dimensioned< Type > &)
void removeFiles() const
Remove all files from mesh instance()
Vector< label > geometricD_
Vector of non-constrained directions in mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
label tetPt() const
Return the characterising tetPtI.
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
A simple container for copying or transferring objects of type <T>.
Mesh consisting of general polyhedral cells.
Point centre() const
Return centre (centroid)
Registry of regIOobjects.
fileName objectPath() const
Return complete path + object name.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
A triangle primitive used to calculate face normals and swept volumes.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
labelIOList owner_
Face owner.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Inter-processor communications stream.
Pre-declare SubField and related Field type.
vector normal() const
Return vector normal.
readOption readOpt() const
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
A patch is a list of labels that address the faces in the global face list.
virtual const labelList & faceOwner() const
Return face owner.
polyBoundaryMesh boundary_
Boundary mesh.
label face() const
Return the face.
label eventNo() const
Event number at last update.
A List of objects of type <T> with automated input and output using a compact storage....
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
const point & min() const
Minimum describing the bounding box.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
label size() const
Return number of elements in table.
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.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
virtual bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
errorManip< error > abort(error &err)
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
const double e
Elementary charge.
void calcGeometry()
Calculate the geometry for the patches (transformation tensors etc.)
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
void updateMesh()
Correct polyBoundaryMesh after topology update.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
virtual ~polyMesh()
Destructor.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void calcDirections() const
Calculate the valid directions in the mesh from the boundaries.
prefixOSstream Pout(cout, "Pout")
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.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
static label worldComm
Default communicator (all processors)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
A bounding box defined in terms of the points at its extremities.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Vector< label > solutionD_
Vector of valid directions in mesh.
void findNearest(const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint, const FindNearestOp &fnOp) const
Find nearest point to line.
A face is a list of labels corresponding to mesh vertices.
void size(const label)
Override size to be inconsistent with allocated storage.
const globalMeshData & globalData() const
Return parallel info.
vector point
Point is a vector.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
defineTypeNameAndDebug(combustionModel, 0)
Cmpt cmptSum(const VectorSpace< Form, Cmpt, nCmpt > &vs)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
bool rmDir(const fileName &)
Remove a dirctory and its contents.
cachedRandom rndGen(label(0), -1)
virtual void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
polyMesh(const polyMesh &)
Disallow construct as copy.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const vector & centreNormal() const
Return plane normal between the wedge boundaries.
void initMesh()
Initialise the polyMesh from the primitive data.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
const vectorField & faceAreas() const
Cell-face mesh analysis engine.