OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
Vector_util.hpp
1 /*
2  * Vector_util.hpp
3  *
4  * Created on: Dec 7, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UTIL_HPP_
9 #define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UTIL_HPP_
10 
11 #include "Grid/grid_dist_key.hpp"
12 #include "Space/Shape/HyperCube.hpp"
13 #include "util/mul_array_extents.hpp"
14 
23 template<typename copy_type, typename T, typename Ev, typename Eqs_sys, int sa>
25 {
38  template<typename Grid> inline static void copy(Grid & grid_dst, const grid_dist_key_dx<Eqs_sys::dims> & key, const Ev & x,size_t lin_id, size_t base_id, size_t gs_size)
39  {
40  grid_dst.template get<T::value>(key) = x(lin_id * Eqs_sys::nvar + base_id);
41  }
42 };
43 
53 template<typename copy_type, typename T, typename Ev, typename Eqs_sys>
54 struct copy_ele_sca_array<copy_type,T,Ev,Eqs_sys,1>
55 {
68  template<typename Grid> inline static void copy(Grid & grid_dst, const grid_dist_key_dx<Eqs_sys::dims> & key, const Ev & x,size_t lin_id, size_t base_id, size_t gs_size)
69  {
70  for (size_t i = 0 ; i < std::extent<copy_type>::value ; i++)
71  {
72  grid_dst.template get<T::value>(key)[i] = x(lin_id * Eqs_sys::nvar + base_id + i);
73  }
74  }
75 };
76 
77 
90 template<typename Eqs_sys, typename S, typename Ev>
91 struct copy_ele
92 {
95 
97  S & grid_dst;
98 
100  size_t lin_id;
101 
103  size_t prp_id;
104 
106  size_t gs_size;
107 
109  const Ev & x;
110 
122  inline copy_ele(const grid_dist_key_dx<Eqs_sys::dims> & key, S & grid_dst, const Ev & x, size_t lin_id, size_t gs_size)
123  :key(key),grid_dst(grid_dst),lin_id(lin_id),prp_id(0),gs_size(gs_size),x(x){};
124 
125 
126 #ifdef SE_CLASS1
127 
134  :key(key),grid_dst(grid_dst),x(x)
135  {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object";};
136 #endif
137 
143  template<typename T>
144  inline void operator()(T& t)
145  {
146  // This is the type of the object we have to copy
147  typedef typename boost::mpl::at_c<typename S::value_type::type,T::value>::type copy_type;
148 
151  }
152 };
153 
154 
155 #endif /* OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UTIL_HPP_ */
const grid_dist_key_dx< Eqs_sys::dims > key
destination grid element
Definition: Vector_util.hpp:94
static void copy(Grid &grid_dst, const grid_dist_key_dx< Eqs_sys::dims > &key, const Ev &x, size_t lin_id, size_t base_id, size_t gs_size)
Constructor.
Definition: Vector_util.hpp:68
size_t gs_size
It is basically the number of grid points the vector has inside.
static void copy(Grid &grid_dst, const grid_dist_key_dx< Eqs_sys::dims > &key, const Ev &x, size_t lin_id, size_t base_id, size_t gs_size)
Constructor.
Definition: Vector_util.hpp:38
size_t prp_id
counter
S & grid_dst
destination grid
Definition: Vector_util.hpp:97
void operator()(T &t)
It call the copy function for each property.
const Ev & x
source vector
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
Struct that give functionalities on array extensions.
Copy scalar elements.
Definition: Vector_util.hpp:24
size_t lin_id
source element inside the vector
copy_ele(const grid_dist_key_dx< Eqs_sys::dims > &key, S &grid_dst, const Ev &x, size_t lin_id, size_t gs_size)
Constructor.
this class is a functor for "for_each" algorithm
Definition: Vector_util.hpp:91