8#ifndef EXAMPLE_VECTOR_4_REORDER_ENERGY_FORCE_HPP_
9#define EXAMPLE_VECTOR_4_REORDER_ENERGY_FORCE_HPP_
11constexpr int velocity = 0;
12constexpr int force = 1;
15template<
typename CellList>
void calc_forces(
vector_dist<3,
double,
aggregate<
double[3],
double[3]> > & vd,
CellList & NN,
double sigma12,
double sigma6)
18 vd.updateCellList(NN);
21 auto it2 = vd.getDomainIterator();
33 vd.template getProp<force>(p)[0] = 0.0;
34 vd.template getProp<force>(p)[1] = 0.0;
35 vd.template getProp<force>(p)[2] = 0.0;
38 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(vd.getPos(p)));
47 if (q == p.getKey()) {++Np;
continue;};
59 Point<3,double> f = 24.0*(2.0 *sigma12 / (rn*rn*rn*rn*rn*rn*rn) - sigma6 / (rn*rn*rn*rn)) * r;
62 vd.template getProp<force>(p)[0] += f.get(0);
63 vd.template getProp<force>(p)[1] += f.get(1);
64 vd.template getProp<force>(p)[2] += f.get(2);
76template<
typename CellList>
double calc_energy(
vector_dist<3,
double,
aggregate<
double[3],
double[3]> > & vd,
CellList & NN,
double sigma12,
double sigma6)
81 vd.updateCellList(NN);
84 auto it2 = vd.getDomainIterator();
96 vd.template getProp<force>(p)[0] = 0.0;
97 vd.template getProp<force>(p)[1] = 0.0;
98 vd.template getProp<force>(p)[2] = 0.0;
101 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(vd.getPos(p)));
110 if (q == p.getKey()) {++Np;
continue;};
116 double rn = norm2(xp - xq);
119 E += 4.0 * ( sigma12 / (rn*rn*rn*rn*rn*rn) - sigma6 / ( rn*rn*rn) );
126 E += (vd.template getProp<velocity>(p)[0]*vd.template getProp<velocity>(p)[0] +
127 vd.template getProp<velocity>(p)[1]*vd.template getProp<velocity>(p)[1] +
128 vd.template getProp<velocity>(p)[2]*vd.template getProp<velocity>(p)[2]) / 2;
Class for FAST cell list implementation.
This class implement the point shape in an N-dimensional space.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...