STYLE: use polyPatchList instead of List<polyPatch*> in more places

This commit is contained in:
Mark Olesen
2022-09-23 11:33:30 +02:00
parent 3c7088b6c0
commit 5130c7bcbc
26 changed files with 388 additions and 238 deletions

View File

@ -226,14 +226,18 @@ int main(int argc, char *argv[])
// Add the boundary patches
const polyBoundaryMesh& patches = mesh.boundaryMesh();
List<polyPatch*> p(patches.size());
polyPatchList newPatches(patches.size());
forAll(p, patchi)
forAll(newPatches, patchi)
{
p[patchi] = patches[patchi].clone(fMesh.boundaryMesh()).ptr();
newPatches.set
(
patchi,
patches[patchi].clone(fMesh.boundaryMesh())
);
}
fMesh.addFvPatches(p);
fMesh.addFvPatches(newPatches);
// Refinement level

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -205,34 +205,43 @@ label addPatch(polyMesh& mesh, const word& patchName)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
List<polyPatch*> newPatches(patches.size() + 1);
polyPatchList newPatches(patches.size() + 1);
label nPatches = 0;
// Add empty patch as 0th entry (Note: only since subsetMesh wants this)
patchi = 0;
newPatches[patchi] =
{
newPatches.set
(
nPatches,
new emptyPolyPatch
(
Foam::word(patchName),
patchName,
0,
mesh.nInternalFaces(),
patchi,
nPatches,
patches,
emptyPolyPatch::typeName
)
);
++nPatches;
}
forAll(patches, i)
for (const polyPatch& pp : patches)
{
const polyPatch& pp = patches[i];
newPatches[i+1] =
newPatches.set
(
nPatches,
pp.clone
(
patches,
i+1,
nPatches,
pp.size(),
pp.start()
).ptr();
)
);
++nPatches;
}
mesh.removeBoundary();

View File

