Adding patch information from surface. Changing dualMesh.obj writing to use points and faces derived during polyMesh calculation rather than recalculating.

This commit is contained in:
graham
2008-11-05 11:34:56 +00:00
parent 7d08315863
commit 0180a47666
5 changed files with 68 additions and 78 deletions

View File

@ -527,7 +527,6 @@ void Foam::CV3D::write()
writePoints("points.obj", true); writePoints("points.obj", true);
writeTriangles("allTriangles.obj", false); writeTriangles("allTriangles.obj", false);
writeTriangles("triangles.obj", true); writeTriangles("triangles.obj", true);
writeDual("dualMesh.obj");
} }
writeMesh(); writeMesh();

View File

@ -422,7 +422,12 @@ public:
void writeTriangles(const fileName& fName, bool internalOnly) const; void writeTriangles(const fileName& fName, bool internalOnly) const;
//- Write dual points and faces as .obj file //- Write dual points and faces as .obj file
void writeDual(const fileName& fName) const; void writeDual
(
const pointField& points,
const faceList& faces,
const fileName& fName
) const;
//- Write polyMesh //- Write polyMesh
void writeMesh(bool writeToTimestep = false); void writeMesh(bool writeToTimestep = false);

View File

@ -31,7 +31,7 @@ License
void Foam::CV3D::writePoints(const fileName& fName, bool internalOnly) const void Foam::CV3D::writePoints(const fileName& fName, bool internalOnly) const
{ {
Info << "Writing points to " << fName << nl << endl; Info<< nl << "Writing points to " << fName << nl << endl;
OFstream str(fName); OFstream str(fName);
for for
@ -49,86 +49,41 @@ void Foam::CV3D::writePoints(const fileName& fName, bool internalOnly) const
} }
void Foam::CV3D::writeDual(const fileName& fName) const void Foam::CV3D::writeDual
(
const pointField& points,
const faceList& faces,
const fileName& fName
) const
{ {
Info << "Writing dual points and faces to " << fName << nl << endl; Info<< nl << "Writing dual points and faces to " << fName << nl << endl;
OFstream str(fName); OFstream str(fName);
label dualVerti = 0; forAll(points, p)
for
(
Triangulation::Finite_cells_iterator cit = finite_cells_begin();
cit != finite_cells_end();
++cit
)
{ {
cit->cellIndex() = -1; meshTools::writeOBJ(str, points[p]);
if
(
cit->vertex(0)->internalOrBoundaryPoint()
|| cit->vertex(1)->internalOrBoundaryPoint()
|| cit->vertex(2)->internalOrBoundaryPoint()
|| cit->vertex(3)->internalOrBoundaryPoint()
)
{
cit->cellIndex() = dualVerti;
meshTools::writeOBJ(str, topoint(dual(cit)));
dualVerti++;
}
// else
// {
// cit->cellIndex() = -1;
// }
} }
for forAll (faces, f)
(
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
eit != finite_edges_end();
++eit
)
{ {
if str<< 'f';
(
eit->first->vertex(eit->second)->internalOrBoundaryPoint() const face& fP = faces[f];
|| eit->first->vertex(eit->third)->internalOrBoundaryPoint()
) forAll(fP, p)
{ {
Cell_circulator ccStart = incident_cells(*eit); str<< ' ' << fP[p] + 1;
Cell_circulator cc = ccStart;
str<< 'f';
do
{
if (!is_infinite(cc))
{
if (cc->cellIndex() < 0)
{
FatalErrorIn
(
"Foam::CV3D::writeDual(const fileName& fName)"
)
<< "Dual face uses circumcenter defined by a Delaunay "
"tetrahedron with no internal or boundary points."
<< exit(FatalError);
}
str<< ' ' << cc->cellIndex() + 1;
}
} while (++cc != ccStart);
str<< nl;
} }
str<< nl;
} }
} }
void Foam::CV3D::writeTriangles(const fileName& fName, bool internalOnly) const void Foam::CV3D::writeTriangles(const fileName& fName, bool internalOnly) const
{ {
Info << "Writing triangles to " << fName << nl << endl; Info<< nl << "Writing triangles to " << fName << nl << endl;
OFstream str(fName); OFstream str(fName);
labelList vertexMap(number_of_vertices()); labelList vertexMap(number_of_vertices());
@ -271,6 +226,8 @@ void Foam::CV3D::writeMesh(bool writeToTimestep)
<< "Failed writing polyMesh." << "Failed writing polyMesh."
<< exit(FatalError); << exit(FatalError);
} }
writeDual(points, faces, "dualMesh.obj");
} }
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
<< "Read surface with " << surf.size() << " triangles from file " << "Read surface with " << surf.size() << " triangles from file "
<< args.args()[1] << nl << endl; << args.args()[1] << nl << endl;
// Read and triangulation // Read and triangulation
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~
CV3D mesh(runTime, surf); CV3D mesh(runTime, surf);

View File

@ -278,11 +278,20 @@ void Foam::CV3D::calcDualMesh
// ~~~~~~~~~~~~ dual face and owner neighbour construction ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~ dual face and owner neighbour construction ~~~~~~~~~~~~~~~~~
label nPatches = 1; label nPatches = qSurf_.patches().size() + 1;
label defaultPatchIndex = qSurf_.patches().size();
patchNames.setSize(nPatches); patchNames.setSize(nPatches);
patchNames[0] = "CV3D_default_patch"; const geometricSurfacePatchList& surfacePatches = qSurf_.patches();
forAll(surfacePatches, sP)
{
patchNames[sP] = surfacePatches[sP].name();
}
patchNames[defaultPatchIndex] = "CV3D_default_patch";
patchSizes.setSize(nPatches); patchSizes.setSize(nPatches);
@ -399,8 +408,28 @@ void Foam::CV3D::calcDualMesh
dcOwn = dcA; dcOwn = dcA;
} }
// find which patch this face is on; Hardcoded for now. // Find which patch this face is on by finding the
label patchIndex = 0; // intersection with the surface of the Delaunay edge
// generating the face and identify the region of the
// intersection.
point ptA = topoint(vA->point());
point ptB = topoint(vB->point());
pointIndexHit pHit = qSurf_.tree().findLineAny(ptA, ptB);
label patchIndex = qSurf_[pHit.index()].region();
if (patchIndex == -1)
{
patchIndex = defaultPatchIndex;
WarningIn("Foam::CV3D::calcDualMesh.C")
<< "Dual face found that is not on a surface "
<< "patch. Adding to CV3D_default_patch."
<< endl;
}
patchFaces[patchIndex].append(newDualFace); patchFaces[patchIndex].append(newDualFace);
patchOwners[patchIndex].append(dcOwn); patchOwners[patchIndex].append(dcOwn);
@ -432,11 +461,11 @@ void Foam::CV3D::calcDualMesh
dualFacei++; dualFacei++;
} }
} }
else // else
{ // {
Info<< verticesOnFace.size() // Info<< verticesOnFace.size()
<< " size face not created." << endl; // << " size face not created." << endl;
} // }
} }
} }