diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 2b0d76a005..c64e26e68d 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -927,7 +927,7 @@ Foam::polyMesh::cellTree() const void Foam::polyMesh::addPatches ( - const List& p, + PtrList& plist, const bool validBoundary ) { @@ -942,13 +942,7 @@ void Foam::polyMesh::addPatches geometricD_ = Zero; solutionD_ = Zero; - boundary_.setSize(p.size()); - - // Copy the patch pointers - forAll(p, pI) - { - boundary_.set(pI, p[pI]); - } + boundary_.transfer(plist); // parallelData depends on the processorPatch ordering so force // recalculation. Problem: should really be done in removeBoundary but @@ -1027,6 +1021,19 @@ void Foam::polyMesh::addZones } +void Foam::polyMesh::addPatches +( + const List& p, + const bool validBoundary +) +{ + // Acquire ownership of the pointers + PtrList plist(const_cast&>(p)); + + addPatches(plist, validBoundary); +} + + const Foam::pointField& Foam::polyMesh::points() const { if (clearedPrimitives_) diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index 5421d0e92f..a3e9486adb 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -573,7 +573,14 @@ public: //- Add boundary patches void addPatches ( - const List&, + PtrList& plist, + const bool validBoundary = true + ); + + //- Add boundary patches + void addPatches + ( + const List& p, const bool validBoundary = true ); diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 8aece6aa55..df461cf197 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -478,7 +478,7 @@ Foam::SolverPerformance Foam::fvMesh::solve void Foam::fvMesh::addFvPatches ( - const List& p, + PtrList& plist, const bool validBoundary ) { @@ -489,12 +489,24 @@ void Foam::fvMesh::addFvPatches << abort(FatalError); } - // first add polyPatches - addPatches(p, validBoundary); + addPatches(plist, validBoundary); boundary_.addPatches(boundaryMesh()); } +void Foam::fvMesh::addFvPatches +( + const List& p, + const bool validBoundary +) +{ + // Acquire ownership of the pointers + PtrList plist(const_cast&>(p)); + + addFvPatches(plist, validBoundary); +} + + void Foam::fvMesh::removeFvBoundary() { if (debug) diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 4436f37bbf..e0719626a9 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -186,7 +186,7 @@ public: explicit fvMesh(const IOobject& io); //- Construct from IOobject or as zero-sized mesh - // Boundary is added using addPatches() member function + // Boundary is added using addFvPatches() member function fvMesh(const IOobject& io, const zero, bool syncPar=true); //- Construct from components without boundary. @@ -202,7 +202,7 @@ public: ); //- Construct without boundary from cells rather than owner/neighbour. - // Boundary is added using addPatches() member function + // Boundary is added using addFvPatches() member function fvMesh ( const IOobject& io, @@ -221,6 +221,13 @@ public: // Helpers + //- Add boundary patches. Constructor helper + void addFvPatches + ( + PtrList& plist, + const bool validBoundary = true + ); + //- Add boundary patches. Constructor helper void addFvPatches (