From cd31a868ffaf48efe6e010e1ab06251227f48468 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 22 Feb 2019 18:11:00 +0100 Subject: [PATCH] ENH: support addPatches with PtrList --- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 23 +++++++++++++++-------- src/OpenFOAM/meshes/polyMesh/polyMesh.H | 9 ++++++++- src/finiteVolume/fvMesh/fvMesh.C | 18 +++++++++++++++--- src/finiteVolume/fvMesh/fvMesh.H | 13 ++++++++++--- 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 0e3917f2df..168a76938d 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 857484b698..fbb7649d5e 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 cb0e01b671..57ad0aa940 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 a77bd28a4e..9e17494d51 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) 2004-2011, 2016-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011, 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 (