58 return io.db().dbDir()/io.local();
62 return io.db().dbDir()/io.local()/io.
name();
67 void Foam::polyMesh::calcDirections()
const
77 label nEmptyPatches = 0;
78 label nWedgePatches = 0;
85 if (boundaryMesh()[
patchi].size())
87 if (isA<emptyPolyPatch>(boundaryMesh()[
patchi]))
92 else if (isA<wedgePolyPatch>(boundaryMesh()[
patchi]))
94 const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
100 wedgeDirVec +=
cmptMag(wpp.centreNormal());
105 reduce(nEmptyPatches, maxOp<label>());
106 reduce(nWedgePatches, maxOp<label>());
110 reduce(emptyDirVec, sumOp<vector>());
112 emptyDirVec /=
mag(emptyDirVec);
116 if (emptyDirVec[cmpt] > 1
e-6)
118 solutionD_[cmpt] = -1;
122 solutionD_[cmpt] = 1;
130 geometricD_ = solutionD_;
134 reduce(wedgeDirVec, sumOp<vector>());
136 wedgeDirVec /=
mag(wedgeDirVec);
140 if (wedgeDirVec[cmpt] > 1
e-6)
142 geometricD_[cmpt] = -1;
146 geometricD_[cmpt] = 1;
155 typeIOobject<labelIOList> io
171 return autoPtr<labelIOList>(
nullptr);
187 time().findInstance(meshDir(),
"points"),
199 time().findInstance(meshDir(),
"faces"),
230 clearedPrimitives_(false),
248 tetBasePtIsPtr_(readTetBasePtIs()),
306 globalMeshDataPtr_(nullptr),
307 curMotionTimeIndex_(-1),
308 oldPointsPtr_(nullptr),
309 oldCellCentresPtr_(nullptr),
310 storeOldCellCentres_(false),
344 boundary_.calcGeometry();
351 <<
"no points in mesh" <<
endl;
356 <<
"no cells in mesh" <<
endl;
433 clearedPrimitives_(false),
448 bounds_(points_, syncPar),
452 tetBasePtIsPtr_(readTetBasePtIs()),
492 globalMeshDataPtr_(nullptr),
493 curMotionTimeIndex_(-1),
494 oldPointsPtr_(nullptr),
495 oldCellCentresPtr_(nullptr),
496 storeOldCellCentres_(false),
503 const face& curFace = faces_[facei];
505 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
508 <<
"Face " << facei <<
"contains vertex labels out of range: "
509 << curFace <<
" Max point index = " << points_.
size()
582 clearedPrimitives_(false),
597 bounds_(points_, syncPar),
601 tetBasePtIsPtr_(readTetBasePtIs()),
641 globalMeshDataPtr_(nullptr),
642 curMotionTimeIndex_(-1),
643 oldPointsPtr_(nullptr),
644 oldCellCentresPtr_(nullptr),
645 storeOldCellCentres_(false),
652 const face& curFace = faces_[facei];
654 if (
min(curFace) < 0 ||
max(curFace) > points_.
size())
657 <<
"Face " << facei <<
"contains vertex labels out of range: "
658 << curFace <<
" Max point index = " << points_.
size()
669 const cell& curCell = cLst[celli];
671 if (
min(curCell) < 0 ||
max(curCell) > faces_.size())
674 <<
"Cell " << celli <<
"contains face labels out of range: "
675 << curCell <<
" Max face index = " << faces_.size()
689 points_(move(
mesh.points_)),
690 faces_(move(
mesh.faces_)),
691 owner_(move(
mesh.owner_)),
692 neighbour_(move(
mesh.neighbour_)),
693 clearedPrimitives_(
mesh.clearedPrimitives_),
694 boundary_(move(
mesh.boundary_)),
695 bounds_(move(
mesh.bounds_)),
697 geometricD_(
mesh.geometricD_),
698 solutionD_(
mesh.solutionD_),
699 tetBasePtIsPtr_(move(
mesh.tetBasePtIsPtr_)),
700 pointZones_(move(
mesh.pointZones_)),
701 faceZones_(move(
mesh.faceZones_)),
702 cellZones_(move(
mesh.cellZones_)),
703 globalMeshDataPtr_(move(
mesh.globalMeshDataPtr_)),
704 curMotionTimeIndex_(
mesh.curMotionTimeIndex_),
705 oldPointsPtr_(move(
mesh.oldPointsPtr_)),
706 oldCellCentresPtr_(move(
mesh.oldCellCentresPtr_)),
707 storeOldCellCentres_(
mesh.storeOldCellCentres_),
708 moving_(
mesh.moving_),
709 topoChanged_(
mesh.topoChanged_)
721 const bool validBoundary
725 clearAddressing(
true);
732 bounds_ =
boundBox(points_, validBoundary);
737 faces_ = move(faces);
742 owner_ = move(owner);
747 neighbour_ = move(neighbour);
766 setInstance(time().
name());
771 const face& curFace = faces_[facei];
773 if (
min(curFace) < 0 ||
max(curFace) > points_.size())
776 <<
"Face " << facei <<
" contains vertex labels out of range: "
777 << curFace <<
" Max point index = " << points_.
size()
795 boundary_.topoChange();
798 boundary_.calcGeometry();
808 <<
"no points or no cells in mesh"
818 clearAddressing(
true);
822 points_.swap(otherMesh.points_);
824 faces_.swap(otherMesh.faces_);
825 owner_.swap(otherMesh.owner_);
826 neighbour_.swap(otherMesh.neighbour_);
829 boundary_.clearGeom();
830 boundary_.clearAddressing();
835 auto updatePatches = []
841 boundaryMesh.resize(otherPatches.
size());
843 forAll(otherPatches, otherPatchi)
849 if (isA<processorPolyPatch>(otherPatches[otherPatchi]))
854 otherPatches[otherPatchi].
clone(boundaryMesh)
861 boundaryMesh[otherPatchi],
864 otherPatches[otherPatchi].size(),
865 otherPatches[otherPatchi].start()
883 updatePatches(otherPatches, boundary_);
884 updatePatches(
patches, otherMesh.boundary_);
888 globalMeshDataPtr_.clear();
889 otherMesh.globalMeshDataPtr_.clear();
892 setInstance(time().
name());
900 const face& curFace =
mesh.faces_[facei];
905 <<
"Face " << facei <<
" contains vertex labels out of "
906 <<
"range: " << curFace <<
" Max point index = "
913 checkFaces(otherMesh);
918 otherMesh.initMesh();
921 boundary_.topoChange();
925 boundary_.calcGeometry();
926 otherMesh.boundary_.calcGeometry();
929 if (foundObject<pointMesh>(pointMesh::typeName))
940 pointZones_.swap(otherMesh.pointZones_);
941 faceZones_.swap(otherMesh.faceZones_);
942 cellZones_.swap(otherMesh.cellZones_);
982 return dbDir()/meshSubDir;
988 return points_.instance();
994 return faces_.instance();
1000 return points_.writeOpt();
1006 return faces_.writeOpt();
1012 if (geometricD_.x() == 0)
1029 if (solutionD_.x() == 0)
1046 if (tetBasePtIsPtr_.empty())
1051 <<
"Forcing storage of base points."
1055 tetBasePtIsPtr_.reset
1073 return tetBasePtIsPtr_();
1080 const bool validBoundary
1083 if (boundaryMesh().size())
1086 <<
"boundary already exists"
1094 boundary_.setSize(
p.size());
1099 boundary_.set(pI,
p[pI]);
1106 globalMeshDataPtr_.clear();
1122 if (pointZones().size() || faceZones().size() || cellZones().size())
1125 <<
"point, face or cell zone already exists"
1132 pointZones_.setSize(pz.
size());
1137 pointZones_.set(pI, pz[pI]->
name(), pz[pI]);
1146 faceZones_.setSize(fz.
size());
1151 faceZones_.set(fI, fz[fI]->
name(), fz[fI]);
1160 cellZones_.setSize(cz.
size());
1165 cellZones_.set(cI, cz[cI]->
name(), cz[cI]);
1176 const bool validBoundary
1180 boundary_.clearGeom();
1181 clearAddressing(
true);
1206 setInstance(time().
name());
1208 boundary_.reorderPatches(newToOld, validBoundary);
1211 meshObjects::reorderPatches<polyMesh>(*
this, newToOld, validBoundary);
1212 meshObjects::reorderPatches<pointMesh>(*
this, newToOld, validBoundary);
1218 const label insertPatchi,
1222 const label sz = boundary_.size();
1224 label startFacei = nFaces();
1225 if (insertPatchi < sz)
1227 startFacei = boundary_[insertPatchi].start();
1234 for (
label i = 0; i < insertPatchi; i++)
1238 for (
label i = insertPatchi; i < sz; i++)
1242 newToOld[insertPatchi] = -1;
1245 reorderPatches(newToOld,
false);
1248 boundary_.clearGeom();
1249 clearAddressing(
true);
1285 meshObjects::addPatch<polyMesh>(*
this, insertPatchi);
1286 meshObjects::addPatch<pointMesh>(*
this, insertPatchi);
1293 boundary_.topoChange();
1296 boundary_.calcGeometry();
1298 boundary_.checkDefinition();
1304 if (clearedPrimitives_)
1307 <<
"points deallocated"
1317 if (clearedPrimitives_)
1320 <<
"faces deallocated"
1347 if (oldPointsPtr_.empty())
1350 <<
"Old points have not been stored"
1354 return oldPointsPtr_();
1360 storeOldCellCentres_ =
true;
1364 return cellCentres();
1367 if (oldCellCentresPtr_.empty())
1370 <<
"Old cell centres have not been stored"
1374 return oldCellCentresPtr_();
1383 <<
"Set points for time " << time().value()
1384 <<
" index " << time().timeIndex() <<
endl;
1389 points_ = newPoints;
1391 setPointsInstance(time().
name());
1394 if (globalMeshDataPtr_.valid())
1396 globalMeshDataPtr_().movePoints(points_);
1402 boundary_.movePoints(points_);
1404 pointZones_.movePoints(points_);
1405 faceZones_.movePoints(points_);
1406 cellZones_.movePoints(points_);
1412 meshObjects::movePoints<polyMesh>(*
this);
1413 meshObjects::movePoints<pointMesh>(*
this);
1425 <<
"Moving points for time " << time().value()
1426 <<
" index " << time().timeIndex() <<
endl;
1430 if (curMotionTimeIndex_ != time().
timeIndex())
1432 oldPointsPtr_.clear();
1433 oldPointsPtr_.reset(
new pointField(points_));
1434 if (storeOldCellCentres_)
1436 oldCellCentresPtr_.clear();
1437 oldCellCentresPtr_.reset(
new pointField(cellCentres()));
1439 curMotionTimeIndex_ = time().timeIndex();
1442 points_ = newPoints;
1444 setPointsInstance(time().
name());
1453 if (globalMeshDataPtr_.valid())
1455 globalMeshDataPtr_().movePoints(points_);
1461 boundary_.movePoints(points_);
1463 pointZones_.movePoints(points_);
1464 faceZones_.movePoints(points_);
1465 cellZones_.movePoints(points_);
1471 meshObjects::movePoints<polyMesh>(*
this);
1472 meshObjects::movePoints<pointMesh>(*
this);
1480 curMotionTimeIndex_ = -1;
1481 oldPointsPtr_.clear();
1482 oldCellCentresPtr_.clear();
1488 if (globalMeshDataPtr_.empty())
1492 Pout<<
"polyMesh::globalData() const : "
1493 <<
"Constructing parallelData from processor topology"
1500 return globalMeshDataPtr_();
1518 fileName meshFilesPath = thisDb().time().
path()/instanceDir/meshDir();
1520 rm(meshFilesPath/
"points");
1521 rm(meshFilesPath/
"faces");
1522 rm(meshFilesPath/
"owner");
1523 rm(meshFilesPath/
"neighbour");
1524 rm(meshFilesPath/
"cells");
1525 rm(meshFilesPath/
"boundary");
1526 rm(meshFilesPath/
"pointZones");
1527 rm(meshFilesPath/
"faceZones");
1528 rm(meshFilesPath/
"cellZones");
1529 rm(meshFilesPath/
"meshModifiers");
1530 rm(meshFilesPath/
"parallelData");
1533 if (
isDir(meshFilesPath/
"sets"))
1535 rmDir(meshFilesPath/
"sets");
1542 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....
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
label size() const
Return number of elements in table.
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...
bool processorCase() const
Return true if this is a processor case.
Inter-processor communications stream.
static bool & parRun()
Is this a parallel run?
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 /)
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?
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.
bool foundObject(const word &name) const
Is the named Type in registry.
Mesh representing a set of points created from polyMesh.
void reset()
Reset pointMesh with respect to the updated polyMesh.
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.
static bool found(const IOobject &io)
Return whether the given IOobject relates to a mesh on disk.
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 clearAddressing(const bool isMeshUpdate=false)
Clear addressing.
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.
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 InfoInFunction
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.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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.
defineTypeNameAndDebug(combustionModel, 0)
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)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void cmptMag(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)