1 #include "Vector/vector_dist.hpp" 
    2 #include "Plot/GoogleChart.hpp" 
    3 #include "Operators/Vector/vector_dist_operators.hpp" 
    6 constexpr 
int velocity = 0;
 
    7 constexpr 
int force = 1;
 
   11     double sigma12,sigma6,r_cut2,
shift;
 
   13     ln_potential(
double sigma12_, 
double sigma6_, 
double r_cut2_, 
double shift_) {sigma12 = sigma12_; sigma6 = sigma6_; r_cut2 = r_cut2_;
shift = shift_;}
 
   17         double rn = norm2(xp - xq);
 
   18         if (rn >= r_cut2)   
return 0.0;
 
   28     double sigma12,sigma6,r_cut2;
 
   30     ln_force(
double sigma12_, 
double sigma6_, 
double r_cut2_) {sigma12 = sigma12_; sigma6 = sigma6_;r_cut2 = r_cut2_;}
 
   37         if (rn > r_cut2)    
return 0.0;
 
   39         return 24.0*(2.0 * sigma12 / (rn*rn*rn*rn*rn*rn*rn) -  sigma6 / (rn*rn*rn*rn)) * r;
 
   43 int main(
int argc, 
char* argv[])
 
   45     double dt = 0.0005, sigma = 0.1, r_cut = 3.0*sigma;
 
   47     double sigma6 = pow(sigma,6), sigma12 = pow(sigma,12);
 
   48     double rc2 = r_cut * r_cut;
 
   49     double shift = 2.0 * ( sigma12 / (rc2*rc2*rc2*rc2*rc2*rc2) - sigma6 / ( rc2*rc2*rc2) );
 
   55     openfpm_init(&argc,&argv);
 
   58     size_t sz[3] = {10,10,10};
 
   60     size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
 
   63     ln_force lf(sigma12,sigma6,r_cut*r_cut);
 
   68     auto v_force = getV<force>(vd);
 
   69     auto v_velocity = getV<velocity>(vd);
 
   70     auto v_pos = getV<PROP_POS>(vd);
 
   72     auto it = vd.getGridIterator(sz);
 
   80         vd.getLastPos()[0] = 
key.get(0) * it.getSpacing(0);
 
   81         vd.getLastPos()[1] = 
key.get(1) * it.getSpacing(1);
 
   82         vd.getLastPos()[2] = 
key.get(2) * it.getSpacing(2);
 
   93     auto NN = vd.getCellList(r_cut);
 
   95     vd.updateCellList(NN);
 
   96     v_force = applyKernel_in_sim(vd,NN,lf);
 
   97     unsigned long int f = 0;
 
  100     for (
size_t i = 0; i < 10000 ; i++)
 
  102         assign(v_velocity, v_velocity + 0.5*dt*v_force,
 
  103                v_pos, v_pos + v_velocity*dt);
 
  106         vd.template ghost_get<>();
 
  109         vd.updateCellList(NN);
 
  110         v_force = applyKernel_in_sim(vd,NN,lf);
 
  112         v_velocity = v_velocity + 0.5*dt*v_force;
 
  117             vd.write(
"particles_",f);
 
  120             vd.updateCellList(NN);
 
  121             Point<2,double> E = rsum(applyKernel_in_sim(vd,NN,lp) + (v_velocity * v_velocity)/2.0,vd).get();
 
  131                 std::cout << 
"Energy Total: " << E.
get(0) << 
"   Kinetic: " <<  E.
get(1) << 
"   Potential: " << E.
get(0) - E.
get(1) << std::endl;
 
  138     std::cout << 
"Time: " << tsim.
getwct() << std::endl;
 
  141     options.
title = std::string(
"Energy with time");
 
  142     options.
yAxis = std::string(
"Energy");
 
  143     options.
xAxis = std::string(
"iteration");
 
  148     cg.
write(
"gc_plot2_out.html");
 
void sum(T &num)
Sum the numbers across all processors and get the result. 
 
void AddLinesGraph(openfpm::vector< X > &x, openfpm::vector< Y > &y, const GCoptions &opt)
Add a simple lines graph. 
 
size_t getProcessUnitID()
Get the process unit id. 
 
void execute()
Execute all the requests. 
 
std::string title
Title of the chart. 
 
This class implement the point shape in an N-dimensional space. 
 
double getwct()
Return the elapsed real time. 
 
Implementation of VCluster class. 
 
std::string yAxis
Y axis name. 
 
Small class to produce graph with Google chart in HTML. 
 
void start()
Start the timer. 
 
const T & get(size_t i) const 
Get coordinate. 
 
size_t lineWidth
Width of the line. 
 
This class is a trick to indicate the compiler a specific specialization pattern. ...
 
void write(std::string file)
It write the graphs on file in html format using Google charts. 
 
Implementation of 1-D std::vector like structure. 
 
std::string xAxis
X axis name. 
 
Class for cpu time benchmarking. 
 
void stop()
Stop the timer.