8#ifndef CELLDECOMPOSER_HPP_
9#define CELLDECOMPOSER_HPP_
11#include "Space/SpaceBox.hpp"
12#include "Space/Matrix.hpp"
13#include "util/copy_compare/meta_compare.hpp"
14#include "Grid/grid_sm.hpp"
16#define CELL_DECOMPOSER 8001lu
25template<
unsigned int dim,
typename T>
56 __device__ __host__
inline T
transform(
const T(&s)[dim],
const size_t i)
const
58 return s[i] -
sh.get(i);
71 return s.
get(i) -
sh.get(i);
84 return s.template get<0>()[i] -
sh.get(i);
95 for (
size_t i = 0 ; i < dim ; i++)
96 sh.get(i) = orig.
get(i);
148template<
unsigned int dim,
typename T>
183 __device__ __host__
inline T
transform(
const T * s,
const int i)
const
185 return s[i] -
sh.get(i);
196 __device__ __host__
inline T
transform(
const T(&s)[dim],
const int i)
const
198 return s[i] -
sh.get(i);
211 return s.
get(i) -
sh.get(i);
224 return s.template get<0>()[i] -
sh.get(i);
235 for (
size_t i = 0 ; i < dim ; i++)
236 sh.get(i) = orig.
get(i);
276template<
unsigned int dim,
typename T>
307 __device__ __host__
inline T
transform(
const T(&s)[dim],
const size_t i)
const
335 return s.template get<Point<dim,T>::x>()[i];
399template<
unsigned int dim,
typename T>
423 __device__ __host__
inline T
transform(
const T * s,
const int i)
const
436 __device__ __host__
inline T
transform(
const T(&s)[dim],
const int i)
const
464 return s.template get<Point<dim,T>::x>()[i];
547template<
unsigned int dim,
typename T,
typename transform = no_transform<dim,T>>
548class CellDecomposer_sm
578 inline size_t ConvertToID(
const T (&x)[dim] ,
size_t s)
const
580 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
581 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
591 inline size_t ConvertToID(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
593 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
594 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
604 inline size_t ConvertToID_me(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
606 T cc = t.transform(x,s) / box_unit.getHigh(s) - 0.015625;
607 size_t id = openfpm::math::size_t_floor(cc) + off[s];
608 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
618 inline size_t ConvertToID_pe(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
620 T cc = t.transform(x,s) / box_unit.getHigh(s) + 0.015625;
621 size_t id = openfpm::math::size_t_floor(cc) + off[s];
622 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
632 inline size_t ConvertToID_ns(
const T (&x)[dim] ,
size_t s)
const
634 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
635 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1):id;
645 inline size_t ConvertToID_ns(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
647 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
648 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1):id;
658 template <
typename Mem>
inline size_t ConvertToID_(
const encapc<1,
Point<dim,T>,Mem> & x ,
size_t s,
size_t sc = 0)
const
660 size_t id = (size_t)(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
661 id = (
id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
671 template<
typename Ele>
inline void check_and_print_error(
const Ele & pos ,
size_t s)
const
676 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
677 ACTION_ON_ERROR(CELL_DECOMPOSER);
680 if (pos[s] < box.getLow(s) - off[s]*box_unit.getP2()[s] || pos[s] > box.getHigh(s) + off[s]*box_unit.getP2()[s])
682 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " <<
Point<dim,T>(pos).
toString() <<
" is not inside the cell space";
683 ACTION_ON_ERROR(CELL_DECOMPOSER);
689 template<
typename Ele>
inline size_t getCellDom_impl(
const Ele & pos)
const
691 check_and_print_error(pos,0);
693 size_t cell_id = ConvertToID_ns(pos,0);
695 cell_id = (cell_id == gr_cell.size(0) - off[0])?gr_cell.size(0) - off[0] - 1:cell_id;
696 cell_id = (cell_id == off[0]-1)?off[0]:cell_id;
698 cell_id -= cell_shift.get(0);
700 for (
size_t s = 1 ; s < dim ; s++)
703 check_and_print_error(pos,s);
705 size_t cell_idt = ConvertToID_ns(pos,s);
707 cell_idt = (cell_idt == gr_cell.size(s) - off[s])?gr_cell.size(s) - off[s] - 1:cell_idt;
708 cell_idt = (cell_idt == off[s]-1)?off[s]:cell_idt;
710 cell_idt -= cell_shift.get(s);
712 cell_id += gr_cell2.size_s(s-1) * cell_idt;
718 template<
typename Ele>
inline size_t getCellPad_impl(
const Ele & pos)
const
720 check_and_print_error(pos,0);
722 size_t cell_id = ConvertToID_ns(pos,0);
723 cell_id = (cell_id == off[0])?off[0]-1:cell_id;
724 cell_id = (cell_id == gr_cell.size(0) - off[0] - 1)?gr_cell.size(0) - off[0]:cell_id;
726 cell_id -= cell_shift.get(0);
728 for (
size_t s = 1 ; s < dim ; s++)
730 check_and_print_error(pos,s);
732 size_t cell_idt = ConvertToID_ns(pos,s);
733 cell_idt = (cell_idt == off[s])?off[s]-1:cell_idt;
734 cell_idt = (cell_idt == gr_cell.size(s) - off[s] - 1)?gr_cell.size(s) - off[s]:cell_idt;
736 cell_idt -= cell_shift.get(s);
738 cell_id += gr_cell2.size_s(s-1) * cell_idt;
772 mutable size_t div_wp[dim];
777 void Initialize(
const size_t pad,
const size_t (& div)[dim])
781 for (
size_t i = 0 ; i < dim ; i++)
785 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" the number of cells on each dimension must be different from zero\n";
786 ACTION_ON_ERROR(CELL_DECOMPOSER)
793 for (
size_t i = 0 ; i < dim ; i++)
799 for (
size_t i = 0 ; i < dim ; i++)
800 div_p[i] = div[i] + 2*pad;
809 for (
size_t i = 0 ; i < dim ; i++)
811 tot_n_cell *= gr_cell.
size(i);
817 for (
size_t i = 0; i < dim ; i++)
822 p_middle = box_unit.
getP2();
823 p_middle = p_middle / 2;
833 const transform & getTransform()
847 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
867 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
868 ACTION_ON_ERROR(CELL_DECOMPOSER);
873 key.
set_d(0,ConvertToID(pos,0));
875 for (
size_t s = 1 ; s < dim ; s++)
878 if ((
size_t)(t.transform(pos,s) / box_unit.
getHigh(s)) + off[s] < 0)
880 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point is not inside the cell space\n";
881 ACTION_ON_ERROR(CELL_DECOMPOSER);
884 key.
set_d(s,ConvertToID(pos,s));
905 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
906 ACTION_ON_ERROR(CELL_DECOMPOSER);
909 if (gr_cell2.
size(0) < k.get(0) + off[0] - cell_shift.
get(0))
911 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cell_shift.
get(0) <<
" bigger than cell space " << gr_cell2.
size(0) << std::endl;
912 ACTION_ON_ERROR(CELL_DECOMPOSER);
916 size_t cell_id = k.get(0) + off[0] - cell_shift.
get(0);
918 for (
size_t s = 1 ; s < dim ; s++)
921 if (gr_cell2.
size(s) < k.get(s) + off[s] - cell_shift.
get(s))
923 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cell_shift.
get(0) <<
" bigger than cell space " << gr_cell2.
size(s) << std::endl;
924 ACTION_ON_ERROR(CELL_DECOMPOSER);
927 cell_id += gr_cell2.
size_s(s-1) * (k.get(s) + off[s] -cell_shift.
get(s));
947 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
948 ACTION_ON_ERROR(CELL_DECOMPOSER);
951 if (gr_cell2.
size(0) < k.get(0) + off[0] - cell_shift.
get(0))
953 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cell_shift.
get(0) <<
" bigger than cell space " << gr_cell2.
size(0) << std::endl;
954 ACTION_ON_ERROR(CELL_DECOMPOSER);
958 size_t cell_id = k.get(0) + off[0] -cell_shift.
get(0);
960 for (
size_t s = 1 ; s < dim ; s++)
963 if (gr_cell2.
size(s) < k.get(s) + off[s] - cell_shift.
get(s))
965 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cell_shift.
get(0) <<
" bigger than cell space " << gr_cell2.
size(s) << std::endl;
966 ACTION_ON_ERROR(CELL_DECOMPOSER);
969 cell_id += gr_cell2.
size_s(s-1) * (k.get(s) + off[s] -cell_shift.
get(s));
989 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer" << std::endl;
990 ACTION_ON_ERROR(CELL_DECOMPOSER);
995 key.
set_d(0,ConvertToID_me(pos,0));
997 for (
size_t s = 1 ; s < dim ; s++)
1000 if ((
size_t)(t.transform(pos,s) / box_unit.
getHigh(s)) + off[s] < 0)
1002 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point is not inside the cell space" << std::endl;
1003 ACTION_ON_ERROR(CELL_DECOMPOSER);
1007 key.
set_d(s,ConvertToID_me(pos,s));
1025 if (tot_n_cell == 0)
1027 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer" << std::endl;
1028 ACTION_ON_ERROR(CELL_DECOMPOSER);
1033 key.
set_d(0,ConvertToID_pe(pos,0));
1035 for (
size_t s = 1 ; s < dim ; s++)
1038 if ((
size_t)(t.transform(pos,s) / box_unit.
getHigh(s)) + off[s] < 0)
1040 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point is not inside the cell space" << std::endl;
1041 ACTION_ON_ERROR(CELL_DECOMPOSER);
1045 key.
set_d(s,ConvertToID_pe(pos,s));
1063 if (tot_n_cell == 0)
1065 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer" << std::endl;
1066 ACTION_ON_ERROR(CELL_DECOMPOSER);
1071 key.
set_d(0,ConvertToID(pos,0));
1073 for (
size_t s = 1 ; s < dim ; s++)
1076 if ((
size_t)(t.transform(pos,s) / box_unit.
getHigh(s)) + off[s] < 0)
1078 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point is not inside the cell space" << std::endl;
1079 ACTION_ON_ERROR(CELL_DECOMPOSER);
1083 key.
set_d(s,ConvertToID(pos,s));
1100 inline size_t getCellDom(
const Point<dim,T> & pos)
const
1102 return getCellDom_impl<Point<dim,T>>(pos);
1117 inline size_t getCellDom(
const T (& pos)[dim])
const
1119 return getCellDom_impl<T[dim]>(pos);
1133 inline size_t getCellPad(
const Point<dim,T> & pos)
const
1135 return getCellPad_impl<Point<dim,T>>(pos);
1149 inline size_t getCellPad(
const T (& pos)[dim])
const
1151 return getCellPad_impl<T[dim]>(pos);
1163 inline size_t getCell(
const T (& pos)[dim])
const
1166 if (tot_n_cell == 0)
1168 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
1169 ACTION_ON_ERROR(CELL_DECOMPOSER);
1172 if (pos[0] < box.
getLow(0) - off[0]*box_unit.
getP2()[0] || pos[0] > box.
getHigh(0) + off[0]*box_unit.
getP2()[0])
1174 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << toPointString(pos) <<
" is not inside the cell space";
1175 ACTION_ON_ERROR(CELL_DECOMPOSER);
1179 size_t cell_id = ConvertToID(pos,0);
1181 for (
size_t s = 1 ; s < dim ; s++)
1184 if (pos[s] < box.
getLow(s) - off[s]*box_unit.
getP2()[s] || pos[s] > box.
getHigh(s) + off[s]*box_unit.
getP2()[s])
1186 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << toPointString(pos) <<
" is not inside the cell space";
1187 ACTION_ON_ERROR(CELL_DECOMPOSER);
1190 cell_id += gr_cell2.
size_s(s-1) * ConvertToID(pos,s);
1208 if (tot_n_cell == 0)
1210 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
1211 ACTION_ON_ERROR(CELL_DECOMPOSER);
1216 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << pos.
toPointString() <<
" is not inside the cell space";
1217 ACTION_ON_ERROR(CELL_DECOMPOSER);
1221 size_t cell_id = ConvertToID(pos,0);
1223 for (
size_t s = 1 ; s < dim ; s++)
1228 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << pos.
toPointString() <<
" is not inside the cell space";
1229 ACTION_ON_ERROR(CELL_DECOMPOSER);
1233 cell_id += gr_cell2.
size_s(s-1) * ConvertToID(pos,s);
1248 template<
typename Mem>
inline size_t getCell(
const encapc<1,
Point<dim,T>,Mem> & pos)
const
1252 if (tot_n_cell == 0)
1254 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
1255 ACTION_ON_ERROR(CELL_DECOMPOSER);
1258 if (pos.template get<0>()[0] < box.
getLow(0) - off[0]*box_unit.
getP2()[0] || pos.template get<0>()[0] > box.
getHigh(0) + off[0]*box_unit.
getP2()[0])
1260 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << toPointString(pos) <<
" is not inside the cell space " << box.
toString() << std::endl;
1261 ACTION_ON_ERROR(CELL_DECOMPOSER);
1265 size_t cell_id = ConvertToID_(pos,0);
1267 for (
size_t s = 1 ; s < dim ; s++)
1271 if (pos.template get<0>()[s] < box.
getLow(s) - off[s]*box_unit.
getP2()[s] || pos.template get<0>()[s] > box.
getHigh(s) + off[s]*box_unit.
getP2()[s])
1273 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << toPointString(pos) <<
" is not inside the cell space";
1274 ACTION_ON_ERROR(CELL_DECOMPOSER);
1277 cell_id += gr_cell2.
size_s(s-1) * ConvertToID_(pos,s);
1328 bx.
setP2(getCellGrid(p2));
1329 bx.
setP1(getCellGrid(p1));
1341 inline void setDimensions(
const Box<dim,T> & box,
const size_t (&div)[dim],
const size_t (&div2)[dim],
const size_t pad,
Point<dim,long int> cell_shift)
1345 t.setTransform(mat,box.
getP1());
1348 Initialize(pad,div);
1352 for (
size_t i = 0 ; i < dim ; i++)
1353 cells[i] = div2[i] + 2*pad;
1357 for (
size_t i = 0 ; i < dim ; i++)
1358 this->cell_shift.
get(i) = cell_shift.
get(i) - off[i];
1368 inline void setDimensions(
const Box<dim,T> & box,
const size_t (&div)[dim],
const size_t pad)
1372 t.setTransform(mat,box.
getP1());
1374 Initialize(pad,div);
1375 this->cell_shift = 0;
1390 t.setTransform(mat,box.
getP1());
1393 Initialize(pad,div);
1397 size_t div_with_off[dim];
1399 for(
size_t i = 0 ; i < dim ; i++)
1400 div_with_off[i] = div2[i] + 2*off[i];
1404 for (
size_t i = 0 ; i < dim ; i++)
1405 this->cell_shift.
get(i) = cell_shift.
get(i) - off[i];
1417 inline void setDimensions(
const Box<dim,T> & box,
const size_t (&div)[dim],
const Matrix<dim,T> & mat,
const size_t pad)
1419 t.setTransform(mat,box.
getP1());
1421 Initialize(pad,div);
1422 this->cell_shift = 0;
1437 inline void setDimensions(
const CellDecomposer_sm<dim,T,transform> & cd,
const Box<dim,size_t> & cell_extension)
1439 this->cell_shift = 0;
1443 t.setTransform(cd.getMat(),cd.getOrig());
1452 for (
size_t i = 0 ; i < dim ; i++)
1454 if (pad < cell_extension.
getLow(i))
1455 pad = cell_extension.
getLow(i);
1456 else if (pad > cell_extension.
getHigh(i))
1457 pad = cell_extension.
getHigh(i);
1464 for (
size_t i = 0 ; i < dim ; i++)
1465 sz_div[i] = cd.gr_cell.size(i) - 2*cd.off[i];
1467 Initialize(pad,sz_div);
1500 :t(
Matrix<dim,T>::identity(),box.getP1()),box(box),gr_cell()
1534 CellDecomposer_sm(
const SpaceBox<dim,T> & box,
const size_t (&div)[dim],
const size_t pad)
1535 :t(
Matrix<dim,T>::identity(),box.getP1()),box(box),gr_cell(div)
1537 Initialize(pad,div);
1547 CellDecomposer_sm(
const CellDecomposer_sm<dim,T,transform> & cd,
Box<dim,size_t> & ext)
1548 :t(
Matrix<dim,T>::identity(),cd.getOrig())
1550 setDimensions(cd,ext);
1556 :t(
Matrix<dim,T>::identity(),
Point<dim,T>::zero_p()),tot_n_cell(0)
1642 b /= getCellBox().getP2();
1656 for (
size_t i = 0 ; i < dim ; i++)
1667 for (
size_t i = 0 ; i < dim ; i++)
1672 if (bc[i] == NON_PERIODIC)
1688 if (bc[i] == NON_PERIODIC)
1768 b /= getCellBox().getP2();
1779 for (
size_t i = 0 ; i < dim ; i++) {b.setHigh(i,b.getHigh(i)-1);}
1788 for (
size_t i = 0 ; i < dim ; i++)
1793 if (bc[i] == NON_PERIODIC)
1809 if (bc[i] == NON_PERIODIC)
1886 for (
size_t i = 0 ; i < dim ; i++)
1888 if ((
long int)gr_cell.
size(i) - (
long int)off[i] == b_d.
getLow(i))
1890 else if ((
long int)off[i] == b_d.
getLow(i))
1895 if ((
long int)gr_cell.
size(i) - (
long int)off[i] == b_d.
getHigh(i))
1897 else if ((
long int)off[i] == b_d.
getHigh(i))
1957 for (
size_t i = 0 ; i < dim ; i++)
1959 if ((
long int)gr_cell.
size(i) - (
long int)off[i] == b_d.
getLow(i))
1961 else if ((
long int)off[i] == b_d.
getLow(i))
1966 if ((
long int)gr_cell.
size(i) - (
long int)off[i] == b_d.
getHigh(i))
1968 else if ((
long int)off[i] == b_d.
getHigh(i))
1982 const size_t (& getDiv()
const)[dim]
1993 const size_t (& getDivWP()
const)[dim]
1995 for (
size_t i = 0 ; i < dim ; i++)
1996 {div_wp[i] = gr_cell.
getSize()[i] - 2*getPadding(i);}
2016 inline void swap(CellDecomposer_sm<dim,T,transform> & cd)
2019 p_middle.swap(cd.p_middle);
2027 size_t tot_n_cell_t = tot_n_cell;
2028 tot_n_cell = cd.tot_n_cell;
2029 cd.tot_n_cell = tot_n_cell_t;
2032 box_unit.
swap(cd.box_unit);
2033 gr_cell.
swap(cd.gr_cell);
2034 gr_cell2.
swap(cd.gr_cell2);
2036 for (
size_t i = 0 ; i < dim ; i++)
2038 size_t off_t = off[i];
2042 size_t cs_t = cell_shift.
get(i);
2043 cell_shift.
get(i) = cd.cell_shift.get(i);
2044 cd.cell_shift.get(i) = cs_t;
2055 inline bool operator==(
const CellDecomposer_sm<dim,T,transform> & cd)
2063 if (tot_n_cell != cd.tot_n_cell)
2069 if (box_unit != cd.box_unit)
2072 if (gr_cell != cd.gr_cell)
2075 if (gr_cell2 != cd.gr_cell2)
2078 for (
size_t i = 0 ; i < dim ; i++)
2080 if (off[i] != cd.off[i])
2083 if (cell_shift.
get(i) != cd.cell_shift.get(i))
2097 inline bool operator!=(
const CellDecomposer_sm<dim,T,transform> & cd)
2099 return ! this->operator==(cd);
2109 size_t getPadding(
size_t i)
const
2120 size_t (& getPadding())[dim]
2137 for (
size_t i = 0 ; i < dim ; i++)
2157 for (
size_t i = 0 ; i < dim ; i++)
2159 key.
set_d(i,cell_shift.
get(i) + gr_cell2.
size(i) - 2*getPadding(i) - 1);
2174 for (
size_t i = 0 ; i < dim ; i++)
2175 k.set_d(i,cell_shift.
get(i));
This class represent an N-dimensional box.
Point< dim, T > getP2() const
Get the point p2.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
std::string toString() const
Produce a string from the object.
__device__ __host__ T getHigh(int i) const
get the high interval of the box
void setP2(const grid_key_dx< dim > &p2)
Set the point P2 of the box.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
Point< dim, T > getP1() const
Get the point p1.
void setP1(const grid_key_dx< dim > &p1)
Set the point P1 of the box.
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
void swap(Box< dim, T > &b)
exchange the data of two boxes
This class implement an NxN (dense) matrix.
static Matrix< dim, T > identity()
Identity matrix.
This class implement the point shape in an N-dimensional space.
std::string toPointString() const
Convert the point into a string.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
std::string toString() const
Return the string with the point coordinate.
This class represent an N-dimensional box.
grid_key_dx is the key to access any element in the grid
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
void setDimensions(const size_t(&dims)[N])
Reset the dimension of the grid.
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
__device__ __host__ size_t size_s(unsigned int i) const
void swap(grid_sm< N, T > &g)
swap the grid_sm informations
__device__ __host__ size_t size() const
Return the size of the grid.
shift_only()
Default constructor.
Point< dim, T > sh
Shift point.
bool operator!=(const shift< dim, T > &s)
It return true if the shift is different.
__device__ __host__ const Point< dim, T > & getOrig() const
Get the shift vector.
void setTransform(const Matrix< dim, T > &mat, const Point< dim, T > &orig)
Set the transformation Matrix and shift.
shift_only(const Matrix< dim, T > &t, const Point< dim, T > &s)
Constructor.
__device__ __host__ T transform(const T *s, const int i) const
Shift the point transformation.
__device__ __host__ T transform(const encapc< 1, Point< dim, T >, Mem > &s, const int i) const
Shift the point transformation.
bool operator==(const shift< dim, T > &s)
It return true if the shift match.
__device__ __host__ T transform(const Point< dim, T > &s, const int i) const
Shift the point transformation.
__device__ __host__ T transform(const T(&s)[dim], const int i) const
Shift the point transformation.
__device__ __host__ T transform(const Point< dim, T > &s, const size_t i) const
Shift the point transformation.
const Point< dim, T > & getOrig() const
Get the shift vector.
Matrix< dim, T > mat
Matrix transformation.
__device__ __host__ T transform(const encapc< 1, Point< dim, T >, Mem > &s, const size_t i) const
Shift the point transformation.
bool operator==(const shift< dim, T > &s)
It return true if the shift match.
__device__ __host__ T transform(const T(&s)[dim], const size_t i) const
Shift the point transformation.
__device__ __host__ shift(const Matrix< dim, T > &t, const Point< dim, T > &s)
Constructor.
bool operator!=(const shift< dim, T > &s)
It return true if the shift is different.
__device__ __host__ void setTransform(const Matrix< dim, T > &mat, const Point< dim, T > &orig)
Set the transformation Matrix and shift.
Point< dim, T > sh
Shift point.
const Matrix< dim, T > & getMat() const
Get the transformation Matrix.