1#include "Vector/vector_dist.hpp"
2#include "data_type/aggregate.hpp"
3#include "Plot/GoogleChart.hpp"
4#include "Plot/util.hpp"
6#include "energy_force.hpp"
24int main(
int argc,
char* argv[])
45 double sigma = r_cut/3.0;
46 double sigma12 = pow(sigma,12);
47 double sigma6 = pow(sigma,6);
52 openfpm_init(&argc,&argv);
56 size_t sz[3] = {40,40,40};
62 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
87 auto it = vd.getGridIterator(sz);
95 vd.getLastPos()[0] = key.get(0) * it.getSpacing(0);
96 vd.getLastPos()[1] = key.get(1) * it.getSpacing(1);
97 vd.getLastPos()[2] = key.get(2) * it.getSpacing(2);
99 vd.template getLastProp<velocity>()[0] = 0.0;
100 vd.template getLastProp<velocity>()[1] = 0.0;
101 vd.template getLastProp<velocity>()[2] = 0.0;
103 vd.template getLastProp<force>()[0] = 0.0;
104 vd.template getLastProp<force>()[1] = 0.0;
105 vd.template getLastProp<force>()[2] = 0.0;
271 auto NN = vd.getCellList(r_cut);
274 calc_forces(vd,NN,sigma12,sigma6);
275 unsigned long int f = 0;
281 size_t Nstep = 30000;
287 for (
size_t i = 0; i < Nstep ; i++)
290 auto it3 = vd.getDomainIterator();
298 vd.template getProp<velocity>(p)[0] += 0.5*dt*vd.template getProp<force>(p)[0];
299 vd.template getProp<velocity>(p)[1] += 0.5*dt*vd.template getProp<force>(p)[1];
300 vd.template getProp<velocity>(p)[2] += 0.5*dt*vd.template getProp<force>(p)[2];
303 vd.getPos(p)[0] += vd.template getProp<velocity>(p)[0]*dt;
304 vd.getPos(p)[1] += vd.template getProp<velocity>(p)[1]*dt;
305 vd.getPos(p)[2] += vd.template getProp<velocity>(p)[2]*dt;
312 vd.template ghost_get<>();
330 calc_forces(vd,NN,sigma12,sigma6);
344 auto it4 = vd.getDomainIterator();
351 vd.template getProp<velocity>(p)[0] += 0.5*dt*vd.template getProp<force>(p)[0];
352 vd.template getProp<velocity>(p)[1] += 0.5*dt*vd.template getProp<force>(p)[1];
353 vd.template getProp<velocity>(p)[2] += 0.5*dt*vd.template getProp<force>(p)[2];
362 double energy = calc_energy(vd,NN,sigma12,sigma6);
363 auto & vcl = create_vcluster();
369 if (vcl.getProcessUnitID() == 0)
370 std::cout <<
"Energy: " << energy << std::endl;
377 std::cout <<
"Performance: " << time2.
getwct() << std::endl;
401 options.
title = std::string(
"Force calculation time");
404 options.
yAxis = std::string(
"Time");
407 options.
xAxis = std::string(
"iteration");
420 cg.
write(
"gc_plot2_out.html");
This class represent an N-dimensional box.
Small class to produce graph with Google chart in HTML.
void write(std::string file)
It write the graphs on file in html format using Google charts.
void AddLinesGraph(openfpm::vector< X > &x, openfpm::vector< Y > &y, const GCoptions &opt)
Add a simple lines graph.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
std::string xAxis
X axis name.
size_t lineWidth
Width of the line.
std::string title
Title of the chart.
std::string yAxis
Y axis name.