1#define SYNC_BEFORE_TAKE_TIME 
    2#include "Decomposition/Distribution/BoxDistribution.hpp" 
    3#include "Grid/grid_dist_id.hpp" 
    4#include "data_type/aggregate.hpp" 
   41constexpr int U_next = 2;
 
   42constexpr int V_next = 3;
 
   46typedef sgrid_dist_id_gpu<3,double,aggregate<double,double,double,double>, 
CudaMemory,Dec > 
sgrid_type;
 
   50    auto it = 
grid.getGridIterator();
 
   57    double spacing_x = 
grid.spacing(0);
 
   58    double spacing_y = 
grid.spacing(1);
 
   59    double spacing_z = 
grid.spacing(2);
 
   64    for (
int i = 0 ; i < 100 ; i++)
 
   71        for (
int j = 0 ; j < 3 ; j++)
 
   73            bx.
setLow(j,(
size_t)((sph.center(j) - 0.4 - (
double)i/160.0)/
grid.spacing(j)));
 
   74            bx.
setHigh(j,(
size_t)((sph.center(j) + 0.4 + (
double)i/160.0)/
grid.spacing(j)));
 
   80        grid.addPoints(bx.
getKP1(),bx.
getKP2(),[spacing_x,spacing_y,spacing_z,sph,sph2] __device__ (
int i, 
int j, 
int k)
 
   85                                        if (sph2.isInside(pc) )
 
   87                            if (sph.isInside(pc) == 
false)
 
   93                                [] __device__ (InsertBlockT & data, 
int i, 
int j, 
int k)
 
   95                                        data.template get<U>() = 1.0;
 
   96                                        data.template get<V>() = 0.0;
 
  104                grid.template flush<smax_<U>,
smax_<V>>(flush_type::FLUSH_ON_DEVICE);
 
  109                grid.template ghost_get<U,V>(RUN_ON_DEVICE);
 
  113                grid.template ghost_get<U,V>(RUN_ON_DEVICE | SKIP_LABELLING);
 
  115                std::cout << t_ghost.
getwct() << std::endl;
 
  117                std::cout << 
"TIME ghost1: " << t_ghost.
getwct() << 
"  ghost2: " << t_ghost2.
getwct()  << 
" flush: " <<  t_flush.
getwct() << 
" " << std::endl;
 
  120        grid.removeUnusedBuffers();
 
  124    std::cout << 
"Second Pass" <<std::endl;
 
  126    for (
int i = 0 ; i < 100 ; i++)
 
  133        for (
int j = 0 ; j < 3 ; j++)
 
  135            bx.
setLow(j,(
size_t)((sph.center(j) - 0.4 - (
double)i/160.0)/
grid.spacing(j)));
 
  136            bx.
setHigh(j,(
size_t)((sph.center(j) + 0.4 + (
double)i/160.0)/
grid.spacing(j)));
 
  142        grid.addPoints(bx.
getKP1(),bx.
getKP2(),[spacing_x,spacing_y,spacing_z,sph,sph2] __device__ (
int i, 
int j, 
int k)
 
  147                                        if (sph2.isInside(pc) )
 
  149                            if (sph.isInside(pc) == 
false)
 
  155                                [] __device__ (InsertBlockT & data, 
int i, 
int j, 
int k)
 
  157                                        data.template get<U>() = 1.0;
 
  158                                        data.template get<V>() = 0.0;
 
  167        grid.template flush<smax_<U>,
smax_<V>>(flush_type::FLUSH_ON_DEVICE);
 
  174        grid.template ghost_get<U,V>(RUN_ON_DEVICE);
 
  178                grid.template ghost_get<U,V>(RUN_ON_DEVICE | SKIP_LABELLING);
 
  181        std::cout << 
"TIME ghost1: " << t_ghost.
getwct() << 
"  ghost2: " << t_ghost2.
getwct()  << 
" flush: " <<  t_flush.
getwct() << 
" " << std::endl;
 
  193int main(
int argc, 
char* argv[])
 
  195    openfpm_init(&argc,&argv);
 
  201        size_t sz[3] = {384,384,384};
 
  210    double deltaT = 0.025;
 
  220        size_t timeSteps = 300;
 
  223        size_t timeSteps = 50000;
 
  234    grid.template setBackgroundValue<0>(-0.5);
 
  235    grid.template setBackgroundValue<1>(-0.5);
 
  236    grid.template setBackgroundValue<2>(-0.5);
 
  237    grid.template setBackgroundValue<3>(-0.5);
 
  240    double spacing[3] = {
grid.spacing(0),
grid.spacing(1),
grid.spacing(2)};
 
  242    draw_oscillation_shock(
grid,domain);
 
  244    grid.template deviceToHost<U,V>();
 
  278int main(
int argc, 
char* argv[])
 
This class represent an N-dimensional box.
 
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
 
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
 
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
 
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
 
This class decompose a space into sub-sub-domains and distribute them across processors.
 
This class implement the point shape in an N-dimensional space.
 
This class implement the Sphere concept in an N-dimensional space.
 
This is a distributed grid.
 
Class for cpu time benchmarking.
 
void stop()
Stop the timer.
 
void start()
Start the timer.
 
double getwct()
Return the elapsed real time.
 
[v_transform metafunction]