Hello community and everyone,
Thank you for the powerful tool VTK for scientific data processing. I use Paraview to display my computational fluid dynamics(CFD) data and it really helps me. Now I encounter a problem for large dataset and I need your help since I am very new to VTK.
My software currently only generates Legacy ASCII vtk files of the computational data. The file size becomes very large when I do a complex computation. Now I have a datafile of around 50GB for post-processing. I prepared 1TB RAM memory on the cluster to avoid any memory overflow for large datasets. When I read the data in Paraview and pressed the “apply” button, it gives the following error in a short time:
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc
Loguru caught a signal: SIGABRT
Stack trace:
…
error: exception occurred: Child aborted
which seems to be related to memory allocation problem though I check that there is still 800GB RAM available in my cluster. I have 308075091 POINTS data in my vtk file, which may be too large for the Paraview vtk reader.
Then I learnt that I can split the data file into smaller pieces using python and VTK package. Since I have never used VTK alone, I asked ChatGPT for help and it gave me the split code below:
import vtk
def read_vtk_file(filename):
reader=vtk.vtkDataSetReader()
reader.SetFileName(filename)
reader.Update()
return reader.GetOutput()
def write_vtk_file(data, filename):
writer=vtk.vtkDataSetWriter()
writer.SetFileName(filename)
writer.SetInputData(data)
writer.Write()
def split_vtk_file(input_filename, output_filenames):
data=read_vtk_file(input_filename)
bounds=data.GetBounds()
for i, output_filename in enumerate(output_filenames):
clipper=vtk.vtkClipDataSet()
clipper.SetInputData(data)
box=vtk.vtkBox()
box.SetBounds(
bounds[0] if i%2==0 else (bounds[0]+bounds[1])/2,
(bounds[0]+bounds[1])/2 if i%2==0 else bounds[1],
bounds[2] if i//2==0 else (bounds[2]+bounds[3])/2,
(bounds[2]+bounds[3])/2 if i//2==0 else bounds[3],
bounds[4],
bounds[5]
)
clipper.SetClipFunction(box)
clipper.Update()
write_vtk_file(clipper.GetOutput(), output_filename)
input_filename=“…/snapdat_0.010.vtk”
output_filenames=[“part1.vtk”, “part2.vtk”, “part3.vtk”, “part4.vtk”]
split_vtk_file(input_filename, output_filenames)
Running the split code also gives the error:
vtkExecutive.cxx:729 ERR| vtkCompositeDataPipeline (0x1b0b560): Algorithm vtkUnstructuredGridReader (0x1b0a240) returned failure for request: vtkInformation (0x1b0bdf0)
Debug: Off
Modified Time: 308
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
FROM_OUTPUT_PORT: 0
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
which shows that the file is not read successfully and the datasize is too large to handle. Since the computation takes really long time and I only have vtk datafiles now, I want to know if I can further split the datafiles or convert them to other format with VTK. I am currently using Paraview-5.9.0-64bit and VTK 9.3.1. Thank you for your kind help!
Best regards,
Shine Sun