I have the following C function that is a part of a code written in C.
void pusher(int part, int ntime,long double x[3], long double v[3], long double E[3], long double B[3], long double Vth, long double c2, long double x_new[3], long double v_new[3]){
long double x_mid[3];
long double upart_new[3];
// half time-step for Euler step
long double dth = 0.5*dt;
// position x_{i+1/2} at time t_{i+1/2} + dt/2 (1st-order Euler scheme)
for(int i=0;i<3;i++){
x_mid[i] = x[i] + v[i]*dth;
}
// TO DO: Get E, B at new position
/* I want to add the Cpp function at this point in the code. */
// interpolate_fields();
// 'Kick' particle (update velocity) based on the chosen integrator
switch(pusher_name) {
case 1 :
Vay(v, E, B, c2, upart_new);
break;
case 0 :
Boris_relativ(v, E, B, c2, upart_new);
break;
}
long double gL_new = gamma_u(upart_new, c2);
// full position update at t_{i+1} = t_{i+1/2} + dt/2 = t_i + dt
for(int i=0;i<3;i++){
v_new[i] = upart_new[i]/gL_new;
x_new[i] = x_mid[i] + v_new[i]*dth;
}
}
I also have the following Cpp function that I would like to include at the indicated point in the code. To avoid including the Cpp code in the question, I have uploaded the file here:
https://www.dropbox.com/s/vbsxme9vozci4tz/ba_interp3.cpp?dl=0
Is this possible?
Any suggestions for how I could do this?