ENH: Improved vertex referring scheme, patching.

This commit is contained in:
graham
2011-03-10 18:15:23 +00:00
parent 9160021cc5
commit 4b407090e7
5 changed files with 145 additions and 26 deletions

View File

@ -70,6 +70,10 @@ void Foam::conformalVoronoiMesh::calcDualMesh
vit->index() = dualCellI;
dualCellI++;
}
else if (vit->referred())
{
vit->index() = -1;
}
else
{
vit->type() = Vb::ptFarPoint;
@ -1781,12 +1785,67 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
{
patchNames = geometryToConformTo_.patchNames();
label nProcPatches = 0;
labelList procPatchIndices(0);
if (Pstream::parRun())
{
boolList procUsed(Pstream::nProcs(), false);
// Determine which processor patches are required
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
vit++
)
{
if (vit->referred())
{
procUsed[vit->procIndex()] = true;
}
}
forAll(procUsed, pUI)
{
if (procUsed[pUI])
{
nProcPatches++;
}
}
label nNonProcPatches = patchNames.size();
patchNames.setSize(patchNames.size() + nProcPatches);
procPatchIndices.setSize(patchNames.size() + 1, -1);
label procAddI = 0;
forAll(procUsed, pUI)
{
if (procUsed[pUI])
{
patchNames[nNonProcPatches + procAddI] =
"proc_" + name(Pstream::myProcNo()) + "_" + name(pUI);
procPatchIndices[nNonProcPatches + procAddI] = pUI;
procAddI++;
}
}
}
patchNames.setSize(patchNames.size() + 1);
label defaultPatchIndex = patchNames.size() - 1;
patchNames[defaultPatchIndex] = "cvMesh_defaultPatch";
Pout<< patchNames << endl;
label nPatches = patchNames.size();
List<DynamicList<face> > patchFaces(nPatches, DynamicList<face>(0));
@ -1837,7 +1896,21 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
Foam::point ptA = topoint(vA->point());
Foam::point ptB = topoint(vB->point());
label patchIndex = geometryToConformTo_.findPatch(ptA, ptB);
label patchIndex = -1;
if (vA->referred() || vB->referred())
{
// One (and only one) of the points is from another
// processor
label procIndex = max(vA->procIndex(), vB->procIndex());
patchIndex = findIndex(procPatchIndices, procIndex);
}
else
{
patchIndex = geometryToConformTo_.findPatch(ptA, ptB);
}
if (patchIndex == -1)
{

View File

@ -218,8 +218,7 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
{
// Propagating vertices to other processors to form halo information
DynamicList<Foam::point> parallelInterfacePoints;
DynamicList<label> targetProcessor;
List<DynamicList<label> > verticesToProc(number_of_vertices());
for
(
@ -233,19 +232,23 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
{
List<label> toProcs = parallelInterfaceIntersection(vit);
label vIndex = vit->index();
DynamicList<label>& vertexToProc = verticesToProc[vIndex];
forAll(toProcs, tPI)
{
label toProc = toProcs[tPI];
if (toProc > -1)
{
parallelInterfacePoints.append
(
topoint(vit->point())
);
targetProcessor.append(toProc);
if (findIndex(vertexToProc, toProc) == -1)
{
vertexToProc.append(toProc);
}
// Refer all incident vertices to neighbour
// processor too
std::list<Vertex_handle> incidentVertices;
incident_vertices
@ -262,18 +265,54 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
++ivit
)
{
parallelInterfacePoints.append
(
topoint((*ivit)->point())
);
label ivIndex = (*ivit)->index();
targetProcessor.append(toProc);
DynamicList<label>& iVertexToProc =
verticesToProc[ivIndex];
if (findIndex(iVertexToProc, toProc) == -1)
{
iVertexToProc.append(toProc);
}
}
}
}
}
}
DynamicList<Foam::point> parallelInterfacePoints;
DynamicList<label> targetProcessor;
for
(
Delaunay::Finite_vertices_iterator vit =
finite_vertices_begin();
vit != finite_vertices_end();
vit++
)
{
if (vit->internalOrBoundaryPoint())
{
label vIndex = vit->index();
const DynamicList<label>& vertexToProc =
verticesToProc[vIndex];
if (!verticesToProc.empty())
{
forAll(vertexToProc, vTPI)
{
parallelInterfacePoints.append
(
topoint(vit->point())
);
targetProcessor.append(vertexToProc[vTPI]);
}
}
}
}
writePoints("parallelInterfacePoints.obj", parallelInterfacePoints);
// Determine send map
@ -357,13 +396,22 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
pointMap.distribute(parallelInterfacePoints);
forAll(parallelInterfacePoints, ptI)
for (label domain = 0; domain < Pstream::nProcs(); domain++)
{
insertPoint
(
parallelInterfacePoints[ptI],
Vb::ptFarPoint
);
const labelList& constructMap =
pointMap.constructMap()[domain];
if (constructMap.size())
{
forAll(constructMap, i)
{
insertPoint
(
parallelInterfacePoints[constructMap[i]],
-(domain + 1)
);
}
}
}
Info<< "totalInterfacePoints " << totalInterfacePoints << endl;

View File

@ -299,9 +299,6 @@ void Foam::conformalVoronoiMesh::writeMesh
mesh.addFvPatches(patches);
Pout<< "Writing mesh to " << mesh.pointsInstance()
<< " " << mesh.name() << endl;
if (!mesh.write())
{
FatalErrorIn("Foam::conformalVoronoiMesh::writeMesh")

View File

@ -74,6 +74,7 @@ std::vector<Vb::Point> pointFile::initialPoints() const
<< exit(FatalError) << endl;
}
// Filter the points to be only those on this processor
boolList procPt(points.size(), false);
forAll(points, ptI)

View File

@ -62,15 +62,15 @@ std::vector<Vb::Point> uniformGrid::initialPoints() const
scalar x0 = bb.min().x();
scalar xR = bb.max().x() - x0;
label ni = label(xR/initialCellSize_) + 1;
label ni = label(xR/initialCellSize_);
scalar y0 = bb.min().y();
scalar yR = bb.max().y() - y0;
label nj = label(yR/initialCellSize_) + 1;
label nj = label(yR/initialCellSize_);
scalar z0 = bb.min().z();
scalar zR = bb.max().z() - z0;
label nk = label(zR/initialCellSize_) + 1;
label nk = label(zR/initialCellSize_);
vector delta(xR/ni, yR/nj, zR/nk);