@ -1678,7 +1678,7 @@ int main(int argc, char *argv[])
label defaultPatchID = mesh.boundaryMesh().findPatchID(defaultFacesName);
if (mesh.boundaryMesh()[defaultPatchID].size() == 0)
{
List<polyPatch*> newPatchPtrList((mesh.boundaryMesh().size() - 1));
polyPatchList newPatches((mesh.boundaryMesh().size() - 1));
label newPatchi = 0;
forAll(mesh.boundaryMesh(), patchi)
{
@ -1686,18 +1686,21 @@ int main(int argc, char *argv[])
{
const polyPatch& patch = mesh.boundaryMesh()[patchi];
newPatchPtrList[newPatchi] = patch.clone
newPatches.set
(
newPatchi,
patch.clone
(
mesh.boundaryMesh(),
newPatchi,
patch.size(),
patch.start()
).ptr();
newPatchi++;
)
);
++newPatchi;
}
}
repatcher.changePatches(newPatchPtrList);
repatcher.changePatches(newPatches);
}
// Set the precision of the points data to 10

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -167,28 +167,32 @@ int main(int argc, char *argv[])
);
Info<< "Constructing patches." << endl;
List<polyPatch*> patches(poly2DMesh.patchNames().size());
label countPatches = 0;
polyPatchList newPatches(poly2DMesh.patchNames().size());
label nPatches = 0;
forAll(patches, patchi)
forAll(newPatches, patchi)
{
if (poly2DMesh.patchSizes()[patchi] != 0)
{
patches[countPatches] = new polyPatch
newPatches.set
(
nPatches,
new polyPatch
(
poly2DMesh.patchNames()[patchi],
poly2DMesh.patchSizes()[patchi],
poly2DMesh.patchStarts()[patchi],
countPatches,
nPatches,
pMesh.boundaryMesh(),
word::null
)
);
countPatches++;
++nPatches;
}
}
patches.setSize(countPatches);
pMesh.addPatches(patches);
newPatches.resize(nPatches);
pMesh.addPatches(newPatches);
if (extrude)
{

View File

@ -191,7 +191,7 @@ int main(int argc, char *argv[])
const PtrList<boundaryPatch>& patches = bMesh.patches();
// Create new list of patches with old ones first
List<polyPatch*> newPatchPtrList(patches.size());
polyPatchList newPatches(patches.size());
newPatchi = 0;
@ -200,34 +200,41 @@ int main(int argc, char *argv[])
{
const polyPatch& patch = mesh.boundaryMesh()[patchi];
newPatchPtrList[newPatchi] =
newPatches.set
(
newPatchi,
patch.clone
(
mesh.boundaryMesh(),
newPatchi,
patch.size(),
patch.start()
).ptr();
)
);
newPatchi++;
++newPatchi;
}
// Add new ones with empty size.
for (label patchi = newPatchi; patchi < patches.size(); patchi++)
{
const boundaryPatch& bp = patches[patchi];
const word& patchName = patches[patchi].name();
newPatchPtrList[newPatchi] = polyPatch::New
newPatches.set
(
newPatchi,
polyPatch::New
(
polyPatch::typeName,
bp.name(),
patchName,
0,
mesh.nFaces(),
newPatchi,
mesh.boundaryMesh()
).ptr();
)
);
newPatchi++;
++newPatchi;
}
if (!overwrite)
@ -238,7 +245,7 @@ int main(int argc, char *argv[])
// Change patches
repatchPolyTopoChanger polyMeshRepatcher(mesh);
polyMeshRepatcher.changePatches(newPatchPtrList);
polyMeshRepatcher.changePatches(newPatches);
// Change face ordering

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -136,46 +136,55 @@ void Foam::mergePolyMesh::sortProcessorPatches()
const polyBoundaryMesh& oldPatches = boundaryMesh();
DynamicList<polyPatch*> newPatches(oldPatches.size());
polyPatchList newPatches(oldPatches.size());
labelList oldToSorted(oldPatches.size());
label nPatches = 0;
forAll(oldPatches, patchi)
{
const polyPatch& pp = oldPatches[patchi];
if (!isA<processorPolyPatch>(pp))
{
oldToSorted[patchi] = newPatches.size();
newPatches.append
newPatches.set
(
nPatches,
pp.clone
(
oldPatches,
oldToSorted[patchi],
nPatches,
0,
nInternalFaces()
).ptr()
)
);
oldToSorted[patchi] = nPatches;
++nPatches;
}
}
forAll(oldPatches, patchi)
{
const polyPatch& pp = oldPatches[patchi];
if (isA<processorPolyPatch>(pp))
{
oldToSorted[patchi] = newPatches.size();
newPatches.append
newPatches.set
(
nPatches,
pp.clone
(
oldPatches,
oldToSorted[patchi],
0,
nInternalFaces()
).ptr()
)
);
oldToSorted[patchi] = nPatches;
++nPatches;
}
}
@ -461,7 +470,7 @@ void Foam::mergePolyMesh::merge()
{
Info<< "Copying old patches" << endl;
List<polyPatch*> newPatches(patchNames_.size());
polyPatchList newPatches(patchNames_.size());
const polyBoundaryMesh& oldPatches = boundaryMesh();
@ -470,7 +479,11 @@ void Foam::mergePolyMesh::merge()
for (patchi = 0; patchi < oldPatches.size(); patchi++)
{
newPatches[patchi] = oldPatches[patchi].clone(oldPatches).ptr();
newPatches.set
(
patchi,
oldPatches[patchi].clone(oldPatches)
);
}
Info<< "Adding new patches. " << endl;
@ -487,7 +500,9 @@ void Foam::mergePolyMesh::merge()
dict.set("nFaces", 0);
dict.set("startFace", endOfLastPatch);
newPatches[patchi] =
newPatches.set
(
patchi,
(
polyPatch::New
(
@ -495,7 +510,8 @@ void Foam::mergePolyMesh::merge()
dict,
patchi,
oldPatches
).ptr()
)
)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -404,20 +404,24 @@ Foam::mirrorFvMesh::mirrorFvMesh
fvMesh& pMesh = mirrorMeshPtr_();
// Add the boundary patches
List<polyPatch*> p(newPatchSizes.size());
polyPatchList newPatches(newPatchSizes.size());
forAll(p, patchi)
forAll(newPatches, patchi)
{
p[patchi] = boundaryMesh()[patchi].clone
newPatches.set
(
patchi,
boundaryMesh()[patchi].clone
(
pMesh.boundaryMesh(),
patchi,
newPatchSizes[patchi],
newPatchStarts[patchi]
).ptr();
)
);
}
pMesh.addPatches(p);
pMesh.addPatches(newPatches);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,7 +58,7 @@ label addPatch(polyMesh& mesh, const word& patchName)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
List<polyPatch*> newPatches(patches.size() + 1);
polyPatchList newPatches(patches.size() + 1);
patchi = 0;
@ -67,20 +67,25 @@ label addPatch(polyMesh& mesh, const word& patchName)
{
const polyPatch& pp = patches[i];
newPatches[patchi] =
newPatches.set
(
patchi,
pp.clone
(
patches,
patchi,
pp.size(),
pp.start()
).ptr();
)
);
patchi++;
}
// Add zero-sized patch
newPatches[patchi] =
newPatches.set
(
patchi,
new polyPatch
(
patchName,
@ -89,6 +94,7 @@ label addPatch(polyMesh& mesh, const word& patchName)
patchi,
patches,
polyPatch::typeName
)
);
mesh.removeBoundary();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -2420,7 +2420,7 @@ void Foam::ccm::reader::addPatches
{
// Create patches
// use patch types to determine what Foam types to generate
List<polyPatch*> newPatches(origBndId_.size());
polyPatchList newPatches(origBndId_.size());
label meshFaceI = nInternalFaces_;
wordHashSet hashedNames(origBndId_.size());
@ -2463,7 +2463,9 @@ void Foam::ccm::reader::addPatches
if (patchType == "wall")
{
newPatches[patchI] =
newPatches.set
(
patchI,
new wallPolyPatch
(
patchName,
@ -2472,11 +2474,14 @@ void Foam::ccm::reader::addPatches
patchI,
mesh.boundaryMesh(),
patchType
)
);
}
else if (patchType == "symmetry")
{
newPatches[patchI] =
newPatches.set
(
patchI,
new symmetryPolyPatch
(
patchName,
@ -2485,12 +2490,15 @@ void Foam::ccm::reader::addPatches
patchI,
mesh.boundaryMesh(),
patchType
)
);
}
else if (patchType == "empty")
{
// Note: not ccm name, may have been introduced by us
newPatches[patchI] =
newPatches.set
(
patchI,
new emptyPolyPatch
(
patchName,
@ -2499,13 +2507,16 @@ void Foam::ccm::reader::addPatches
patchI,
mesh.boundaryMesh(),
patchType
)
);
}
else
{
// All other ccm types become straight polyPatch:
// 'inlet', 'outlet', 'pressure'.
newPatches[patchI] =
newPatches.set
(
patchI,
new polyPatch
(
patchName,
@ -2514,6 +2525,7 @@ void Foam::ccm::reader::addPatches
patchI,
mesh.boundaryMesh(),
patchType
)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -377,7 +377,7 @@ void Foam::meshReader::createPolyBoundary()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::List<Foam::polyPatch*>
Foam::polyPatchList
Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
{
label nUsed = 0, nEmpty = 0;
@ -416,7 +416,7 @@ Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
patchSizes_.setSize(nPatches);
List<polyPatch*> p(nPatches);
polyPatchList newPatches(nPatches);
// All patch dictionaries
PtrList<dictionary> patchDicts(patchNames_.size());
@ -469,16 +469,20 @@ Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
forAll(patchStarts_, patchi)
{
p[patchi] = polyPatch::New
newPatches.set
(
patchi,
polyPatch::New
(
patchNames_[patchi],
patchDicts[patchi],
patchi,
mesh.boundaryMesh()
).ptr();
)
);
}
return p;
return newPatches;
}

View File

@ -109,8 +109,10 @@ Foam::autoPtr<Foam::polyMesh> Foam::meshReader::mesh
);
polyMesh& mesh = *meshPtr;
polyPatchList newPatches(polyBoundaryPatches(mesh));
// Adding patches also checks the mesh
mesh.addPatches(polyBoundaryPatches(mesh));
mesh.addPatches(newPatches);
warnDuplicates("boundaries", mesh.boundaryMesh().names());

View File

@ -49,8 +49,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef meshReader_H
#define meshReader_H
#ifndef Foam_meshReader_H
#define Foam_meshReader_H
#include "polyMesh.H"
#include "HashTable.H"
@ -179,7 +179,7 @@ private:
void createPolyBoundary();
//- Add polyhedral boundary
List<polyPatch*> polyBoundaryPatches(const polyMesh&);
polyPatchList polyBoundaryPatches(const polyMesh&);
//- Clear extra storage before creation of the mesh to remove
// a memory peak

View File

@ -342,8 +342,8 @@ void Foam::fileFormats::FIREMeshReader::reorganize()
void Foam::fileFormats::FIREMeshReader::addPatches(polyMesh& mesh) const
{
// create patches
List<polyPatch*> newPatches(patchSizes_.size());
// Create patches
polyPatchList newPatches(patchSizes_.size());
label meshFaceI = nInternalFaces_;
@ -355,7 +355,10 @@ void Foam::fileFormats::FIREMeshReader::addPatches(polyMesh& mesh) const
<< endl;
// don't know anything better - just make it a wall
newPatches[patchI] = new polyPatch
newPatches.set
(
patchI,
new polyPatch
(
patchNames_[patchI],
patchSizes_[patchI],
@ -363,6 +366,7 @@ void Foam::fileFormats::FIREMeshReader::addPatches(polyMesh& mesh) const
patchI,
mesh.boundaryMesh(),
word::null
)
);
meshFaceI += patchSizes_[patchI];

View File

@ -1315,19 +1315,23 @@ void Foam::polyDualMesh::calcDual
// Add patches. First add zero sized (since mesh still 0 size)
List<polyPatch*> dualPatches(patches.size());
polyPatchList dualPatches(patches.size());
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchi];
dualPatches[patchi] = pp.clone
dualPatches.set
(
patchi,
pp.clone
(
boundaryMesh(),
patchi,
0, //patchSizes[patchi],
0 //patchStarts[patchi]
).ptr();
)
);
}
addPatches(dualPatches);

