68 const int Foam::faMesh::quadricsFit_ = 0;
125 for (
const label facei :
pbm[patchi].
range())
140 void Foam::faMesh::checkBoundaryEdgeLabelRange
147 for (
const label edgei : edgeLabels)
149 if (edgei < nInternalEdges_ || edgei >= nEdges_)
154 <<
"Boundary edge label out of range " 155 << nInternalEdges_ <<
".." << (nEdges_-1) <<
nl 170 void Foam::faMesh::initPatch()
const 176 UIndirectList<face>(
mesh().faces(), faceLabels_),
185 bndConnectPtr_.reset(
nullptr);
186 haloMapPtr_.reset(
nullptr);
187 haloFaceCentresPtr_.reset(
nullptr);
188 haloFaceNormalsPtr_.reset(
nullptr);
192 void Foam::faMesh::setPrimitiveMeshData()
201 nEdges_ = bp.nEdges();
202 nInternalEdges_ = bp.nInternalEdges();
204 nPoints_ = bp.nPoints();
206 edges_.resize(nEdges_);
207 edgeOwner_.resize(nEdges_);
208 edgeNeighbour_.resize(nInternalEdges_);
211 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
213 edges_[edgei] = bp.edges()[edgei];
215 edgeOwner_[edgei] = edgeFaces[edgei][0];
217 edgeNeighbour_[edgei] = edgeFaces[edgei][1];
221 label edgei = nInternalEdges_;
225 for (
const label patchEdgei :
p.edgeLabels())
227 edges_[edgei] = bp.edges()[patchEdgei];
229 edgeOwner_[edgei] = edgeFaces[patchEdgei][0];
237 void Foam::faMesh::clearHalo()
const 241 haloMapPtr_.reset(
nullptr);
242 haloFaceCentresPtr_.reset(
nullptr);
243 haloFaceNormalsPtr_.reset(
nullptr);
247 void Foam::faMesh::clearGeomNotAreas()
const 252 patchPtr_.reset(
nullptr);
253 polyPatchFacesPtr_.reset(
nullptr);
254 polyPatchIdsPtr_.reset(
nullptr);
255 bndConnectPtr_.reset(
nullptr);
264 pointAreaNormalsPtr_.reset(
nullptr);
270 void Foam::faMesh::clearGeom()
const 281 void Foam::faMesh::clearAddressing()
const 289 void Foam::faMesh::clearOut()
const 293 globalMeshDataPtr_.reset(
nullptr);
306 faceCentresPtr_->boundaryFieldRef()
311 if (faceAreaNormalsPtr_)
313 faceAreaNormalsPtr_->boundaryFieldRef()
324 setPrimitiveMeshData();
334 boundary_.updateMesh();
337 boundary_.calcGeometry();
377 time().findInstance(meshDir(),
"faceLabels"),
395 faceLabels_.instance()
408 polyPatchFacesPtr_(nullptr),
409 polyPatchIdsPtr_(nullptr),
410 bndConnectPtr_(nullptr),
416 patchStartsPtr_(nullptr),
419 faceCentresPtr_(nullptr),
420 edgeCentresPtr_(nullptr),
421 faceAreaNormalsPtr_(nullptr),
422 edgeAreaNormalsPtr_(nullptr),
423 pointAreaNormalsPtr_(nullptr),
424 faceCurvaturesPtr_(nullptr),
425 edgeTransformTensorsPtr_(nullptr),
426 correctPatchPointNormalsPtr_(nullptr),
427 globalMeshDataPtr_(nullptr),
429 haloMapPtr_(nullptr),
430 haloFaceCentresPtr_(nullptr),
431 haloFaceNormalsPtr_(nullptr)
435 setPrimitiveMeshData();
459 rio.resetHeader(
"S0");
462 S0Ptr_ =
new DimensionedField<scalar, areaMesh>
475 const polyMesh& pMesh,
504 mesh().facesInstance(),
517 mesh().facesInstance(),
530 polyPatchFacesPtr_(nullptr),
531 polyPatchIdsPtr_(nullptr),
532 bndConnectPtr_(nullptr),
538 patchStartsPtr_(nullptr),
541 faceCentresPtr_(nullptr),
542 edgeCentresPtr_(nullptr),
543 faceAreaNormalsPtr_(nullptr),
544 edgeAreaNormalsPtr_(nullptr),
545 pointAreaNormalsPtr_(nullptr),
546 faceCurvaturesPtr_(nullptr),
547 edgeTransformTensorsPtr_(nullptr),
548 correctPatchPointNormalsPtr_(nullptr),
549 globalMeshDataPtr_(nullptr),
551 haloMapPtr_(nullptr),
552 haloFaceCentresPtr_(nullptr),
553 haloFaceNormalsPtr_(nullptr)
559 nFaces_ = faceLabels_.
size();
575 static_cast<const
dictionary*>(baseMesh.hasSchemes())
582 static_cast<const
dictionary*>(baseMesh.hasSolution())
589 mesh().facesInstance(),
602 mesh().facesInstance(),
615 polyPatchFacesPtr_(nullptr),
616 polyPatchIdsPtr_(nullptr),
617 bndConnectPtr_(nullptr),
623 patchStartsPtr_(nullptr),
626 faceCentresPtr_(nullptr),
627 edgeCentresPtr_(nullptr),
628 faceAreaNormalsPtr_(nullptr),
629 edgeAreaNormalsPtr_(nullptr),
630 pointAreaNormalsPtr_(nullptr),
631 faceCurvaturesPtr_(nullptr),
632 edgeTransformTensorsPtr_(nullptr),
633 correctPatchPointNormalsPtr_(nullptr),
634 globalMeshDataPtr_(nullptr),
636 haloMapPtr_(nullptr),
637 haloFaceCentresPtr_(nullptr),
638 haloFaceNormalsPtr_(nullptr)
644 nFaces_ = faceLabels_.
size();
648 Foam::faMesh::faMesh(
const polyPatch&
pp,
const bool doInit)
661 createOnePatch(
"default")
666 setPrimitiveMeshData();
677 const polyMesh& pMesh,
678 const dictionary& faMeshDefinition,
687 pMesh.boundaryMesh(),
688 faMeshDefinition.
get<wordRes>(
"polyMeshPatches")
698 faMeshDefinition.subDict(
"boundary"),
701 faMeshDefinition.getOrDefault<word>(
"emptyPatch",
word::null),
704 faMeshDefinition.findDict(
"defaultPatch")
732 rio.resetHeader(
"S0");
735 S0Ptr_ =
new DimensionedField<scalar, areaMesh>
758 return static_cast<const faSchemes*
>(
this);
770 return static_cast<const faSchemes&
>(*this);
840 for (label& val : list)
843 val = faceOwner[val];
854 Foam::rm(meshFilesPath/
"faceLabels");
855 Foam::rm(meshFilesPath/
"faBoundary");
861 removeFiles(thisDb().instance());
867 if (!patchStartsPtr_)
872 return *patchStartsPtr_;
900 if (!faceCentresPtr_)
905 return *faceCentresPtr_;
911 if (!edgeCentresPtr_)
916 return *edgeCentresPtr_;
938 <<
"S0 is not available" 951 S00Ptr_ =
new DimensionedField<scalar, areaMesh>
973 if (!faceAreaNormalsPtr_)
975 calcFaceAreaNormals();
978 return *faceAreaNormalsPtr_;
984 if (!edgeAreaNormalsPtr_)
986 calcEdgeAreaNormals();
989 return *edgeAreaNormalsPtr_;
995 if (!pointAreaNormalsPtr_)
999 calcPointAreaNormals(*pointAreaNormalsPtr_);
1001 if (quadricsFit_ > 0)
1003 calcPointAreaNormalsByQuadricsFit(*pointAreaNormalsPtr_);
1007 return *pointAreaNormalsPtr_;
1013 if (!faceCurvaturesPtr_)
1015 calcFaceCurvatures();
1018 return *faceCurvaturesPtr_;
1025 if (!edgeTransformTensorsPtr_)
1027 calcEdgeTransformTensors();
1030 return *edgeTransformTensorsPtr_;
1036 return bool(globalMeshDataPtr_);
1042 if (!globalMeshDataPtr_)
1047 return *globalMeshDataPtr_;
1055 calcLduAddressing();
1070 if (S00Ptr_ && S0Ptr_)
1085 S0Ptr_ =
new DimensionedField<scalar, areaMesh>
1100 curTimeIndex_ = time().timeIndex();
1103 clearGeomNotAreas();
1107 patchPtr_->movePoints(newPoints);
1111 boundary_.movePoints(newPoints);
1128 bool(correctPatchPointNormalsPtr_)
1141 if (!correctPatchPointNormalsPtr_)
1146 return *correctPatchPointNormalsPtr_;
1152 faceLabels_.write();
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
registerOptSwitch("fa:geometryOrder", int, faMesh::geometryOrder_)
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
const labelList patchIDs(pbm.indices(polyPatchNames, true))
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
void addFaPatches(faPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const DimensionedField< scalar, areaMesh > & S00() const
Return old-old-time face areas.
const fileName & facesInstance() const
Return the current instance directory for faces.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
const Time & time() const
Return reference to time.
void syncGeom()
Processor/processor synchronisation for geometry fields.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
const DimensionedField< scalar, areaMesh > & S() const
Return face areas.
Face to edge interpolation scheme. Included in faMesh.
bool operator!=(const faMesh &m) const
static bool & parRun() noexcept
Test if this a parallel run.
Various mesh related information for a parallel run.
Generic GeometricField class.
const faGlobalMeshData & globalData() const
Return parallel info (demand-driven)
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
static std::string path(const std::string &str)
Return directory path name (part before last /)
const labelList & patchStarts() const
Return patch starts.
Ignore writing from objectRegistry::writeObject()
bool movePoints() const
Do what is necessary if the mesh has moved.
const Time & time() const
Return the top-level database.
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
const areaVectorField & areaCentres() const
Return face centres as areaVectorField.
labelList faceLabels(nFaceLabels)
List< labelList > labelListList
List of labelList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual const objectRegistry & thisDb() const
Return reference to the mesh database.
const edgeScalarField & magLe() const
Return edge length magnitudes.
bool hasGlobalData() const noexcept
Is demand-driven parallel info available?
UList< label > labelUList
A UList of labels.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
virtual const pointField & points() const
Return raw points.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
virtual bool hasDb() const
Return true if thisDb() is a valid DB.
const fileName & pointsInstance() const
Return the current instance directory for points.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual ~faMesh()
Destructor.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
A class for handling words, derived from Foam::string.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
bool operator==(const faMesh &m) const
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
#define DebugInFunction
Report an information message using Foam::Info.
const edgeVectorField & Le() const
Return edge length vectors.
label size() const noexcept
The number of entries in the list.
static const word prefix
The prefix to local: finite-area.
virtual const labelList & faceOwner() const
Return face owner.
static const word null
An empty word.
A List of wordRe with additional matching capabilities.
errorManip< error > abort(error &err)
#define DebugInfo
Report an information message using Foam::Info.
const FieldField< Field, tensor > & edgeTransformTensors() const
Return edge transformation tensors.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
static labelList selectPatchFaces(const polyBoundaryMesh &pbm, const wordRes &polyPatchNames)
virtual bool movePoints()
Update after mesh motion.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
virtual bool write(const bool writeOnProc=true) const
Write mesh.
defineTypeNameAndDebug(combustionModel, 0)
const polyMesh & mesh() const
Return access to polyMesh.
const areaScalarField & faceCurvatures() const
Return face curvatures.
boolList & correctPatchPointNormals() const
Set whether point normals should be corrected for a patch.
Template functions to aid in the implementation of demand driven data.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
const fileName & facesInstance() const
Return the current instance directory for faces.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
Selector class for finite area differencing schemes. faMesh is derived from faSchemes so that all fie...
const edgeVectorField & edgeCentres() const
Return edge centres as edgeVectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
IOobject(const IOobject &)=default
Copy construct.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const faSchemes * hasSchemes() const
Non-null if faSchemes exists (can test as bool).
Automatically write from objectRegistry::writeObject()
const std::string patch
OpenFOAM patch number as a std::string.
const fileName & pointsInstance() const
Return the current instance directory for points.
Selector class for finite area solution. faMesh is derived from faSolution so that all fields have ac...
const edgeVectorField & edgeAreaNormals() const
Return edge area normals.
bool init(const bool doInit)
Initialise non-demand-driven data etc.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
labelList faceCells() const
The volume (owner) cells associated with the area-mesh.
Reading is optional [identical to READ_IF_PRESENT].
Field< vector > vectorField
Specialisation of Field<T> for vector.
static const objectRegistry * registry(const polyMesh &pMesh)
The parent registry containing all finite-area meshes on the polyMesh.
static int geometryOrder_
Geometry treatment.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
void removeFiles() const
Remove all files from mesh instance()
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void deleteDemandDrivenData(DataPtr &dataPtr)
const vectorField & pointAreaNormals() const
Return point area normals.
Defines the attributes of an object for which implicit objectRegistry management is supported...
const areaVectorField & faceAreaNormals() const
Return face area normals.
const faSolution & solution() const
Read-access to the faSolution controls.
List< bool > boolList
A List of bools.
const faSolution * hasSolution() const
Non-null if faSolution exists (can test as bool).
Inter-processor communications stream.
Do not request registration (bool: false)
const dimensionSet dimArea(sqr(dimLength))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const DimensionedField< scalar, areaMesh > & S0() const
Return old-time face areas.
const faSchemes & schemes() const
Read-access to the faSchemes controls.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
static constexpr const zero Zero
Global zero (0)