8 #ifndef CELLDECOMPOSER_HPP_
9 #define CELLDECOMPOSER_HPP_
11 #include "Space/Ghost.hpp"
12 #include "Space/Shape/Box.hpp"
13 #include "Space/Matrix.hpp"
14 #include "util/copy_compare/meta_compare.hpp"
15 #include "Grid/grid_sm.hpp"
17 #define CELL_DECOMPOSER 8001lu
26 template<
unsigned int dim,
typename T>
57 __device__ __host__
inline T
transform(
const T(&s)[dim],
const size_t i)
const
59 return s[i] -
sh.get(i);
72 return s.
get(i) -
sh.get(i);
85 return s.template get<0>()[i] -
sh.get(i);
96 for (
size_t i = 0 ; i < dim ; i++)
97 sh.get(i) = orig.
get(i);
149 template<
unsigned int dim,
typename T>
184 __device__ __host__
inline T
transform(
const T * s,
const int i)
const
186 return s[i] -
sh.get(i);
197 __device__ __host__
inline T
transform(
const T(&s)[dim],
const int i)
const
199 return s[i] -
sh.get(i);
212 return s.
get(i) -
sh.get(i);
225 return s.template get<0>()[i] -
sh.get(i);
236 for (
size_t i = 0 ; i < dim ; i++)
237 sh.get(i) = orig.
get(i);
277 template<
unsigned int dim,
typename T>
308 __device__ __host__
inline T
transform(
const T(&s)[dim],
const size_t i)
const
336 return s.template get<Point<dim,T>::x>()[i];
400 template<
unsigned int dim,
typename T>
424 __device__ __host__
inline T
transform(
const T * s,
const int i)
const
437 __device__ __host__
inline T
transform(
const T(&s)[dim],
const int i)
const
465 return s.template get<Point<dim,T>::x>()[i];
548 template<
unsigned int dim,
typename T,
typename transform_type = no_transform<dim,T>>
549 class CellDecomposer_sm
571 transform_type pointTransform;
579 inline size_t ConvertToID(
const T (&x)[dim] ,
size_t s)
const
581 size_t id = openfpm::math::size_t_floor(pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s)) + off[s];
582 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1-cellShift.get(s)):
id-cellShift.get(s);
592 inline size_t ConvertToID(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
594 size_t id = openfpm::math::size_t_floor(pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s)) + off[s];
595 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1-cellShift.get(s)):
id-cellShift.get(s);
605 inline size_t ConvertToID_me(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
607 T cc = pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s) - 0.015625;
608 size_t id = openfpm::math::size_t_floor(cc) + off[s];
609 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1-cellShift.get(s)):
id-cellShift.get(s);
619 inline size_t ConvertToID_pe(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
621 T cc = pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s) + 0.015625;
622 size_t id = openfpm::math::size_t_floor(cc) + off[s];
623 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1-cellShift.get(s)):
id-cellShift.get(s);
633 inline size_t ConvertToID_ns(
const T (&x)[dim] ,
size_t s)
const
635 size_t id = openfpm::math::size_t_floor(pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s)) + off[s];
636 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1):
id;
646 inline size_t ConvertToID_ns(
const Point<dim,T> & x ,
size_t s,
size_t sc = 0)
const
648 size_t id = openfpm::math::size_t_floor(pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s)) + off[s];
649 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1):
id;
659 template <
typename Mem>
inline size_t ConvertToID_(
const encapc<1,
Point<dim,T>,Mem> & x ,
size_t s,
size_t sc = 0)
const
661 size_t id = (size_t)(pointTransform.transform(x,s) / unitCellSpaceBox.getHigh(s)) + off[s];
662 id = (
id >= cellListGrid.size(s))?(cellListGrid.size(s)-1-cellShift.get(s)):
id-cellShift.get(s);
672 template<
typename Ele>
inline void check_and_print_error(
const Ele & pos ,
size_t s)
const
675 if (cellTotalCount == 0)
677 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
678 ACTION_ON_ERROR(CELL_DECOMPOSER);
681 if (pos[s] < cellListSpaceBox.getLow(s) - off[s]*unitCellSpaceBox.getP2()[s] || pos[s] > cellListSpaceBox.getHigh(s) + off[s]*unitCellSpaceBox.getP2()[s])
683 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " <<
Point<dim,T>(pos).
toString() <<
" is not inside the cell space";
684 ACTION_ON_ERROR(CELL_DECOMPOSER);
690 template<
typename Ele>
inline size_t getCellDom_impl(
const Ele & pos)
const
692 check_and_print_error(pos,0);
694 size_t cell_id = ConvertToID_ns(pos,0);
696 cell_id = (cell_id == cellListGrid.size(0) - off[0])?cellListGrid.size(0) - off[0] - 1:cell_id;
697 cell_id = (cell_id == off[0]-1)?off[0]:cell_id;
699 cell_id -= cellShift.get(0);
701 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 == cellListGrid.size(s) - off[s])?cellListGrid.size(s) - off[s] - 1:cell_idt;
708 cell_idt = (cell_idt == off[s]-1)?off[s]:cell_idt;
710 cell_idt -= cellShift.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);
724 cell_id = (cell_id == off[0])?off[0]-1:cell_id;
725 cell_id = (cell_id == cellListGrid.size(0) - off[0] - 1)?cellListGrid.size(0) - off[0]:cell_id;
727 cell_id -= cellShift.get(0);
729 for (
size_t s = 1 ; s < dim ; s++)
731 check_and_print_error(pos,s);
733 size_t cell_idt = ConvertToID_ns(pos,s);
734 cell_idt = (cell_idt == off[s])?off[s]-1:cell_idt;
735 cell_idt = (cell_idt == cellListGrid.size(s) - off[s] - 1)?cellListGrid.size(s) - off[s]:cell_idt;
737 cell_idt -= cellShift.get(s);
739 cell_id += gr_cell2.size_s(s-1) * cell_idt;
749 size_t cellTotalCount;
773 mutable size_t div_wp[dim];
778 void Initialize(
const size_t pad,
const size_t (& div)[dim])
782 for (
size_t i = 0 ; i < dim ; i++)
786 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" the number of cells on each dimension must be different from zero\n";
787 ACTION_ON_ERROR(CELL_DECOMPOSER)
794 for (
size_t i = 0 ; i < dim ; i++)
800 for (
size_t i = 0 ; i < dim ; i++)
801 div_p[i] = div[i] + 2*pad;
811 for (
size_t i = 0 ; i < dim ; i++)
813 cellTotalCount *= cellListGrid.
size(i);
814 unitCellSpaceBox.
setHigh(i,(cellListSpaceBox.
getHigh(i) - cellListSpaceBox.
getLow(i)) / (cellListGrid.
size(i)- 2*pad) );
817 for (
size_t i = 0; i < dim ; i++)
822 p_middle = unitCellSpaceBox.
getP2();
823 p_middle = p_middle / 2;
833 const transform_type & getTransform()
835 return pointTransform;
846 if (cellTotalCount == 0)
847 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
865 if (cellTotalCount == 0)
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)(pointTransform.transform(pos,s) / unitCellSpaceBox.
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));
903 if (cellTotalCount == 0)
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] - cellShift.
get(0))
911 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cellShift.
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] - cellShift.
get(0);
918 for (
size_t s = 1 ; s < dim ; s++)
921 if (gr_cell2.
size(s) < k.get(s) + off[s] - cellShift.
get(s))
923 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cellShift.
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] -cellShift.
get(s));
945 if (cellTotalCount == 0)
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] - cellShift.
get(0))
953 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cellShift.
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] -cellShift.
get(0);
960 for (
size_t s = 1 ; s < dim ; s++)
963 if (gr_cell2.
size(s) < k.get(s) + off[s] - cellShift.
get(s))
965 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" cell coordinate 0 = " << k.get(0) + off[0] - cellShift.
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] -cellShift.
get(s));
987 if (cellTotalCount == 0)
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)(pointTransform.transform(pos,s) / unitCellSpaceBox.
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 (cellTotalCount == 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)(pointTransform.transform(pos,s) / unitCellSpaceBox.
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 (cellTotalCount == 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)(pointTransform.transform(pos,s) / unitCellSpaceBox.
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);
1164 inline size_t getCell(
const T (& pos)[dim])
const
1167 if (cellTotalCount == 0)
1169 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
1170 ACTION_ON_ERROR(CELL_DECOMPOSER);
1174 size_t cell_id = ConvertToID(pos,0);
1176 for (
size_t s = 1 ; s < dim ; s++)
1179 if (pos[s] < cellListSpaceBox.
getLow(s) - off[s]*unitCellSpaceBox.
getP2()[s] || pos[s] > cellListSpaceBox.
getHigh(s) + off[s]*unitCellSpaceBox.
getP2()[s])
1182 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << toPointString(pos) <<
" is not inside the cell space";
1183 ACTION_ON_ERROR(CELL_DECOMPOSER);
1186 cell_id += gr_cell2.
size_s(s-1) * ConvertToID(pos,s);
1205 if (cellTotalCount == 0)
1207 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
1208 ACTION_ON_ERROR(CELL_DECOMPOSER);
1212 size_t cell_id = ConvertToID(pos,0);
1214 for (
size_t s = 1 ; s < dim ; s++)
1217 if (pos.
get(s) < cellListSpaceBox.
getLow(s) - off[s]*unitCellSpaceBox.
getP2()[s] || pos.
get(s) > cellListSpaceBox.
getHigh(s) + off[s]*unitCellSpaceBox.
getP2()[s])
1220 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << pos.
toPointString() <<
" is not inside the cell space";
1221 ACTION_ON_ERROR(CELL_DECOMPOSER);
1225 cell_id += gr_cell2.
size_s(s-1) * ConvertToID(pos,s);
1240 template<
typename Mem>
inline int getCell(
const encapc<1,
Point<dim,T>,Mem> & pos)
const
1244 if (cellTotalCount == 0)
1246 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using an uninitialized CellDecomposer";
1247 ACTION_ON_ERROR(CELL_DECOMPOSER);
1252 size_t cell_id = ConvertToID_(pos,0);
1254 for (
size_t s = 1 ; s < dim ; s++)
1258 if (pos.template get<0>()[s] < cellListSpaceBox.
getLow(s) - off[s]*unitCellSpaceBox.
getP2()[s] || pos.template get<0>()[s] > cellListSpaceBox.
getHigh(s) + off[s]*unitCellSpaceBox.
getP2()[s])
1261 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" point " << toPointString(pos) <<
" is not inside the cell space";
1262 ACTION_ON_ERROR(CELL_DECOMPOSER);
1265 cell_id += gr_cell2.
size_s(s-1) * ConvertToID_(pos,s);
1316 bx.
setP2(getCellGrid(p2));
1317 bx.
setP1(getCellGrid(p1));
1329 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> cellShift)
1333 pointTransform.setTransform(mat,box.
getP1());
1334 this->cellListSpaceBox = box;
1336 Initialize(pad,div);
1340 for (
size_t i = 0 ; i < dim ; i++)
1341 cells[i] = div2[i] + 2*pad;
1345 for (
size_t i = 0 ; i < dim ; i++)
1346 this->cellShift.
get(i) = cellShift.
get(i) - off[i];
1356 inline void setDimensions(
const Box<dim,T> & box,
const size_t (&div)[dim],
const size_t pad)
1360 pointTransform.setTransform(mat,box.
getP1());
1361 this->cellListSpaceBox = box;
1362 Initialize(pad,div);
1363 this->cellShift = 0;
1378 pointTransform.setTransform(mat,box.
getP1());
1379 this->cellListSpaceBox = box;
1381 Initialize(pad,div);
1385 size_t div_with_off[dim];
1387 for(
size_t i = 0 ; i < dim ; i++)
1388 div_with_off[i] = div2[i] + 2*off[i];
1392 for (
size_t i = 0 ; i < dim ; i++)
1393 this->cellShift.
get(i) = cellShift.
get(i) - off[i];
1405 inline void setDimensions(
const Box<dim,T> & box,
const size_t (&div)[dim],
const Matrix<dim,T> & mat,
const size_t pad)
1407 pointTransform.setTransform(mat,box.
getP1());
1408 this->cellListSpaceBox = box;
1409 Initialize(pad,div);
1410 this->cellShift = 0;
1425 inline void setDimensions(
const CellDecomposer_sm<dim,T,transform_type> & cd,
const Box<dim,size_t> & cell_extension)
1427 this->cellShift = 0;
1431 pointTransform.setTransform(cd.getMat(),cd.getOrig());
1434 this->cellListSpaceBox = cd.cellListSpaceBox;
1440 for (
size_t i = 0 ; i < dim ; i++)
1442 if (pad < cell_extension.
getLow(i))
1443 pad = cell_extension.
getLow(i);
1444 else if (pad > cell_extension.
getHigh(i))
1445 pad = cell_extension.
getHigh(i);
1452 for (
size_t i = 0 ; i < dim ; i++)
1453 sz_div[i] = cd.cellListGrid.size(i) - 2*cd.off[i];
1455 Initialize(pad,sz_div);
1488 :pointTransform(
Matrix<dim,T>::identity(),box.getP1()),cellListSpaceBox(box),cellListGrid()
1490 Initialize(pad,div);
1522 CellDecomposer_sm(
const Box<dim,T> & box,
const size_t (&div)[dim],
const size_t pad)
1523 :pointTransform(
Matrix<dim,T>::identity(),box.getP1()),cellListSpaceBox(box),cellListGrid(div)
1525 Initialize(pad,div);
1535 CellDecomposer_sm(
const CellDecomposer_sm<dim,T,transform_type> & cd,
Box<dim,size_t> & ext)
1536 :pointTransform(
Matrix<dim,T>::identity(),cd.getOrig())
1538 setDimensions(cd,ext);
1544 :pointTransform(
Matrix<dim,T>::identity(),
Point<dim,T>::zero_p()),cellTotalCount(0)
1558 return unitCellSpaceBox;
1568 return pointTransform.getMat();
1578 return pointTransform.getOrig();
1630 b /= getCellBox().getP2();
1644 for (
size_t i = 0 ; i < dim ; i++)
1655 for (
size_t i = 0 ; i < dim ; i++)
1660 if (bc[i] == NON_PERIODIC)
1676 if (bc[i] == NON_PERIODIC)
1681 g_box.
setLow(i,cellListGrid.
size(i) - off[i]);
1687 g_box.
setLow(i,cellListGrid.
size(i) - off[i]);
1756 b /= getCellBox().getP2();
1767 for (
size_t i = 0 ; i < dim ; i++) {b.setHigh(i,b.getHigh(i)-1);}
1776 for (
size_t i = 0 ; i < dim ; i++)
1781 if (bc[i] == NON_PERIODIC)
1797 if (bc[i] == NON_PERIODIC)
1802 g_box.
setLow(i,cellListGrid.
size(i) - off[i]);
1808 g_box.
setLow(i,cellListGrid.
size(i) - off[i]);
1874 for (
size_t i = 0 ; i < dim ; i++)
1876 if ((
long int)cellListGrid.
size(i) - (
long int)off[i] == b_d.
getLow(i))
1878 else if ((
long int)off[i] == b_d.
getLow(i))
1883 if ((
long int)cellListGrid.
size(i) - (
long int)off[i] == b_d.
getHigh(i))
1885 else if ((
long int)off[i] == b_d.
getHigh(i))
1945 for (
size_t i = 0 ; i < dim ; i++)
1947 if ((
long int)cellListGrid.
size(i) - (
long int)off[i] == b_d.
getLow(i))
1949 else if ((
long int)off[i] == b_d.
getLow(i))
1952 {be.
setLow(i,(b_d.
getLow(i) - off[i]) * unitCellSpaceBox.
getP2()[i] + cellListSpaceBox.
getLow(i) - unitCellSpaceBox.
getP2()[i] / 2.0);}
1954 if ((
long int)cellListGrid.
size(i) - (
long int)off[i] == b_d.
getHigh(i))
1956 else if ((
long int)off[i] == b_d.
getHigh(i))
1970 const size_t (& getDiv()
const)[dim]
1972 return cellListGrid.
getSize();
1981 const size_t (& getDivWP()
const)[dim]
1983 for (
size_t i = 0 ; i < dim ; i++)
1984 {div_wp[i] = cellListGrid.
getSize()[i] - 2*getPadding(i);}
1996 return cellListSpaceBox;
2004 inline void swap(CellDecomposer_sm<dim,T,transform_type> & cd)
2007 p_middle.swap(cd.p_middle);
2010 transform_type t_t = pointTransform;
2011 pointTransform = cd.pointTransform;
2012 cd.pointTransform = t_t;
2015 size_t cellTotalCount_t = cellTotalCount;
2016 cellTotalCount = cd.cellTotalCount;
2017 cd.cellTotalCount = cellTotalCount_t;
2019 cellListSpaceBox.
swap(cd.cellListSpaceBox);
2020 unitCellSpaceBox.
swap(cd.unitCellSpaceBox);
2021 cellListGrid.
swap(cd.cellListGrid);
2022 gr_cell2.
swap(cd.gr_cell2);
2024 for (
size_t i = 0 ; i < dim ; i++)
2026 size_t off_t = off[i];
2030 size_t cs_t = cellShift.
get(i);
2031 cellShift.
get(i) = cd.cellShift.get(i);
2032 cd.cellShift.get(i) = cs_t;
2043 inline bool operator==(
const CellDecomposer_sm<dim,T,transform_type> & cd)
2048 if (pointTransform != cd.pointTransform)
2051 if (cellTotalCount != cd.cellTotalCount)
2054 if (cellListSpaceBox != cd.cellListSpaceBox)
2057 if (unitCellSpaceBox != cd.unitCellSpaceBox)
2060 if (cellListGrid != cd.cellListGrid)
2063 if (gr_cell2 != cd.gr_cell2)
2066 for (
size_t i = 0 ; i < dim ; i++)
2068 if (off[i] != cd.off[i])
2071 if (cellShift.
get(i) != cd.cellShift.get(i))
2085 inline bool operator!=(
const CellDecomposer_sm<dim,T,transform_type> & cd)
2087 return ! this->operator==(cd);
2097 size_t getPadding(
size_t i)
const
2108 size_t (& getPadding())[dim]
2125 for (
size_t i = 0 ; i < dim ; i++)
2145 for (
size_t i = 0 ; i < dim ; i++)
2147 key.
set_d(i,cellShift.
get(i) + gr_cell2.
size(i) - 2*getPadding(i) - 1);
2162 for (
size_t i = 0 ; i < dim ; i++)
2163 k.set_d(i,cellShift.
get(i));
This class represent an N-dimensional box.
Point< dim, T > getP1() const
Get the point p1.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__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.
Point< dim, T > getP2() const
Get the point p2.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
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.
__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.
Matrix< dim, T > mat
Matrix transformation.
const Point< dim, T > & getOrig() const
Get the shift vector.
__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.
const Matrix< dim, T > & getMat() const
Get the transformation Matrix.
Point< dim, T > sh
Shift point.