mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -527,7 +527,6 @@ void Foam::CV3D::write()
|
||||
writePoints("points.obj", true);
|
||||
writeTriangles("allTriangles.obj", false);
|
||||
writeTriangles("triangles.obj", true);
|
||||
writeDual("dualMesh.obj");
|
||||
}
|
||||
|
||||
writeMesh();
|
||||
|
||||
@ -422,7 +422,12 @@ public:
|
||||
void writeTriangles(const fileName& fName, bool internalOnly) const;
|
||||
|
||||
//- 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
|
||||
void writeMesh(bool writeToTimestep = false);
|
||||
|
||||
@ -31,7 +31,7 @@ License
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
label dualVerti = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_cells_iterator cit = finite_cells_begin();
|
||||
cit != finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
forAll(points, p)
|
||||
{
|
||||
cit->cellIndex() = -1;
|
||||
|
||||
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;
|
||||
// }
|
||||
meshTools::writeOBJ(str, points[p]);
|
||||
}
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
|
||||
eit != finite_edges_end();
|
||||
++eit
|
||||
)
|
||||
forAll (faces, f)
|
||||
{
|
||||
if
|
||||
(
|
||||
eit->first->vertex(eit->second)->internalOrBoundaryPoint()
|
||||
|| eit->first->vertex(eit->third)->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
Cell_circulator ccStart = incident_cells(*eit);
|
||||
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);
|
||||
}
|
||||
const face& fP = faces[f];
|
||||
|
||||
str<< ' ' << cc->cellIndex() + 1;
|
||||
forAll(fP, p)
|
||||
{
|
||||
str<< ' ' << fP[p] + 1;
|
||||
}
|
||||
} while (++cc != ccStart);
|
||||
|
||||
str<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
labelList vertexMap(number_of_vertices());
|
||||
@ -271,6 +226,8 @@ void Foam::CV3D::writeMesh(bool writeToTimestep)
|
||||
<< "Failed writing polyMesh."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
writeDual(points, faces, "dualMesh.obj");
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
@ -278,11 +278,20 @@ void Foam::CV3D::calcDualMesh
|
||||
|
||||
// ~~~~~~~~~~~~ dual face and owner neighbour construction ~~~~~~~~~~~~~~~~~
|
||||
|
||||
label nPatches = 1;
|
||||
label nPatches = qSurf_.patches().size() + 1;
|
||||
|
||||
label defaultPatchIndex = qSurf_.patches().size();
|
||||
|
||||
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);
|
||||
|
||||
@ -399,8 +408,28 @@ void Foam::CV3D::calcDualMesh
|
||||
dcOwn = dcA;
|
||||
}
|
||||
|
||||
// find which patch this face is on; Hardcoded for now.
|
||||
label patchIndex = 0;
|
||||
// Find which patch this face is on by finding the
|
||||
// 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);
|
||||
patchOwners[patchIndex].append(dcOwn);
|
||||
@ -432,11 +461,11 @@ void Foam::CV3D::calcDualMesh
|
||||
dualFacei++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< verticesOnFace.size()
|
||||
<< " size face not created." << endl;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// Info<< verticesOnFace.size()
|
||||
// << " size face not created." << endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user