Basic objects
The definition of a vector, grid, or graph, define how your data is organized, but does not define what is storing. For example a vector can store float, double, long int, or even more complex objects, same for grid, each point in the grid can store generic objects, same for Graph each vertex and edge can store generic objects. Generic object has two formats, here an example
/////////////////////////////////////
// C++ FORMAT
/////////////////////////////////////
template<typename T> class Point_orig
{
public:
T x;
T y;
T z;
T s;
T v[3];
T t[3][3];
// setter method
inline void setx(T x_) {x = x_;};
inline void sety(T y_) {y = y_;};
inline void setz(T z_) {z = z_;};
inline void sets(T s_) {s = s_;};
};
////////////////////////////////////
// OPENFPM DATA STRUCTURE FORMAT
////////////////////////////////////
template<typename T> class Point_test
{
public:
typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
type data;
static const unsigned int x = 0;
static const unsigned int y = 1;
static const unsigned int z = 2;
static const unsigned int s = 3;
static const unsigned int v = 4;
static const unsigned int t = 5;
static const unsigned int max_prop = 6;
// Setter method
inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
};
The two definitions are equivalent, but the second one give the possibility to analyse/parse the members of the basic data. This can be useful in several situation, when the memory representation (Mappings) depend from the basic object, or for IO to produce output that require to go through each element of the structure to produce a nice output, or VCluster to check that the data structure you are sending contain no pointers. In any case all the structures implemented in OpenFPM_data must work at least with the OpenFPM data structure format. In case you are going to implementing a new structure inside OpenFPM_data, consider to use already implemented structure like vector or grid that already implements the capabilities that we are going to present in the following sections.