55void Foam::polyMesh::calcDirections()
const
65 label nEmptyPatches = 0;
66 label nWedgePatches = 0;
74 if (isA<emptyPolyPatch>(pp))
86 else if (isA<wedgePolyPatch>(pp))
88 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>(pp);
92 (void)wpp.faceNormals();
97 wedgeDirVec +=
cmptMag(wpp.centreNormal());
102 reduce(nEmptyPatches, maxOp<label>());
103 reduce(nWedgePatches, maxOp<label>());
107 reduce(emptyDirVec, sumOp<vector>());
109 emptyDirVec.normalise();
113 if (emptyDirVec[cmpt] > 1
e-6)
115 solutionD_[cmpt] = -1;
119 solutionD_[cmpt] = 1;
127 geometricD_ = solutionD_;
131 reduce(wedgeDirVec, sumOp<vector>());
133 wedgeDirVec.normalise();
137 if (wedgeDirVec[cmpt] > 1
e-6)
139 geometricD_[cmpt] = -1;
143 geometricD_[cmpt] = 1;
182 time().findInstance(meshDir(),
"points"),
194 time().findInstance(meshDir(),
"faces"),
225 clearedPrimitives_(false),
249 tetBasePtIsPtr_(readTetBasePtIs()),
250 cellTreePtr_(nullptr),
308 globalMeshDataPtr_(nullptr),
310 topoChanging_(false),
311 storeOldCellCentres_(false),
313 oldPointsPtr_(nullptr),
314 oldCellCentresPtr_(nullptr)
346 <<
"mesh missing boundary on one or more domains" <<
endl;
351 <<
"no points in mesh" <<
endl;
356 <<
"no cells in mesh" <<
endl;
375 boundary_.updateMesh();
378 boundary_.calcGeometry();
451 clearedPrimitives_(false),
466 bounds_(points_, syncPar),
470 tetBasePtIsPtr_(nullptr),
471 cellTreePtr_(nullptr),
514 globalMeshDataPtr_(nullptr),
516 topoChanging_(false),
517 storeOldCellCentres_(false),
519 oldPointsPtr_(nullptr),
520 oldCellCentresPtr_(nullptr)
525 const face& curFace = faces_[facei];
527 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
530 <<
"Face " << facei <<
"contains vertex labels out of range: "
531 << curFace <<
" Max point index = " << points_.
size()
604 clearedPrimitives_(false),
619 bounds_(points_, syncPar),
623 tetBasePtIsPtr_(nullptr),
624 cellTreePtr_(nullptr),
667 globalMeshDataPtr_(nullptr),
669 topoChanging_(false),
670 storeOldCellCentres_(false),
672 oldPointsPtr_(nullptr),
673 oldCellCentresPtr_(nullptr)
678 const face& curFace = faces_[facei];
680 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
683 <<
"Face " << facei <<
"contains vertex labels out of range: "
684 << curFace <<
" Max point index = " << points_.
size()
695 const cell& curCell = cLst[celli];
697 if (
min(curCell) < 0 ||
max(curCell) > faces_.
size())
700 <<
"Cell " << celli <<
"contains face labels out of range: "
701 << curCell <<
" Max face index = " << faces_.
size()
725 const bool validBoundary
729 clearAddressing(
true);
735 points_.transfer(*
points);
736 bounds_ =
boundBox(points_, validBoundary);
741 faces_.transfer(*faces);
746 owner_.transfer(*owner);
751 neighbour_.transfer(*neighbour);
775 const face& curFace = faces_[facei];
777 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
780 <<
"Face " << facei <<
" contains vertex labels out of range: "
781 << curFace <<
" Max point index = " << points_.
size()
799 boundary_.updateMesh();
802 boundary_.calcGeometry();
812 <<
"no points or no cells in mesh" <<
endl;
841 return parent().dbDir();
850 return dbDir()/meshSubDir;
862 return points_.instance();
868 return faces_.instance();
874 if (geometricD_.x() == 0)
891 if (solutionD_.x() == 0)
908 if (!tetBasePtIsPtr_)
913 <<
"Forcing storage of base points."
917 tetBasePtIsPtr_.reset
935 return *tetBasePtIsPtr_;
970 return *cellTreePtr_;
977 const bool validBoundary
983 <<
"boundary already exists"
991 boundary_.transfer(plist);
997 globalMeshDataPtr_.clear();
1002 boundary_.updateMesh();
1005 boundary_.calcGeometry();
1007 boundary_.checkDefinition();
1019 if (pointZones().size() || faceZones().size() || cellZones().size())
1022 <<
"point, face or cell zone already exists"
1029 pointZones_.setSize(pz.
size());
1034 pointZones_.set(pI, pz[pI]);
1043 faceZones_.setSize(fz.
size());
1048 faceZones_.set(fI, fz[fI]);
1057 cellZones_.setSize(cz.
size());
1062 cellZones_.set(cI, cz[cI]);
1073 const bool validBoundary
1079 addPatches(plist, validBoundary);
1085 if (clearedPrimitives_)
1088 <<
"points deallocated"
1098 return io.upToDate(points_);
1104 io.eventNo() = points_.eventNo()+1;
1110 if (clearedPrimitives_)
1113 <<
"faces deallocated"
1147 oldPointsPtr_.reset(
new pointField(points_));
1148 curMotionTimeIndex_ = time().timeIndex();
1151 return *oldPointsPtr_;
1157 storeOldCellCentres_ =
true;
1161 return cellCentres();
1164 if (!oldCellCentresPtr_)
1166 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1169 return *oldCellCentresPtr_;
1176 <<
"Moving points for time " << time().value()
1177 <<
" index " << time().timeIndex() <<
endl;
1179 if (newPoints.
size() != points_.size())
1182 <<
"Size of newPoints " << newPoints.
size()
1183 <<
" does not correspond to current mesh points size "
1192 if (curMotionTimeIndex_ != time().
timeIndex())
1196 Info<<
"tmp<scalarField> polyMesh::movePoints(const pointField&) : "
1197 <<
" Storing current points for time " << time().value()
1198 <<
" index " << time().timeIndex() <<
endl;
1201 if (storeOldCellCentres_)
1203 oldCellCentresPtr_.clear();
1204 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1208 oldPointsPtr_.clear();
1209 oldPointsPtr_.reset(
new pointField(points_));
1210 curMotionTimeIndex_ = time().timeIndex();
1213 points_ = newPoints;
1215 bool moveError =
false;
1219 if (checkMeshMotion(points_,
true))
1224 <<
"Moving the mesh with given points will "
1225 <<
"invalidate the mesh." <<
nl
1226 <<
"Mesh motion should not be executed." <<
endl;
1231 points_.instance() = time().timeName();
1232 points_.eventNo() = getEvent();
1234 if (tetBasePtIsPtr_)
1237 tetBasePtIsPtr_->instance() = time().timeName();
1238 tetBasePtIsPtr_->eventNo() = getEvent();
1254 if (globalMeshDataPtr_)
1256 globalMeshDataPtr_->movePoints(points_);
1262 boundary_.movePoints(points_);
1264 pointZones_.movePoints(points_);
1265 faceZones_.movePoints(points_);
1266 cellZones_.movePoints(points_);
1277 cellTreePtr_.clear();
1287 meshObject::movePoints<polyMesh>(*
this);
1288 meshObject::movePoints<pointMesh>(*
this);
1290 const_cast<Time&
>(time()).functionObjects().movePoints(*
this);
1293 if (debug && moveError)
1304 curMotionTimeIndex_ = 0;
1305 oldPointsPtr_.clear();
1306 oldCellCentresPtr_.clear();
1312 if (!globalMeshDataPtr_)
1316 Pout<<
"polyMesh::globalData() const : "
1317 <<
"Constructing parallelData from processor topology"
1324 return *globalMeshDataPtr_;
1342 fileName meshFilesPath = thisDb().time().
path()/instanceDir/meshDir();
1344 rm(meshFilesPath/
"points");
1345 rm(meshFilesPath/
"faces");
1346 rm(meshFilesPath/
"owner");
1347 rm(meshFilesPath/
"neighbour");
1348 rm(meshFilesPath/
"cells");
1349 rm(meshFilesPath/
"boundary");
1350 rm(meshFilesPath/
"pointZones");
1351 rm(meshFilesPath/
"faceZones");
1352 rm(meshFilesPath/
"cellZones");
1353 rm(meshFilesPath/
"meshModifiers");
1354 rm(meshFilesPath/
"parallelData");
1357 if (
isDir(meshFilesPath/
"sets"))
1359 rmDir(meshFilesPath/
"sets");
1366 removeFiles(instance());
1390 findTetFacePt(celli,
p, tetFacei, tetPti);
1406 tetFacei = tet.
face();
1407 tetPti = tet.
tetPt();
1426 case FACE_CENTRE_TRIS:
1434 label facei = cFaces[cFacei];
1435 const face&
f = faces_[facei];
1436 const point& fc = faceCentres()[facei];
1437 bool isOwn = (owner_[facei] == celli);
1447 nextPointi =
f.nextLabel(fp);
1451 pointi =
f.nextLabel(fp);
1474 case FACE_DIAG_TRIS:
1482 label facei = cFaces[cFacei];
1483 const face&
f = faces_[facei];
1485 for (label tetPti = 1; tetPti <
f.
size() - 1; tetPti++)
1510 findTetFacePt(celli,
p, tetFacei, tetPti);
1512 return tetFacei != -1;
1530 && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS)
1539 (void)tetBasePtIs();
1547 if (decompMode == CELL_TETS)
1556 findCellFacePt(
p, celli, tetFacei, tetPti);
1571 (void)tetBasePtIs();
1575 label celli = findNearestCell(
p);
1578 if (pointInCell(
p, celli, decompMode))
1586 for (label celli = 0; celli < nCells(); celli++)
1588 if (pointInCell(
p, celli, decompMode))
A List of objects of type <T> with automated input and output using a compact storage....
SubField< vector > subField
Declare type of subField.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
bool hasHeaderClass() const noexcept
True if headerClassName() is non-empty (after reading)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void size(const label n)
Older name for setAddressableSize.
Inter-processor communications stream.
static bool & parRun() noexcept
Test if this a parallel run.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bounding box defined in terms of min/max extrema points.
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum describing the bounding box.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A cell is defined as a list of faces with extra functionality.
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
static std::string path(const std::string &str)
Return directory path name (part before last /)
virtual bool write()
Write the output fields.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Non-pointer based hierarchical recursive searching.
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
void movePoints()
Update for new mesh geometry.
Registry of regIOobjects.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
const Time & time() const noexcept
Return time registry.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
static constexpr direction nComponents
Number of components in bool is 1.
static labelList findFaceBasePts(const polyMesh &mesh, scalar tol=minTetQuality, bool report=false)
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
Mesh consisting of general polyhedral cells.
virtual ~polyMesh()
Destructor.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
const fileName & facesInstance() const
Return the current instance directory for faces.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
static word defaultRegion
Return the default region name.
void addPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches.
label comm() const noexcept
Return communicator used for parallel communication.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
cellDecomposition
Enumeration defining the decomposition of the cell for.
virtual const faceList & faces() const
Return raw faces.
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
virtual const labelList & faceOwner() const
Return face owner.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
const globalMeshData & globalData() const
Return parallel info.
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
virtual const pointField & oldPoints() const
Return old points (mesh motion)
const fileName & pointsInstance() const
Return the current instance directory for points.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
void resetMotion() const
Reset motion.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
virtual const pointField & points() const
Return raw points.
virtual void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
void removeFiles() const
Remove all files from mesh instance()
virtual const pointField & oldCellCentres() const
Return old cellCentres (mesh motion)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void resetPrimitives(autoPtr< pointField > &&points, autoPtr< faceList > &&faces, autoPtr< labelList > &&owner, autoPtr< labelList > &&neighbour, const labelUList &patchSizes, const labelUList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
Cell-face mesh analysis engine.
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
const cellList & cells() const
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
virtual bool write(const bool valid=true) const
Write using setting from DB.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
label face() const noexcept
Return the face index.
triPointRef faceTri(const polyMesh &mesh) const
label tetPt() const noexcept
Return the characterising tet point index.
Standard boundBox with extra functionality for use in octree.
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
A triangle primitive used to calculate face normals and swept volumes.
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
Point centre() const
Return centre (centroid)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Cmpt cmptSum(const SphericalTensor< Cmpt > &st)
Return the sum of components of a SphericalTensor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
IOList< label > labelIOList
Label container classes.
static constexpr const zero Zero
Global zero (0)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.