Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/avt/Pipeline/Sinks/avtDatabaseWriter.C
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <vtkPointData.h>
#include <vtkPolyDataReader.h>
#include <vtkPolyDataWriter.h>
#include <vtkPolyDataRelevantPointsFilter.h>
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridRelevantPointsFilter.h>
#include <vtkCharArray.h>
#include <vtkPolyData.h>
#include <vtkTriangleFilter.h>
Expand Down Expand Up @@ -1046,6 +1049,7 @@ avtDatabaseWriter::Write(const std::string &plotName,
debug5 << line << endl << endl;
}


// ****************************************************************************
// Method: avtDatabaseWriter::GroupWrite
//
Expand All @@ -1063,6 +1067,9 @@ avtDatabaseWriter::Write(const std::string &plotName,
//
// Modifications:
//
// Cyrus Harrison, Wed Jul 16 09:18:14 PDT 2025
// Added call to remove unused points for the non combined case
//
// ****************************************************************************
void
avtDatabaseWriter::GroupWrite(const std::string &plotName,
Expand Down Expand Up @@ -1246,9 +1253,19 @@ avtDatabaseWriter::GroupWrite(const std::string &plotName,
vtkDataSet *in_ds = dt->GetDataRepresentation().GetDataVTK();
int domainId = dt->GetDataRepresentation().GetDomain();
std::string label(dt->GetDataRepresentation().GetLabel());

// RemoveUnusedPoints returns input dataset or new cleaned dataset
vtkDataSet *clean_ds = RemoveUnusedPoints(in_ds);

WriteChunk(in_ds, chunkID, domainId, label);
Comment thread
cyrush marked this conversation as resolved.
Outdated
chunkID++;
++nWritten;

// clean up the clean_ds if RemoveUnusedPoints created new dataset
if(clean_ds != in_ds)
{
clean_ds->Delete();
}
}
}

Expand Down Expand Up @@ -1897,3 +1914,57 @@ avtDatabaseWriter::SetContractToUse(avtContract_p ps)
{
savedContract = ps;
}

// ****************************************************************************
// Method: avtDatabaseWriter::RemoveUnusedPoints
//
// Purpose:
// Cleans up unused points vtkDataset
//
// Arguments:
//
// Returns:
//
// Programmer: Cyrus Harrison
// Creation: Wed Jul 16 09:15:44 PDT 2025
//
// Modifications:
//
// ****************************************************************************
vtkDataSet *
avtDatabaseWriter::RemoveUnusedPoints(vtkDataSet *ds)
{
vtkDataSet *res = nullptr;
switch(ds->GetDataObjectType())
{
case VTK_POLY_DATA:
{
vtkPolyDataRelevantPointsFilter *rpfPD = vtkPolyDataRelevantPointsFilter::New();
rpfPD->SetInputData((vtkPolyData*)ds);
vtkPolyData *out_pd = vtkPolyData::New();
rpfPD->SetOutput(out_pd);
rpfPD->Update();
rpfPD->Delete();
res = out_pd;
break;
}
case VTK_UNSTRUCTURED_GRID:
{
vtkUnstructuredGridRelevantPointsFilter *rpfUG = vtkUnstructuredGridRelevantPointsFilter::New();
rpfUG->SetInputData((vtkUnstructuredGrid*)ds);
vtkUnstructuredGrid *out_ug = vtkUnstructuredGrid::New();
rpfUG->SetOutput(out_ug);
rpfUG->Update();
rpfUG->Delete();
res = out_ug;
break;
}
default: // we do not need to filter points for other dataset types
{
res = ds;
break;
}
}

return res;
}
4 changes: 4 additions & 0 deletions src/avt/Pipeline/Sinks/avtDatabaseWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class vtkPolyData;
// Kathleen Biagas, Wed Nov 18 2020
// Replace VISIT_LONG_LONG with long long.
//
// Cyrus Harrison, Wed Jul 16 09:08:30 PDT 2025
// Added helper to remove unused points during export.
//
// ****************************************************************************

class PIPELINE_API avtDatabaseWriter : public virtual avtTerminatingDatasetSink
Expand Down Expand Up @@ -221,6 +224,7 @@ class PIPELINE_API avtDatabaseWriter : public virtual avtTerminatingDatasetSink
const std::vector<std::string> &materialList,
int numTotalChunks, int startIndex,
int tag, bool writeUsingGroups, int groupSize);
vtkDataSet *RemoveUnusedPoints(vtkDataSet *ds);
void WaitForTurn(int tag, int &nWritten);
void GrantTurn(int tag, int &nWritten);
};
Expand Down
72 changes: 66 additions & 6 deletions src/databases/Blueprint/avtBlueprintWriter.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkXMLRectilinearGridWriter.h>
#include <vtkXMLStructuredGridWriter.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtkPolyDataRelevantPointsFilter.h>
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridRelevantPointsFilter.h>

#include <avtDatabaseMetaData.h>
#include <avtParallelContext.h>
Expand Down Expand Up @@ -493,9 +492,16 @@ avtBlueprintWriter::ChunkToBpMesh(vtkDataSet *ds, int chunk, int ndims,
{
mesh["state/time"] = m_time;
}


vtkDataSet *clean_ds = RemoveUnusedPoints(ds);

avtConduitBlueprintDataAdaptor::VTKToBlueprint::VTKToBlueprintMesh(mesh, ds, ndims);


if(clean_ds != ds)
{
clean_ds->Delete();
}

Node verify_info;
if(!blueprint::mesh::verify(mesh,verify_info))
{
Expand Down Expand Up @@ -652,3 +658,57 @@ avtBlueprintWriter::WriteRootFile()
{
// root file has already been written
}

// ****************************************************************************
// Method: avtBlueprintWriter::RemoveUnusedPoints
//
// Purpose:
// Cleans up unused points vtkDataset
//
// Arguments:
//
// Returns:
//
// Programmer: Cyrus Harrison
// Creation: Wed Jul 16 09:15:44 PDT 2025
//
// Modifications:
//
// ****************************************************************************
vtkDataSet *
avtBlueprintWriter::RemoveUnusedPoints(vtkDataSet *ds)
{
vtkDataSet *res = nullptr;
switch(ds->GetDataObjectType())
{
case VTK_POLY_DATA:
{
vtkPolyDataRelevantPointsFilter *rpfPD = vtkPolyDataRelevantPointsFilter::New();
rpfPD->SetInputData((vtkPolyData*)ds);
vtkPolyData *out_pd = vtkPolyData::New();
rpfPD->SetOutput(out_pd);
rpfPD->Update();
rpfPD->Delete();
res = out_pd;
break;
}
case VTK_UNSTRUCTURED_GRID:
{
vtkUnstructuredGridRelevantPointsFilter *rpfUG = vtkUnstructuredGridRelevantPointsFilter::New();
rpfUG->SetInputData((vtkUnstructuredGrid*)ds);
vtkUnstructuredGrid *out_ug = vtkUnstructuredGrid::New();
rpfUG->SetOutput(out_ug);
rpfUG->Update();
rpfUG->Delete();
res = out_ug;
break;
}
default: // we do not need to filter points for other dataset types
{
res = ds;
break;
}
}

return res;
}
3 changes: 3 additions & 0 deletions src/databases/Blueprint/avtBlueprintWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ avtBlueprintWriter : public virtual avtDatabaseWriter
virtual void WriteChunk(vtkDataSet *, int);
virtual void CloseFile(void);
virtual void WriteRootFile();


vtkDataSet *RemoveUnusedPoints(vtkDataSet *ds);
};


Expand Down
Loading