ENH: cvMesh: Use dictionary constructor for polyPatch

This commit is contained in:
laurence
2013-02-06 12:10:25 +00:00
parent 986532b18a
commit 84ad150b88
6 changed files with 220 additions and 175 deletions

View File

@ -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;

View File

@ -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
);
label totalPatchSize = readLabel(patchDicts[p].lookup("nFaces"));
nValidPatches++;
}
}
else
{
patches[nValidPatches] = polyPatch::New
(
patchTypes[p],
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh()
).ptr();
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++;
}
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);

View File

@ -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"));
procPatchSizes[Pstream::myProcNo()][procNeighb]
= readLabel(patchDicts[patchI].lookup("nFaces"));
}
}
@ -771,15 +770,16 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
faceList& faces,
const wordList& patchTypes,
const wordList& patchNames,
const labelList& patchSizes,
const labelList& patchStarts,
const labelList& procNeighbours
const PtrList<dictionary>& patchDicts
// const labelList& patchSizes,
// const labelList& patchStarts,
// const labelList& procNeighbours
) const
{
Info<< incrIndent << indent << "Reordering processor patches" << endl;
Info<< incrIndent;
checkProcessorPatchesMatch(patchTypes, patchSizes, procNeighbours);
checkProcessorPatchesMatch(patchTypes, patchDicts);
// Create dummy mesh with correct proc boundaries to do sorting
autoPtr<fvMesh> sortMeshPtr
@ -797,9 +797,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
),
patchTypes,
patchNames,
patchSizes,
patchStarts,
procNeighbours
patchDicts
)
);
const fvMesh& sortMesh = sortMeshPtr();
@ -842,8 +840,8 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
SubList<face>
(
faces,
patchSizes[patchI],
patchStarts[patchI]
readLabel(patchDicts[patchI].lookup("nFaces")),
readLabel(patchDicts[patchI].lookup("startFace"))
),
points
)
@ -862,8 +860,13 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
if (isA<processorPolyPatch>(pp))
{
labelList patchFaceMap(patchSizes[patchI], -1);
labelList patchFaceRotation(patchSizes[patchI], 0);
const label nPatchFaces =
readLabel(patchDicts[patchI].lookup("nFaces"));
const label patchStartFace =
readLabel(patchDicts[patchI].lookup("startFace"));
labelList patchFaceMap(nPatchFaces, -1);
labelList patchFaceRotation(nPatchFaces, 0);
bool changed = refCast<const processorPolyPatch>(pp).order
(
@ -873,8 +876,8 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
SubList<face>
(
faces,
patchSizes[patchI],
patchStarts[patchI]
nPatchFaces,
patchStartFace
),
points
),
@ -885,11 +888,9 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
if (changed)
{
// Merge patch face reordering into mesh face reordering table
label start = patchStarts[patchI];
forAll(patchFaceRotation, patchFaceI)
{
rotation[patchFaceI + start]
rotation[patchFaceI + patchStartFace]
= patchFaceRotation[patchFaceI];
}
@ -897,8 +898,8 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
{
if (patchFaceMap[patchFaceI] != patchFaceI)
{
faceMap[patchFaceI + start]
= patchFaceMap[patchFaceI] + start;
faceMap[patchFaceI + patchStartFace]
= patchFaceMap[patchFaceI] + patchStartFace;
}
}
@ -947,9 +948,7 @@ void Foam::conformalVoronoiMesh::writeMesh
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
@ -959,7 +958,9 @@ void Foam::conformalVoronoiMesh::writeMesh
writeObjMesh(points, faces, word(meshName + ".obj"));
}
reorderPoints(points, boundaryPts, faces, patchStarts[0]);
const label nInternalFaces = readLabel(patchDicts[0].lookup("startFace"));
reorderPoints(points, boundaryPts, faces, nInternalFaces);
if (Pstream::parRun())
{
@ -971,9 +972,7 @@ void Foam::conformalVoronoiMesh::writeMesh
faces,
patchTypes,
patchNames,
patchSizes,
patchStarts,
procNeighbours
patchDicts
);
}
@ -999,27 +998,28 @@ void Foam::conformalVoronoiMesh::writeMesh
Info<< " Adding patches to mesh" << endl;
List<polyPatch*> patches(patchStarts.size());
List<polyPatch*> patches(patchNames.size());
label nValidPatches = 0;
forAll(patches, p)
{
label totalPatchSize = readLabel(patchDicts[p].lookup("nFaces"));
Pout<< patchDicts[p] << endl;
if (patchTypes[p] == processorPolyPatch::typeName)
{
// Do not create empty processor patches
if (patchSizes[p] > 0)
if (totalPatchSize > 0)
{
patches[nValidPatches] = new processorPolyPatch
(
patchNames[p],
patchSizes[p],
patchStarts[p],
patchDicts[p],
nValidPatches,
mesh.boundaryMesh(),
Pstream::myProcNo(),
procNeighbours[p],
coupledPolyPatch::NOORDERING
patchTypes[p]
);
nValidPatches++;
@ -1028,7 +1028,6 @@ void Foam::conformalVoronoiMesh::writeMesh
else
{
// Check that the patch is not empty on every processor
label totalPatchSize = patchSizes[p];
reduce(totalPatchSize, sumOp<label>());
if (totalPatchSize > 0)
@ -1037,8 +1036,7 @@ void Foam::conformalVoronoiMesh::writeMesh
(
patchTypes[p],
patchNames[p],
patchSizes[p],
patchStarts[p],
patchDicts[p],
nValidPatches,
mesh.boundaryMesh()
).ptr();

View File

@ -409,7 +409,6 @@ Foam::conformationSurfaces::conformationSurfaces
searchableSurface::UNKNOWN
);
Info<< endl
<< "Testing for locationInMesh " << locationInMesh_ << endl;