diff --git a/src/finiteVolume/expressions/fields/base/patchExprFieldBase.C b/src/finiteVolume/expressions/fields/base/patchExprFieldBase.C index 8056893f296ce9c51d61809e90eb9d8e7f45bc1c..ae817c86ff9bdb7341e86d7085cf4d6ec836555f 100644 --- a/src/finiteVolume/expressions/fields/base/patchExprFieldBase.C +++ b/src/finiteVolume/expressions/fields/base/patchExprFieldBase.C @@ -32,46 +32,6 @@ License #include "fvPatch.H" #include "pointMesh.H" -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -const Foam::fvPatch& -Foam::expressions::patchExprFieldBase::getFvPatch(const facePointPatch& pp) -{ - const polyMesh& pmesh = pp.boundaryMesh().mesh().mesh(); - - const fvMesh* meshptr = isA<fvMesh>(pmesh); - - if (!meshptr) - { - FatalErrorInFunction - << "Point patch not attached to a base fvMesh, " - << "cannot use patch expressions" << nl << endl - << exit(FatalError); - } - - return meshptr->boundary()[pp.index()]; -} - - -const Foam::fvPatch& -Foam::expressions::patchExprFieldBase::getFvPatch(const polyPatch& pp) -{ - const polyMesh& pmesh = pp.boundaryMesh().mesh(); - - const fvMesh* meshptr = isA<fvMesh>(pmesh); - - if (!meshptr) - { - FatalErrorInFunction - << "Poly patch not attached to a base fvMesh, " - << "cannot use patch expressions" << nl << endl - << exit(FatalError); - } - - return meshptr->boundary()[pp.index()]; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::expressions::patchExprFieldBase::patchExprFieldBase() diff --git a/src/finiteVolume/expressions/fields/base/patchExprFieldBase.H b/src/finiteVolume/expressions/fields/base/patchExprFieldBase.H index 06529939bfd20c851017f1c0f4e40ec4e531f758..67f3d075955402753be47085a6e86e12d8f821a2 100644 --- a/src/finiteVolume/expressions/fields/base/patchExprFieldBase.H +++ b/src/finiteVolume/expressions/fields/base/patchExprFieldBase.H @@ -87,15 +87,6 @@ protected: public: - // Static Methods - - //- Find (guess) fvPatch from a pointPatch - static const fvPatch& getFvPatch(const facePointPatch& fp); - - //- Find (guess) fvPatch from a polyPatch - static const fvPatch& getFvPatch(const polyPatch& pp); - - // Constructors //- Default construct diff --git a/src/finiteVolume/expressions/fields/pointPatchFields/exprValuePointPatchField.C b/src/finiteVolume/expressions/fields/pointPatchFields/exprValuePointPatchField.C index 9324282d531dd23308bb317f5f0c24a12d87aba4..252a7a635068f6fda107c1846bc3bdfa2058c08b 100644 --- a/src/finiteVolume/expressions/fields/pointPatchFields/exprValuePointPatchField.C +++ b/src/finiteVolume/expressions/fields/pointPatchFields/exprValuePointPatchField.C @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Original code Copyright (C) 2010-2018 Bernhard Gschaider - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2010-2018 Bernhard Gschaider + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,9 +44,9 @@ Foam::exprValuePointPatchField<Type>::exprValuePointPatchField expressions::patchExprFieldBase(false), driver_ ( - expressions::patchExprFieldBase::getFvPatch + fvPatch::lookupPatch ( - dynamicCast<const facePointPatch>(this->patch()) + dynamicCast<const facePointPatch>(this->patch()).patch() ) ) {} @@ -65,9 +65,9 @@ Foam::exprValuePointPatchField<Type>::exprValuePointPatchField expressions::patchExprFieldBase(ptf), driver_ ( - expressions::patchExprFieldBase::getFvPatch + fvPatch::lookupPatch ( - dynamicCast<const facePointPatch>(this->patch()) + dynamicCast<const facePointPatch>(this->patch()).patch() ), ptf.driver_ ) @@ -86,9 +86,9 @@ Foam::exprValuePointPatchField<Type>::exprValuePointPatchField expressions::patchExprFieldBase(dict, false, true), driver_ ( - expressions::patchExprFieldBase::getFvPatch + fvPatch::lookupPatch ( - dynamicCast<const facePointPatch>(this->patch()) + dynamicCast<const facePointPatch>(this->patch()).patch() ), dict ) @@ -138,9 +138,9 @@ Foam::exprValuePointPatchField<Type>::exprValuePointPatchField expressions::patchExprFieldBase(ptf), driver_ ( - expressions::patchExprFieldBase::getFvPatch + fvPatch::lookupPatch ( - dynamicCast<const facePointPatch>(this->patch()) + dynamicCast<const facePointPatch>(this->patch()).patch() ), ptf.driver_ ) @@ -157,9 +157,9 @@ Foam::exprValuePointPatchField<Type>::exprValuePointPatchField expressions::patchExprFieldBase(ptf), driver_ ( - expressions::patchExprFieldBase::getFvPatch + fvPatch::lookupPatch ( - dynamicCast<const facePointPatch>(this->patch()) + dynamicCast<const facePointPatch>(this->patch()).patch() ), ptf.driver_ ) @@ -216,4 +216,5 @@ void Foam::exprValuePointPatchField<Type>::write(Ostream& os) const driver_.writeCommon(os,this->debug_ || debug); } + // ************************************************************************* // diff --git a/src/finiteVolume/expressions/patch/patchExprDriver.C b/src/finiteVolume/expressions/patch/patchExprDriver.C index 5f22efe3e0dec4ec842c3992fb2bda09424560f8..a3ae3a790138ccb2209bb06e9ea318e8f055f317 100644 --- a/src/finiteVolume/expressions/patch/patchExprDriver.C +++ b/src/finiteVolume/expressions/patch/patchExprDriver.C @@ -69,30 +69,13 @@ addNamedToRunTimeSelectionTable namespace Foam { - static label getPatchID(const fvMesh& mesh, const word& patchName) - { - const auto& bMesh = mesh.boundaryMesh(); - - const label patchId = bMesh.findPatchID(patchName); - - if (patchId < 0) - { - FatalErrorInFunction - << "No patch " << patchName << " found in " - << flatOutput(bMesh.names()) << nl - << exit(FatalError); - } - return patchId; - } - - - static inline const fvPatch& findFvPatch + static inline const fvPatch& lookupFvPatch ( const fvMesh& mesh, const word& patchName ) { - return mesh.boundary()[getPatchID(mesh, patchName)]; + return mesh.boundary()[patchName]; } } // End namespace Foam @@ -106,7 +89,7 @@ const Foam::fvPatch& Foam::expressions::patchExpr::parseDriver::getFvPatch const dictionary& dict ) { - return findFvPatch + return lookupFvPatch ( regionMesh(dict, fvm, true), dict.get<word>("patch") @@ -154,7 +137,7 @@ Foam::expressions::patchExpr::parseDriver::parseDriver const fvMesh& mesh ) : - parseDriver(findFvPatch(mesh, patchName)) + parseDriver(lookupFvPatch(mesh, patchName)) {} diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C index 1539075971e1b53a716fc8ca7e9b17c03e76ac45..2b0b8ee5cba6e28b171382559c7eb6c205e1c5b4 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,6 +44,23 @@ namespace Foam } +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +const Foam::fvPatch& Foam::fvPatch::lookupPatch(const polyPatch& p) +{ + const fvMesh* meshptr = isA<fvMesh>(p.boundaryMesh().mesh()); + + if (!meshptr) + { + FatalErrorInFunction + << "The polyPatch is not attached to a base fvMesh" << nl + << exit(FatalError); + } + + return meshptr->boundary()[p.index()]; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm) @@ -55,7 +73,7 @@ Foam::fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::fvPatch::~fvPatch() -{} +{} // fvBoundaryMesh was forward declared // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -100,8 +118,8 @@ const Foam::vectorField& Foam::fvPatch::Cf() const Foam::tmp<Foam::vectorField> Foam::fvPatch::Cn() const { - tmp<vectorField> tcc(new vectorField(size())); - vectorField& cc = tcc.ref(); + auto tcc = tmp<vectorField>::New(size()); + auto& cc = tcc.ref(); const labelUList& faceCells = this->faceCells(); diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H index eebf06011cb0da7ef3ef9f065a97afd7a7e7fb0e..7f1e99775f9beda654b35a3285f5812bcdf4b442 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,6 +55,7 @@ SourceFiles namespace Foam { +// Forward Declarations class fvBoundaryMesh; class surfaceInterpolation; @@ -63,7 +65,7 @@ class surfaceInterpolation; class fvPatch { - // Private data + // Private Data //- Reference to the underlying polyPatch const polyPatch& polyPatch_; @@ -72,15 +74,6 @@ class fvPatch const fvBoundaryMesh& boundaryMesh_; - // Private Member Functions - - //- No copy construct - fvPatch(const fvPatch&) = delete; - - //- No copy assignment - void operator=(const fvPatch&) = delete; - - protected: // Protected Member Functions @@ -94,6 +87,11 @@ protected: //- Correct patches after moving points virtual void movePoints(); + //- No copy construct + fvPatch(const fvPatch&) = delete; + + //- No copy assignment + void operator=(const fvPatch&) = delete; public: @@ -140,6 +138,11 @@ public: // Member Functions + //- Lookup the polyPatch index on corresponding fvMesh + // \note Fatal if the polyPatch is not associated with a fvMesh + static const fvPatch& lookupPatch(const polyPatch& p); + + // Access //- Return the polyPatch