mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use updated surface methods, additional debugging for isoTopo
This commit is contained in:
@ -861,15 +861,14 @@ void Foam::isoSurfaceTopo::removeInsidePoints
|
|||||||
const labelUList& start, // Per cell the starting triangle
|
const labelUList& start, // Per cell the starting triangle
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
DynamicList<label>& pointCompactMap, // Per returned point the original
|
|
||||||
DynamicList<label>& compactCellIDs // Per returned tri the cellID
|
DynamicList<label>& compactCellIDs // Per returned tri the cellID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
pointCompactMap.clear();
|
|
||||||
compactCellIDs.clear();
|
|
||||||
|
|
||||||
const pointField& points = s.points();
|
const pointField& points = s.points();
|
||||||
|
|
||||||
|
compactCellIDs.clear();
|
||||||
|
compactCellIDs.reserve(s.size()/4);
|
||||||
|
|
||||||
DynamicList<face> compactFaces(s.size()/4);
|
DynamicList<face> compactFaces(s.size()/4);
|
||||||
|
|
||||||
for (label celli = 0; celli < start.size()-1; ++celli)
|
for (label celli = 0; celli < start.size()-1; ++celli)
|
||||||
@ -900,43 +899,7 @@ void Foam::isoSurfaceTopo::removeInsidePoints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.swapFaces(compactFaces); // Use new faces
|
||||||
// Compact out unused points
|
|
||||||
labelList oldToCompact(points.size(), -1);
|
|
||||||
pointCompactMap.clear(); // Extra safety (paranoid)
|
|
||||||
|
|
||||||
for (face& f : compactFaces)
|
|
||||||
{
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
label pointi = f[fp];
|
|
||||||
label compacti = oldToCompact[pointi];
|
|
||||||
if (compacti == -1)
|
|
||||||
{
|
|
||||||
compacti = pointCompactMap.size();
|
|
||||||
oldToCompact[pointi] = compacti;
|
|
||||||
pointCompactMap.append(pointi);
|
|
||||||
}
|
|
||||||
f[fp] = compacti;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pointField compactPoints
|
|
||||||
(
|
|
||||||
UIndirectList<point>(s.points(), pointCompactMap)
|
|
||||||
);
|
|
||||||
|
|
||||||
surfZoneList newZones(s.surfZones());
|
|
||||||
|
|
||||||
s.clear();
|
|
||||||
Mesh updated
|
|
||||||
(
|
|
||||||
std::move(compactPoints),
|
|
||||||
std::move(compactFaces),
|
|
||||||
s.surfZones()
|
|
||||||
);
|
|
||||||
|
|
||||||
s.transfer(updated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -957,6 +920,9 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
// The cell cut type
|
// The cell cut type
|
||||||
List<cutType> cellCutType_(mesh.nCells(), cutType::UNVISITED);
|
List<cutType> cellCutType_(mesh.nCells(), cutType::UNVISITED);
|
||||||
|
|
||||||
|
// Time description (for debug output)
|
||||||
|
const word timeDesc(word::printf("%08d", mesh_.time().timeIndex()));
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "isoSurfaceTopo:" << nl
|
Pout<< "isoSurfaceTopo:" << nl
|
||||||
@ -1033,11 +999,6 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
// Additional debugging
|
// Additional debugging
|
||||||
if (debug & 8)
|
if (debug & 8)
|
||||||
{
|
{
|
||||||
const word timeDesc
|
|
||||||
(
|
|
||||||
word::printf("%08d", mesh_.time().timeIndex())
|
|
||||||
);
|
|
||||||
|
|
||||||
// Write debug cuts cells in VTK format
|
// Write debug cuts cells in VTK format
|
||||||
{
|
{
|
||||||
constexpr uint8_t realCut(cutType::CUT | cutType::TETCUT);
|
constexpr uint8_t realCut(cutType::CUT | cutType::TETCUT);
|
||||||
@ -1071,12 +1032,12 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
|
|
||||||
writer.writeGeometry();
|
writer.writeGeometry();
|
||||||
|
|
||||||
// Cell qualities
|
// CellData
|
||||||
writer.beginCellData();
|
writer.beginCellData();
|
||||||
writer.writeProcIDs();
|
writer.writeProcIDs();
|
||||||
writer.writeCellData("cutField", cVals_);
|
writer.writeCellData("cutField", cVals_);
|
||||||
|
|
||||||
// Point qualities
|
// PointData
|
||||||
writer.beginPointData();
|
writer.beginPointData();
|
||||||
writer.writePointData("cutField", pVals_);
|
writer.writePointData("cutField", pVals_);
|
||||||
|
|
||||||
@ -1163,23 +1124,75 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
|
|
||||||
|
|
||||||
// Assign to MeshedSurface
|
// Assign to MeshedSurface
|
||||||
|
static_cast<Mesh&>(*this) = Mesh
|
||||||
Mesh::clear();
|
|
||||||
Mesh updated
|
|
||||||
(
|
(
|
||||||
std::move(allTriPoints),
|
std::move(allTriPoints),
|
||||||
std::move(allTriFaces),
|
std::move(allTriFaces),
|
||||||
surfZoneList(one{}, surfZone("allFaces", allTriFaces.size()))
|
surfZoneList() // zones not required (one zone)
|
||||||
);
|
);
|
||||||
Mesh::transfer(updated);
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "isoSurfaceTopo : generated "
|
Pout<< "isoSurfaceTopo : generated "
|
||||||
<< Mesh::size() << " faces "
|
<< Mesh::size() << " triangles "
|
||||||
<< Mesh::points().size() << " points" << endl;
|
<< Mesh::points().size() << " points" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write debug triangulated surface
|
||||||
|
if ((debug & 8) && (params.filter() != filterType::NONE))
|
||||||
|
{
|
||||||
|
const Mesh& s = *this;
|
||||||
|
|
||||||
|
vtk::surfaceWriter writer
|
||||||
|
(
|
||||||
|
s.points(),
|
||||||
|
s,
|
||||||
|
fileName
|
||||||
|
(
|
||||||
|
mesh_.time().globalPath()
|
||||||
|
/ ("isoSurfaceTopo." + timeDesc + "-triangles")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
writer.writeGeometry();
|
||||||
|
|
||||||
|
// CellData
|
||||||
|
writer.beginCellData();
|
||||||
|
writer.writeProcIDs();
|
||||||
|
writer.write("cellID", meshCells_);
|
||||||
|
|
||||||
|
// PointData
|
||||||
|
writer.beginPointData();
|
||||||
|
{
|
||||||
|
// NB: may have non-compact surface points
|
||||||
|
// --> use points().size() not nPoints()!
|
||||||
|
|
||||||
|
labelList pointStatus(s.points().size(), Zero);
|
||||||
|
|
||||||
|
forAll(pointToVerts_, i)
|
||||||
|
{
|
||||||
|
const edge& verts = pointToVerts_[i];
|
||||||
|
if (verts.first() == verts.second())
|
||||||
|
{
|
||||||
|
// Duplicate index (ie, snapped)
|
||||||
|
pointStatus[i] = 1;
|
||||||
|
}
|
||||||
|
if (tetCutAddr.pointFromDiag().test(i))
|
||||||
|
{
|
||||||
|
// Point on triangulation diagonal
|
||||||
|
pointStatus[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.write("point-status", pointStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "isoSurfaceTopo : (debug) wrote "
|
||||||
|
<< returnReduce(s.size(), sumOp<label>())
|
||||||
|
<< " triangles : "
|
||||||
|
<< writer.output().name() << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Now:
|
// Now:
|
||||||
// - generated faces and points are assigned to *this
|
// - generated faces and points are assigned to *this
|
||||||
@ -1189,14 +1202,27 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
// (note that the pyramid faces are shared between multiple mesh faces)
|
// (note that the pyramid faces are shared between multiple mesh faces)
|
||||||
// - pointToVerts_ : originating mesh vertex or cell centre
|
// - pointToVerts_ : originating mesh vertex or cell centre
|
||||||
|
|
||||||
// Basic filtering
|
if (params.filter() == filterType::NONE)
|
||||||
|
|
||||||
if (params.filter() != filterType::NONE)
|
|
||||||
{
|
{
|
||||||
// Triangulate outside (filter edges to cell centres and optionally
|
// Compact out unused (snapped) points
|
||||||
// face diagonals)
|
if (this->snap())
|
||||||
DynamicList<label> pointCompactMap(size()); // Back to original point
|
{
|
||||||
DynamicList<label> compactCellIDs(size()); // Per tri the cell
|
Mesh& s = *this;
|
||||||
|
|
||||||
|
labelList pointMap; // Back to original point
|
||||||
|
s.compactPoints(pointMap); // Compact out unused points
|
||||||
|
pointToVerts_ = UIndirectList<edge>(pointToVerts_, pointMap)();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Initial filtering
|
||||||
|
|
||||||
|
Mesh& s = *this;
|
||||||
|
|
||||||
|
// Triangulate outside
|
||||||
|
// (filter edges to cell centres and optionally face diagonals)
|
||||||
|
DynamicList<label> compactCellIDs; // Per tri the cell
|
||||||
|
|
||||||
removeInsidePoints
|
removeInsidePoints
|
||||||
(
|
(
|
||||||
@ -1209,17 +1235,19 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
tetCutAddr.pointFromDiag(),
|
tetCutAddr.pointFromDiag(),
|
||||||
tetCutAddr.pointToFace(),
|
tetCutAddr.pointToFace(),
|
||||||
startTri,
|
startTri,
|
||||||
pointCompactMap,
|
|
||||||
compactCellIDs
|
compactCellIDs
|
||||||
);
|
);
|
||||||
|
|
||||||
pointToVerts_ = UIndirectList<edge>(pointToVerts_, pointCompactMap)();
|
labelList pointMap; // Back to original point
|
||||||
|
s.compactPoints(pointMap); // Compact out unused points
|
||||||
|
|
||||||
|
pointToVerts_ = UIndirectList<edge>(pointToVerts_, pointMap)();
|
||||||
meshCells_.transfer(compactCellIDs);
|
meshCells_.transfer(compactCellIDs);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "isoSurfaceTopo :"
|
Pout<< "isoSurfaceTopo :"
|
||||||
" after removing cell centre and face-diag triangles "
|
" after removing cell centre and face-diag triangles: "
|
||||||
<< Mesh::size() << " faces "
|
<< Mesh::size() << " faces "
|
||||||
<< Mesh::points().size() << " points"
|
<< Mesh::points().size() << " points"
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -1284,11 +1312,6 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
// Additional debugging
|
// Additional debugging
|
||||||
if (tetCutAddr.debugCutTetsOn())
|
if (tetCutAddr.debugCutTetsOn())
|
||||||
{
|
{
|
||||||
const word timeDesc
|
|
||||||
(
|
|
||||||
word::printf("%08d", mesh_.time().timeIndex())
|
|
||||||
);
|
|
||||||
|
|
||||||
// Write debug cut tets in VTK format
|
// Write debug cut tets in VTK format
|
||||||
{
|
{
|
||||||
const auto& debugCuts = tetCutAddr.debugCutTets();
|
const auto& debugCuts = tetCutAddr.debugCutTets();
|
||||||
@ -1314,6 +1337,7 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
|
|
||||||
writer.writeGeometry();
|
writer.writeGeometry();
|
||||||
|
|
||||||
|
// CellData
|
||||||
writer.beginCellData();
|
writer.beginCellData();
|
||||||
writer.writeProcIDs();
|
writer.writeProcIDs();
|
||||||
|
|
||||||
@ -1333,21 +1357,23 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
writer.writeCellData("tetQuality", cutTetQuality);
|
writer.writeCellData("tetQuality", cutTetQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PointData
|
||||||
if (this->snap())
|
if (this->snap())
|
||||||
{
|
{
|
||||||
labelList snapped(vtuCells.nFieldPoints(), Zero);
|
writer.beginPointData();
|
||||||
|
|
||||||
|
labelList pointStatus(vtuCells.nFieldPoints(), Zero);
|
||||||
|
|
||||||
for (const edge& verts : pointToVerts_)
|
for (const edge& verts : pointToVerts_)
|
||||||
{
|
{
|
||||||
if (verts.first() == verts.second())
|
if (verts.first() == verts.second())
|
||||||
{
|
{
|
||||||
// Duplicate index (ie, snapped)
|
// Duplicate index (ie, snapped)
|
||||||
snapped[verts.first()] = 1;
|
pointStatus[verts.first()] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.beginPointData();
|
writer.writePointData("point-status", pointStatus);
|
||||||
writer.writePointData("snapped", snapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "isoSurfaceTopo : (debug) wrote "
|
Info<< "isoSurfaceTopo : (debug) wrote "
|
||||||
@ -1423,6 +1449,7 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
|
|
||||||
writer.writeGeometry();
|
writer.writeGeometry();
|
||||||
|
|
||||||
|
// CellData
|
||||||
writer.beginCellData();
|
writer.beginCellData();
|
||||||
writer.writeProcIDs();
|
writer.writeProcIDs();
|
||||||
|
|
||||||
@ -1454,23 +1481,30 @@ Foam::isoSurfaceTopo::isoSurfaceTopo
|
|||||||
|
|
||||||
writer.writeGeometry();
|
writer.writeGeometry();
|
||||||
|
|
||||||
|
// CellData
|
||||||
writer.beginCellData();
|
writer.beginCellData();
|
||||||
writer.writeProcIDs();
|
writer.writeProcIDs();
|
||||||
|
writer.write("cellID", meshCells_);
|
||||||
|
|
||||||
|
// PointData
|
||||||
|
writer.beginPointData();
|
||||||
{
|
{
|
||||||
labelList snapped(s.nPoints(), Zero);
|
// NB: may have non-compact surface points
|
||||||
|
// --> use points().size() not nPoints()!
|
||||||
|
|
||||||
|
labelList pointStatus(s.points().size(), Zero);
|
||||||
|
|
||||||
forAll(pointToVerts_, i)
|
forAll(pointToVerts_, i)
|
||||||
{
|
{
|
||||||
const edge& verts =pointToVerts_[i];
|
const edge& verts = pointToVerts_[i];
|
||||||
if (verts.first() == verts.second())
|
if (verts.first() == verts.second())
|
||||||
{
|
{
|
||||||
// Duplicate index (ie, snapped)
|
// Duplicate index (ie, snapped)
|
||||||
snapped[i] = 1;
|
pointStatus[i] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.beginPointData();
|
writer.write("point-status", pointStatus);
|
||||||
writer.write("snapped", snapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "isoSurfaceTopo : (debug) wrote "
|
Info<< "isoSurfaceTopo : (debug) wrote "
|
||||||
|
|||||||
@ -189,8 +189,7 @@ class isoSurfaceTopo
|
|||||||
const labelUList& start, // Per cell:starting tri
|
const labelUList& start, // Per cell:starting tri
|
||||||
|
|
||||||
// Outputs
|
// Outputs
|
||||||
DynamicList<label>& pointCompactMap, // Per point the original
|
DynamicList<label>& compactCellIDs // Per face the cellID
|
||||||
DynamicList<label>& compactCellIDs // Per face the cellID
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user