48 bool deactivate_on, log_on, verbose_on;
53 rmax = cfg.
optional(
"rmax",std::numeric_limits<float>::max());
54 deactivate_on = cfg.
optional(
"deactivate_on_any_large_distance",
false);
55 log_on = cfg.
optional(
"log_on_any_large_distance",
false);
56 verbose_on = cfg.
optional(
"verbose_on_any_large_distance",
false);
79 bool need_full_test, condition_met;
81 ensemble::SystemRef& _sys;
86 static GENERIC int thread_per_system(T compile_time_param){
91 static GENERIC int shmem_per_system(T compile_time_param) {
94 GPUAPI
bool is_deactivate_on() {
return _params.deactivate_on; };
95 GPUAPI
bool is_log_on() {
return _params.log_on; };
96 GPUAPI
bool is_verbose_on() {
return _params.verbose_on; };
97 GPUAPI
bool is_any_on() {
return is_deactivate_on() || is_log_on() || is_verbose_on() ; }
98 GPUAPI
bool is_condition_met () {
return ( condition_met ); }
99 GPUAPI
bool need_to_log_system ()
100 {
return (is_log_on() && is_condition_met() ); }
101 GPUAPI
bool need_to_deactivate ()
102 {
return ( is_deactivate_on() && is_condition_met() ); }
104 GPUAPI
void log_system() {
log::system(_log, _sys); }
109 need_full_test =
false;
110 condition_met =
false;
111 if(is_any_on()&&(thread_in_system==0))
113 bool is_any_body_far_from_origin =
false;
114 for(
int b = 0 ; b < _sys.nbod(); b ++ )
116 if(_sys.distance_to_origin_squared(b) > _params.rmax * _params.rmax )
117 is_any_body_far_from_origin =
true;
119 if(!is_any_body_far_from_origin)
break;
120 bool need_to_log =
false;
121 for(
int b = 0 ; b < _sys.nbod(); b ++ )
123 if(_sys.distance_to_origin_squared(b) >= _params.rmax * _params.rmax )
125 bool is_far_from_every_body =
true;
126 for(
int bb = 0 ; bb < _sys.nbod(); bb ++ )
129 double r2 = _sys.distance_squared_between(b,bb);
130 if(r2 < _params.rmax*_params.rmax )
131 is_far_from_every_body =
false;
133 if(is_far_from_every_body)
135 condition_met =
true;
137 need_full_test =
true;
139 lprintf(_log,
"Distance from all bodies exceeds rmax: _sys=%d, bod=%d, T=%lg r=%lg rmax=%lg.\n", _sys.number(), b, _sys.time() , sqrt(r2), _params.rmax);
144 return need_full_test;
150 if(is_condition_met() && is_deactivate_on() &&(thread_in_system==0) )
151 { _sys.set_disabled(); }
166 GPUAPI
void operator () (
int thread_in_system) {
167 if(!is_any_on())
return;
169 if(thread_in_system==0)
172 bool is_any_body_far_from_origin =
false;
173 for(
int b = 0 ; b < _sys.nbod(); b ++ ){
174 if(_sys.distance_to_origin_squared(b) > _params.rmax * _params.rmax )
175 is_any_body_far_from_origin =
true;
177 if(!is_any_body_far_from_origin)
return;
178 bool need_to_log =
false;
179 for(
int b = 0 ; b < _sys.nbod(); b ++ ){
180 if(_sys.distance_to_origin_squared(b) >= _params.rmax * _params.rmax ) {
181 bool is_far_from_every_body =
true;
182 for(
int bb = 0 ; bb < _sys.nbod(); bb ++ )
184 double r2 = _sys.distance_squared_between(b,bb);
185 if(r2 < _params.rmax*_params.rmax )
186 is_far_from_every_body =
false;
188 if(is_far_from_every_body) {
190 lprintf(_log,
"Distance from all bodies exceeds rmax: _sys=%d, bod=%d, T=%lg r=%lg rmax=%lg.\n", _sys.number(), b, _sys.time() , sqrt(r2), _params.rmax);
194 if(is_deactivate_on() )
195 a_sys.set_disabled();
205 GPUAPI stop_on_any_large_distance(
const params& p,ensemble::SystemRef& s,log_t& l)
206 :_params(p),_sys(s),_log(l)