OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
23template<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
53template<typename copy_type, typename T, typename Ev, typename Eqs_sys>
54struct 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
90template<typename Eqs_sys, typename S, typename Ev>
92{
95
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)
124
125
126#ifdef SE_CLASS1
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_ */
Grid key for a distributed grid.
Struct that give functionalities on array extensions.
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.
Copy scalar elements.
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.
this class is a functor for "for_each" algorithm
S & grid_dst
destination grid
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.
size_t prp_id
counter
const grid_dist_key_dx< Eqs_sys::dims > key
destination grid element
const Ev & x
source vector
size_t lin_id
source element inside the vector
void operator()(T &t)
It call the copy function for each property.
size_t gs_size
It is basically the number of grid points the vector has inside.