mappedExtrudedPatchBase: New base class for extruded patches

mappedExtrudedPolyPatch and mappedExtrudedWallPolyPatch are now derived from mappedExtrudedPatchBase
This commit is contained in:
Henry Weller
2023-03-02 20:25:22 +00:00
parent 7cc5cba5b4
commit 390c588cd4
19 changed files with 470 additions and 296 deletions

View File

@ -552,11 +552,21 @@ void addCouplingPatches
<< "-------\t-----\t----" << "-------\t-----\t----"
<< endl; << endl;
const wordList patchNames wordList patchNames
( (
dict.lookupOrDefault("patchNames", wordList()) dict.lookupOrDefault("patchNames", wordList())
); );
wordList regionPatchNames
(
dict.lookupOrDefault("regionPatchNames", wordList())
);
if (isShellMesh)
{
patchNames.swap(regionPatchNames);
}
const wordList patchTypes const wordList patchTypes
( (
isShellMesh isShellMesh
@ -572,11 +582,6 @@ void addCouplingPatches
) )
); );
const wordList regionPatchNames
(
dict.lookupOrDefault("regionPatchNames", wordList())
);
const wordList regionOppositePatchTypes const wordList regionOppositePatchTypes
( (
dict.lookupOrDefault("regionOppositePatchTypes", wordList()) dict.lookupOrDefault("regionOppositePatchTypes", wordList())
@ -672,7 +677,7 @@ void addCouplingPatches
topPatchDict.add("neighbourPatch", topNbrPatchName); topPatchDict.add("neighbourPatch", topNbrPatchName);
if (isShellMesh) if (isShellMesh)
{ {
topPatchDict.add("bottomPatch", bottomPatchName); topPatchDict.add("oppositePatch", bottomPatchName);
} }
zoneTopPatch[zonei] = addPatch zoneTopPatch[zonei] = addPatch

View File

@ -141,7 +141,8 @@ Foam::mappedValueFvPatchField<Type>::mappedValueFvPatchField
{ {
OStringStream str; OStringStream str;
str << "Field " << this->internalField().name() << " of type " str << "Field " << this->internalField().name() << " of type "
<< type() << " on patch " << this->patch().name() << " does not " << type() << " on patch " << this->patch().name()
<< " of type " << p.patch().type() << " does not "
<< "have mapping specified (i.e., neighbourPatch, and/or " << "have mapping specified (i.e., neighbourPatch, and/or "
<< "neighbourRegion entries) nor is the patch of " << "neighbourRegion entries) nor is the patch of "
<< mappedPolyPatch::typeName << " type"; << mappedPolyPatch::typeName << " type";

View File

@ -230,10 +230,12 @@ meshToMesh/meshToMesh.C
mappedPatches/mappedPatchBase/mappedPatchBase.C mappedPatches/mappedPatchBase/mappedPatchBase.C
mappedPatches/mappedPolyPatch/mappedPolyPatch.C mappedPatches/mappedPolyPatch/mappedPolyPatch.C
mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C
mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.C
mappedPatches/mappedPointPatch/mappedPointPatch.C mappedPatches/mappedPointPatch/mappedPointPatch.C
mappedPatches/mappedPointPatch/mappedWallPointPatch.C mappedPatches/mappedPointPatch/mappedWallPointPatch.C
mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.C
mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.C
mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.C
mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.C
mappedPatches/mappedInternalPatchBase/mappedInternalPatchBase.C mappedPatches/mappedInternalPatchBase/mappedInternalPatchBase.C
mappedPatches/mappedInternalPolyPatch/mappedInternalPolyPatch.C mappedPatches/mappedInternalPolyPatch/mappedInternalPolyPatch.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -52,9 +52,9 @@ class transformer;
template<class Type> template<class Type>
class LayerInfoData; class LayerInfoData;
template<class Type> template<class Type>
Ostream& operator<<(Ostream&, const LayerInfoData<Type>&); inline Ostream& operator<<(Ostream&, const LayerInfoData<Type>&);
template<class Type> template<class Type>
Istream& operator>>(Istream&, LayerInfoData<Type>&); inline Istream& operator>>(Istream&, LayerInfoData<Type>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class LayerInfoData Declaration Class LayerInfoData Declaration

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -185,14 +185,18 @@ inline bool Foam::LayerInfoData<Type>::operator!=
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::Ostream& Foam::operator<<(Ostream& os, const LayerInfoData<Type>& l) inline Foam::Ostream& Foam::operator<<
(
Ostream& os,
const LayerInfoData<Type>& l
)
{ {
return os << static_cast<const layerInfo&>(l) << token::SPACE << l.data_; return os << static_cast<const layerInfo&>(l) << token::SPACE << l.data_;
} }
template<class Type> template<class Type>
Foam::Istream& Foam::operator>>(Istream& is, LayerInfoData<Type>& l) inline Foam::Istream& Foam::operator>>(Istream& is, LayerInfoData<Type>& l)
{ {
return is >> static_cast<layerInfo&>(l) >> l.data_; return is >> static_cast<layerInfo&>(l) >> l.data_;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -50,8 +50,8 @@ class transformer;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class layerInfo; class layerInfo;
Ostream& operator<<(Ostream&, const layerInfo&); inline Ostream& operator<<(Ostream&, const layerInfo&);
Istream& operator>>(Istream&, layerInfo&); inline Istream& operator>>(Istream&, layerInfo&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class layerInfo Declaration Class layerInfo Declaration

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -229,13 +229,13 @@ inline bool Foam::layerInfo::operator!=(const Foam::layerInfo& rhs) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const layerInfo& l) inline Foam::Ostream& Foam::operator<<(Ostream& os, const layerInfo& l)
{ {
return os << l.layer_ << token::SPACE << l.direction_; return os << l.layer_ << token::SPACE << l.direction_;
} }
Foam::Istream& Foam::operator>>(Istream& is, layerInfo& l) inline Foam::Istream& Foam::operator>>(Istream& is, layerInfo& l)
{ {
return is >> l.layer_ >> l.direction_; return is >> l.layer_ >> l.direction_;
} }

View File

@ -23,8 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "mappedExtrudedWallPolyPatch.H" #include "mappedExtrudedPatchBase.H"
#include "addToRunTimeSelectionTable.H"
#include "LayerInfoData.H" #include "LayerInfoData.H"
#include "FaceCellWave.H" #include "FaceCellWave.H"
@ -32,73 +31,18 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(mappedExtrudedWallPolyPatch, 0); defineTypeNameAndDebug(mappedExtrudedPatchBase, 0);
addToRunTimeSelectionTable(polyPatch, mappedExtrudedWallPolyPatch, word);
addToRunTimeSelectionTable
(
polyPatch,
mappedExtrudedWallPolyPatch,
dictionary
);
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::mappedExtrudedWallPolyPatch::initCalcGeometry(PstreamBuffers& pBufs)
{
mappedWallPolyPatch::initCalcGeometry(pBufs);
}
void Foam::mappedExtrudedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{
mappedWallPolyPatch::calcGeometry(pBufs);
bottomFaceCentresPtr_.clear();
}
void Foam::mappedExtrudedWallPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
mappedWallPolyPatch::initMovePoints(pBufs, p);
}
void Foam::mappedExtrudedWallPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
mappedWallPolyPatch::movePoints(pBufs, p);
bottomFaceCentresPtr_.clear();
}
void Foam::mappedExtrudedWallPolyPatch::initTopoChange(PstreamBuffers& pBufs)
{
mappedWallPolyPatch::initTopoChange(pBufs);
}
void Foam::mappedExtrudedWallPolyPatch::topoChange(PstreamBuffers& pBufs)
{
mappedWallPolyPatch::topoChange(pBufs);
bottomFaceCentresPtr_.clear();
}
Foam::tmp<Foam::vectorField> Foam::tmp<Foam::vectorField>
Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const Foam::mappedExtrudedPatchBase::patchFaceAreas() const
{ {
if (!bottomFaceAreasPtr_.valid()) if (!bottomFaceAreasPtr_.valid())
{ {
const bool isExtrudedRegion = bottomPatch_ != word::null; const bool isExtrudedRegion = oppositePatch_ != word::null;
if (isExtrudedRegion) if (isExtrudedRegion)
{ {
@ -106,9 +50,9 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const
// corresponding areas and centres are on the bottom patch. We do // corresponding areas and centres are on the bottom patch. We do
// this by waving these values across the layers. // this by waving these values across the layers.
const polyMesh& mesh = boundaryMesh().mesh(); const polyMesh& mesh = patch_.boundaryMesh().mesh();
const polyPatch& pp = *this; const polyPatch& pp = patch_;
const polyPatch& bottomPp = boundaryMesh()[bottomPatch_]; const polyPatch& bottomPp = patch_.boundaryMesh()[oppositePatch_];
// Initialise faces on the bottom patch to wave from // Initialise faces on the bottom patch to wave from
labelList initialFaces(bottomPp.size()); labelList initialFaces(bottomPp.size());
@ -157,7 +101,7 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Mesh \"" << mesh.name() << "Mesh \"" << mesh.name()
<< "\" is not layered between the extruded wall patch " << "\" is not layered between the extruded patch "
<< "\"" << pp.name() << "\" and the bottom patch \"" << "\"" << pp.name() << "\" and the bottom patch \""
<< bottomPp.name() << "\"" << exit(FatalError); << bottomPp.name() << "\"" << exit(FatalError);
} }
@ -172,21 +116,21 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const
// of mapping on the extruded region and then reverse map the // of mapping on the extruded region and then reverse map the
// extruded region's data so it is available here // extruded region's data so it is available here
const mappedExtrudedWallPolyPatch& nbrPp = const mappedExtrudedPatchBase& nbrPp =
refCast<const mappedExtrudedWallPolyPatch>(nbrPolyPatch()); refCast<const mappedExtrudedPatchBase>(nbrPolyPatch());
bottomFaceAreasPtr_.set bottomFaceAreasPtr_.set
( (
nbrPp.reverseDistribute nbrPp.reverseDistribute
( (
nbrPp.primitivePatch::faceAreas() nbrPp.patch_.primitivePatch::faceAreas()
).ptr() ).ptr()
); );
bottomFaceCentresPtr_.set bottomFaceCentresPtr_.set
( (
nbrPp.reverseDistribute nbrPp.reverseDistribute
( (
nbrPp.primitivePatch::faceCentres() nbrPp.patch_.primitivePatch::faceCentres()
).ptr() ).ptr()
); );
} }
@ -197,7 +141,7 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const
Foam::tmp<Foam::pointField> Foam::tmp<Foam::pointField>
Foam::mappedExtrudedWallPolyPatch::patchFaceCentres() const Foam::mappedExtrudedPatchBase::patchFaceCentres() const
{ {
if (!bottomFaceCentresPtr_.valid()) if (!bottomFaceCentresPtr_.valid())
{ {
@ -209,7 +153,7 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceCentres() const
Foam::tmp<Foam::pointField> Foam::tmp<Foam::pointField>
Foam::mappedExtrudedWallPolyPatch::patchLocalPoints() const Foam::mappedExtrudedPatchBase::patchLocalPoints() const
{ {
NotImplemented; NotImplemented;
return tmp<pointField>(nullptr); return tmp<pointField>(nullptr);
@ -218,72 +162,72 @@ Foam::mappedExtrudedWallPolyPatch::patchLocalPoints() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch Foam::mappedExtrudedPatchBase::mappedExtrudedPatchBase(const polyPatch& pp)
(
const word& name,
const label size,
const label start,
const label index,
const polyBoundaryMesh& bm,
const word& patchType
)
: :
mappedWallPolyPatch(name, size, start, index, bm, patchType), mappedPatchBase(pp),
bottomPatch_(word::null) oppositePatch_(word::null)
{} {}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch Foam::mappedExtrudedPatchBase::mappedExtrudedPatchBase
( (
const word& name, const polyPatch& pp,
const word& nbrRegionName,
const word& nbrPatchName,
const word& oppositePatch,
const cyclicTransform& transform
)
:
mappedPatchBase(pp, nbrRegionName, nbrPatchName, transform),
oppositePatch_(oppositePatch)
{}
Foam::mappedExtrudedPatchBase::mappedExtrudedPatchBase
(
const polyPatch& pp,
const dictionary& dict, const dictionary& dict,
const label index, const bool transformIsNone
const polyBoundaryMesh& bm,
const word& patchType
) )
: :
mappedWallPolyPatch(name, dict, index, bm, patchType), mappedPatchBase(pp, dict, transformIsNone),
bottomPatch_(dict.lookupOrDefault<word>("bottomPatch", word::null)) oppositePatch_(dict.lookupOrDefault<word>("oppositePatch", word::null))
{} {}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch Foam::mappedExtrudedPatchBase::mappedExtrudedPatchBase
( (
const mappedExtrudedWallPolyPatch& pp, const polyPatch& pp,
const polyBoundaryMesh& bm const mappedExtrudedPatchBase& mepb
) )
: :
mappedWallPolyPatch(pp, bm), mappedPatchBase(pp),
bottomPatch_(pp.bottomPatch_) oppositePatch_(mepb.oppositePatch_)
{}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch
(
const mappedExtrudedWallPolyPatch& pp,
const polyBoundaryMesh& bm,
const label index,
const label newSize,
const label newStart
)
:
mappedWallPolyPatch(pp, bm, index, newSize, newStart),
bottomPatch_(pp.bottomPatch_)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::mappedExtrudedWallPolyPatch::~mappedExtrudedWallPolyPatch() Foam::mappedExtrudedPatchBase::~mappedExtrudedPatchBase()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::mappedExtrudedWallPolyPatch::write(Ostream& os) const void Foam::mappedExtrudedPatchBase::clearOut()
{ {
mappedWallPolyPatch::write(os); mappedPatchBase::clearOut();
writeEntryIfDifferent(os, "bottomPatch", word::null, bottomPatch_); if (reMapAfterMove_)
{
bottomFaceCentresPtr_.clear();
}
}
void Foam::mappedExtrudedPatchBase::write(Ostream& os) const
{
mappedPatchBase::write(os);
writeEntryIfDifferent(os, "oppositePatch", word::null, oppositePatch_);
} }

View File

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::mappedExtrudedPatchBase
Description
Engine which provides mapping between two patches
and which offsets the geometry to account for the extrusion thickness
SourceFiles
mappedExtrudedPatchBase.C
\*---------------------------------------------------------------------------*/
#ifndef mappedExtrudedPatchBase_H
#define mappedExtrudedPatchBase_H
#include "mappedPatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class mappedExtrudedPatchBase Declaration
\*---------------------------------------------------------------------------*/
class mappedExtrudedPatchBase
:
public mappedPatchBase
{
// Private Member Data
//- The patch on the opposite side of the extruded region.
// Empty if this is not the extruded region.
mutable word oppositePatch_;
//- The face areas on the bottom patch
mutable autoPtr<vectorField> bottomFaceAreasPtr_;
//- The face centres on the bottom patch
mutable autoPtr<pointField> bottomFaceCentresPtr_;
//- The local points on the bottom patch
mutable autoPtr<pointField> bottomLocalPointsPtr_;
protected:
// Protected Member Functions
//- Get the face-areas for the patch
virtual tmp<vectorField> patchFaceAreas() const;
//- Get the face-centres for the patch
virtual tmp<pointField> patchFaceCentres() const;
//- Get the local points for the patch
virtual tmp<pointField> patchLocalPoints() const;
public:
//- Runtime type information
TypeName("mappedExtrudedPatchBase");
// Constructors
//- Construct from patch
mappedExtrudedPatchBase(const polyPatch&);
//- Construct from components
mappedExtrudedPatchBase
(
const polyPatch& pp,
const word& nbrRegionName,
const word& nbrPatchName,
const word& oppositePatch,
const cyclicTransform& transform
);
//- Construct from dictionary
mappedExtrudedPatchBase
(
const polyPatch& pp,
const dictionary& dict,
const bool transformisNone
);
//- Construct as copy, resetting the boundary mesh
mappedExtrudedPatchBase
(
const polyPatch&,
const mappedExtrudedPatchBase&
);
//- Destructor
virtual ~mappedExtrudedPatchBase();
// Member Functions
// Edit
//- Clear out data on mesh change
virtual void clearOut();
// I/O
//- Write the polyPatch data as a dictionary
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -0,0 +1,179 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "mappedExtrudedWallPolyPatch.H"
#include "mappedPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(mappedExtrudedWallPolyPatch, 0);
addToRunTimeSelectionTable(polyPatch, mappedExtrudedWallPolyPatch, word);
addToRunTimeSelectionTable
(
polyPatch,
mappedExtrudedWallPolyPatch,
dictionary
);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::mappedExtrudedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{
wallPolyPatch::calcGeometry(pBufs);
mappedExtrudedPatchBase::clearOut();
}
void Foam::mappedExtrudedWallPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
wallPolyPatch::movePoints(pBufs, p);
mappedExtrudedPatchBase::clearOut();
}
void Foam::mappedExtrudedWallPolyPatch::topoChange(PstreamBuffers& pBufs)
{
wallPolyPatch::topoChange(pBufs);
mappedExtrudedPatchBase::clearOut();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const polyBoundaryMesh& bm,
const word& patchType
)
:
wallPolyPatch(name, size, start, index, bm, patchType),
mappedExtrudedPatchBase(static_cast<const polyPatch&>(*this))
{
// mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
{
inGroups().append(mappedPolyPatch::typeName);
}
}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const word& neighbourRegion,
const word& neighbourPatch,
const word& bottomPatch,
const polyBoundaryMesh& bm
)
:
wallPolyPatch(name, size, start, index, bm, typeName),
mappedExtrudedPatchBase
(
*this,
neighbourRegion,
neighbourPatch,
bottomPatch,
cyclicTransform(true)
)
{}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch
(
const word& name,
const dictionary& dict,
const label index,
const polyBoundaryMesh& bm,
const word& patchType
)
:
wallPolyPatch(name, dict, index, bm, patchType),
mappedExtrudedPatchBase(*this, dict, true)
{
// mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
{
inGroups().append(mappedPolyPatch::typeName);
}
}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch
(
const mappedExtrudedWallPolyPatch& pp,
const polyBoundaryMesh& bm
)
:
wallPolyPatch(pp, bm),
mappedExtrudedPatchBase(*this, pp)
{}
Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch
(
const mappedExtrudedWallPolyPatch& pp,
const polyBoundaryMesh& bm,
const label index,
const label newSize,
const label newStart
)
:
wallPolyPatch(pp, bm, index, newSize, newStart),
mappedExtrudedPatchBase(*this, pp)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::mappedExtrudedWallPolyPatch::~mappedExtrudedWallPolyPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::mappedExtrudedWallPolyPatch::write(Ostream& os) const
{
wallPolyPatch::write(os);
mappedExtrudedPatchBase::write(os);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,8 +25,7 @@ Class
Foam::mappedExtrudedWallPolyPatch Foam::mappedExtrudedWallPolyPatch
Description Description
Wall patch which holds a mapping engine to map values from another patch, Wall patch which holds a mapping engine to map values from another patch
and which offsets the geometry to account for the extrusion thickness
SourceFiles SourceFiles
mappedExtrudedWallPolyPatch.C mappedExtrudedWallPolyPatch.C
@ -36,72 +35,37 @@ SourceFiles
#ifndef mappedExtrudedWallPolyPatch_H #ifndef mappedExtrudedWallPolyPatch_H
#define mappedExtrudedWallPolyPatch_H #define mappedExtrudedWallPolyPatch_H
#include "mappedWallPolyPatch.H" #include "wallPolyPatch.H"
#include "mappedExtrudedPatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
class polyMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class mappedExtrudedWallPolyPatch Declaration Class mappedExtrudedWallPolyPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class mappedExtrudedWallPolyPatch class mappedExtrudedWallPolyPatch
: :
public mappedWallPolyPatch public wallPolyPatch,
public mappedExtrudedPatchBase
{ {
private:
// Private Member Data
//- The bottom patch on the other side of the extruded region. Empty if
// this is not the extruded region.
word bottomPatch_;
//- The face areas on the bottom patch
mutable autoPtr<vectorField> bottomFaceAreasPtr_;
//- The face centres on the bottom patch
mutable autoPtr<pointField> bottomFaceCentresPtr_;
//- The local points on the bottom patch
mutable autoPtr<pointField> bottomLocalPointsPtr_;
protected: protected:
// Protected Member Functions // Protected Member Functions
//- Initialise the calculation of the patch geometry
virtual void initCalcGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(PstreamBuffers&); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points
virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(PstreamBuffers&, const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology
virtual void initTopoChange(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void topoChange(PstreamBuffers&); virtual void topoChange(PstreamBuffers&);
//- Get the face-areas for the patch
virtual tmp<vectorField> patchFaceAreas() const;
//- Get the face-centres for the patch
virtual tmp<pointField> patchFaceCentres() const;
//- Get the local points for the patch
virtual tmp<pointField> patchLocalPoints() const;
public: public:
@ -122,6 +86,19 @@ public:
const word& patchType const word& patchType
); );
//- Construct from components
mappedExtrudedWallPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const word& neighbourRegion,
const word& neighbourPatch,
const word& bottomPatch,
const polyBoundaryMesh& bm
);
//- Construct from dictionary //- Construct from dictionary
mappedExtrudedWallPolyPatch mappedExtrudedWallPolyPatch
( (

View File

@ -31,8 +31,6 @@ License
#include "indexedOctree.H" #include "indexedOctree.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "RemoteData.H" #include "RemoteData.H"
#include "OBJstream.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -317,7 +315,8 @@ Foam::mappedPatchBase::mappedPatchBase(const polyPatch& pp)
patchToPatchIsUsed_(false), patchToPatchIsUsed_(false),
patchToPatchIsValid_(false), patchToPatchIsValid_(false),
patchToPatchPtr_(nullptr), patchToPatchPtr_(nullptr),
matchTol_(defaultMatchTol_) matchTol_(defaultMatchTol_),
reMapAfterMove_(true)
{} {}
@ -339,7 +338,8 @@ Foam::mappedPatchBase::mappedPatchBase
patchToPatchIsUsed_(false), patchToPatchIsUsed_(false),
patchToPatchIsValid_(false), patchToPatchIsValid_(false),
patchToPatchPtr_(nullptr), patchToPatchPtr_(nullptr),
matchTol_(defaultMatchTol_) matchTol_(defaultMatchTol_),
reMapAfterMove_(true)
{} {}
@ -387,7 +387,8 @@ Foam::mappedPatchBase::mappedPatchBase
).ptr() ).ptr()
: nullptr : nullptr
), ),
matchTol_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)) matchTol_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)),
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true))
{ {
const bool haveCoupleGroup = coupleGroup_.valid(); const bool haveCoupleGroup = coupleGroup_.valid();
@ -435,7 +436,8 @@ Foam::mappedPatchBase::mappedPatchBase
? patchToPatch::New(mpb.patchToPatchPtr_->type(), false).ptr() ? patchToPatch::New(mpb.patchToPatchPtr_->type(), false).ptr()
: nullptr : nullptr
), ),
matchTol_(mpb.matchTol_) matchTol_(mpb.matchTol_),
reMapAfterMove_(true)
{} {}
@ -493,9 +495,12 @@ const Foam::mappedPatchBase& Foam::mappedPatchBase::getMap
void Foam::mappedPatchBase::clearOut() void Foam::mappedPatchBase::clearOut()
{ {
mapPtr_.clear(); if (reMapAfterMove_)
nbrPatchFaceIndices_.clear(); {
patchToPatchIsValid_ = false; mapPtr_.clear();
nbrPatchFaceIndices_.clear();
patchToPatchIsValid_ = false;
}
} }
@ -526,6 +531,8 @@ void Foam::mappedPatchBase::write(Ostream& os) const
} }
writeEntryIfDifferent(os, "matchTolerance", defaultMatchTol_, matchTol_); writeEntryIfDifferent(os, "matchTolerance", defaultMatchTol_, matchTol_);
writeEntryIfDifferent<bool>(os, "reMapAfterMove", true, reMapAfterMove_);
} }

View File

@ -112,6 +112,10 @@ protected:
//- Matching tolerance //- Matching tolerance
const scalar matchTol_; const scalar matchTol_;
//- Do we need to re-calculate the mapping if mesh motion takes place?
// Defaults to true.
const bool reMapAfterMove_;
// Protected Member Functions // Protected Member Functions
@ -238,7 +242,7 @@ public:
// Edit // Edit
//- Clear out data on mesh change //- Clear out data on mesh change
void clearOut(); virtual void clearOut();
// Distribute // Distribute

View File

@ -39,12 +39,6 @@ namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::mappedPolyPatch::initCalcGeometry(PstreamBuffers& pBufs)
{
polyPatch::initCalcGeometry(pBufs);
}
void Foam::mappedPolyPatch::calcGeometry(PstreamBuffers& pBufs) void Foam::mappedPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
polyPatch::calcGeometry(pBufs); polyPatch::calcGeometry(pBufs);
@ -52,16 +46,6 @@ void Foam::mappedPolyPatch::calcGeometry(PstreamBuffers& pBufs)
} }
void Foam::mappedPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
polyPatch::initMovePoints(pBufs, p);
}
void Foam::mappedPolyPatch::movePoints void Foam::mappedPolyPatch::movePoints
( (
PstreamBuffers& pBufs, PstreamBuffers& pBufs,
@ -69,16 +53,7 @@ void Foam::mappedPolyPatch::movePoints
) )
{ {
polyPatch::movePoints(pBufs, p); polyPatch::movePoints(pBufs, p);
if (reMapAfterMove_) mappedPatchBase::clearOut();
{
mappedPatchBase::clearOut();
}
}
void Foam::mappedPolyPatch::initTopoChange(PstreamBuffers& pBufs)
{
polyPatch::initTopoChange(pBufs);
} }
@ -102,8 +77,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(name, size, start, index, bm, patchType), polyPatch(name, size, start, index, bm, patchType),
mappedPatchBase(static_cast<const polyPatch&>(*this)), mappedPatchBase(static_cast<const polyPatch&>(*this))
reMapAfterMove_(true)
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), typeName) == -1) if (findIndex(inGroups(), typeName) == -1)
@ -123,8 +97,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(name, dict, index, bm, patchType), polyPatch(name, dict, index, bm, patchType),
mappedPatchBase(*this, dict, false), mappedPatchBase(*this, dict, false)
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true))
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), typeName) == -1) if (findIndex(inGroups(), typeName) == -1)
@ -141,8 +114,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(pp, bm), polyPatch(pp, bm),
mappedPatchBase(*this, pp), mappedPatchBase(*this, pp)
reMapAfterMove_(true)
{} {}
@ -156,8 +128,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(pp, bm, index, newSize, newStart), polyPatch(pp, bm, index, newSize, newStart),
mappedPatchBase(*this, pp), mappedPatchBase(*this, pp)
reMapAfterMove_(true)
{} {}
@ -173,7 +144,6 @@ void Foam::mappedPolyPatch::write(Ostream& os) const
{ {
polyPatch::write(os); polyPatch::write(os);
mappedPatchBase::write(os); mappedPatchBase::write(os);
writeEntryIfDifferent<bool>(os, "reMapAfterMove", true, reMapAfterMove_);
} }