View File

@ -1149,7 +1149,7 @@ void Foam::boundaryMesh::patchify
// zero faces (repatched later on). Exception is coupled patches which
// keep their size.
List<polyPatch*> newPatchPtrList(nNewPatches);
polyPatchList newPatches(nNewPatches);
label meshFacei = newMesh.nInternalFaces();
@ -1174,7 +1174,10 @@ void Foam::boundaryMesh::patchify
<< " type:" << bp.physicalType() << endl;
}
newPatchPtrList[newPatchi] = polyPatch::New
newPatches.set
(
newPatchi,
polyPatch::New
(
bp.physicalType(),
bp.name(),
@ -1182,7 +1185,8 @@ void Foam::boundaryMesh::patchify
meshFacei,
newPatchi,
newMesh.boundaryMesh()
).ptr();
)
);
meshFacei += facesToBeDone;
@ -1200,13 +1204,17 @@ void Foam::boundaryMesh::patchify
<< oldPatch.name() << endl;
}
newPatchPtrList[newPatchi] = oldPatch.clone
newPatches.set
(
newPatchi,
oldPatch.clone
(
newMesh.boundaryMesh(),
newPatchi,
facesToBeDone,
meshFacei
).ptr();
)
);
meshFacei += facesToBeDone;
@ -1220,9 +1228,9 @@ void Foam::boundaryMesh::patchify
{
Pout<< "Patchify : new polyPatch list:" << endl;
forAll(newPatchPtrList, patchi)
forAll(newPatches, patchi)
{
const polyPatch& newPatch = *newPatchPtrList[patchi];
const polyPatch& newPatch = newPatches[patchi];
if (debug)
{
@ -1237,13 +1245,13 @@ void Foam::boundaryMesh::patchify
// Actually add new list of patches
repatchPolyTopoChanger polyMeshRepatcher(newMesh);
polyMeshRepatcher.changePatches(newPatchPtrList);
polyMeshRepatcher.changePatches(newPatches);
// Pass2:
// Change patch type for face
if (newPatchPtrList.size())
if (newPatches.size())
{
List<DynamicList<label>> patchFaces(nNewPatches);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,7 +77,7 @@ Foam::extrudePatchMesh::extrudePatchMesh
const fvPatch& p,
const dictionary& dict,
const word& regionName,
const List<polyPatch*>& regionPatches
polyPatchList& regionPatches
)
:
extrudePatchMesh(regionName, mesh, p, dict)
@ -86,6 +86,24 @@ Foam::extrudePatchMesh::extrudePatchMesh
}
Foam::extrudePatchMesh::extrudePatchMesh
(
const fvMesh& mesh,
const fvPatch& p,
const dictionary& dict,
const word& regionName,
const List<polyPatch*>& regionPatches
)
:
extrudePatchMesh(regionName, mesh, p, dict)
{
// Acquire ownership of the pointers
polyPatchList plist(const_cast<List<polyPatch*>&>(regionPatches));
extrudeMesh(plist);
}
Foam::extrudePatchMesh::extrudePatchMesh
(
const fvMesh& mesh,
@ -96,18 +114,10 @@ Foam::extrudePatchMesh::extrudePatchMesh
:
extrudePatchMesh(regionName, mesh, p, dict)
{
List<polyPatch*> regionPatches(3);
polyPatchList regionPatches(3);
List<dictionary> dicts(regionPatches.size());
List<word> patchNames(regionPatches.size());
List<word> patchTypes(regionPatches.size());
PtrList<dictionary> dicts(regionPatches.size());
forAll(dicts, patchi)
{
if (!dicts.set(patchi))
{
dicts.set(patchi, new dictionary());
}
}
dicts[bottomPatchID] = dict_.subDict("bottomCoeffs");
dicts[sidePatchID] = dict_.subDict("sideCoeffs");
@ -125,22 +135,26 @@ Foam::extrudePatchMesh::extrudePatchMesh
patchDict.set("nFaces", 0);
patchDict.set("startFace", 0);
regionPatches[patchi] = polyPatch::New
regionPatches.set
(
patchi,
polyPatch::New
(
patchNames[patchi],
patchDict,
patchi,
mesh.boundaryMesh()
).ptr();
)
);
}
extrudeMesh(regionPatches);
}
void Foam::extrudePatchMesh::extrudeMesh(const List<polyPatch*>& regionPatches)
void Foam::extrudePatchMesh::extrudeMesh(polyPatchList& regionPatches)
{
if (this->boundaryMesh().size() == 0)
if (this->boundaryMesh().empty())
{
const bool columnCells = dict_.get<bool>("columnCells");

View File

@ -70,12 +70,11 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef extrudePatchMesh_H
#define extrudePatchMesh_H
#ifndef Foam_extrudePatchMesh_H
#define Foam_extrudePatchMesh_H
#include "extrudeModel.H"
#include "autoPtr.H"
#include "fvMesh.H"
#include "Time.H"
@ -97,12 +96,12 @@ class extrudePatchMesh
{
// Private Data
//- Enumeration of patch IDs
//- Enumeration of patch IDs. Must be 0,1,2,...
enum patchID
{
bottomPatchID,
topPatchID,
sidePatchID
bottomPatchID = 0,
topPatchID = 1,
sidePatchID = 2
};
//- Const reference to the patch from which this mesh is extruded
@ -115,7 +114,7 @@ class extrudePatchMesh
// Private Member Functions
//- Extrude mesh using polyPatches
void extrudeMesh(const List<polyPatch*>& regionPatches);
void extrudeMesh(polyPatchList& regionPatches);
//- Construct from mesh, patch and dictionary without patches.
// Only used internally
@ -145,14 +144,25 @@ public:
);
//- Construct from mesh, patch, dictionary and new mesh
// polyPatch information
//- polyPatch information
extrudePatchMesh
(
const fvMesh& mesh,
const fvPatch& p,
const dictionary& dict,
const word& regionName,
const List<polyPatch*>& polyPatches
polyPatchList& regionPatches
);
//- Construct from mesh, patch, dictionary and new mesh
//- polyPatch information
extrudePatchMesh
(
const fvMesh& mesh,
const fvPatch& p,
const dictionary& dict,
const word& regionName,
const List<polyPatch*>& regionPatches
);

View File

@ -1796,17 +1796,21 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshDistribute::receiveMesh
);
fvMesh& domainMesh = *domainMeshPtr;
List<polyPatch*> patches(patchEntries.size());
polyPatchList patches(patchEntries.size());
forAll(patchEntries, patchi)
{
patches[patchi] = polyPatch::New
patches.set
(
patchi,
polyPatch::New
(
patchEntries[patchi].keyword(),
patchEntries[patchi].dict(),
patchi,
domainMesh.boundaryMesh()
).ptr();
)
);
}
// Add patches; no parallel comms
domainMesh.addFvPatches(patches, false);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -80,34 +81,40 @@ void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
// Re-do the boundary patches, removing the ones with zero size
const polyBoundaryMesh& oldPatches = mesh_.boundaryMesh();
List<polyPatch*> newPatches(oldPatches.size());
polyPatchList newPatches(oldPatches.size());
label nNewPatches = 0;
forAll(oldPatches, patchi)
{
if (oldPatches[patchi].size())
const word& patchName = oldPatches[patchi].name();
if (returnReduceOr(oldPatches[patchi].size()))
{
newPatches[nNewPatches] = oldPatches[patchi].clone
newPatches.set
(
nNewPatches,
oldPatches[patchi].clone
(
mesh_.boundaryMesh(),
nNewPatches,
oldPatches[patchi].size(),
oldPatches[patchi].start()
).ptr();
)
);
nNewPatches++;
++nNewPatches;
}
else
{
if (debug)
{
Pout<< "Removing zero-sized patch " << patchi
<< " named " << oldPatches[patchi].name() << endl;
<< " named " << patchName << endl;
}
}
}
newPatches.setSize(nNewPatches);
newPatches.resize(nNewPatches);
mesh_.removeBoundary();
mesh_.addPatches(newPatches);

