diff --git a/applications/utilities/mesh/generation/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrudeToRegionMesh/extrudeToRegionMesh.C index 655739fd01..a2e53c3a9d 100644 --- a/applications/utilities/mesh/generation/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -552,11 +552,21 @@ void addCouplingPatches << "-------\t-----\t----" << endl; - const wordList patchNames + wordList patchNames ( dict.lookupOrDefault("patchNames", wordList()) ); + wordList regionPatchNames + ( + dict.lookupOrDefault("regionPatchNames", wordList()) + ); + + if (isShellMesh) + { + patchNames.swap(regionPatchNames); + } + const wordList patchTypes ( isShellMesh @@ -572,11 +582,6 @@ void addCouplingPatches ) ); - const wordList regionPatchNames - ( - dict.lookupOrDefault("regionPatchNames", wordList()) - ); - const wordList regionOppositePatchTypes ( dict.lookupOrDefault("regionOppositePatchTypes", wordList()) @@ -672,7 +677,7 @@ void addCouplingPatches topPatchDict.add("neighbourPatch", topNbrPatchName); if (isShellMesh) { - topPatchDict.add("bottomPatch", bottomPatchName); + topPatchDict.add("oppositePatch", bottomPatchName); } zoneTopPatch[zonei] = addPatch diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C index b362db7ebe..1067f88470 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C @@ -141,7 +141,8 @@ Foam::mappedValueFvPatchField::mappedValueFvPatchField { OStringStream str; 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 " << "neighbourRegion entries) nor is the patch of " << mappedPolyPatch::typeName << " type"; diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index e260435c39..4a4916f6a4 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -230,10 +230,12 @@ meshToMesh/meshToMesh.C mappedPatches/mappedPatchBase/mappedPatchBase.C mappedPatches/mappedPolyPatch/mappedPolyPatch.C mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C -mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.C mappedPatches/mappedPointPatch/mappedPointPatch.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/mappedInternalPolyPatch/mappedInternalPolyPatch.C diff --git a/src/meshTools/layerInfo/LayerInfoData.H b/src/meshTools/layerInfo/LayerInfoData.H index 0d63171d96..e1e33fd942 100644 --- a/src/meshTools/layerInfo/LayerInfoData.H +++ b/src/meshTools/layerInfo/LayerInfoData.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,9 +52,9 @@ class transformer; template class LayerInfoData; template -Ostream& operator<<(Ostream&, const LayerInfoData&); +inline Ostream& operator<<(Ostream&, const LayerInfoData&); template -Istream& operator>>(Istream&, LayerInfoData&); +inline Istream& operator>>(Istream&, LayerInfoData&); /*---------------------------------------------------------------------------*\ Class LayerInfoData Declaration diff --git a/src/meshTools/layerInfo/LayerInfoDataI.H b/src/meshTools/layerInfo/LayerInfoDataI.H index 101d93c444..454ef4207a 100644 --- a/src/meshTools/layerInfo/LayerInfoDataI.H +++ b/src/meshTools/layerInfo/LayerInfoDataI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -185,14 +185,18 @@ inline bool Foam::LayerInfoData::operator!= // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template -Foam::Ostream& Foam::operator<<(Ostream& os, const LayerInfoData& l) +inline Foam::Ostream& Foam::operator<< +( + Ostream& os, + const LayerInfoData& l +) { return os << static_cast(l) << token::SPACE << l.data_; } template -Foam::Istream& Foam::operator>>(Istream& is, LayerInfoData& l) +inline Foam::Istream& Foam::operator>>(Istream& is, LayerInfoData& l) { return is >> static_cast(l) >> l.data_; } diff --git a/src/meshTools/layerInfo/layerInfo.H b/src/meshTools/layerInfo/layerInfo.H index ff16c698ef..f1cf6f1615 100644 --- a/src/meshTools/layerInfo/layerInfo.H +++ b/src/meshTools/layerInfo/layerInfo.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,8 +50,8 @@ class transformer; // Forward declaration of friend functions and operators class layerInfo; -Ostream& operator<<(Ostream&, const layerInfo&); -Istream& operator>>(Istream&, layerInfo&); +inline Ostream& operator<<(Ostream&, const layerInfo&); +inline Istream& operator>>(Istream&, layerInfo&); /*---------------------------------------------------------------------------*\ Class layerInfo Declaration diff --git a/src/meshTools/layerInfo/layerInfoI.H b/src/meshTools/layerInfo/layerInfoI.H index 1e7ca071a3..a397dde571 100644 --- a/src/meshTools/layerInfo/layerInfoI.H +++ b/src/meshTools/layerInfo/layerInfoI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -229,13 +229,13 @@ inline bool Foam::layerInfo::operator!=(const Foam::layerInfo& rhs) const // * * * * * * * * * * * * * * * 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_; } -Foam::Istream& Foam::operator>>(Istream& is, layerInfo& l) +inline Foam::Istream& Foam::operator>>(Istream& is, layerInfo& l) { return is >> l.layer_ >> l.direction_; } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.C b/src/meshTools/mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.C similarity index 61% rename from src/meshTools/mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.C rename to src/meshTools/mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.C index 7a606bd981..58f3ba9646 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.C @@ -23,8 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "mappedExtrudedWallPolyPatch.H" -#include "addToRunTimeSelectionTable.H" +#include "mappedExtrudedPatchBase.H" #include "LayerInfoData.H" #include "FaceCellWave.H" @@ -32,73 +31,18 @@ License namespace Foam { - defineTypeNameAndDebug(mappedExtrudedWallPolyPatch, 0); - - addToRunTimeSelectionTable(polyPatch, mappedExtrudedWallPolyPatch, word); - addToRunTimeSelectionTable - ( - polyPatch, - mappedExtrudedWallPolyPatch, - dictionary - ); + defineTypeNameAndDebug(mappedExtrudedPatchBase, 0); } // * * * * * * * * * * * * 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::mappedExtrudedWallPolyPatch::patchFaceAreas() const +Foam::mappedExtrudedPatchBase::patchFaceAreas() const { if (!bottomFaceAreasPtr_.valid()) { - const bool isExtrudedRegion = bottomPatch_ != word::null; + const bool isExtrudedRegion = oppositePatch_ != word::null; if (isExtrudedRegion) { @@ -106,9 +50,9 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const // corresponding areas and centres are on the bottom patch. We do // this by waving these values across the layers. - const polyMesh& mesh = boundaryMesh().mesh(); - const polyPatch& pp = *this; - const polyPatch& bottomPp = boundaryMesh()[bottomPatch_]; + const polyMesh& mesh = patch_.boundaryMesh().mesh(); + const polyPatch& pp = patch_; + const polyPatch& bottomPp = patch_.boundaryMesh()[oppositePatch_]; // Initialise faces on the bottom patch to wave from labelList initialFaces(bottomPp.size()); @@ -157,7 +101,7 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const { FatalErrorInFunction << "Mesh \"" << mesh.name() - << "\" is not layered between the extruded wall patch " + << "\" is not layered between the extruded patch " << "\"" << pp.name() << "\" and the bottom patch \"" << bottomPp.name() << "\"" << exit(FatalError); } @@ -172,21 +116,21 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const // of mapping on the extruded region and then reverse map the // extruded region's data so it is available here - const mappedExtrudedWallPolyPatch& nbrPp = - refCast(nbrPolyPatch()); + const mappedExtrudedPatchBase& nbrPp = + refCast(nbrPolyPatch()); bottomFaceAreasPtr_.set ( nbrPp.reverseDistribute ( - nbrPp.primitivePatch::faceAreas() + nbrPp.patch_.primitivePatch::faceAreas() ).ptr() ); bottomFaceCentresPtr_.set ( nbrPp.reverseDistribute ( - nbrPp.primitivePatch::faceCentres() + nbrPp.patch_.primitivePatch::faceCentres() ).ptr() ); } @@ -197,7 +141,7 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceAreas() const Foam::tmp -Foam::mappedExtrudedWallPolyPatch::patchFaceCentres() const +Foam::mappedExtrudedPatchBase::patchFaceCentres() const { if (!bottomFaceCentresPtr_.valid()) { @@ -209,7 +153,7 @@ Foam::mappedExtrudedWallPolyPatch::patchFaceCentres() const Foam::tmp -Foam::mappedExtrudedWallPolyPatch::patchLocalPoints() const +Foam::mappedExtrudedPatchBase::patchLocalPoints() const { NotImplemented; return tmp(nullptr); @@ -218,72 +162,72 @@ Foam::mappedExtrudedWallPolyPatch::patchLocalPoints() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch -( - const word& name, - const label size, - const label start, - const label index, - const polyBoundaryMesh& bm, - const word& patchType -) +Foam::mappedExtrudedPatchBase::mappedExtrudedPatchBase(const polyPatch& pp) : - mappedWallPolyPatch(name, size, start, index, bm, patchType), - bottomPatch_(word::null) + mappedPatchBase(pp), + 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 label index, - const polyBoundaryMesh& bm, - const word& patchType + const bool transformIsNone ) : - mappedWallPolyPatch(name, dict, index, bm, patchType), - bottomPatch_(dict.lookupOrDefault("bottomPatch", word::null)) + mappedPatchBase(pp, dict, transformIsNone), + oppositePatch_(dict.lookupOrDefault("oppositePatch", word::null)) {} -Foam::mappedExtrudedWallPolyPatch::mappedExtrudedWallPolyPatch +Foam::mappedExtrudedPatchBase::mappedExtrudedPatchBase ( - const mappedExtrudedWallPolyPatch& pp, - const polyBoundaryMesh& bm + const polyPatch& pp, + const mappedExtrudedPatchBase& mepb ) : - mappedWallPolyPatch(pp, bm), - bottomPatch_(pp.bottomPatch_) -{} - - -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_) + mappedPatchBase(pp), + oppositePatch_(mepb.oppositePatch_) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::mappedExtrudedWallPolyPatch::~mappedExtrudedWallPolyPatch() +Foam::mappedExtrudedPatchBase::~mappedExtrudedPatchBase() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::mappedExtrudedWallPolyPatch::write(Ostream& os) const +void Foam::mappedExtrudedPatchBase::clearOut() { - mappedWallPolyPatch::write(os); - writeEntryIfDifferent(os, "bottomPatch", word::null, bottomPatch_); + mappedPatchBase::clearOut(); + if (reMapAfterMove_) + { + bottomFaceCentresPtr_.clear(); + } +} + + +void Foam::mappedExtrudedPatchBase::write(Ostream& os) const +{ + mappedPatchBase::write(os); + writeEntryIfDifferent(os, "oppositePatch", word::null, oppositePatch_); } diff --git a/src/meshTools/mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.H b/src/meshTools/mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.H new file mode 100644 index 0000000000..e1a24a82d0 --- /dev/null +++ b/src/meshTools/mappedPatches/mappedExtrudedPatchBase/mappedExtrudedPatchBase.H @@ -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 . + +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 bottomFaceAreasPtr_; + + //- The face centres on the bottom patch + mutable autoPtr bottomFaceCentresPtr_; + + //- The local points on the bottom patch + mutable autoPtr bottomLocalPointsPtr_; + + +protected: + + // Protected Member Functions + + //- Get the face-areas for the patch + virtual tmp patchFaceAreas() const; + + //- Get the face-centres for the patch + virtual tmp patchFaceCentres() const; + + //- Get the local points for the patch + virtual tmp 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 + +// ************************************************************************* // diff --git a/src/meshTools/mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.C b/src/meshTools/mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.C similarity index 96% rename from src/meshTools/mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.C rename to src/meshTools/mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.C index a76c03fece..e8e2e94ff2 100644 --- a/src/meshTools/mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.C +++ b/src/meshTools/mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/meshTools/mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.H b/src/meshTools/mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.H similarity index 96% rename from src/meshTools/mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.H rename to src/meshTools/mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.H index e0b4acfede..227789c298 100644 --- a/src/meshTools/mappedPatches/mappedPointPatch/mappedExtrudedWallPointPatch.H +++ b/src/meshTools/mappedPatches/mappedExtrudedPointPatch/mappedExtrudedWallPointPatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/meshTools/mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.C b/src/meshTools/mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.C new file mode 100644 index 0000000000..f66ca4e365 --- /dev/null +++ b/src/meshTools/mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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(*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); +} + + +// ************************************************************************* // diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.H b/src/meshTools/mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.H similarity index 76% rename from src/meshTools/mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.H rename to src/meshTools/mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.H index 1ca88f9ba9..afe96928ed 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedExtrudedWallPolyPatch.H +++ b/src/meshTools/mappedPatches/mappedExtrudedPolyPatch/mappedExtrudedWallPolyPatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,8 +25,7 @@ Class Foam::mappedExtrudedWallPolyPatch Description - Wall patch which holds a mapping engine to map values from another patch, - and which offsets the geometry to account for the extrusion thickness + Wall patch which holds a mapping engine to map values from another patch SourceFiles mappedExtrudedWallPolyPatch.C @@ -36,72 +35,37 @@ SourceFiles #ifndef mappedExtrudedWallPolyPatch_H #define mappedExtrudedWallPolyPatch_H -#include "mappedWallPolyPatch.H" +#include "wallPolyPatch.H" +#include "mappedExtrudedPatchBase.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -class polyMesh; - /*---------------------------------------------------------------------------*\ Class mappedExtrudedWallPolyPatch Declaration \*---------------------------------------------------------------------------*/ 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 bottomFaceAreasPtr_; - - //- The face centres on the bottom patch - mutable autoPtr bottomFaceCentresPtr_; - - //- The local points on the bottom patch - mutable autoPtr bottomLocalPointsPtr_; - - protected: // Protected Member Functions - //- Initialise the calculation of the patch geometry - virtual void initCalcGeometry(PstreamBuffers&); - //- Calculate the patch geometry virtual void calcGeometry(PstreamBuffers&); - //- Initialise the patches for moving points - virtual void initMovePoints(PstreamBuffers&, const pointField&); - //- Correct patches after moving points virtual void movePoints(PstreamBuffers&, const pointField&); - //- Initialise the update of the patch topology - virtual void initTopoChange(PstreamBuffers&); - //- Update of the patch topology virtual void topoChange(PstreamBuffers&); - //- Get the face-areas for the patch - virtual tmp patchFaceAreas() const; - - //- Get the face-centres for the patch - virtual tmp patchFaceCentres() const; - - //- Get the local points for the patch - virtual tmp patchLocalPoints() const; - public: @@ -122,6 +86,19 @@ public: 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 mappedExtrudedWallPolyPatch ( diff --git a/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C index b3755e570d..bfc1a1095a 100644 --- a/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C @@ -31,8 +31,6 @@ License #include "indexedOctree.H" #include "globalIndex.H" #include "RemoteData.H" -#include "OBJstream.H" -#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -317,7 +315,8 @@ Foam::mappedPatchBase::mappedPatchBase(const polyPatch& pp) patchToPatchIsUsed_(false), patchToPatchIsValid_(false), patchToPatchPtr_(nullptr), - matchTol_(defaultMatchTol_) + matchTol_(defaultMatchTol_), + reMapAfterMove_(true) {} @@ -339,7 +338,8 @@ Foam::mappedPatchBase::mappedPatchBase patchToPatchIsUsed_(false), patchToPatchIsValid_(false), patchToPatchPtr_(nullptr), - matchTol_(defaultMatchTol_) + matchTol_(defaultMatchTol_), + reMapAfterMove_(true) {} @@ -387,7 +387,8 @@ Foam::mappedPatchBase::mappedPatchBase ).ptr() : nullptr ), - matchTol_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)) + matchTol_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)), + reMapAfterMove_(dict.lookupOrDefault("reMapAfterMove", true)) { const bool haveCoupleGroup = coupleGroup_.valid(); @@ -435,7 +436,8 @@ Foam::mappedPatchBase::mappedPatchBase ? patchToPatch::New(mpb.patchToPatchPtr_->type(), false).ptr() : nullptr ), - matchTol_(mpb.matchTol_) + matchTol_(mpb.matchTol_), + reMapAfterMove_(true) {} @@ -493,9 +495,12 @@ const Foam::mappedPatchBase& Foam::mappedPatchBase::getMap void Foam::mappedPatchBase::clearOut() { - mapPtr_.clear(); - nbrPatchFaceIndices_.clear(); - patchToPatchIsValid_ = false; + if (reMapAfterMove_) + { + mapPtr_.clear(); + nbrPatchFaceIndices_.clear(); + patchToPatchIsValid_ = false; + } } @@ -526,6 +531,8 @@ void Foam::mappedPatchBase::write(Ostream& os) const } writeEntryIfDifferent(os, "matchTolerance", defaultMatchTol_, matchTol_); + + writeEntryIfDifferent(os, "reMapAfterMove", true, reMapAfterMove_); } diff --git a/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.H index b1addbe851..12bf86c05f 100644 --- a/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.H @@ -112,6 +112,10 @@ protected: //- Matching tolerance 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 @@ -238,7 +242,7 @@ public: // Edit //- Clear out data on mesh change - void clearOut(); + virtual void clearOut(); // Distribute diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C index 7e61cea890..ca46807175 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C @@ -39,12 +39,6 @@ namespace Foam // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::mappedPolyPatch::initCalcGeometry(PstreamBuffers& pBufs) -{ - polyPatch::initCalcGeometry(pBufs); -} - - void Foam::mappedPolyPatch::calcGeometry(PstreamBuffers& 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 ( PstreamBuffers& pBufs, @@ -69,16 +53,7 @@ void Foam::mappedPolyPatch::movePoints ) { polyPatch::movePoints(pBufs, p); - if (reMapAfterMove_) - { - mappedPatchBase::clearOut(); - } -} - - -void Foam::mappedPolyPatch::initTopoChange(PstreamBuffers& pBufs) -{ - polyPatch::initTopoChange(pBufs); + mappedPatchBase::clearOut(); } @@ -102,8 +77,7 @@ Foam::mappedPolyPatch::mappedPolyPatch ) : polyPatch(name, size, start, index, bm, patchType), - mappedPatchBase(static_cast(*this)), - reMapAfterMove_(true) + mappedPatchBase(static_cast(*this)) { // mapped is not constraint type so add mapped group explicitly if (findIndex(inGroups(), typeName) == -1) @@ -123,8 +97,7 @@ Foam::mappedPolyPatch::mappedPolyPatch ) : polyPatch(name, dict, index, bm, patchType), - mappedPatchBase(*this, dict, false), - reMapAfterMove_(dict.lookupOrDefault("reMapAfterMove", true)) + mappedPatchBase(*this, dict, false) { // mapped is not constraint type so add mapped group explicitly if (findIndex(inGroups(), typeName) == -1) @@ -141,8 +114,7 @@ Foam::mappedPolyPatch::mappedPolyPatch ) : polyPatch(pp, bm), - mappedPatchBase(*this, pp), - reMapAfterMove_(true) + mappedPatchBase(*this, pp) {} @@ -156,8 +128,7 @@ Foam::mappedPolyPatch::mappedPolyPatch ) : polyPatch(pp, bm, index, newSize, newStart), - mappedPatchBase(*this, pp), - reMapAfterMove_(true) + mappedPatchBase(*this, pp) {} @@ -173,7 +144,6 @@ void Foam::mappedPolyPatch::write(Ostream& os) const { polyPatch::write(os); mappedPatchBase::write(os); - writeEntryIfDifferent(os, "reMapAfterMove", true, reMapAfterMove_); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.H index 6457414704..367b835003 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.H @@ -44,8 +44,6 @@ SourceFiles namespace Foam { -class polyMesh; - /*---------------------------------------------------------------------------*\ Class mappedPolyPatch Declaration \*---------------------------------------------------------------------------*/ @@ -55,32 +53,17 @@ class mappedPolyPatch public polyPatch, 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 Member Functions - //- Initialise the calculation of the patch geometry - virtual void initCalcGeometry(PstreamBuffers&); - //- Calculate the patch geometry virtual void calcGeometry(PstreamBuffers&); - //- Initialise the patches for moving points - virtual void initMovePoints(PstreamBuffers&, const pointField&); - //- Correct patches after moving points virtual void movePoints(PstreamBuffers&, const pointField&); - //- Initialise the update of the patch topology - virtual void initTopoChange(PstreamBuffers&); - //- Update of the patch topology virtual void topoChange(PstreamBuffers&); diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C index ea1773dcfc..3625344889 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C @@ -44,12 +44,6 @@ namespace Foam // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::mappedWallPolyPatch::initCalcGeometry(PstreamBuffers& pBufs) -{ - wallPolyPatch::initCalcGeometry(pBufs); -} - - void Foam::mappedWallPolyPatch::calcGeometry(PstreamBuffers& 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 ( PstreamBuffers& pBufs, @@ -74,16 +58,7 @@ void Foam::mappedWallPolyPatch::movePoints ) { wallPolyPatch::movePoints(pBufs, p); - if (reMapAfterMove_) - { - mappedPatchBase::clearOut(); - } -} - - -void Foam::mappedWallPolyPatch::initTopoChange(PstreamBuffers& pBufs) -{ - wallPolyPatch::initTopoChange(pBufs); + mappedPatchBase::clearOut(); } @@ -107,8 +82,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch ) : wallPolyPatch(name, size, start, index, bm, patchType), - mappedPatchBase(static_cast(*this)), - reMapAfterMove_(true) + mappedPatchBase(static_cast(*this)) { // mapped is not constraint type so add mapped group explicitly if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) @@ -136,8 +110,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch neighbourRegion, neighbourPatch, cyclicTransform(true) - ), - reMapAfterMove_(true) + ) {} @@ -151,8 +124,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch ) : wallPolyPatch(name, dict, index, bm, patchType), - mappedPatchBase(*this, dict, true), - reMapAfterMove_(dict.lookupOrDefault("reMapAfterMove", true)) + mappedPatchBase(*this, dict, true) { // mapped is not constraint type so add mapped group explicitly if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) @@ -169,8 +141,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch ) : wallPolyPatch(pp, bm), - mappedPatchBase(*this, pp), - reMapAfterMove_(true) + mappedPatchBase(*this, pp) {} @@ -184,8 +155,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch ) : wallPolyPatch(pp, bm, index, newSize, newStart), - mappedPatchBase(*this, pp), - reMapAfterMove_(true) + mappedPatchBase(*this, pp) {} @@ -201,7 +171,6 @@ void Foam::mappedWallPolyPatch::write(Ostream& os) const { wallPolyPatch::write(os); mappedPatchBase::write(os); - writeEntryIfDifferent(os, "reMapAfterMove", true, reMapAfterMove_); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.H index f6ceb0860b..5bd53429ef 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.H @@ -38,14 +38,11 @@ SourceFiles #include "wallPolyPatch.H" #include "mappedPatchBase.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -class polyMesh; - /*---------------------------------------------------------------------------*\ Class mappedWallPolyPatch Declaration \*---------------------------------------------------------------------------*/ @@ -55,32 +52,16 @@ class mappedWallPolyPatch public wallPolyPatch, 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 Member Functions - //- Initialise the calculation of the patch geometry - virtual void initCalcGeometry(PstreamBuffers&); - //- Calculate the patch geometry virtual void calcGeometry(PstreamBuffers&); - //- Initialise the patches for moving points - virtual void initMovePoints(PstreamBuffers&, const pointField&); - //- Correct patches after moving points virtual void movePoints(PstreamBuffers&, const pointField&); - //- Initialise the update of the patch topology - virtual void initTopoChange(PstreamBuffers&); - //- Update of the patch topology virtual void topoChange(PstreamBuffers&);