64 const Foam::word Foam::faMesh::prefix_(
"finite-area");
68 const int Foam::faMesh::quadricsFit_ = 0;
92 const word& volRegion,
93 const word& areaRegion
128 const word& volRegion,
129 const word& areaRegion
176 const word& areaRegion
187 if (areaRegion.empty())
231 for (
const label facei :
pbm[patchi].
range())
246 void Foam::faMesh::checkBoundaryEdgeLabelRange
253 for (
const label edgei : edgeLabels)
255 if (edgei < nInternalEdges_ || edgei >= nEdges_)
260 <<
"Boundary edge label out of range " 261 << nInternalEdges_ <<
".." << (nEdges_-1) <<
nl 276 void Foam::faMesh::initPatch()
const 278 patchPtr_ = std::make_unique<uindirectPrimitivePatch>
280 UIndirectList<face>(
mesh().
faces(), faceLabels_),
289 bndConnectPtr_.reset(
nullptr);
290 haloMapPtr_.reset(
nullptr);
291 haloFaceCentresPtr_.reset(
nullptr);
292 haloFaceNormalsPtr_.reset(
nullptr);
296 void Foam::faMesh::setPrimitiveMeshData()
305 nEdges_ = bp.nEdges();
306 nInternalEdges_ = bp.nInternalEdges();
308 nPoints_ = bp.nPoints();
310 edges_.resize(nEdges_);
311 edgeOwner_.resize(nEdges_);
312 edgeNeighbour_.resize(nInternalEdges_);
315 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
317 edges_[edgei] = bp.edges()[edgei];
319 edgeOwner_[edgei] = edgeFaces[edgei][0];
321 edgeNeighbour_[edgei] = edgeFaces[edgei][1];
325 label edgei = nInternalEdges_;
329 for (
const label patchEdgei :
p.edgeLabels())
331 edges_[edgei] = bp.edges()[patchEdgei];
333 edgeOwner_[edgei] = edgeFaces[patchEdgei][0];
341 void Foam::faMesh::clearHalo()
const 345 haloMapPtr_.reset(
nullptr);
346 haloFaceCentresPtr_.reset(
nullptr);
347 haloFaceNormalsPtr_.reset(
nullptr);
351 void Foam::faMesh::clearGeomNotAreas()
const 356 patchPtr_.reset(
nullptr);
357 polyPatchFacesPtr_.reset(
nullptr);
358 polyPatchIdsPtr_.reset(
nullptr);
359 bndConnectPtr_.reset(
nullptr);
360 SPtr_.reset(
nullptr);
361 patchStartsPtr_.reset(
nullptr);
362 LePtr_.reset(
nullptr);
363 magLePtr_.reset(
nullptr);
364 faceCentresPtr_.reset(
nullptr);
365 edgeCentresPtr_.reset(
nullptr);
366 faceAreaNormalsPtr_.reset(
nullptr);
367 edgeAreaNormalsPtr_.reset(
nullptr);
368 pointAreaNormalsPtr_.reset(
nullptr);
369 faceCurvaturesPtr_.reset(
nullptr);
370 edgeTransformTensorsPtr_.reset(
nullptr);
374 void Foam::faMesh::clearGeom()
const 379 S0Ptr_.reset(
nullptr);
380 S00Ptr_.reset(
nullptr);
381 correctPatchPointNormalsPtr_.reset(
nullptr);
385 void Foam::faMesh::clearAddressing()
const 389 lduPtr_.reset(
nullptr);
393 void Foam::faMesh::clearOut()
const 397 globalMeshDataPtr_.reset(
nullptr);
410 faceCentresPtr_->boundaryFieldRef()
415 if (faceAreaNormalsPtr_)
417 faceAreaNormalsPtr_->boundaryFieldRef()
428 setPrimitiveMeshData();
438 boundary_.updateMesh();
441 boundary_.calcGeometry();
453 const word& meshName,
480 const word& meshName,
501 const word& meshName,
590 const word& meshName,
612 time().findInstance(meshDir(),
"faceLabels"),
630 faceLabels_.instance()
644 setPrimitiveMeshData();
668 rio.resetHeader(
"S0");
671 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
684 const word& meshName,
685 const polyMesh& pMesh,
689 faMeshRegistry(meshName, pMesh),
693 IOobjectOption::MUST_READ
698 IOobjectOption::MUST_READ
700 edgeInterpolation(*this),
706 pMesh.facesInstance(),
719 faceLabels_.instance(),
735 nFaces_ = faceLabels_.size();
743 const word& meshName,
766 pMesh.facesInstance(),
779 faceLabels_.instance(),
795 nFaces_ = faceLabels_.size();
806 const word& meshName,
817 static_cast<const
dictionary*>(baseMesh.hasSchemes())
823 static_cast<const
dictionary*>(baseMesh.hasSolution())
832 baseMesh.
mesh().facesInstance(),
845 faceLabels_.instance(),
861 nFaces_ = faceLabels_.size();
867 const word& meshName,
884 createOnePatch(
"default")
889 setPrimitiveMeshData();
900 const word& meshName,
901 const polyMesh& pMesh,
902 const dictionary& faMeshDefinition,
912 pMesh.boundaryMesh(),
913 faMeshDefinition.
get<wordRes>(
"polyMeshPatches")
923 faMeshDefinition.subDict(
"boundary"),
926 faMeshDefinition.getOrDefault<word>(
"emptyPatch",
word::null),
929 faMeshDefinition.findDict(
"defaultPatch")
957 rio.resetHeader(
"S0");
960 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
983 return static_cast<const faSchemes*
>(
this);
995 return static_cast<const faSchemes&
>(*this);
1007 return static_cast<const faSolution&
>(*this);
1059 for (label& val : list)
1062 val = faceOwner[val];
1073 Foam::rm(meshFilesPath/
"faceLabels");
1074 Foam::rm(meshFilesPath/
"faBoundary");
1080 removeFiles(thisDb().instance());
1086 if (!patchStartsPtr_)
1091 return *patchStartsPtr_;
1119 if (!faceCentresPtr_)
1124 return *faceCentresPtr_;
1130 if (!edgeCentresPtr_)
1135 return *edgeCentresPtr_;
1157 <<
"S0 is not available" 1170 S00Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1192 if (!faceAreaNormalsPtr_)
1194 calcFaceAreaNormals();
1197 return *faceAreaNormalsPtr_;
1203 if (!edgeAreaNormalsPtr_)
1205 calcEdgeAreaNormals();
1208 return *edgeAreaNormalsPtr_;
1214 if (!pointAreaNormalsPtr_)
1216 pointAreaNormalsPtr_ = std::make_unique<vectorField>(
nPoints());
1218 calcPointAreaNormals(*pointAreaNormalsPtr_);
1220 if (quadricsFit_ > 0)
1222 calcPointAreaNormalsByQuadricsFit(*pointAreaNormalsPtr_);
1226 return *pointAreaNormalsPtr_;
1232 if (!faceCurvaturesPtr_)
1234 calcFaceCurvatures();
1237 return *faceCurvaturesPtr_;
1244 if (!edgeTransformTensorsPtr_)
1246 calcEdgeTransformTensors();
1249 return *edgeTransformTensorsPtr_;
1255 return bool(globalMeshDataPtr_);
1261 if (!globalMeshDataPtr_)
1266 return *globalMeshDataPtr_;
1274 calcLduAddressing();
1289 if (S00Ptr_ && S0Ptr_)
1304 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1319 curTimeIndex_ = time().timeIndex();
1322 clearGeomNotAreas();
1326 patchPtr_->movePoints(newPoints);
1330 boundary_.movePoints(newPoints);
1347 bool(correctPatchPointNormalsPtr_)
1360 if (!correctPatchPointNormalsPtr_)
1362 correctPatchPointNormalsPtr_ =
1366 return *correctPatchPointNormalsPtr_;
1372 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
faMesh(const faMesh &)=delete
No copy construct.
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.
const word & name() const noexcept
Return the object name.
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...
The objectRegistry for faMesh.
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)
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.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
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.
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.
A field of fields is a PtrList of fields with reference counting.
virtual const objectRegistry & thisDb() const
Reference to the mesh database.
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.
virtual const fileName & dbDir() const
Local directory path of the objectRegistry relative to Time with override for the single-region case...
const fileName & pointsInstance() const
Return the current instance directory for points.
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.
const Time & time() const noexcept
Return time registry.
#define DebugInFunction
Report an information message using Foam::Info.
static word defaultRegion
Return the default region name.
const edgeVectorField & Le() const
Return edge length vectors.
label size() const noexcept
The number of entries in the list.
virtual const labelList & faceOwner() const
Return face owner.
static const word null
An empty word.
A List of wordRe with additional matching capabilities.
virtual const faceList & faces() const
Return raw faces.
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.
const objectRegistry & parent() const noexcept
Return the parent objectRegistry.
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.
const objectRegistry & thisDb() const noexcept
Return the object registry.
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.
static const word & prefix() noexcept
The prefix to the parent registry name: finite-area.
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.
const faSolution * hasSolution() const
Non-null if faSolution exists (can test as bool).
static const word & regionName(const word ®ion)
The mesh region name or word::null if polyMesh::defaultRegion.
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)