1 #include "Vector/vector_dist.hpp" 
    2 #include "Decomposition/CartDecomposition.hpp" 
    3 #include "data_type/aggregate.hpp" 
    4 #include "Plot/GoogleChart.hpp" 
    5 #include "Plot/util.hpp" 
   97 constexpr 
int velocity = 0;
 
   98 constexpr 
int force = 1;
 
  130 template<
typename VerletList>
 
  135     auto itg = vd.getDomainAndGhostIterator();
 
  142         vd.getProp<force>(p)[0] = 0.0;
 
  143         vd.getProp<force>(p)[1] = 0.0;
 
  144         vd.getProp<force>(p)[2] = 0.0;
 
  152     auto it2 = vd.getParticleIteratorCRS(NN);
 
  167         auto Np = NN.template getNNIterator<NO_CHECK>(p);
 
  176             if (q == p) {++Np; 
continue;};
 
  185             double rn = norm2(r);
 
  187             if (rn > r_cut * r_cut) {++Np;
continue;}
 
  190             Point<3,double> f = 24.0*(2.0 *sigma12 / (rn*rn*rn*rn*rn*rn*rn) -  sigma6 / (rn*rn*rn*rn)) * r;
 
  193             vd.template getProp<force>(p)[0] += f.
get(0);
 
  194             vd.template getProp<force>(p)[1] += f.
get(1);
 
  195             vd.template getProp<force>(p)[2] += f.
get(2);
 
  200             vd.template getProp<force>(q)[0] -= f.
get(0);
 
  201             vd.template getProp<force>(q)[1] -= f.
get(1);
 
  202             vd.template getProp<force>(q)[2] -= f.
get(2);
 
  217     vd.ghost_put<
add_,force>();
 
  246 template<
typename VerletList>
 
  251     double rc = r_cut*r_cut;
 
  252     double shift = 4.0 * ( sigma12 / (rc*rc*rc*rc*rc*rc) - sigma6 / ( rc*rc*rc) );
 
  255     auto it2 = vd.getParticleIteratorCRS(NN);
 
  267         auto Np = NN.template getNNIterator<NO_CHECK>(p);
 
  278             if (q == p) {++Np; 
continue;};
 
  284             double rn = norm2(xp - xq);
 
  286             if (rn >= r_cut*r_cut)  {++Np;
continue;}
 
  289             E += 4.0 * ( sigma12 / (rn*rn*rn*rn*rn*rn) - sigma6 / ( rn*rn*rn) ) - shift;
 
  299         if (p < vd.size_local())
 
  302             E += (vd.template getProp<velocity>(p)[0]*vd.template getProp<velocity>(p)[0] +
 
  303                     vd.template getProp<velocity>(p)[1]*vd.template getProp<velocity>(p)[1] +
 
  304                     vd.template getProp<velocity>(p)[2]*vd.template getProp<velocity>(p)[2]) / 2;
 
  317 int main(
int argc, 
char* argv[])
 
  351     double r_cut = 3.0*sigma;
 
  352     double r_gskin = 1.3*r_cut;
 
  353     double sigma12 = pow(sigma,12);
 
  354     double sigma6 = pow(sigma,6);
 
  359     openfpm_init(&argc,&argv);
 
  360     Vcluster & v_cl = create_vcluster();
 
  363     size_t sz[3] = {10,10,10};
 
  369     size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
 
  388     size_t start = vd.accum();
 
  390     auto it = vd.getGridIterator(sz);
 
  398         vd.getLastPos()[0] = 
key.get(0) * it.getSpacing(0);
 
  399         vd.getLastPos()[1] = 
key.get(1) * it.getSpacing(1);
 
  400         vd.getLastPos()[2] = 
key.get(2) * it.getSpacing(2);
 
  402         vd.template getLastProp<velocity>()[0] = 0.0;
 
  403         vd.template getLastProp<velocity>()[1] = 0.0;
 
  404         vd.template getLastProp<velocity>()[2] = 0.0;
 
  406         vd.template getLastProp<force>()[0] = 0.0;
 
  407         vd.template getLastProp<force>()[1] = 0.0;
 
  408         vd.template getLastProp<force>()[2] = 0.0;
 
  423     auto NN = vd.getVerletCrs(r_gskin);;
 
  428     calc_forces(vd,NN,sigma12,sigma6,r_cut);
 
  429     unsigned long int f = 0;
 
  432     double max_disp = 0.0;
 
  435     for (
size_t i = 0; i < 10000 ; i++)
 
  438         auto it3 = vd.getDomainIterator();
 
  440         double max_displ = 0.0;
 
  448             vd.template getProp<velocity>(p)[0] += 0.5*dt*vd.template getProp<force>(p)[0];
 
  449             vd.template getProp<velocity>(p)[1] += 0.5*dt*vd.template getProp<force>(p)[1];
 
  450             vd.template getProp<velocity>(p)[2] += 0.5*dt*vd.template getProp<force>(p)[2];
 
  452             Point<3,double> disp({vd.template getProp<velocity>(p)[0]*dt,vd.template getProp<velocity>(p)[1]*dt,vd.template getProp<velocity>(p)[2]*dt});
 
  455             vd.getPos(p)[0] += disp.get(0);
 
  456             vd.getPos(p)[1] += disp.get(1);
 
  457             vd.getPos(p)[2] += disp.get(2);
 
  459             if (disp.norm() > max_displ)
 
  460                 max_displ = disp.norm();
 
  465         if (max_disp < max_displ)
 
  466             max_disp = max_displ;
 
  472             vd.template ghost_get<>();
 
  474             vd.updateVerlet(NN,r_gskin,VL_CRS_SYMMETRIC);
 
  478             vd.template ghost_get<>(SKIP_LABELLING);
 
  484         calc_forces(vd,NN,sigma12,sigma6,r_cut);
 
  487         auto it4 = vd.getDomainIterator();
 
  494             vd.template getProp<velocity>(p)[0] += 0.5*dt*vd.template getProp<force>(p)[0];
 
  495             vd.template getProp<velocity>(p)[1] += 0.5*dt*vd.template getProp<force>(p)[1];
 
  496             vd.template getProp<velocity>(p)[2] += 0.5*dt*vd.template getProp<force>(p)[2];
 
  506             vd.write(
"particles_",f);
 
  513             double energy = calc_energy(vd,NN,sigma12,sigma6,r_cut);
 
  514             auto & vcl = create_vcluster();
 
  525             if (vcl.getProcessUnitID() == 0)
 
  526                 std::cout << 
"Energy: " << energy << 
"   " << max_disp << 
"   " << std::endl;
 
  535     std::cout << 
"Time: " << tsim.
getwct()  << std::endl;
 
  543     options.
title = std::string(
"Energy with time");
 
  546     options.
yAxis = std::string(
"Energy");
 
  549     options.
xAxis = std::string(
"iteration");
 
  562     cg.
write(
"gc_plot2_out.html");
 
size_t get(size_t i, size_t j) const 
Get the neighborhood element j for the particle i. 
 
void AddLinesGraph(openfpm::vector< X > &x, openfpm::vector< Y > &y, const GCoptions &opt)
Add a simple lines graph. 
 
Class for Verlet list implementation. 
 
std::string title
Title of the chart. 
 
This structure define the operation add to use with copy general. 
 
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. 
 
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
 
Implementation of 1-D std::vector like structure. 
 
std::string xAxis
X axis name. 
 
Class for cpu time benchmarking. 
 
void stop()
Stop the timer.