Timm
May 18, 2010, 10:50am
#1
Hello,
this issue is not really related to Palabos, but maybe someone has an idea.
In order to save disk space I would like to write the simulation data as binary vtk file. Does anybody know the specifications for that? Or does anybody have a simple example code? In principle, it doesn’t need to be vtk. I just want to import the files in ParaView.
There is also a related question: Is there a data format readable by ParaView which can story data from more than one time step? If I have 5000 files of 5 MB each, it takes ages for the OS to access and copy the data. It would be much better to have only one or few large files containing many time steps. Is there a data format which can handle that?
Thanks a lot,
Timm
SaS
May 18, 2010, 11:23am
#2
Dear Timm
Tecplot data format is redable from para view 3.8
It is one of the strongest data format
I am using tacplot data format. It supports binary format, and you can store more than one time step in a single file
you can look to this refrence
http://download.tecplot.com/tecio/360/dataformat.pdf
also they have Pre-compiled library to read and write the data in their format.
http://download.tecplot.com/tecio/360/
I hope It will Help you.
Thanks
Saleh Bawazeer
Timm
May 18, 2010, 12:49pm
#3
Hello SaS,
this seems to be very helpful.
Thank you very much!
Timm
Alex
June 10, 2010, 5:56pm
#4
Hi Timm,
I can send you small VTK XML writer cpp code that you can use it - it does it in binary format. Let me know if you are still interested in it.
Cheers,
Alex
Timm
June 10, 2010, 9:23pm
#5
Hey Alex,
yes, that would be nice. I just take all I can get and see which option is the best one for me.
Thanks,
Timm
Hi Alex,
I’d be interested, too.
Could you just post the code here?
Best wishes,
Arne
Alex
June 28, 2010, 6:08pm
#7
Hi guys,
Sorry for being late - was just really busy with everything. So here it is:
#include <vtkXMLStructuredGridWriter.h>
#include <vtkSmartPointer.h>
#include <vtkStructuredGrid.h>
#include <vtkIdList.h>
#include <vtkDoubleArray.h>
#include <vtkPointData.h>
void Solver::writeVTKWholePhase(std::string name)
{
Solver::getWholePhase();
if (rank==0)
{
name=name+".vtk";
std::ofstream fout(name.c_str());
fout<<"# vtk DataFile Version 3.0\n";
fout<<"Binary liquid phase field vtk representation\n";
fout<<"ASCII\n\n";
fout<<"DATASET STRUCTURED_GRID\n";
fout<<"DIMENSIONS "<<NX<<" "<<NY<<" "<<NZ<<"\n";
//fout<<"ORIGIN "<<floor(NX/2)<<" "<<floor(NY/2)<<" "<<floor(NZ/2)<<"\n";
//fout<<"SPACING 1 1 1\n";
fout<<"POINTS "<<NX*NY*NZ<<" double\n";
for(int counterZ=0;counterZ<NZ;counterZ++)
for(int counterY=0;counterY<NY;counterY++)
for(int counterX=0;counterX<NX;counterX++)
fout<<counterX<<" "<<counterY<<" "<<counterZ<<"\n";
fout<<"\n";
fout<<"POINT_DATA "<<NX*NY*NZ<<"\n";
fout<<"SCALARS phase double\n";
fout<<"LOOKUP_TABLE phase_table\n";
for(int counterZ=0;counterZ<NZ;counterZ++)
for(int counterY=0;counterY<NY;counterY++)
for(int counterX=0;counterX<NX;counterX++)
fout<<phase[counterZ*NX*NY+counterY*NX+counterX]<<"\n";
}
}
void Solver::writeWholePhase(std::string name)
{
Solver::getWholePhase();
if (rank==0)
{
name=name+".vts";
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
for(int counterZ=0;counterZ<NZ;counterZ++)
for(int counterY=0;counterY<NY;counterY++)
for(int counterX=0;counterX<NX;counterX++)
points->InsertNextPoint(counterX,counterY,counterZ);
vtkSmartPointer<vtkDoubleArray> data = vtkSmartPointer<vtkDoubleArray>::New();
data->SetNumberOfComponents(1);
data->SetName("Phase");
for(vtkIdType i = 0; i < points->GetNumberOfPoints(); i++)
{
double * temp_data=&phase[i];
data->InsertNextTupleValue(temp_data);
}
vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New();
structuredGrid->SetDimensions(NX,NY,NZ);
structuredGrid->SetPoints(points);
structuredGrid->GetPointData()->AddArray(data);
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName(name.c_str());
//writer.SetPoints();
writer->SetInput(structuredGrid);
writer->Write();
}
}