diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 19e599f3b3..4f203daa53 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1578,4 +1578,18 @@ Foam::label Foam::polyMesh::findCell } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +bool Foam::polyMesh::writeObject +( + IOstreamOption streamOpt, + const bool writeOnProc +) const +{ + // Currently no special treatment. Just write the objects + + return objectRegistry::writeObject(streamOpt, writeOnProc); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index 513f9413c5..4ce8270ebc 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -792,6 +792,17 @@ public: const point& p, const cellDecomposition = CELL_TETS ) const; + + + // Write + + //- Write items held in the objectRegistry. Normally includes mesh + //- components (points, faces, etc) and any registered fields. + virtual bool writeObject + ( + IOstreamOption streamOpt, + const bool writeOnProc = true + ) const; }; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H index 63a2786417..0853c0e307 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coupledPolyPatch_H -#define coupledPolyPatch_H +#ifndef Foam_coupledPolyPatch_H +#define Foam_coupledPolyPatch_H #include "polyPatch.H" #include "diagTensorField.H" @@ -242,7 +242,6 @@ public: // Member Functions - // Access //- Return true because this patch is coupled @@ -260,6 +259,12 @@ public: return !owner(); } + //- The referring patchID (eg, for cyclics). + virtual label referPatchID() const + { + return -1; + } + //- Type of transform virtual transformType transform() const { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 6c042881e0..9341a5ad12 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -38,7 +38,7 @@ License #include "PstreamBuffers.H" #include "Circulator.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { @@ -47,7 +47,24 @@ namespace Foam } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::word Foam::processorPolyPatch::newName +( + const label myProcNo, + const label neighbProcNo +) +{ + return word + ( + "procBoundary" + + std::to_string(myProcNo) + "to" + std::to_string(neighbProcNo), + false // No stripping needed + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::processorPolyPatch::processorPolyPatch ( @@ -181,20 +198,6 @@ Foam::processorPolyPatch::~processorPolyPatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::word Foam::processorPolyPatch::newName -( - const label myProcNo, - const label neighbProcNo -) -{ - return - "procBoundary" - + Foam::name(myProcNo) - + "to" - + Foam::name(neighbProcNo); -} - - void Foam::processorPolyPatch::initGeometry(PstreamBuffers& pBufs) { if (Pstream::parRun()) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H index ea445773ce..54835b0253 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H @@ -250,7 +250,18 @@ public: virtual ~processorPolyPatch(); - // Member functions + // Static Functions + + //- Return the name of a processorPolyPatch ("procBoundary..") + //- constructed from the pair of processor IDs. + static word newName + ( + const label myProcNo, + const label neighbProcNo + ); + + + // Member Functions //- Return true only if this is a parallel run virtual bool coupled() const @@ -282,14 +293,6 @@ public: return !owner(); } - //- Return the name of a processorPolyPatch - // constructed from the processor IDs - static word newName - ( - const label myProcNo, - const label neighbProcNo - ); - //- Return processor-neighbour patch face centres const vectorField& neighbFaceCentres() const noexcept { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C index 96f76a8a13..6238e7bfd3 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +31,7 @@ License #include "SubField.H" #include "cyclicPolyPatch.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { @@ -40,6 +40,41 @@ namespace Foam } +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::word Foam::processorCyclicPolyPatch::newName +( + const word& cyclicPolyPatchName, + const label myProcNo, + const label neighbProcNo +) +{ + return word + ( + processorPolyPatch::newName(myProcNo, neighbProcNo) + + "through" + + cyclicPolyPatchName + ); +} + + +Foam::labelList Foam::processorCyclicPolyPatch::patchIDs +( + const word& cyclicPolyPatchName, + const polyBoundaryMesh& bm +) +{ + return bm.indices + ( + wordRe + ( + "procBoundary.*to.*through" + cyclicPolyPatchName, + wordRe::REGEX + ) + ); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::processorCyclicPolyPatch::processorCyclicPolyPatch @@ -151,42 +186,28 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::processorCyclicPolyPatch::~processorCyclicPolyPatch() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::word Foam::processorCyclicPolyPatch::newName -( - const word& cyclicPolyPatchName, - const label myProcNo, - const label neighbProcNo -) +Foam::label Foam::processorCyclicPolyPatch::referPatchID() const { - return - processorPolyPatch::newName(myProcNo, neighbProcNo) - + "through" - + cyclicPolyPatchName; -} - - -Foam::labelList Foam::processorCyclicPolyPatch::patchIDs -( - const word& cyclicPolyPatchName, - const polyBoundaryMesh& bm -) -{ - return bm.indices - ( - wordRe + if (referPatchID_ == -1) + { + referPatchID_ = this->boundaryMesh().findPatchID ( - "procBoundary.*to.*through" + cyclicPolyPatchName, - wordRe::REGEX - ) - ); + referPatchName_ + ); + + if (referPatchID_ == -1) + { + FatalErrorInFunction + << "Illegal referPatch name " << referPatchName_ << nl + << "Valid patch names: " + << this->boundaryMesh().names() << nl + << exit(FatalError); + } + } + + return referPatchID_; } @@ -242,9 +263,8 @@ void Foam::processorCyclicPolyPatch::calcGeometry(PstreamBuffers& pBufs) // Receive and initialise processorPolyPatch data processorPolyPatch::calcGeometry(pBufs); - if (Pstream::parRun()) + if (UPstream::parRun()) { - // Where do we store the calculated transformation? // - on the processor patch? // - on the underlying cyclic patch? diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H index f0d9b03b50..acdbfe981f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorCyclicPolyPatch_H -#define processorCyclicPolyPatch_H +#ifndef Foam_processorCyclicPolyPatch_H +#define Foam_processorCyclicPolyPatch_H #include "processorPolyPatch.H" @@ -54,7 +54,7 @@ class processorCyclicPolyPatch : public processorPolyPatch { - // Private data + // Private Data //- Name of originating patch const word referPatchName_; @@ -257,19 +257,13 @@ public: // Destructor - virtual ~processorCyclicPolyPatch(); + virtual ~processorCyclicPolyPatch() = default; - // Member functions + // Static Functions - //- Return name of originating cyclicPolyPatch patch - const word& referPatchName() const - { - return referPatchName_; - } - - //- Return the name of a processorCyclicPolyPatch - // constructed from cyclicPolyPatch name and the processor IDs + //- Return the name of a processorCyclicPolyPatch constructed from + //- the cyclicPolyPatch name and the pair of processor IDs. static word newName ( const word& cyclicPolyPatchName, @@ -285,27 +279,20 @@ public: const polyBoundaryMesh& bm ); - //- Referring patchID. - label referPatchID() const + + // Member Functions + + //- Return name of originating cyclicPolyPatch patch + const word& referPatchName() const { - if (referPatchID_ == -1) - { - referPatchID_ = this->boundaryMesh().findPatchID - ( - referPatchName_ - ); - if (referPatchID_ == -1) - { - FatalErrorInFunction - << "Illegal referPatch name " << referPatchName_ - << endl << "Valid patch names are " - << this->boundaryMesh().names() - << exit(FatalError); - } - } - return referPatchID_; + return referPatchName_; } + //- The referring patchID. + //- Searches for referPatchName() on the first call. + virtual label referPatchID() const; + + //- The referred coupled patch const coupledPolyPatch& referPatch() const { const polyPatch& pp = this->boundaryMesh()[referPatchID()]; diff --git a/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H b/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H index 0b3b9f12e4..a4bdba28e5 100644 --- a/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H +++ b/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H @@ -160,6 +160,13 @@ public: return !owner(); } + //- The referring patchID (eg, for cyclics). + // Here for consistency with coupledPolyPatch + virtual label referPatchID() const + { + return -1; + } + //- Are the coupled planes separated? bool separated() const {