28 #include "../swarm/types/config.hpp"
44 bool deactivate_on, log_on, verbose_on;
49 rmax = cfg.
optional(
"rmax",std::numeric_limits<float>::max());
50 deactivate_on = cfg.
optional(
"deactivate_on_ejection",
false);
51 log_on = cfg.
optional(
"log_on_ejection",
false);
52 verbose_on = cfg.
optional(
"verbose_on_ejection",
false);
73 ensemble::SystemRef& _sys;
78 GPUAPI
bool is_deactivate_on() {
return _params.deactivate_on; };
79 GPUAPI
bool is_log_on() {
return _params.log_on; };
80 GPUAPI
bool is_verbose_on() {
return _params.verbose_on; };
81 GPUAPI
bool is_any_on() {
return is_deactivate_on() || is_log_on() || is_verbose_on() ; }
82 GPUAPI
bool is_condition_met () {
return ( condition_met ); }
83 GPUAPI
bool need_to_log_system ()
84 {
return (is_log_on() && is_condition_met() ); }
85 GPUAPI
bool need_to_deactivate ()
86 {
return ( is_deactivate_on() && is_condition_met() ); }
88 GPUAPI
void log_system() {
log::system(_log, _sys); }
91 static GENERIC int thread_per_system(T compile_time_param){
96 static GENERIC int shmem_per_system(T compile_time_param) {
110 double x,y,z,vx,vy,vz; _sys[b].get(x,y,z,vx,vy,vz);
112 double r = _sys[b].distance_to_origin();
113 if( r < _params.rmax )
return false;
114 double rdotv = x*vx+y*vy+z*vz;
115 if( rdotv <= 0. )
return false;
118 double speed_sq = _sys[b].speed_squared();
119 double epp = 0.5*speed_sq*r/_sys[b].mass()-1.;
120 if( fabs(epp) < 1e-4 ) {
121 double energy = 0.5*speed_sq-_sys[b].mass()/r;
123 lprintf(_log,
"Orbit is nearly parabolic: _sys=%d, bod=%d, T=%lg r=%lg energy=%lg energy*r/GM=%lg.\n"
124 , _sys.number(), b, _sys.time() , r, energy, epp );
126 }
else if ( epp > 0 ){
127 double energy = 0.5*speed_sq-_sys[b].mass()/r;
129 lprintf(_log,
"Orbit is hyperbolic: _sys=%d, bod=%d, T=%lg r=%lg energy=%lg energy*r/GM=%lg.\n"
130 , _sys.number(), b, _sys.time() , r, energy, epp );
144 if(need_to_log_system() && (thread_in_system==0) )
150 GPUAPI
void operator () (
int thread_in_system)
152 if(!is_any_on())
return;
155 if(thread_in_system==0)
158 for(
int b = 1; b < _sys.nbod(); b++)
165 if(is_deactivate_on())
174 :_params(p),_sys(s),_log(l){}
179 bool need_full_test =
false;
180 condition_met =
false;
181 if(is_any_on()&&(thread_in_system==0))
184 for(
int b = 1; b < _sys.nbod(); b++)
185 condition_met = condition_met ||
test_body(b);
187 if( condition_met && is_log_on() )
188 { need_full_test =
true; }
192 return need_full_test;
198 if(is_condition_met() && is_deactivate_on() )
199 { _sys.set_disabled(); }