24 enum IntegrationMode { IntEuler=0, IntRK2, IntRK4 };
27 template<
class VelKernel>
29 typedef typename VelKernel::type0 PosType;
30 PosType& x = k.getArg0();
31 const std::vector<Vec3>& u = k.getRet();
32 const int N = x.size();
34 if (mode == IntEuler) {
35 for(
int i=0; i<N; i++) x[i].pos += u[i];
37 else if (mode == IntRK2) {
40 for(
int i=0; i<N; i++) x[i].pos = x0[i].pos + 0.5*u[i];
43 for(
int i=0; i<N; i++) x[i].pos = x0[i].pos + u[i];
45 else if (mode == IntRK4) {
47 std::vector<Vec3> uTotal(u);
49 for(
int i=0; i<N; i++) x[i].pos = x0[i].pos + 0.5*u[i];
52 for(
int i=0; i<N; i++) {
53 x[i].pos = x0[i].pos + 0.5*u[i];
58 for(
int i=0; i<N; i++) {
59 x[i].pos = x0[i].pos + u[i];
64 for(
int i=0; i<N; i++) x[i].pos = x0[i].pos + (Real)(1./6.) * (uTotal[i] + u[i]);
67 errMsg(
"unknown integration type");
Definition: commonkernels.h:22
void integratePointSet(VelKernel &k, int mode)
Integrate a particle set with a given velocity kernel.
Definition: integrator.h:28