Data

Data

Data class is associated with grids. Constructors for Data require Grid objects as arguments. For instance:

  RegularGrid<float> GridT(Nt), GridX(Nx), GridY(Ny), GridZ(Nz);
  Data<double, 4, float> ConcIn(GridT, GridZ, GridY, GridX);

The first template parameter for Data is the type of values to be stored. The second template parameter is the number of dimensions (from 1 to 10). The last template parameter is optional and is the type of grid values. If this third paramer is not provided, then grid values must be of the same type as data values. In any case, all grids must have the same value type. An instance of Data may be resized by Resize in the same way. Grids associated with the instance may be changed thanks to ResizeGrid, which doesn't resize the data array associated with the instance.

It is possible to define an instance of Data with integers instead of grids. In this case, grids in each direction are assumed to be regular grids (and they are allocated automatically).

  Data<double, 4> ConcIn(10, 5, 7, 18);

Some methods

Data is a high-level class with several convenient methods. The documentation should be enough to understand how each method works. However let us point out a few methods.

SubData

SubData enables to extract values. Example example3.cpp shows SubData abilities:

#define SELDONDATA_DEBUG_LEVEL_4

#include "SeldonData.hxx"
using namespace SeldonData;

int main()
{

  TRY;

  RegularGrid<double> G1(1);
  RegularGrid<double> G2(2);
  RegularGrid<double> G3(3);
  Data<double, 1> D1(G1);
  Data<double, 2> D2(G2, G2), D3(G2, G3);

  D3.Fill(1.5);

  D1.SubData(D3, Range(0), 1);
  D2.SubData(D3, Range::all(), Range(1, 2));

  END;

  return 0;

}

Range(0) means [0..0]. Warning: Range(0) is different from 0. In D1.SubData(D3, Range(0), 1), the integer 1 mutes the second dimension (D1 is a 1D array whereas D2 is a 2D array). In a more general case, D1.SubData(D3, Range(a, b), 1) would mean D1(:) = D3(a:b, 1); in the previous case, it is: D1(:) = D3(0:0, 1) (notice that Range(0) is the same as Range(0, 0)). So, ranges are vectors that determine a subset, and integers imply a projection reducing the output dimension. So, D1.SubData(D3, 0, 1) is not correct because D1 is a one-dimensional data, not a zero-dimensional data!

The following makefile may be used (command: make example3):

CC	=	g++
# Put the paths to Blitz++, Talos and SeldonData.
INCPATH	=	-I/home/vivien/codes/MyBlitz++-0.7 \
		-I/home/vivien/codes/Talos-0.3 \
		-I/home/vivien/codes/SeldonData-1.4
LINK	=	g++

TARGETS	=	example1 example2 example3

all: $(TARGETS)

$(TARGETS): % : %.o
	$(LINK) -o $@ $<

%.o : %.cpp
	$(CC) $(INCPATH) -c -o $@ $<

clean:
	rm -f $(TARGETS) $(TARGETS:%=%.o)

operator[]

operator[] returns a reference to a grid. For example, one may get the i-th grid of an instance D of Data through D[i-1].