[Paraview-developers] minimizing memory for reader (or catalyst)

Mark Olesen Mark.Olesen at esi-group.com
Wed May 24 11:04:53 EDT 2017


Thank Andy for the extra information - the first tests (in paraview) seems to look pretty good. I had a smile on my face watching it run!

For general documentation's sake, here's the bookkeeping organization that I use. With more comments below.

    //- Bookkeeping for internal caching.
    //  Retain an original copy of the geometry as well as a shallow copy
    //  with the output fields.
    //  The original copy is reused for different timesteps etc.
    template<class DataType>
    class foamVtkCaching
    {
    public:
        typedef DataType dataType;

        //- The geometry, without any cell/point data
        vtkSmartPointer<dataType> vtkgeom;

        //- The shallow-copy of geometry, plus additional data
        vtkSmartPointer<dataType> dataset;

        //- Return a shallow copy of vtkgeom for manipulation
        vtkSmartPointer<dataType> getCopy() const
        {
            auto copy = vtkSmartPointer<dataType>::New();
            copy->ShallowCopy(vtkgeom);
            return copy;
        }

        //- Make a shallow copy of vtkgeom into dataset
        void reuse()
        {
            dataset = vtkSmartPointer<dataType>::New();
            dataset->ShallowCopy(vtkgeom);
        }

        //- Set the geometry and make a shallow copy to dataset
        void set(vtkSmartPointer<dataType> geom)
        {
            vtkgeom = geom;
            reuse();
        }
    };


Following your comment

> Shallow-copy will allow some of the data to be different. For example, shallow-copying a vtkUnstructuredGrid would initially have them looking identical. The source and target unstructured grids would be sharing references to the same arrays but some of the data members (e.g. PointData, CellData, FieldData) would be separate. Thus, after the shallow copy you could add in another point data array to the target unstructured grid and this would not affect the source unstructured grid. Similarly, you could replace an array in the target grid and not affect the source grid but if you went and got a specific array from the target grid and changed some values in there that change would also be reflected in the source grid.


Case 1: Completely new geometry (eg, on startup, or topology changes).
====
Create vtkUnstructuredGrid, vtkPolyData as geometry only (no cell/point data).
Use the set() method to make cached copy and a shallow copy of that as my 'dataset'.
Add all cell/point data onto the 'dataset'.

Case 2: Moving points, no topology change.
====
Use the getCopy() method to make a shallow copy of the geometry structure.
Replace the points with the newly moved ones. Call set() to cache this 'moved' geometry and create the 'dataset' for adding cell/point data etc.

Case 3: No change
====
Simply use the reuse() method to make a shallow copy of the cached geometry as my 'dataset'.


At the moment, it seems to work OK.


Thanks again for the pointers, and have no worries - I'll certainly be back with more questions!

Cheers,
/mark



More information about the Paraview-developers mailing list