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())
462 <<
"Face " << facei <<
"contains vertex labels out of range: " 463 << curFace <<
" Max point index = " << points_.
size()
473 Foam::polyMesh::polyMesh
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
660 bounds_ =
boundBox(points_, validBoundary);
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()
726 boundary_.calcGeometry();
736 <<
"no points or no cells in mesh" <<
endl;
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())
851 overallBb = overallBb.
extend(rndGen, 1
e-4);
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" 899 boundary_.
set(pI, p[pI]);
906 globalMeshDataPtr_.clear();
914 boundary_.calcGeometry();
931 <<
"point, face or cell zone already exists" 943 pointZones_.
set(pI, pz[pI]);
957 faceZones_.
set(fI, fz[fI]);
971 cellZones_.
set(cI, cz[cI]);
981 if (clearedPrimitives_)
984 <<
"points deallocated" 1006 if (clearedPrimitives_)
1009 <<
"faces deallocated" 1031 if (oldPointsPtr_.empty())
1039 oldPointsPtr_.reset(
new pointField(points_));
1043 return oldPointsPtr_();
1055 <<
"Moving points for time " <<
time().
value()
1065 oldPointsPtr_.clear();
1066 oldPointsPtr_.reset(
new pointField(points_));
1070 points_ = newPoints;
1072 bool moveError =
false;
1081 <<
"Moving the mesh with given points will " 1082 <<
"invalidate the mesh." <<
nl 1083 <<
"Mesh motion should not be executed." <<
endl;
1098 if (globalMeshDataPtr_.valid())
1100 globalMeshDataPtr_().movePoints(points_);
1116 meshObject::movePoints<polyMesh>(*this);
1117 meshObject::movePoints<pointMesh>(*this);
1119 const_cast<Time&
>(
time()).functionObjects().movePoints(*
this);
1122 if (debug && moveError)
1135 curMotionTimeIndex_ = 0;
1136 oldPointsPtr_.clear();
1142 if (globalMeshDataPtr_.empty())
1146 Pout<<
"polyMesh::globalData() const : " 1147 <<
"Constructing parallelData from processor topology" 1154 return globalMeshDataPtr_();
1174 rm(meshFilesPath/
"points");
1175 rm(meshFilesPath/
"faces");
1176 rm(meshFilesPath/
"owner");
1177 rm(meshFilesPath/
"neighbour");
1178 rm(meshFilesPath/
"cells");
1179 rm(meshFilesPath/
"boundary");
1180 rm(meshFilesPath/
"pointZones");
1181 rm(meshFilesPath/
"faceZones");
1182 rm(meshFilesPath/
"cellZones");
1183 rm(meshFilesPath/
"meshModifiers");
1184 rm(meshFilesPath/
"parallelData");
1187 if (
isDir(meshFilesPath/
"sets"))
1189 rmDir(meshFilesPath/
"sets");
1228 celli = nearestCelli;
1240 label testCelli = tree.
shapes().cellLabels()[testCells[pCI]];
1242 if (testCelli == nearestCelli)
1266 <<
"Did not find nearest cell in search tree." 1283 tetFacei = tet.
face();
1284 tetPti = tet.
tetPt();
1311 label facei = cFaces[cFacei];
1312 const face&
f = faces_[facei];
1314 bool isOwn = (owner_[facei] == celli);
1341 if ((faceTri.
normal() & proj) > 0)
1359 label facei = cFaces[cFacei];
1360 const face&
f = faces_[facei];
1362 for (
label tetPti = 1; tetPti < f.
size() - 1; tetPti++)
1380 if ((faceTri.
normal() & proj) > 0)
1398 return tetFacei != -1;
label timeIndex() const
Return current time index.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
cachedRandom rndGen(label(0),-1)
const Time & time() const
Return time.
A simple container for copying or transferring objects of type <T>.
fileName objectPath() const
Return complete path + object name.
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.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
void clearAddressing()
Clear topological data.
A triangle primitive used to calculate face normals 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.
label comm() const
Return communicator used for parallel communication.
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.
void removeFiles() const
Remove all files from mesh instance()
A face is a list of labels corresponding to mesh vertices.
void resetMotion() const
Reset motion.
const double e
Elementary charge.
const point & min() const
Minimum describing the bounding box.
bool checkDefinition(const bool report=false) const
Check boundary definition. Return true if in error.
const fileName & facesInstance() const
Return the current instance directory for faces.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the.
Cell-face mesh analysis engine.
bool hit() const
Is there a hit.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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")
void size(const label)
Override size to be inconsistent with allocated storage.
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
primitiveMesh()
Construct null.
const point & max() const
Maximum describing the bounding box.
A bounding box defined in terms of the points at its extremities.
const Type & value() const
Return const reference to value.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
label size() const
Return number of elements in table.
label eventNo() const
Event number at last update.
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.
const objectRegistry & parent() const
Return the parent objectRegistry.
static label worldComm
Default communicator (all processors)
const vectorField & faceCentres() const
label tetPt() const
Return the characterising tetPtI.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
const cellList & cells() const
writeOption writeOpt() const
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
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.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
bool moving() const
Is mesh moving.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
virtual const pointField & points() const
Return raw points.
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
static const direction nComponents
Number of components in this vector space.
vectorField pointField
pointField is a vectorField.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
virtual void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
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.
virtual bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
InfoProxy< IOobject > info() const
Return info proxy.
bool set(const label) const
Is element set.
const objectRegistry & thisDb() const
Return the object registry.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Point centre() const
Return centre (centroid)
label face() const
Return the face.
errorManip< error > abort(error &err)
Simple random number generator.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
const globalMeshData & globalData() const
Return parallel info.
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 dirctory and its contents.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
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.
prefixOSstream Pout(cout,"Pout")
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
label getEvent() const
Return new event number.
void updateMesh()
Correct polyBoundaryMesh after topology update.
defineTypeNameAndDebug(combustionModel, 0)
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
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 > &)
const pointZoneMesh & pointZones() const
Return point zone mesh.
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.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
static bool & parRun()
Is this a parallel run?
const cellZoneMesh & cellZones() const
Return cell zone mesh.
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
virtual const labelList & faceNeighbour() const
Return face neighbour.
vector point
Point is a vector.
label findNearestCell(const point &location) const
Find the cell with the nearest cell centre to location.
#define WarningInFunction
Report a warning using Foam::Warning.
const fileName & pointsInstance() const
Return the current instance directory for points.
A cell is defined as a list of faces with extra functionality.
const Type & shapes() const
Reference to shape.
label index() const
Return index.
readOption readOpt() const
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
virtual bool write() const
Write using setting from DB.
virtual ~polyMesh()
Destructor.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
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 > &)
const faceZoneMesh & faceZones() const
Return face zone mesh.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
label nextLabel(const label i) const
Next vertex on face.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
A class for managing temporary objects.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
virtual const labelList & faceOwner() const
Return face owner.
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
virtual const faceList & faces() const
Return raw faces.
fileName path() const
Return path.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const fileName & instance() const
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Inter-processor communications stream.
vector normal() const
Return vector normal.
#define InfoInFunction
Report an information message using Foam::Info.