ENH: support addPatches with PtrList

This commit is contained in:
Mark Olesen
2019-02-22 18:11:00 +01:00
committed by Andrew Heather
parent 7795adfcb4
commit bdf57fb44e
4 changed files with 48 additions and 15 deletions

View File

@ -927,7 +927,7 @@ Foam::polyMesh::cellTree() const
void Foam::polyMesh::addPatches void Foam::polyMesh::addPatches
( (
const List<polyPatch*>& p, PtrList<polyPatch>& plist,
const bool validBoundary const bool validBoundary
) )
{ {
@ -942,13 +942,7 @@ void Foam::polyMesh::addPatches
geometricD_ = Zero; geometricD_ = Zero;
solutionD_ = Zero; solutionD_ = Zero;
boundary_.setSize(p.size()); boundary_.transfer(plist);
// Copy the patch pointers
forAll(p, pI)
{
boundary_.set(pI, p[pI]);
}
// parallelData depends on the processorPatch ordering so force // parallelData depends on the processorPatch ordering so force
// recalculation. Problem: should really be done in removeBoundary but // recalculation. Problem: should really be done in removeBoundary but
@ -1027,6 +1021,19 @@ void Foam::polyMesh::addZones
} }
void Foam::polyMesh::addPatches
(
const List<polyPatch*>& p,
const bool validBoundary
)
{
// Acquire ownership of the pointers
PtrList<polyPatch> plist(const_cast<List<polyPatch*>&>(p));
addPatches(plist, validBoundary);
}
const Foam::pointField& Foam::polyMesh::points() const const Foam::pointField& Foam::polyMesh::points() const
{ {
if (clearedPrimitives_) if (clearedPrimitives_)

View File

@ -573,7 +573,14 @@ public:
//- Add boundary patches //- Add boundary patches
void addPatches void addPatches
( (
const List<polyPatch*>&, PtrList<polyPatch>& plist,
const bool validBoundary = true
);
//- Add boundary patches
void addPatches
(
const List<polyPatch*>& p,
const bool validBoundary = true const bool validBoundary = true
); );

View File

@ -478,7 +478,7 @@ Foam::SolverPerformance<Foam::tensor> Foam::fvMesh::solve
void Foam::fvMesh::addFvPatches void Foam::fvMesh::addFvPatches
( (
const List<polyPatch*>& p, PtrList<polyPatch>& plist,
const bool validBoundary const bool validBoundary
) )
{ {
@ -489,12 +489,24 @@ void Foam::fvMesh::addFvPatches
<< abort(FatalError); << abort(FatalError);
} }
// first add polyPatches addPatches(plist, validBoundary);
addPatches(p, validBoundary);
boundary_.addPatches(boundaryMesh()); boundary_.addPatches(boundaryMesh());
} }
void Foam::fvMesh::addFvPatches
(
const List<polyPatch*>& p,
const bool validBoundary
)
{
// Acquire ownership of the pointers
PtrList<polyPatch> plist(const_cast<List<polyPatch*>&>(p));
addFvPatches(plist, validBoundary);
}
void Foam::fvMesh::removeFvBoundary() void Foam::fvMesh::removeFvBoundary()
{ {
if (debug) if (debug)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -186,7 +186,7 @@ public:
explicit fvMesh(const IOobject& io); explicit fvMesh(const IOobject& io);
//- Construct from IOobject or as zero-sized mesh //- 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); fvMesh(const IOobject& io, const zero, bool syncPar=true);
//- Construct from components without boundary. //- Construct from components without boundary.
@ -202,7 +202,7 @@ public:
); );
//- Construct without boundary from cells rather than owner/neighbour. //- Construct without boundary from cells rather than owner/neighbour.
// Boundary is added using addPatches() member function // Boundary is added using addFvPatches() member function
fvMesh fvMesh
( (
const IOobject& io, const IOobject& io,
@ -221,6 +221,13 @@ public:
// Helpers // Helpers
//- Add boundary patches. Constructor helper
void addFvPatches
(
PtrList<polyPatch>& plist,
const bool validBoundary = true
);
//- Add boundary patches. Constructor helper //- Add boundary patches. Constructor helper
void addFvPatches void addFvPatches
( (