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),
292 curMotionTimeIndex_(-1),
293 oldPointsPtr_(nullptr),
294 oldCellCentresPtr_(nullptr),
295 storeOldCellCentres_(false)
327 boundary_.calcGeometry();
333 <<
"no points in mesh" <<
endl;
338 <<
"no cells in mesh" <<
endl;
410 clearedPrimitives_(
false),
425 bounds_(points_, syncPar),
429 tetBasePtIsPtr_(readTetBasePtIs()),
430 cellTreePtr_(
nullptr),
473 globalMeshDataPtr_(
nullptr),
475 topoChanging_(
false),
476 curMotionTimeIndex_(-1),
477 oldPointsPtr_(
nullptr),
478 oldCellCentresPtr_(
nullptr),
479 storeOldCellCentres_(
false)
484 const face& curFace = faces_[facei];
486 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
489 <<
"Face " << facei <<
"contains vertex labels out of range: " 490 << curFace <<
" Max point index = " << points_.
size()
564 clearedPrimitives_(
false),
579 bounds_(points_, syncPar),
583 tetBasePtIsPtr_(readTetBasePtIs()),
584 cellTreePtr_(
nullptr),
627 globalMeshDataPtr_(
nullptr),
629 topoChanging_(
false),
630 curMotionTimeIndex_(-1),
631 oldPointsPtr_(
nullptr),
632 oldCellCentresPtr_(
nullptr),
633 storeOldCellCentres_(
false)
638 const face& curFace = faces_[facei];
640 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
643 <<
"Face " << facei <<
"contains vertex labels out of range: " 644 << curFace <<
" Max point index = " << points_.
size()
655 const cell& curCell = cLst[celli];
657 if (
min(curCell) < 0 ||
max(curCell) > faces_.
size())
660 <<
"Cell " << celli <<
"contains face labels out of range: " 661 << curCell <<
" Max face index = " << faces_.
size()
679 const bool validBoundary
690 bounds_ =
boundBox(points_, validBoundary);
695 faces_ = move(
faces);
700 owner_ = move(owner);
705 neighbour_ = move(neighbour);
729 const face& curFace = faces_[facei];
731 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
734 <<
"Face " << facei <<
" contains vertex labels out of range: " 735 << curFace <<
" Max point index = " << points_.
size()
756 boundary_.calcGeometry();
766 <<
"no points or no cells in mesh" <<
endl;
816 if (geometricD_.
x() == 0)
833 if (solutionD_.
x() == 0)
850 if (tetBasePtIsPtr_.empty())
855 <<
"Forcing storage of base points." 859 tetBasePtIsPtr_.reset
877 return tetBasePtIsPtr_();
884 if (cellTreePtr_.empty())
904 return cellTreePtr_();
911 const bool validBoundary
917 <<
"boundary already exists" 930 boundary_.
set(pI, p[pI]);
937 globalMeshDataPtr_.clear();
945 boundary_.calcGeometry();
962 <<
"point, face or cell zone already exists" 974 pointZones_.
set(pI, pz[pI]);
988 faceZones_.
set(fI, fz[fI]);
1002 cellZones_.
set(cI, cz[cI]);
1013 const bool validBoundary
1033 TopologicalMeshObject,
1043 meshObject::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1044 meshObject::reorderPatches<pointMesh>(*
this, newToOld, validBoundary);
1050 const label insertPatchi,
1053 const word& defaultPatchFieldType,
1054 const bool validBoundary
1060 if (insertPatchi < sz)
1062 startFacei = boundary_[insertPatchi].start();
1069 for (
label i = 0; i < insertPatchi; i++)
1073 for (
label i = insertPatchi; i < sz; i++)
1077 newToOld[insertPatchi] = -1;
1099 TopologicalMeshObject,
1126 meshObject::addPatch<polyMesh>(*
this, insertPatchi);
1127 meshObject::addPatch<pointMesh>(*
this, insertPatchi);
1133 if (clearedPrimitives_)
1136 <<
"points deallocated" 1158 if (clearedPrimitives_)
1161 <<
"faces deallocated" 1188 if (oldPointsPtr_.empty())
1191 <<
"Old points have not been stored" 1195 return oldPointsPtr_();
1201 storeOldCellCentres_ =
true;
1208 if (oldCellCentresPtr_.empty())
1211 <<
"Old cell centres have not been stored" 1215 return oldCellCentresPtr_();
1294 <<
"Moving points for time " <<
time().
value()
1303 oldPointsPtr_.clear();
1304 oldPointsPtr_.reset(
new pointField(points_));
1305 if (storeOldCellCentres_)
1307 oldCellCentresPtr_.clear();
1313 points_ = newPoints;
1315 bool moveError =
false;
1324 <<
"Moving the mesh with given points will " 1325 <<
"invalidate the mesh." <<
nl 1326 <<
"Mesh motion should not be executed." <<
endl;
1334 if (tetBasePtIsPtr_.valid())
1338 tetBasePtIsPtr_().eventNo() =
getEvent();
1348 if (globalMeshDataPtr_.valid())
1350 globalMeshDataPtr_().movePoints(points_);
1363 cellTreePtr_.clear();
1369 meshObject::movePoints<polyMesh>(*this);
1370 meshObject::movePoints<pointMesh>(*this);
1372 const_cast<Time&
>(
time()).functionObjects().movePoints(*
this);
1375 if (debug && moveError)
1388 curMotionTimeIndex_ = -1;
1389 oldPointsPtr_.clear();
1390 oldCellCentresPtr_.clear();
1396 if (globalMeshDataPtr_.empty())
1400 Pout<<
"polyMesh::globalData() const : " 1401 <<
"Constructing parallelData from processor topology" 1408 return globalMeshDataPtr_();
1428 rm(meshFilesPath/
"points");
1429 rm(meshFilesPath/
"faces");
1430 rm(meshFilesPath/
"owner");
1431 rm(meshFilesPath/
"neighbour");
1432 rm(meshFilesPath/
"cells");
1433 rm(meshFilesPath/
"boundary");
1434 rm(meshFilesPath/
"pointZones");
1435 rm(meshFilesPath/
"faceZones");
1436 rm(meshFilesPath/
"cellZones");
1437 rm(meshFilesPath/
"meshModifiers");
1438 rm(meshFilesPath/
"parallelData");
1441 if (
isDir(meshFilesPath/
"sets"))
1443 rmDir(meshFilesPath/
"sets");
1490 tetFacei = tet.
face();
1491 tetPti = tet.
tetPt();
1518 label facei = cFaces[cFacei];
1519 const face&
f = faces_[facei];
1521 bool isOwn = (owner_[facei] == celli);
1548 if ((faceTri.
area() & proj) > 0)
1566 label facei = cFaces[cFacei];
1567 const face&
f = faces_[facei];
1569 for (
label tetPti = 1; tetPti < f.
size() - 1; tetPti++)
1578 if ((faceTri.
area() & proj) > 0)
1596 return tetFacei != -1;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorder and trim existing patches. If validBoundary the new.
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.
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.
bool moving() const
Is mesh moving.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
const meshCellZones & cellZones() const
Return cell zones.
A list of keyword definitions, which are a keyword followed by any number of values (e...
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.
IOobject(const word &name, const fileName &instance, const objectRegistry ®istry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true)
Construct from name, instance, registry, io options.
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.
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Return the location of "dir" containing the file "name".
label nextLabel(const label i) const
Next vertex on face.
void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorders the patches. Ordering does not have to be done in.
primitiveMesh()
Construct null.
void clearGeom()
Clear geometry at this level and at patches.
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.
void movePoints(const pointField &)
Correct zones after moving points.
cellDecomposition
Enumeration defining the decomposition of the cell for.
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)
const meshPointZones & pointZones() const
Return point zones.
virtual const pointField & points() const
Return raw points.
Mesh representing a set of points created from polyMesh.
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.
objectRegistry(const Time &db, const label nIoObjects=128)
Construct the time objectRegistry given an initial estimate.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary 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.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
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.
static void clearUpto(objectRegistry &)
Clear all meshObject derived from FromType up to (but not including)
label getEvent() const
Return new event number.
virtual void addPatch(const label insertPatchi, const polyPatch &patch, const dictionary &patchFieldDict, const word &defaultPatchFieldType, const bool validBoundary)
Add/insert single patch. If validBoundary the new situation.
const word & constant() const
Return constant name.
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.
const vectorField & cellCentres() const
errorManip< error > abort(error &err)
void addPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
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.
void resetPrimitives(pointField &&points, faceList &&faces, labelList &&owner, labelList &&neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
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.
static IOobject points0IO(const polyMesh &mesh)
Return IO object for points0.
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.
label size() const
Return the number of elements in the UPtrList.
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.
virtual const pointField & oldCellCentres() const
Return old points for mesh motion.
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
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.
virtual bool write(const bool write=true) const
Write using setting from DB.
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.
readOption readOpt() const
fileName path() const
Return path.
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...
A primitive field of type <T> with automated input and output.
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.
polyMesh(const IOobject &io)
Construct from IOobject.
#define InfoInFunction
Report an information message using Foam::Info.