64const Foam::word Foam::faMesh::prefix_(
"finite-area");
68const int Foam::faMesh::quadricsFit_ = 0;
92 const word& volRegion,
93 const word& areaRegion
128 const word& volRegion,
129 const word& areaRegion
182 const word& areaRegion
193 if (areaRegion.empty())
216 pbm.indices(polyPatchNames,
true)
222 <<
"No matching patches: " << polyPatchNames <<
nl
237 for (
const label facei :
pbm[patchi].
range())
252void Foam::faMesh::checkBoundaryEdgeLabelRange
259 for (
const label edgei : edgeLabels)
261 if (edgei < nInternalEdges_ || edgei >= nEdges_)
266 <<
"Boundary edge label out of range "
267 << nInternalEdges_ <<
".." << (nEdges_-1) <<
nl
282void Foam::faMesh::initPatch()
const
284 patchPtr_ = std::make_unique<uindirectPrimitivePatch>
295 bndConnectPtr_.reset(
nullptr);
296 haloMapPtr_.reset(
nullptr);
297 haloFaceCentresPtr_.reset(
nullptr);
298 haloFaceNormalsPtr_.reset(
nullptr);
302void Foam::faMesh::setPrimitiveMeshData()
311 nEdges_ = bp.nEdges();
312 nInternalEdges_ = bp.nInternalEdges();
314 nPoints_ = bp.nPoints();
316 edges_.resize(nEdges_);
317 edgeOwner_.resize(nEdges_);
318 edgeNeighbour_.resize(nInternalEdges_);
321 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
323 edges_[edgei] = bp.edges()[edgei];
325 edgeOwner_[edgei] = edgeFaces[edgei][0];
327 edgeNeighbour_[edgei] = edgeFaces[edgei][1];
331 label edgei = nInternalEdges_;
335 for (
const label patchEdgei :
p.edgeLabels())
337 edges_[edgei] = bp.edges()[patchEdgei];
339 edgeOwner_[edgei] = edgeFaces[patchEdgei][0];
347void Foam::faMesh::clearHalo()
const
351 haloMapPtr_.reset(
nullptr);
352 haloFaceCentresPtr_.reset(
nullptr);
353 haloFaceNormalsPtr_.reset(
nullptr);
357void Foam::faMesh::clearGeomNotAreas()
const
362 patchPtr_.reset(
nullptr);
363 polyPatchFacesPtr_.reset(
nullptr);
364 polyPatchIdsPtr_.reset(
nullptr);
365 bndConnectPtr_.reset(
nullptr);
366 SPtr_.reset(
nullptr);
367 patchStartsPtr_.reset(
nullptr);
368 LePtr_.reset(
nullptr);
369 magLePtr_.reset(
nullptr);
370 faceCentresPtr_.reset(
nullptr);
371 edgeCentresPtr_.reset(
nullptr);
372 faceAreaNormalsPtr_.reset(
nullptr);
373 edgeAreaNormalsPtr_.reset(
nullptr);
374 pointAreaNormalsPtr_.reset(
nullptr);
375 faceCurvaturesPtr_.reset(
nullptr);
376 edgeTransformTensorsPtr_.reset(
nullptr);
380void Foam::faMesh::clearGeom()
const
385 S0Ptr_.reset(
nullptr);
386 S00Ptr_.reset(
nullptr);
387 correctPatchPointNormalsPtr_.reset(
nullptr);
391void Foam::faMesh::clearAddressing()
const
395 lduPtr_.reset(
nullptr);
399void Foam::faMesh::clearOut()
const
403 globalMeshDataPtr_.reset(
nullptr);
416 faceCentresPtr_->boundaryFieldRef()
421 if (faceAreaNormalsPtr_)
423 faceAreaNormalsPtr_->boundaryFieldRef()
434 setPrimitiveMeshData();
444 boundary_.updateMesh();
447 boundary_.calcGeometry();
459 const word& areaName,
486 const word& areaName,
507 const word& areaName,
596 const word& areaName,
618 time().findInstance(meshDir(),
"faceLabels"),
636 faceLabels_.instance()
650 setPrimitiveMeshData();
674 rio.resetHeader(
"S0");
677 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
690 const word& areaName,
712 pMesh.facesInstance(),
725 faceLabels_.instance(),
741 nFaces_ = faceLabels_.size();
749 const word& areaName,
772 pMesh.facesInstance(),
785 faceLabels_.instance(),
801 nFaces_ = faceLabels_.
size();
812 const word& areaName,
823 static_cast<const
dictionary*>(baseMesh.hasSchemes())
829 static_cast<const
dictionary*>(baseMesh.hasSolution())
838 baseMesh.
mesh().facesInstance(),
851 faceLabels_.instance(),
867 nFaces_ = faceLabels_.size();
873 const word& areaName,
890 createOnePatch(
"default")
895 setPrimitiveMeshData();
906 const word& areaName,
907 const polyMesh& pMesh,
918 pMesh.boundaryMesh(),
919 faMeshDefinition.get<wordRes>(
"polyMeshPatches")
929 faMeshDefinition.subDict(
"boundary"),
932 faMeshDefinition.getOrDefault<word>(
"emptyPatch",
word::null),
935 faMeshDefinition.findDict(
"defaultPatch")
963 rio.resetHeader(
"S0");
966 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
989 return static_cast<const faSchemes*
>(
this);
1001 return static_cast<const faSchemes&
>(*this);
1013 return static_cast<const faSolution&
>(*this);
1065 for (label& val : list)
1068 val = faceOwner[val];
1079 Foam::rm(meshFilesPath/
"faceLabels");
1080 Foam::rm(meshFilesPath/
"faBoundary");
1092 if (!patchStartsPtr_)
1097 return *patchStartsPtr_;
1125 if (!faceCentresPtr_)
1130 return *faceCentresPtr_;
1136 if (!edgeCentresPtr_)
1141 return *edgeCentresPtr_;
1163 <<
"S0 is not available"
1176 S00Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1198 if (!faceAreaNormalsPtr_)
1200 calcFaceAreaNormals();
1203 return *faceAreaNormalsPtr_;
1209 if (!edgeAreaNormalsPtr_)
1211 calcEdgeAreaNormals();
1214 return *edgeAreaNormalsPtr_;
1220 if (!pointAreaNormalsPtr_)
1222 pointAreaNormalsPtr_ = std::make_unique<vectorField>(
nPoints());
1224 calcPointAreaNormals(*pointAreaNormalsPtr_);
1226 if (quadricsFit_ > 0)
1228 calcPointAreaNormalsByQuadricsFit(*pointAreaNormalsPtr_);
1232 return *pointAreaNormalsPtr_;
1238 if (!faceCurvaturesPtr_)
1240 calcFaceCurvatures();
1243 return *faceCurvaturesPtr_;
1250 if (!edgeTransformTensorsPtr_)
1252 calcEdgeTransformTensors();
1255 return *edgeTransformTensorsPtr_;
1261 return bool(globalMeshDataPtr_);
1267 if (!globalMeshDataPtr_)
1272 return *globalMeshDataPtr_;
1280 calcLduAddressing();
1295 if (S00Ptr_ && S0Ptr_)
1310 S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1325 curTimeIndex_ = time().timeIndex();
1328 clearGeomNotAreas();
1332 patchPtr_->movePoints(newPoints);
1336 boundary_.movePoints(newPoints);
1353 bool(correctPatchPointNormalsPtr_)
1366 if (!correctPatchPointNormalsPtr_)
1368 correctPatchPointNormalsPtr_ =
1372 return *correctPatchPointNormalsPtr_;
1378 faceLabels_.write();
labelList faceLabels(nFaceLabels)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A field of fields is a PtrList of fields with reference counting.
label size() const noexcept
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
@ NO_REGISTER
Do not request registration (bool: false).
readOption readOpt() const noexcept
Get the read option.
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ LAZY_READ
Reading is optional [identical to READ_IF_PRESENT].
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
const word & name() const noexcept
Return the object name.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info. A void type suppresses trait and t...
void resetHeader(const word &newName=word::null)
Clear various bits (headerClassName, note, sizeof...) that would be obtained when reading from a file...
const fileName & instance() const noexcept
Read access to instance path component.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
Inter-processor communications stream.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Face to edge interpolation scheme. Included in faMesh.
bool movePoints() const
Do what is necessary if the mesh has moved.
edgeInterpolation(const edgeInterpolation &)=delete
No copy construct.
Various mesh related information for a parallel run.
The objectRegistry for faMesh.
faMeshRegistry(const word &areaName, const polyMesh &mesh)
Construct an objectRegistry for given area region name. Treat an empty name like polyMesh::defaultReg...
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
virtual bool movePoints()
Update after mesh motion.
boolList & correctPatchPointNormals() const
Set whether point normals should be corrected for a patch.
virtual const objectRegistry & thisDb() const
Reference to the mesh database.
bool operator==(const faMesh &m) const
const fileName & facesInstance() const
Return the current instance directory for faces.
const labelList & patchStarts() const
Return patch starts.
bool hasGlobalData() const noexcept
Is demand-driven parallel info available?
const Time & time() const
Return reference to time.
faMesh(const faMesh &)=delete
No copy construct.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir).
virtual const fileName & dbDir() const
Local directory path of the objectRegistry relative to Time with override for the single-region case.
const edgeVectorField & edgeCentres() const
Return edge centres as edgeVectorField.
const DimensionedField< scalar, areaMesh > & S00() const
Return old-old-time face areas.
const polyMesh & mesh() const
Return access to polyMesh.
bool init(const bool doInit)
Initialise non-demand-driven data etc.
const edgeScalarField & magLe() const
Return edge length magnitudes.
const DimensionedField< scalar, areaMesh > & S() const
Return face areas.
const faSchemes * hasSchemes() const
Non-null if faSchemes exists (can test as bool).
static const objectRegistry * registry(const polyMesh &pMesh)
Find the singleton parent registry (on the polyMesh) that contains all objects related to finite-area...
const faSolution & solution() const
Read-access to the faSolution controls.
const faSchemes & schemes() const
Read-access to the faSchemes controls.
const edgeVectorField & Le() const
Return edge length vectors.
const FieldField< Field, tensor > & edgeTransformTensors() const
Return edge transformation tensors.
const fileName & pointsInstance() const
Return the current instance directory for points.
static int geometryOrder_
Geometry treatment.
bool operator!=(const faMesh &m) const
const faGlobalMeshData & globalData() const
Return parallel info (demand-driven).
const DimensionedField< scalar, areaMesh > & S0() const
Return old-time face areas.
const areaScalarField & faceCurvatures() const
Return face curvatures.
labelList faceCells() const
The volume (owner) cells associated with the area-mesh.
void syncGeom()
Processor/processor synchronisation for geometry fields.
virtual bool write(const bool writeOnProc=true) const
Write mesh.
void removeFiles(const fileName &instanceDir) const
Remove all files from mesh instance.
static const word & prefix() noexcept
The prefix to the parent registry name: finite-area.
const edgeVectorField & edgeAreaNormals() const
Return edge area normals.
static const objectRegistry & Registry(const polyMesh &pMesh)
Return the singleton parent registry (on the polyMesh) that contains all objects related to finite-ar...
void addFaPatches(faPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
void removeFiles() const
Remove all files from mesh instance().
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
static const faMesh & mesh(const polyMesh &pMesh)
The single-region finite-area region on the polyMesh. Uses lookupObject semantics - Fatal if non-exis...
const vectorField & pointAreaNormals() const
Return point area normals.
virtual ~faMesh()
Destructor.
static word meshSubDir
The mesh sub-directory name (usually "faMesh").
const word & regionName() const
The region name or word::null if polyMesh::defaultRegion.
const areaVectorField & faceAreaNormals() const
Return face area normals.
const faSolution * hasSolution() const
Non-null if faSolution exists (can test as bool).
const areaVectorField & areaCentres() const
Return face centres as areaVectorField.
static FOAM_NO_DANGLING_REFERENCE const objectRegistry & Registry(const polyMesh &mesh)
Return the registry of objects on the singleton.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Selector class for finite area differencing schemes. faMesh is derived from faSchemes so that all fie...
faSchemes(const faSchemes &)=delete
No copy construct.
Selector class for finite area solution. faMesh is derived from faSolution so that all fields have ac...
faSolution(const faSolution &)=delete
No copy construct.
A class for handling file names.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Registry of regIOobjects.
const objectRegistry & parent() const noexcept
Return the parent objectRegistry.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
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...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
static const word & regionName(const word ®ion)
The mesh region name or word::null if polyMesh::defaultRegion.
const fileName & facesInstance() const
Return the current instance directory for faces.
static word defaultRegion
Return the default region name.
virtual const labelList & faceOwner() const
Return face owner.
const fileName & pointsInstance() const
Return the current instance directory for points.
const objectRegistry & thisDb() const noexcept
Return the object registry.
virtual const pointField & points() const
Return raw points.
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
A patch is a list of labels that address the faces in the global face list.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
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...
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
#define DebugInFunction
Report an information message using Foam::Info.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
const std::string patch
OpenFOAM patch number as a std::string.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
const dimensionSet dimArea(sqr(dimLength))
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
static labelList selectPatchFaces(const polyBoundaryMesh &pbm, const wordRes &polyPatchNames)
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...
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define registerOptSwitch(Name, Type, SwitchVar)