mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add fvPatch::lookupPatch static function
- lookup a fvPatch given a polyPatch reference. Replaces ad hoc helpers in patchExprFieldBase
This commit is contained in:
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user