OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
staggered_dist_grid_copy.hpp
1/*
2 * staggered_grid_dist_copy.hpp
3 *
4 * Created on: Apr 9, 2016
5 * Author: i-bird
6 */
7
8#ifndef SRC_GRID_STAGGERED_DIST_GRID_COPY_HPP_
9#define SRC_GRID_STAGGERED_DIST_GRID_COPY_HPP_
10
19template<typename copy_type, typename Tsrc, typename Tdst, typename Grid_src, typename Grid_dst, int sa>
21{
22 inline static void interp(Grid_dst & grid_dst, const grid_dist_key_dx<Grid_dst::dims> & key_dst ,const Grid_src & x, const grid_dist_key_dx<Grid_src::dims> & key_src, const openfpm::vector<std::vector<comb<Grid_src::dims>>> & interp_pos)
23 {
24 typedef typename boost::mpl::at<Tdst,Tsrc>::type Tdst_ele;
25
26 copy_type division = 0.0;
27
28 for (size_t i = 0 ; i < interp_pos.get(0).size() ; i++)
29 {
30 auto key_m = key_src.move(interp_pos.get(0)[i]);
31
32 grid_dst.template get<Tdst_ele::value>(key_dst) += x.template get<Tsrc::value>(key_m);
33
34 division += 1.0;
35 }
36 grid_dst.template get<Tdst_ele::value>(key_dst) /= division;
37 }
38};
39
49template<typename copy_type, typename Tsrc, typename Tdst, typename Grid_src, typename Grid_dst>
50struct interp_ele_sca_array<copy_type,Tsrc,Tdst,Grid_src,Grid_dst,1>
51{
52 inline static void interp(Grid_dst & grid_dst,
53 const grid_dist_key_dx<Grid_dst::dims> & key_dst ,
54 const Grid_src & x,
56 const openfpm::vector<std::vector<comb<Grid_src::dims>>> & interp_pos)
57 {
58 typename std::remove_all_extents<copy_type>::type division;
59 typedef typename boost::mpl::at<Tdst,Tsrc>::type Tdst_ele;
60
61 for (size_t j = 0 ; j < std::extent<copy_type>::value ; j++)
62 {
63 division = 0.0;
64 for (size_t i = 0 ; i < interp_pos.get(j).size() ; i++)
65 {
66 auto key_m = key_src.move(interp_pos.get(j)[i]);
67
68 grid_dst.template get<Tdst_ele::value>(key_dst)[j] += x.template get<Tsrc::value>(key_m)[j];
69
70 division += 1.0;
71 }
72 grid_dst.template get<Tsrc::value>(key_dst)[j] /= division;
73 }
74 }
75};
76
88template<typename Tdst, typename Grid_dst, typename Grid_src, unsigned int nst_pos>
90{
93
95 Grid_dst & grid_dst;
96
99
102
104 const Grid_src & x;
105
118 Grid_dst & grid_dst,
119 const Grid_src & x,
121 openfpm::vector<std::vector<comb<Grid_src::dims>>> (&interp_pos)[nst_pos])
122 :key_dst(key_dst),grid_dst(grid_dst),key_src(key_src),interp_pos(interp_pos),x(x){};
123
124
125#ifdef SE_CLASS1
132 inline interp_ele(const grid_dist_key_dx<Grid_dst::dims> & key_dst, Grid_dst && grid_dst, const Grid_src & x, const grid_dist_key_dx<Grid_src::dims> & key_src, openfpm::vector<std::vector<comb<Grid_src::dims>>> (&interp_pos)[nst_pos])
133 :key_dst(key_dst),grid_dst(grid_dst),key_src(key_src),interp_pos(interp_pos),x(x)
134 {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object";};
135#endif
136
142 template<typename Tsrc>
143 inline void operator()(Tsrc& t)
144 {
145 // This is the type of the object we have to copy
146 typedef typename boost::mpl::at_c<typename Grid_dst::value_type::type,Tsrc::value>::type copy_type;
147
149 }
150};
151
152
153#endif /* SRC_GRID_STAGGERED_DIST_GRID_COPY_HPP_ */
Grid key for a distributed grid.
grid_dist_key_dx< dim, base_key > move(size_t i, int s) const
Create a new key moving the old one.
Implementation of 1-D std::vector like structure.
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35
this class is a functor for "for_each" algorithm
Grid_dst & grid_dst
destination grid
const grid_dist_key_dx< Grid_dst::dims > key_dst
destination point
void operator()(Tsrc &t)
Interpolate each point in the destination grid for each property.
interp_ele(const grid_dist_key_dx< Grid_dst::dims > &key_dst, Grid_dst &grid_dst, const Grid_src &x, const grid_dist_key_dx< Grid_src::dims > &key_src, openfpm::vector< std::vector< comb< Grid_src::dims > > >(&interp_pos)[nst_pos])
constructor
const Grid_src & x
source grid
grid_dist_key_dx< Grid_dst::dims > key_src
source point