42 time_step = cfg.
require(
"time_step", 0.0);
51 template<
class T,
class Gravitation>
54 static const int nbod = T::n;
60 ensemble::SystemRef&
sys;
61 Gravitation& calcForces;
74 :_params(p),
sys(s),calcForces(calc){}
76 __device__
bool is_in_body_component_grid()
77 {
return ((b < nbod) && (c < 3)); }
79 __device__
bool is_in_body_component_grid_no_star()
80 {
return ( (b!=0) && (b < nbod) && (c < 3) ); }
82 __device__
bool is_first_thread_in_system()
85 static GENERIC int thread_per_system(){
89 static GENERIC int shmem_per_system() {
100 sqrtGM = sqrt(
sys[0].mass());
103 acc_bc = calcForces.acc_planets(ij,b,c);
118 double sump = 0., sumv = 0., mtot = 0.;
119 if( is_in_body_component_grid() )
124 calcForces.shared[1][c].acc() =
sys[0][c].pos();
126 for(
int j=0;j<nbod;++j) {
127 const double mj =
sys[j].mass();
129 sump += mj*
sys[j][c].pos();
130 sumv += mj*
sys[j][c].vel();
135 calcForces.shared[0][c].acc() = sumv;
141 if( is_in_body_component_grid() )
145 sys[b][c].vel() = sumv;
146 sys[b][c].pos() = sump/mtot;
150 sys[b][c].vel() -= calcForces.shared[0][c].acc();
151 sys[b][c].pos() -= calcForces.shared[1][c].acc();
161 double sump = 0., sumv = 0., mtot = 0.;
162 if( is_in_body_component_grid() )
164 pc0 =
sys[0][c].pos();
166 for(
int j=0;j<nbod;++j) {
167 const double mj =
sys[j].mass();
169 sump += mj*
sys[j][c].pos();
170 sumv += mj*
sys[j][c].vel();
176 if( is_in_body_component_grid() )
180 sys[b][c].vel() = sumv;
181 sys[b][c].pos() = sump/mtot;
185 sys[b][c].vel() -= sumv;
186 sys[b][c].pos() -= pc0;
197 double sump = 0., sumv = 0., mtot;
199 if ( is_in_body_component_grid() )
202 pc0 =
sys[0][c].pos();
203 vc0 =
sys[0][c].vel();
205 for(
int j=1;j<nbod;++j)
207 const double mj =
sys[j].mass();
209 sump += mj*
sys[j][c].pos();
210 sumv += mj*
sys[j][c].vel();
216 if ( is_in_body_component_grid() )
220 sys[b][c].pos() -= sump;
221 sys[b][c].vel() -= sumv/m0;
225 sys[b][c].pos() += pc0 - sump;
226 sys[b][c].vel() += vc0;
246 sys[b][c].pos() += hby2*
sys[b][c].vel();
251 for(
int j=1;j<nbod;++j)
252 mv +=
sys[j].mass() *
sys[j][c].vel();
254 sys[b][c].pos() += mv*hby2/
sys[0].mass();
262 double hby2 = 0.5 * min( max_timestep , _params.time_step );
265 if ( is_in_body_component_grid() )
269 if( is_in_body_component_grid_no_star() )
270 sys[b][c].vel() += hby2 * acc_bc;
275 if( (ij>0) && (ij<nbod) )
280 acc_bc = calcForces.acc_planets(ij,b,c);
283 if( is_in_body_component_grid_no_star() )
284 sys[b][c].vel() += hby2 * acc_bc;
288 if ( is_in_body_component_grid() )
291 if( is_first_thread_in_system() )
292 sys.time() += 2.0*hby2;