Commit 84ad150b authored by laurence's avatar laurence
Browse files

ENH: cvMesh: Use dictionary constructor for polyPatch

parent 986532b1
......@@ -770,9 +770,7 @@ private:
labelList& neighbour,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes,
labelList& patchStarts,
labelList& procNeighbours,
PtrList<dictionary>& patchDicts,
pointField& cellCentres,
labelList& cellToDelaunayVertex,
labelListList& patchToDelaunayVertex,
......@@ -789,8 +787,7 @@ private:
labelList& neighbour,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes,
labelList& patchStarts
PtrList<dictionary>& patchDicts
);
//- Determines if the dual face constructed by the Delaunay
......@@ -873,7 +870,7 @@ private:
(
wordList& patchNames,
wordList& patchTypes,
labelList& procNeighbours
PtrList<dictionary>& patchDicts
) const;
//- Create all of the internal and boundary faces
......@@ -884,9 +881,7 @@ private:
labelList& neighbour,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes,
labelList& patchStarts,
labelList& procNeighbours,
PtrList<dictionary>& patchDicts,
labelListList& patchPointPairSlaves,
PackedBoolList& boundaryFacesToRemove,
bool includeEmptyPatches = false
......@@ -924,8 +919,7 @@ private:
const label nInternalFaces,
faceList& faces,
labelList& owner,
labelList& patchSizes,
labelList& patchStarts,
PtrList<dictionary>& patchDicts,
PackedBoolList& boundaryFacesToRemove,
const List<DynamicList<face> >& patchFaces,
const List<DynamicList<label> >& patchOwners,
......@@ -954,9 +948,7 @@ private:
const IOobject& io,
const wordList& patchTypes,
const wordList& patchNames,
const labelList& patchSizes,
const labelList& patchStarts,
const labelList& procNeighbours
const PtrList<dictionary>& patchDicts
) const;
//- Create a polyMesh from points.
......@@ -965,8 +957,7 @@ private:
void checkProcessorPatchesMatch
(
const wordList& patchTypes,
const labelList& patchSizes,
const labelList& procNeighbours
const PtrList<dictionary>& patchDicts
) const;
void reorderPoints
......@@ -986,9 +977,7 @@ private:
faceList& faces,
const wordList& patchTypes,
const wordList& patchNames,
const labelList& patchSizes,
const labelList& patchStarts,
const labelList& procNeighbours
const PtrList<dictionary>& patchDicts
) const;
//- Disallow default bitwise copy construct
......@@ -1153,9 +1142,7 @@ public:
labelList& neighbour,
const wordList& patchTypes,
const wordList& patchNames,
const labelList& patchSizes,
const labelList& patchStarts,
const labelList& procNeighbours,
const PtrList<dictionary>& patchDicts,
const pointField& cellCentres,
const PackedBoolList& boundaryFacesToRemove
) const;
......
......@@ -515,9 +515,10 @@ void Foam::conformalVoronoiMesh::calcDualMesh
labelList& neighbour,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes,
labelList& patchStarts,
labelList& procNeighbours,
PtrList<dictionary>& patchDicts,
//labelList& patchSizes,
//labelList& patchStarts,
//labelList& procNeighbours,
pointField& cellCentres,
labelList& cellToDelaunayVertex,
labelListList& patchToDelaunayVertex,
......@@ -564,9 +565,10 @@ void Foam::conformalVoronoiMesh::calcDualMesh
neighbour,
patchTypes,
patchNames,
patchSizes,
patchStarts,
procNeighbours,
patchDicts,
// patchSizes,
// patchStarts,
// procNeighbours,
patchToDelaunayVertex, // from patch face to Delaunay vertex (slavePp)
boundaryFacesToRemove,
false
......@@ -595,8 +597,7 @@ void Foam::conformalVoronoiMesh::calcTetMesh
labelList& neighbour,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes,
labelList& patchStarts
PtrList<dictionary>& patchDicts
)
{
labelList vertexMap(number_of_vertices());
......@@ -771,15 +772,19 @@ void Foam::conformalVoronoiMesh::calcTetMesh
sortFaces(faces, owner, neighbour);
// PackedBoolList boundaryFacesToRemove;
// List<DynamicList<bool> > indirectPatchFace;
//
// addPatches
// (
// nInternalFaces,
// faces,
// owner,
// patchSizes,
// patchStarts,
// patchDicts,
// boundaryFacesToRemove,
// patchFaces,
// patchOwners
// patchOwners,
// indirectPatchFace
// );
}
......@@ -1179,9 +1184,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
labelList neighbour;
wordList patchTypes;
wordList patchNames;
labelList patchSizes;
labelList patchStarts;
labelList procNeighbours;
PtrList<dictionary> patchDicts;
pointField cellCentres;
labelListList patchToDelaunayVertex;
PackedBoolList boundaryFacesToRemove;
......@@ -1197,9 +1200,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
neighbour,
patchTypes,
patchNames,
patchSizes,
patchStarts,
procNeighbours,
patchDicts,
patchToDelaunayVertex,
boundaryFacesToRemove,
false
......@@ -1232,46 +1233,50 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
polyMesh& pMesh = meshPtr();
List<polyPatch*> patches(patchStarts.size());
List<polyPatch*> patches(patchNames.size());
label nValidPatches = 0;
forAll(patches, p)
{
if (patchTypes[p] == processorPolyPatch::typeName)
{
// Do not create empty processor patches
if (patchSizes[p] > 0)
{
patches[nValidPatches] = new processorPolyPatch
(
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh(),
Pstream::myProcNo(),
procNeighbours[p],
coupledPolyPatch::COINCIDENTFULLMATCH
);
nValidPatches++;
}
}
else
{
patches[nValidPatches] = polyPatch::New
(
patchTypes[p],
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh()
).ptr();
nValidPatches++;
}
label totalPatchSize = readLabel(patchDicts[p].lookup("nFaces"));
if (patchTypes[p] == processorPolyPatch::typeName)
{
// Do not create empty processor patches
if (totalPatchSize > 0)
{
patches[nValidPatches] = new processorPolyPatch
(
patchNames[p],
patchDicts[p],
nValidPatches,
pMesh.boundaryMesh(),
patchTypes[p]
);
nValidPatches++;
}
}
else
{
// Check that the patch is not empty on every processor
reduce(totalPatchSize, sumOp<label>());
if (totalPatchSize > 0)
{
patches[nValidPatches] = polyPatch::New
(
patchTypes[p],
patchNames[p],
patchDicts[p],
nValidPatches,
pMesh.boundaryMesh()
).ptr();
nValidPatches++;
}
}
}
patches.setSize(nValidPatches);
......@@ -1816,12 +1821,13 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
(
wordList& patchNames,
wordList& patchTypes,
labelList& procNeighbours
PtrList<dictionary>& patchDicts
) const
{
patchNames = geometryToConformTo_.patchNames();
patchTypes.setSize(patchNames.size() + 1, wallPolyPatch::typeName);
procNeighbours.setSize(patchNames.size() + 1, -1);
patchDicts.setSize(patchNames.size() + 1);
const PtrList<dictionary>& patchInfo = geometryToConformTo_.patchInfo();
......@@ -1836,11 +1842,14 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
wallPolyPatch::typeName
);
}
patchDicts.set(patchI, new dictionary());
}
patchNames.setSize(patchNames.size() + 1);
label defaultPatchIndex = patchNames.size() - 1;
patchNames[defaultPatchIndex] = "cvMesh_defaultPatch";
patchDicts.set(defaultPatchIndex, new dictionary());
label nProcPatches = 0;
......@@ -1895,10 +1904,15 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
}
label nNonProcPatches = patchNames.size();
label nTotalPatches = nNonProcPatches + nProcPatches;
patchNames.setSize(nNonProcPatches + nProcPatches);
patchTypes.setSize(nNonProcPatches + nProcPatches);
procNeighbours.setSize(nNonProcPatches + nProcPatches, -1);
patchNames.setSize(nTotalPatches);
patchTypes.setSize(nTotalPatches);
patchDicts.setSize(nTotalPatches);
for (label pI = nNonProcPatches; pI < nTotalPatches; ++pI)
{
patchDicts.set(pI, new dictionary());
}
label procAddI = 0;
......@@ -1915,7 +1929,12 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
+ "to"
+ name(pUI);
procNeighbours[nNonProcPatches + procAddI] = pUI;
patchDicts[nNonProcPatches + procAddI].set
(
"myProcNo",
Pstream::myProcNo()
);
patchDicts[nNonProcPatches + procAddI].set("neighbProcNo", pUI);
procAddI++;
}
......@@ -1933,9 +1952,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
labelList& neighbour,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes,
labelList& patchStarts,
labelList& procNeighbours,
PtrList<dictionary>& patchDicts,
labelListList& patchPointPairSlaves,
PackedBoolList& boundaryFacesToRemove,
bool includeEmptyPatches
......@@ -1945,11 +1962,25 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
(
patchNames,
patchTypes,
procNeighbours
patchDicts
);
const label nPatches = patchNames.size();
labelList procNeighbours(nPatches, -1);
forAll(procNeighbours, patchI)
{
if (patchDicts[patchI].found("neighbProcNo"))
{
procNeighbours[patchI] =
(
patchDicts[patchI].found("neighbProcNo")
? readLabel(patchDicts[patchI].lookup("neighbProcNo"))
: -1
);
}
}
List<DynamicList<face> > patchFaces(nPatches, DynamicList<face>(0));
List<DynamicList<label> > patchOwners(nPatches, DynamicList<label>(0));
// Per patch face the index of the slave node of the point pair
......@@ -2183,8 +2214,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
nInternalFaces,
faces,
owner,
patchSizes,
patchStarts,
patchDicts,
boundaryFacesToRemove,
patchFaces,
patchOwners,
......@@ -2202,11 +2232,16 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
{
Info<< "Writing processor interfaces" << endl;
forAll(procNeighbours, nbI)
forAll(patchDicts, nbI)
{
if (patchFaces[nbI].size() > 0)
{
const label neighbour = procNeighbours[nbI];
const label neighbour =
(
patchDicts[nbI].found("neighbProcNo")
? readLabel(patchDicts[nbI].lookup("neighbProcNo"))
: -1
);
faceList procPatchFaces = patchFaces[nbI];
......@@ -2401,27 +2436,22 @@ void Foam::conformalVoronoiMesh::addPatches
const label nInternalFaces,
faceList& faces,
labelList& owner,
labelList& patchSizes,
labelList& patchStarts,
PtrList<dictionary>& patchDicts,
PackedBoolList& boundaryFacesToRemove,
const List<DynamicList<face> >& patchFaces,
const List<DynamicList<label> >& patchOwners,
const List<DynamicList<bool> >& indirectPatchFace
) const
{
label nPatches = patchFaces.size();
patchSizes.setSize(nPatches, -1);
patchStarts.setSize(nPatches, -1);
label nBoundaryFaces = 0;
forAll(patchFaces, p)
{
patchSizes[p] = patchFaces[p].size();
patchStarts[p] = nInternalFaces + nBoundaryFaces;
patchDicts[p].set("nFaces", patchFaces[p].size());
patchDicts[p].set("startFace", nInternalFaces + nBoundaryFaces);
patchDicts[p].set("transform", "noOrdering");
nBoundaryFaces += patchSizes[p];
nBoundaryFaces += patchFaces[p].size();
}
faces.setSize(nInternalFaces + nBoundaryFaces);
......
......@@ -339,8 +339,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
labelList neighbour;
wordList patchTypes;
wordList patchNames;
labelList patchSizes;
labelList procNeighbours;
PtrList<dictionary> patchDicts;
pointField cellCentres;
PackedBoolList boundaryFacesToRemove;
......@@ -354,9 +353,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
neighbour,
patchTypes,
patchNames,
patchSizes,
dualPatchStarts,
procNeighbours,
patchDicts,
cellCentres,
cellToDelaunayVertex,
patchToDelaunayVertex,
......@@ -376,12 +373,18 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
neighbour,
patchTypes,
patchNames,
patchSizes,
dualPatchStarts,
procNeighbours,
patchDicts,
cellCentres,
boundaryFacesToRemove
);
dualPatchStarts.setSize(patchDicts.size());
forAll(dualPatchStarts, patchI)
{
dualPatchStarts[patchI] =
readLabel(patchDicts[patchI].lookup("startFace"));
}
}
if (cvMeshControls().writeTetDualMesh())
......@@ -448,8 +451,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
labelList neighbour;
wordList patchTypes;
wordList patchNames;
labelList patchSizes;
labelList patchStarts;
PtrList<dictionary> patchDicts;
pointField cellCentres;
calcTetMesh
......@@ -461,8 +463,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
neighbour,
patchTypes,
patchNames,
patchSizes,
patchStarts
patchDicts
);
......@@ -564,26 +565,24 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
}
labelList procNeighbours(patchNames.size(), -1);
Info<< nl << "Writing tetDualMesh to " << instance << endl;
// Info<< nl << "Writing tetDualMesh to " << instance << endl;
// writeMesh
// (
// "tetDualMesh",
// instance,
// points,
// boundaryPts,
// faces,
// owner,
// neighbour,
// patchTypes,
// patchNames,
// patchSizes,
// patchStarts,
// procNeighbours,
// cellCentres
// );
PackedBoolList boundaryFacesToRemove;
writeMesh
(
"tetDualMesh",
instance,
points,
boundaryPts,
faces,
owner,
neighbour,
patchTypes,
patchNames,
patchDicts,
cellCentres,
boundaryFacesToRemove
);
}
}
......@@ -593,9 +592,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh
const IOobject& io,
const wordList& patchTypes,
const wordList& patchNames,
const labelList& patchSizes,
const labelList& patchStarts,
const labelList& procNeighbours
const PtrList<dictionary>& patchDicts
) const
{
autoPtr<fvMesh> meshPtr
......@@ -610,7 +607,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh
);
fvMesh& mesh = meshPtr();
List<polyPatch*> patches(patchStarts.size());
List<polyPatch*> patches(patchDicts.size());
forAll(patches, patchI)
{
......@@ -623,8 +620,8 @@ Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh
0, //patchStarts[p],
patchI,
mesh.boundaryMesh(),
Pstream::myProcNo(),
procNeighbours[patchI],
readLabel(patchDicts[patchI].lookup("myProcNo")),
readLabel(patchDicts[patchI].lookup("neighbProcNo")),
coupledPolyPatch::COINCIDENTFULLMATCH
);
}
......@@ -650,8 +647,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh
void Foam::conformalVoronoiMesh::checkProcessorPatchesMatch
(
const wordList& patchTypes,
const labelList& patchSizes,
const labelList& procNeighbours
const PtrList<dictionary>& patchDicts
) const
{
// Check patch sizes
......@@ -665,8 +661,11 @@ void Foam::conformalVoronoiMesh::checkProcessorPatchesMatch
{
if (patchTypes[patchI] == processorPolyPatch::typeName)
{
procPatchSizes[Pstream::myProcNo()][procNeighbours[patchI]]
= patchSizes[patchI];
const label procNeighb =
readLabel(patchDicts[patchI].lookup("neighbProcNo"));