55 return io.db().dbDir()/io.local();
59 return io.db().dbDir()/io.local()/io.
name();
64 void Foam::polyMesh::calcDirections()
const
74 label nEmptyPatches = 0;
75 label nWedgePatches = 0;
91 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
97 wedgeDirVec +=
cmptMag(wpp.centreNormal());
102 reduce(nEmptyPatches, maxOp<label>());
103 reduce(nWedgePatches, maxOp<label>());
107 reduce(emptyDirVec, sumOp<vector>());
109 emptyDirVec /=
mag(emptyDirVec);
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 /=
mag(wedgeDirVec);
137 if (wedgeDirVec[cmpt] > 1
e-6)
139 geometricD_[cmpt] = -1;
143 geometricD_[cmpt] = 1;
152 typeIOobject<labelIOList> io
168 return autoPtr<labelIOList>(
nullptr);
184 time().findInstance(meshDir(),
"points"),
196 time().findInstance(meshDir(),
"faces"),
227 clearedPrimitives_(false),
245 tetBasePtIsPtr_(readTetBasePtIs()),
303 globalMeshDataPtr_(nullptr),
304 curMotionTimeIndex_(-1),
305 oldPointsPtr_(nullptr),
306 oldCellCentresPtr_(nullptr),
307 storeOldCellCentres_(false),
341 boundary_.calcGeometry();
347 <<
"no points in mesh" <<
endl;
352 <<
"no cells in mesh" <<
endl;
429 clearedPrimitives_(false),
444 bounds_(points_, syncPar),
448 tetBasePtIsPtr_(readTetBasePtIs()),
488 globalMeshDataPtr_(nullptr),
489 curMotionTimeIndex_(-1),
490 oldPointsPtr_(nullptr),
491 oldCellCentresPtr_(nullptr),
492 storeOldCellCentres_(false),
499 const face& curFace = faces_[facei];
501 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
504 <<
"Face " << facei <<
"contains vertex labels out of range: "
505 << curFace <<
" Max point index = " << points_.
size()
578 clearedPrimitives_(false),
593 bounds_(points_, syncPar),
597 tetBasePtIsPtr_(readTetBasePtIs()),
637 globalMeshDataPtr_(nullptr),
638 curMotionTimeIndex_(-1),
639 oldPointsPtr_(nullptr),
640 oldCellCentresPtr_(nullptr),
641 storeOldCellCentres_(false),
648 const face& curFace = faces_[facei];
650 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
653 <<
"Face " << facei <<
"contains vertex labels out of range: "
654 << curFace <<
" Max point index = " << points_.
size()
665 const cell& curCell = cLst[celli];
667 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
670 <<
"Cell " << celli <<
"contains face labels out of range: "
671 << curCell <<
" Max face index = " << faces_.size()
685 points_(move(
mesh.points_)),
686 faces_(move(
mesh.faces_)),
687 owner_(move(
mesh.owner_)),
688 neighbour_(move(
mesh.neighbour_)),
689 clearedPrimitives_(
mesh.clearedPrimitives_),
690 boundary_(move(
mesh.boundary_)),
691 bounds_(move(
mesh.bounds_)),
693 geometricD_(
mesh.geometricD_),
694 solutionD_(
mesh.solutionD_),
695 tetBasePtIsPtr_(move(
mesh.tetBasePtIsPtr_)),
696 pointZones_(move(
mesh.pointZones_)),
697 faceZones_(move(
mesh.faceZones_)),
698 cellZones_(move(
mesh.cellZones_)),
699 globalMeshDataPtr_(move(
mesh.globalMeshDataPtr_)),
700 curMotionTimeIndex_(
mesh.curMotionTimeIndex_),
701 oldPointsPtr_(move(
mesh.oldPointsPtr_)),
702 oldCellCentresPtr_(move(
mesh.oldCellCentresPtr_)),
703 storeOldCellCentres_(
mesh.storeOldCellCentres_),
704 moving_(
mesh.moving_),
705 topoChanged_(
mesh.topoChanged_)
717 const bool validBoundary
721 meshObjects::clear<polyMesh, DeletableMeshObject>(*
this);
731 bounds_ =
boundBox(points_, validBoundary);
736 faces_ = move(faces);
741 owner_ = move(owner);
746 neighbour_ = move(neighbour);
770 const face& curFace = faces_[facei];
772 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
775 <<
"Face " << facei <<
" contains vertex labels out of range: "
776 << curFace <<
" Max point index = " << points_.
size()
794 boundary_.topoChange();
797 boundary_.calcGeometry();
807 <<
"no points or no cells in mesh"
844 otherMesh.clearAddressing();
847 points_.swap(otherMesh.points_);
849 faces_.swap(otherMesh.faces_);
850 owner_.swap(otherMesh.owner_);
851 neighbour_.swap(otherMesh.neighbour_);
854 boundary_.clearGeom();
855 boundary_.clearAddressing();
860 auto updatePatches = []
866 boundaryMesh.resize(otherPatches.
size());
868 forAll(otherPatches, otherPatchi)
874 if (isA<processorPolyPatch>(otherPatches[otherPatchi]))
879 otherPatches[otherPatchi].
clone(boundaryMesh)
886 boundaryMesh[otherPatchi],
889 otherPatches[otherPatchi].size(),
890 otherPatches[otherPatchi].start()
908 updatePatches(otherPatches, boundary_);
909 updatePatches(
patches, otherMesh.boundary_);
913 globalMeshDataPtr_.clear();
914 otherMesh.globalMeshDataPtr_.clear();
925 const face& curFace =
mesh.faces_[facei];
930 <<
"Face " << facei <<
" contains vertex labels out of "
931 <<
"range: " << curFace <<
" Max point index = "
938 checkFaces(otherMesh);
943 otherMesh.initMesh();
946 boundary_.topoChange();
950 boundary_.calcGeometry();
951 otherMesh.boundary_.calcGeometry();
954 meshObjects::swap<polyMesh>(*
this, otherMesh);
957 pointZones_.swap(otherMesh.pointZones_);
958 faceZones_.swap(otherMesh.faceZones_);
959 cellZones_.swap(otherMesh.cellZones_);
1002 return dbDir()/meshSubDir;
1008 return points_.instance();
1014 return faces_.instance();
1020 return points_.writeOpt();
1026 return faces_.writeOpt();
1032 if (geometricD_.x() == 0)
1049 if (solutionD_.x() == 0)
1066 if (tetBasePtIsPtr_.empty())
1068 tetBasePtIsPtr_.reset
1086 return tetBasePtIsPtr_();
1093 const bool validBoundary
1099 <<
"boundary already exists"
1107 boundary_.setSize(
p.size());
1112 boundary_.set(pI,
p[pI]);
1119 globalMeshDataPtr_.clear();
1135 if (pointZones().size() || faceZones().size() || cellZones().size())
1138 <<
"point, face or cell zone already exists"
1145 pointZones_.setSize(pz.
size());
1150 pointZones_.set(pI, pz[pI]->
name(), pz[pI]);
1159 faceZones_.setSize(fz.
size());
1164 faceZones_.set(fI, fz[fI]->
name(), fz[fI]);
1173 cellZones_.setSize(cz.
size());
1178 cellZones_.set(cI, cz[cI]->
name(), cz[cI]);
1189 const bool validBoundary
1193 boundary_.clearGeom();
1212 boundary_.reorderPatches(newToOld, validBoundary);
1215 meshObjects::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1221 const label insertPatchi,
1225 const label sz = boundary_.size();
1227 label startFacei = nFaces();
1228 if (insertPatchi < sz)
1230 startFacei = boundary_[insertPatchi].start();
1237 for (
label i = 0; i < insertPatchi; i++)
1241 for (
label i = insertPatchi; i < sz; i++)
1245 newToOld[insertPatchi] = -1;
1248 reorderPatches(newToOld,
false);
1251 boundary_.clearGeom();
1279 meshObjects::addPatch<polyMesh>(*
this, insertPatchi);
1286 boundary_.topoChange();
1289 boundary_.calcGeometry();
1291 boundary_.checkDefinition();
1297 if (clearedPrimitives_)
1300 <<
"points deallocated"
1310 if (clearedPrimitives_)
1313 <<
"faces deallocated"
1340 if (oldPointsPtr_.empty())
1343 <<
"Old points have not been stored"
1347 return oldPointsPtr_();
1353 storeOldCellCentres_ =
true;
1357 return cellCentres();
1360 if (oldCellCentresPtr_.empty())
1363 <<
"Old cell centres have not been stored"
1367 return oldCellCentresPtr_();
1374 <<
"Set points for time " <<
time().value()
1375 <<
" index " <<
time().timeIndex() <<
endl;
1379 points_ = newPoints;
1384 if (globalMeshDataPtr_.valid())
1386 globalMeshDataPtr_().movePoints(points_);
1392 boundary_.movePoints(points_);
1394 pointZones_.movePoints(points_);
1395 faceZones_.movePoints(points_);
1396 cellZones_.movePoints(points_);
1402 meshObjects::movePoints<polyMesh>(*
this);
1412 <<
"Moving points for time " <<
time().value()
1413 <<
" index " <<
time().timeIndex() <<
endl;
1418 oldPointsPtr_.clear();
1419 oldPointsPtr_.reset(
new pointField(points_));
1420 if (storeOldCellCentres_)
1422 oldCellCentresPtr_.clear();
1423 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1425 curMotionTimeIndex_ =
time().timeIndex();
1428 points_ = newPoints;
1439 if (globalMeshDataPtr_.valid())
1441 globalMeshDataPtr_().movePoints(points_);
1447 boundary_.movePoints(points_);
1449 pointZones_.movePoints(points_);
1450 faceZones_.movePoints(points_);
1451 cellZones_.movePoints(points_);
1457 meshObjects::movePoints<polyMesh>(*
this);
1465 curMotionTimeIndex_ = -1;
1466 oldPointsPtr_.clear();
1467 oldCellCentresPtr_.clear();
1473 if (globalMeshDataPtr_.empty())
1477 Pout<<
"polyMesh::globalData() const : "
1478 <<
"Constructing parallelData from processor topology"
1486 return globalMeshDataPtr_();
1504 fileName meshFilesPath = db().time().
path()/instanceDir/meshDir();
1506 rm(meshFilesPath/
"points");
1507 rm(meshFilesPath/
"faces");
1508 rm(meshFilesPath/
"owner");
1509 rm(meshFilesPath/
"neighbour");
1510 rm(meshFilesPath/
"cells");
1511 rm(meshFilesPath/
"boundary");
1512 rm(meshFilesPath/
"pointZones");
1513 rm(meshFilesPath/
"faceZones");
1514 rm(meshFilesPath/
"cellZones");
1515 rm(meshFilesPath/
"meshModifiers");
1516 rm(meshFilesPath/
"parallelData");
1519 if (
isDir(meshFilesPath/
"sets"))
1521 rmDir(meshFilesPath/
"sets");
1528 removeFiles(instance());
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
A List of objects of type <Type> with automated input and output using a compact storage....
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const fileName & local() const
const Time & time() const
Return time.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const word & headerClassName() const
Return name of the class name read from header.
const word & name() const
Return name.
writeOption
Enumeration defining the write options.
void size(const label)
Override size to be inconsistent with allocated storage.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Inter-processor communications stream.
label size() const
Return the number of elements in the UPtrList.
static const direction nComponents
Number of components in this vector space.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
bool readIfPresent()
Read zones if the zones file is present.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A bounding box defined in terms of the points at its extremities.
A cell is defined as a list of faces with extra functionality.
const Type & value() const
Return const reference to value.
const word & name() const
Return const reference to name.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
word name() const
Return file name (part beyond last /)
static const fileName null
An empty fileName.
fileName path() const
Return directory path name (part before last /)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a directory in the file system?
label size() const
Return fvMesh size.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
static void clearUpto(objectRegistry &)
Clear all meshObjects derived from FromType up to (but not including)
Registry of regIOobjects.
const Time & time() const
Return time.
void topoChange()
Correct polyBoundaryMesh after topology update.
void clearGeom()
Clear geometry at this level and at patches.
void clearAddressing()
Clear addressing at this level and at patches.
static labelList findFaceBasePts(const polyMesh &mesh, scalar tol=minTetQuality, bool report=false)
Find a suitable base point for each face for decomposition.
Mesh consisting of general polyhedral cells.
virtual ~polyMesh()
Destructor.
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.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
IOobject::writeOption facesWriteOpt() const
Return the points write option.
virtual const faceList & faces() const
Return raw faces.
void addedPatches()
Complete addition of single patches.
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.
virtual const labelList & faceOwner() const
Return face owner.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const globalMeshData & globalData() const
Return parallel info.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
void swap(polyMesh &)
Swap mesh.
const fileName & pointsInstance() const
Return the current instance directory for points.
label comm() const
Return communicator used for parallel communication.
polyMesh(const IOobject &io)
Construct from IOobject.
void resetMotion() const
Reset motion.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
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.
IOobject::writeOption pointsWriteOpt() const
Return the points write option.
void removeFiles() const
Remove all files from mesh instance()
virtual const pointField & oldCellCentres() const
Return old cell centres for mesh motion.
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorder and trim existing patches. If validBoundary the new.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void setInstance(const fileName &)
Set the instance for mesh files.
static fileName meshDirInstance(const IOobject &io)
Return the instance of the polyMesh directory. Returns.
virtual void addPatch(const label insertPatchi, const polyPatch &patch)
Add/insert single patch.
virtual void setPoints(const pointField &)
Reset the points.
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.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Cell-face mesh analysis engine.
void clearGeom()
Clear geometry.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
const cellList & cells() const
virtual bool write(const bool write=true) const
Write using setting from DB.
A class for managing temporary objects.
A class for handling words, derived from string.
static const word null
An empty word.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
const fileOperation & fileHandler()
Get current file handler.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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 rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
bool rmDir(const fileName &)
Remove a directory and its contents.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
IOList< label > labelIOList
Label container classes.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< Type, GeoMesh, Field > > cmptMag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
faceListList boundary(nPatches)