View File

@ -44,8 +44,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
class polyMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class mappedPolyPatch Declaration Class mappedPolyPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -55,32 +53,17 @@ class mappedPolyPatch
public polyPatch, public polyPatch,
public mappedPatchBase public mappedPatchBase
{ {
// Private Data
//- Do we need to re-calculate the mapping if mesh motion takes place?
// Defaults to true.
const bool reMapAfterMove_;
protected: protected:
// Protected Member Functions // Protected Member Functions
//- Initialise the calculation of the patch geometry
virtual void initCalcGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(PstreamBuffers&); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points
virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(PstreamBuffers&, const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology
virtual void initTopoChange(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void topoChange(PstreamBuffers&); virtual void topoChange(PstreamBuffers&);

View File

@ -44,12 +44,6 @@ namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::mappedWallPolyPatch::initCalcGeometry(PstreamBuffers& pBufs)
{
wallPolyPatch::initCalcGeometry(pBufs);
}
void Foam::mappedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs) void Foam::mappedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
wallPolyPatch::calcGeometry(pBufs); wallPolyPatch::calcGeometry(pBufs);
@ -57,16 +51,6 @@ void Foam::mappedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs)
} }
void Foam::mappedWallPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
wallPolyPatch::initMovePoints(pBufs, p);
}
void Foam::mappedWallPolyPatch::movePoints void Foam::mappedWallPolyPatch::movePoints
( (
PstreamBuffers& pBufs, PstreamBuffers& pBufs,
@ -74,16 +58,7 @@ void Foam::mappedWallPolyPatch::movePoints
) )
{ {
wallPolyPatch::movePoints(pBufs, p); wallPolyPatch::movePoints(pBufs, p);
if (reMapAfterMove_) mappedPatchBase::clearOut();
{
mappedPatchBase::clearOut();
}
}
void Foam::mappedWallPolyPatch::initTopoChange(PstreamBuffers& pBufs)
{
wallPolyPatch::initTopoChange(pBufs);
} }
@ -107,8 +82,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(name, size, start, index, bm, patchType), wallPolyPatch(name, size, start, index, bm, patchType),
mappedPatchBase(static_cast<const polyPatch&>(*this)), mappedPatchBase(static_cast<const polyPatch&>(*this))
reMapAfterMove_(true)
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
@ -136,8 +110,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
neighbourRegion, neighbourRegion,
neighbourPatch, neighbourPatch,
cyclicTransform(true) cyclicTransform(true)
), )
reMapAfterMove_(true)
{} {}
@ -151,8 +124,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(name, dict, index, bm, patchType), wallPolyPatch(name, dict, index, bm, patchType),
mappedPatchBase(*this, dict, true), mappedPatchBase(*this, dict, true)
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true))
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
@ -169,8 +141,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(pp, bm), wallPolyPatch(pp, bm),
mappedPatchBase(*this, pp), mappedPatchBase(*this, pp)
reMapAfterMove_(true)
{} {}
@ -184,8 +155,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(pp, bm, index, newSize, newStart), wallPolyPatch(pp, bm, index, newSize, newStart),
mappedPatchBase(*this, pp), mappedPatchBase(*this, pp)
reMapAfterMove_(true)
{} {}
@ -201,7 +171,6 @@ void Foam::mappedWallPolyPatch::write(Ostream& os) const
{ {
wallPolyPatch::write(os); wallPolyPatch::write(os);
mappedPatchBase::write(os); mappedPatchBase::write(os);
writeEntryIfDifferent<bool>(os, "reMapAfterMove", true, reMapAfterMove_);
} }

View File

@ -38,14 +38,11 @@ SourceFiles
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "mappedPatchBase.H" #include "mappedPatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
class polyMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class mappedWallPolyPatch Declaration Class mappedWallPolyPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -55,32 +52,16 @@ class mappedWallPolyPatch
public wallPolyPatch, public wallPolyPatch,
public mappedPatchBase public mappedPatchBase
{ {
// Private Data
//- Do we need to re-calculate the mapping if mesh motion takes place?
// Defaults to true.
const bool reMapAfterMove_;
protected: protected:
// Protected Member Functions // Protected Member Functions
//- Initialise the calculation of the patch geometry
virtual void initCalcGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(PstreamBuffers&); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points
virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(PstreamBuffers&, const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology
virtual void initTopoChange(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void topoChange(PstreamBuffers&); virtual void topoChange(PstreamBuffers&);