View File

@ -46,8 +46,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef attachPolyTopoChanger_H
#define attachPolyTopoChanger_H
#ifndef Foam_attachPolyTopoChanger_H
#define Foam_attachPolyTopoChanger_H
#include "polyTopoChanger.H"
@ -64,9 +64,9 @@ class attachPolyTopoChanger
:
public polyTopoChanger
{
// Private data
public:
// Private Member Functions
// Generated Methods
//- No copy construct
attachPolyTopoChanger(const attachPolyTopoChanger&) = delete;
@ -75,8 +75,6 @@ class attachPolyTopoChanger
void operator=(const attachPolyTopoChanger&) = delete;
public:
// Constructors
//- Read constructor from IOobject and a polyMesh

View File

@ -60,7 +60,7 @@ Foam::repatchPolyTopoChanger::repatchPolyTopoChanger(polyMesh& mesh)
void Foam::repatchPolyTopoChanger::changePatches
(
const List<polyPatch*>& patches
polyPatchList& patches
)
{
if (meshModPtr_)
@ -76,6 +76,18 @@ void Foam::repatchPolyTopoChanger::changePatches
}
void Foam::repatchPolyTopoChanger::changePatches
(
const List<polyPatch*>& patches
)
{
// Acquire ownership of the pointers
polyPatchList plist(const_cast<List<polyPatch*>&>(patches));
changePatches(plist);
}
void Foam::repatchPolyTopoChanger::changePatchID
(
const label faceID,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef repatchPolyTopoChanger_H
#define repatchPolyTopoChanger_H
#ifndef Foam_repatchPolyTopoChanger_H
#define Foam_repatchPolyTopoChanger_H
#include "polyMesh.H"
#include "polyTopoChange.H"
@ -60,7 +60,7 @@ class repatchPolyTopoChanger
polyMesh& mesh_;
//- Topological change to accumulated all mesh changes
unique_ptr<polyTopoChange> meshModPtr_;
std::unique_ptr<polyTopoChange> meshModPtr_;
// Private Member Functions
@ -89,11 +89,14 @@ public:
// Member Functions
//- Change patches.
void changePatches(polyPatchList& patches);
//- Change patches.
void changePatches(const List<polyPatch*>& patches);
//- Change patch ID for a boundary face. Note: patchID should be in new
// numbering.
//- Change patch ID for a boundary face.
//- Note: patchID should be in new numbering.
void changePatchID
(
const label faceID,

View File

@ -83,9 +83,12 @@ Foam::simplifiedMeshes::hexCellFvMesh::hexCellFvMesh
labelList()
)
{
List<polyPatch*> patches(1);
polyPatchList patches(1);
patches[0] = new emptyPolyPatch
patches.set
(
0,
new emptyPolyPatch
(
"boundary",
6,
@ -93,6 +96,7 @@ Foam::simplifiedMeshes::hexCellFvMesh::hexCellFvMesh
0,
boundaryMesh(),
emptyPolyPatch::typeName
)
);
addFvPatches(patches);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -258,16 +258,20 @@ void Foam::singleCellFvMesh::agglomerateMesh
pointField boundaryPoints(mesh.points(), pointMap_);
// Add patches (on still zero sized mesh)
List<polyPatch*> newPatches(oldPatches.size());
polyPatchList newPatches(oldPatches.size());
forAll(oldPatches, patchi)
{
newPatches[patchi] = oldPatches[patchi].clone
newPatches.set
(
patchi,
oldPatches[patchi].clone
(
boundaryMesh(),
patchi,
0,
0
).ptr();
)
);
}
addFvPatches(newPatches);

View File

@ -143,10 +143,10 @@ void thermalBaffleFvPatchScalarField::createPatchMesh()
const word regionName(dict_.get<word>("region"));
List<polyPatch*> regionPatches(3);
polyPatchList regionPatches(3);
List<dictionary> dicts(regionPatches.size());
List<word> patchNames(regionPatches.size());
List<word> patchTypes(regionPatches.size());
List<dictionary> dicts(regionPatches.size());
patchNames[bottomPatchID] = word("bottom");
patchNames[sidePatchID] = word("side");
@ -172,8 +172,7 @@ void thermalBaffleFvPatchScalarField::createPatchMesh()
patchTypes[sidePatchID] = polyPatch::typeName;
}
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(patch().patch(), dict_);
const auto& mpp = refCast<const mappedPatchBase>(patch().patch(), dict_);
const word coupleGroup(mpp.coupleGroup());
@ -206,14 +205,18 @@ void thermalBaffleFvPatchScalarField::createPatchMesh()
patchDict.set("nFaces", 0);
patchDict.set("startFace", 0);
regionPatches[patchi] = polyPatch::New
regionPatches.set
(
patchi,
polyPatch::New
(
patchTypes[patchi],
patchNames[patchi],
dicts[patchi],
patchi,
thisMesh.boundaryMesh()
).ptr();
)
);
}
extrudeMeshPtr_.reset

View File

@ -495,8 +495,11 @@ void Foam::meshToMesh::calculate(const word& methodName, const bool normalise)
);
// create some dummy patch info
List<polyPatch*> patches(1);
patches[0] = new polyPatch
polyPatchList patches(1);
patches.set
(
0,
new polyPatch
(
"defaultFaces",
newTgt.nBoundaryFaces(),
@ -504,6 +507,7 @@ void Foam::meshToMesh::calculate(const word& methodName, const bool normalise)
0,
newTgt.boundaryMesh(),
word::null
)
);
newTgt.addPatches(patches);