63 const Foam::word Foam::faMesh::prefix_(
"finite-area");
67 const int Foam::faMesh::quadricsFit_ = 0;
91 const word& volRegion,
92 const word& areaRegion
127 const word& volRegion,
128 const word& areaRegion
175 const word& areaRegion
186 if (areaRegion.empty())
230 for (
const label facei :
pbm[patchi].
range())
245 void Foam::faMesh::checkBoundaryEdgeLabelRange
252 for (
const label edgei : edgeLabels)
254 if (edgei < nInternalEdges_ || edgei >= nEdges_)
259 <<
"Boundary edge label out of range " 260 << nInternalEdges_ <<
".." << (nEdges_-1) <<
nl 275 void Foam::faMesh::initPatch()
const 277 patchPtr_ = std::make_unique<uindirectPrimitivePatch>
279 UIndirectList<face>(
mesh().
faces(), faceLabels_),
288 bndConnectPtr_.reset(
nullptr);
289 haloMapPtr_.reset(
nullptr);
290 haloFaceCentresPtr_.reset(
nullptr);
291 haloFaceNormalsPtr_.reset(
nullptr);
295 void Foam::faMesh::setPrimitiveMeshData()
304 nEdges_ = bp.nEdges();
305 nInternalEdges_ = bp.nInternalEdges();
307 nPoints_ = bp.nPoints();
309 edges_.resize(nEdges_);
310 edgeOwner_.resize(nEdges_);
311 edgeNeighbour_.resize(nInternalEdges_);
314 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
316 edges_[edgei] = bp.edges()[edgei];
318 edgeOwner_[edgei] = edgeFaces[edgei][0];
320 edgeNeighbour_[edgei] = edgeFaces[edgei][1];
324 label edgei = nInternalEdges_;
328 for (
const label patchEdgei :
p.edgeLabels())
330 edges_[edgei] = bp.edges()[patchEdgei];
332 edgeOwner_[edgei] = edgeFaces[patchEdgei][0];
340 void Foam::faMesh::clearHalo()
const 344 haloMapPtr_.reset(
nullptr);
345 haloFaceCentresPtr_.reset(
nullptr);
346 haloFaceNormalsPtr_.reset(
nullptr);
350 void Foam::faMesh::clearGeomNotAreas()
const 355 patchPtr_.reset(
nullptr);
356 polyPatchFacesPtr_.reset(
nullptr);
357 polyPatchIdsPtr_.reset(
nullptr);
358 bndConnectPtr_.reset(
nullptr);
359 SPtr_.reset(
nullptr);
360 patchStartsPtr_.reset(
nullptr);
361 LePtr_.reset(
nullptr);
362 magLePtr_.reset(
nullptr);
363 faceCentresPtr_.reset(
nullptr);
364 edgeCentresPtr_.reset(
nullptr);
365 faceAreaNormalsPtr_.reset(
nullptr);
366 edgeAreaNormalsPtr_.reset(
nullptr);
367 pointAreaNormalsPtr_.reset(
nullptr);
368 faceCurvaturesPtr_.reset(
nullptr);
369 edgeTransformTensorsPtr_.reset(
nullptr);
373 void Foam::faMesh::clearGeom()
const 378 S0Ptr_.reset(
nullptr);
379 S00Ptr_.reset(
nullptr);
380 correctPatchPointNormalsPtr_.reset(
nullptr);
384 void Foam::faMesh::clearAddressing()
const 388 lduPtr_.reset(
nullptr);
392 void Foam::faMesh::clearOut()
const 396 globalMeshDataPtr_.reset(
nullptr);
409 faceCentresPtr_->boundaryFieldRef()
414 if (faceAreaNormalsPtr_)
416 faceAreaNormalsPtr_->boundaryFieldRef()
427 setPrimitiveMeshData();
437 boundary_.updateMesh();
440 boundary_.calcGeometry();
452 const word& meshName,
479 const word& meshName,
500 const word& meshName,
589 const word& meshName,
611 time().findInstance(meshDir(),
"faceLabels"),
629 faceLabels_.instance()
643 setPrimitiveMeshData();
667 rio.resetHeader(
"S0");
670 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
683 const word& meshName,
684 const polyMesh& pMesh,
688 faMeshRegistry(meshName, pMesh),
692 IOobjectOption::MUST_READ
697 IOobjectOption::MUST_READ
699 edgeInterpolation(*this),
705 pMesh.facesInstance(),
718 faceLabels_.instance(),
734 nFaces_ = faceLabels_.size();
742 const word& meshName,
765 pMesh.facesInstance(),
778 faceLabels_.instance(),
794 nFaces_ = faceLabels_.size();
805 const word& meshName,
816 static_cast<const
dictionary*>(baseMesh.hasSchemes())
822 static_cast<const
dictionary*>(baseMesh.hasSolution())
831 baseMesh.
mesh().facesInstance(),
844 faceLabels_.instance(),
860 nFaces_ = faceLabels_.size();
866 const word& meshName,
883 createOnePatch(
"default")
888 setPrimitiveMeshData();
899 const word& meshName,
900 const polyMesh& pMesh,
901 const dictionary& faMeshDefinition,
911 pMesh.boundaryMesh(),
912 faMeshDefinition.
get<wordRes>(
"polyMeshPatches")
922 faMeshDefinition.subDict(
"boundary"),
925 faMeshDefinition.getOrDefault<word>(
"emptyPatch",
word::null),
928 faMeshDefinition.findDict(
"defaultPatch")
956 rio.resetHeader(
"S0");
959 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
982 return static_cast<const faSchemes*
>(
this);
994 return static_cast<const faSchemes&
>(*this);
1006 return static_cast<const faSolution&
>(*this);
1058 for (label& val : list)
1061 val = faceOwner[val];
1072 Foam::rm(meshFilesPath/
"faceLabels");
1073 Foam::rm(meshFilesPath/
"faBoundary");
1079 removeFiles(thisDb().instance());
1085 if (!patchStartsPtr_)
1090 return *patchStartsPtr_;
1118 if (!faceCentresPtr_)
1123 return *faceCentresPtr_;
1129 if (!edgeCentresPtr_)
1134 return *edgeCentresPtr_;
1156 <<
"S0 is not available" 1169 S00Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1191 if (!faceAreaNormalsPtr_)
1193 calcFaceAreaNormals();
1196 return *faceAreaNormalsPtr_;
1202 if (!edgeAreaNormalsPtr_)
1204 calcEdgeAreaNormals();
1207 return *edgeAreaNormalsPtr_;
1213 if (!pointAreaNormalsPtr_)
1215 pointAreaNormalsPtr_ = std::make_unique<vectorField>(
nPoints());
1217 calcPointAreaNormals(*pointAreaNormalsPtr_);
1219 if (quadricsFit_ > 0)
1221 calcPointAreaNormalsByQuadricsFit(*pointAreaNormalsPtr_);
1225 return *pointAreaNormalsPtr_;
1231 if (!faceCurvaturesPtr_)
1233 calcFaceCurvatures();
1236 return *faceCurvaturesPtr_;
1243 if (!edgeTransformTensorsPtr_)
1245 calcEdgeTransformTensors();
1248 return *edgeTransformTensorsPtr_;
1254 return bool(globalMeshDataPtr_);
1260 if (!globalMeshDataPtr_)
1265 return *globalMeshDataPtr_;
1273 calcLduAddressing();
1288 if (S00Ptr_ && S0Ptr_)
1303 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1318 curTimeIndex_ = time().timeIndex();
1321 clearGeomNotAreas();
1325 patchPtr_->movePoints(newPoints);
1329 boundary_.movePoints(newPoints);
1346 bool(correctPatchPointNormalsPtr_)
1359 if (!correctPatchPointNormalsPtr_)
1361 correctPatchPointNormalsPtr_ =
1365 return *correctPatchPointNormalsPtr_;
1371 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
The (sorted) patch indices for all matches, optionally matching patch groups.
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.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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 registered IO, a reference to the associated polyMesh...
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.
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.
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)