HI Gael,

Saving each time step to a VTI file is very reasonable in the way that you
are doing it. I would recommend doing that.

To assign times to each VTI file, I recommend also writing a .pvd file,
which is an XML file that describes a list of files that can be loaded by
ParaView. You can describe your VTI files in the .pvd file and assign a
time to each VTI file. Please see

http://www.paraview.org/Wiki/ParaView/Data_formats#PVD_File_Format

for more details on the PVD file.

Hope that helps,
Cory

On Thu, Nov 12, 2015 at 1:24 PM, lorieul <gael.lori...@uclouvain.be> wrote:

> Hello,
>
> I wanted to know the cleanest way to save a custom array class instance
> to a *.vti file with time information. I searched through the
> documentation and found some threads in the mailing list archives but
> could not find compelling answers (quite to my surprise… I'm sure the
> information must be there somewhere…).
>
> I am designing a C++ software that performs CFD (Computational Fluid
> Dynamics) simulations. I start from known initial conditions and iterate
> in time. After each iteration, I know the definition of each of the flow
> variables (e.g. I know the velocity field at each time step). I want to
> save this information into a *.vti file so that I can visualise it with
> paraview and (for instance) animate it.
>
> My code uses its own array class which I'll call DblArr. Hence when I
> want to save a field to a file, I need to use a vtkImageData object and
> copy all the data from the DblArr object into it. This means that for
> each DblArr array I want to save, I need a corresponding vtkImageData
> object (hence additional memory and computation costs). Is that the best
> way to do so ?
>
> Besides, how do I store the time information ? Should I call :
>
> myImgData->GetInformation()->Set(
>     vtkDataObject::DATA_TIME_STEPS(), & currentTime, 1);
>
> Or is there a better way to do so ? (I found very little reference to
> DATA_TIME_STEPS() in the documentation)
>
> Gael Lorieul
> PhD student at Université catholique de Louvain
>
>
>
>
>
> Getting more into details :
>
> for each DblArr that I might want to save, I instanciate a Svr_vti
> object (which is another custom class). The purpose of this class is to
> perform the save operation to a *.vti file. It does three things :
>  1. allocating memory i.e. instanciation of vtkImageData object at the
> beginning of the simulation
>  2. handling the copying of data from the DblArr object to the
> vtkImageData
> object
>  3. writing the *.vti file.
>
> Once again, I have strong doubts that this is the best solution to my
> problem…
>
> Currently I have a class called Svr_vti which holds : (amongst other
> things)
>   @ a constructor
>   @ a save() member function
>   @ a vtkImageData member object called _ImgData
>   @ a vtkXMLImageDataWriter object called _Wrtr
>   @ a reference to a DblArr called _Arr
>
> Constructor(DblArr & MyArr) performs :
>
>     _ImgData = vtkSmartPointer<vtkImageData>::New()
>     _Wrtr    = vtkSmartPointer<vtkXMLImageDataWriter>::New()
>     _Arr     = MyArr
>     //
>     _ImgData->SetDimensions(***,***,***);
>     _ImgData->AllocateScalars( VTK_DOUBLE, * );
>     _ImgData->SetOrigin(***, ***, ***);
>     _ImgData->SetSpacing(***, ***, ***)
>     //
>     _Wrtr->SetInputData( _ImgData );
>
>
> save(DblArr &) member function performs :
>
>     for each node (i,j,k) in domain :
>         double * pxl = _ImgData->GetScalarPointer(i,j,k)
>         for each component in vector<DblArr *> :
>             pxl[ind] = Arr(i,j,k, ind)
>         }
>     }
>     //
>     //The file name embeds the number of current time step
>     //Hence the file name is different each time save() is called
>     _Wrtr->SetFileName( *** );
>     _Wrtr->Write();
>
> Note : this is pseudo-code, it might contain syntax errors and/or
> abreviations
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>


-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to