GPUAPI int pass_two (int thread_in_system) 
          {
	    int new_state = _sys.state();
	    if(is_any_on() && need_full_test) // implies thread_in_system==0
	      {
		// Check for distance from other bodies
		int num_body_far_from_all = 0;
		for(int b = 0 ; b < _sys.nbod(); b ++ )
		  {
		    if(_sys.radius_squared(b) <= _params.rmax*_params.rmax ) continue; // WARNING: Confusing function name
		    bool is_far_from_every_body = true;
		    for(int bb = 0 ; bb < _sys.nbod(); bb ++ ){		
		      if(b == bb) continue;
		      if(_sys.distance_squared_between(b,bb) < _params.rmax*_params.rmax )
			{ is_far_from_every_body = false;  break; }
		    }
		    if(is_far_from_every_body) 
		      {   num_body_far_from_all++;	  }
		  }
		if(num_body_far_from_all+2>=_sys.nbod())
		  {
		    condition_met = true;
		    if(is_verbose_on())
		      lprintf(_log, "No more than two bodies are within rmax of other bodies: _sys=%d, bod1=%d, bod2=%d, T=%lg r=%lg rmax=%lg.\n"
			      , _sys.number(), id1, id2, _sys.time() , r, _params.rmax);
		    if(is_deactivate_on() && (_sys.state()>=0) )
		      {  _sys.set_disabled();  new_state = _sys.state(); }
		  }
	      }
	    return new_state;
	  }
예제 #2
0
	GPUAPI bool pass_one (int thread_in_system) 
          {
	    bool need_full_test = false; 
	    condition_met = false;
	    if(is_any_on()&&(thread_in_system==0))
	      {
		// Check each body other than central star
		for(int b = 1; b < _sys.nbod(); b++)
		  condition_met = condition_met || test_body(b);
		
		if( condition_met && is_log_on() )
		  {  need_full_test = true;  }


	      }
	    return need_full_test;
	  }
  //	GPUAPI void operator () () { 
  GPUAPI void operator () (int thread_in_system) {
	  if(!is_any_on()) return;

		if(thread_in_system==0)
		  {
		// Check for distance from origin
		int num_body_near_origin = 0, id1 = -1, id2 = -2;
		for(int b = 0 ; b < _sys.nbod(); b ++ ){
			if(_sys.radius_squared(b) <= _params.rmax*_params.rmax ) // WARNING: Confusing function name
				{
				if(num_body_near_origin==0) id1 = b;
				if(num_body_near_origin==1) id2 = b;
				 num_body_near_origin++;
				}
		}
		if( num_body_near_origin > 2 )
		  return;
 
		// Check for distance from other bodies
		int num_body_far_from_all = 0;
		for(int b = 0 ; b < _sys.nbod(); b ++ ){
			if(_sys.radius_squared(b) <= _params.rmax*_params.rmax ) continue; // WARNING: Confusing function name
			bool is_far_from_every_body = true;
			for(int bb = 0 ; bb < _sys.nbod(); bb ++ ){		
			   if(b == bb) continue;
			   if(_sys.distance_squared_between(b,bb) < _params.rmax*_params.rmax )
					{ is_far_from_every_body = false;  break; }
				}
			if(is_far_from_every_body) 
				{
				num_body_far_from_all++;
				}
		}
		if(num_body_far_from_all+2>=_sys.nbod())
			{
			  if(is_verbose_on())
			lprintf(_log, "No more than two bodies are within rmax of other bodies: _sys=%d, bod1=%d, bod2=%d, T=%lg r=%lg rmax=%lg.\n"
				, _sys.number(), id1, id2, _sys.time() , r, _params.rmax);
			  if(is_log_on())
			log::system(_log, _sys);
			  if(is_deactivate_on())
			  _sys.set_disabled();
			}
		  }
  }
예제 #4
0
  //	GPUAPI void operator () () { 	
	GPUAPI void operator () (int thread_in_system) 
          { 
	  if(!is_any_on()) return;
		bool stopit = false;

		if(thread_in_system==0)
		  {
		// Check each body other than central star
		for(int b = 1; b < _sys.nbod(); b++)
			stopit = stopit || test_body(b);

		    if(stopit) 
		      {
		      if(is_log_on())
			log::system(_log, _sys);
		      if(is_deactivate_on())
			_sys.set_disabled();
		      }
		  }
	  }
	GPUAPI bool pass_one (int thread_in_system) 
          {
	    need_full_test = false; 
	    condition_met = false;
	    if(is_any_on()&&(thread_in_system==0))
	      {
		// Check for distance from origin
		int num_body_near_origin = 0, id1 = -1, id2 = -2;
		for(int b = 0 ; b < _sys.nbod(); b ++ ){
		  if(_sys.radius_squared(b) <= _params.rmax*_params.rmax ) // WARNING: Confusing function name
		    {
		      if(num_body_near_origin==0) id1 = b;
		      if(num_body_near_origin==1) id2 = b;
		      num_body_near_origin++;
		    }
		}
		if( num_body_near_origin <= 2 )
		  {  need_full_test = true;  }
	      }
	    return need_full_test;
	  }
예제 #6
0
	GPUAPI bool pass_one (int thread_in_system) 
          {
	    need_full_test = false; 
	    condition_met = false;
	    if(is_any_on()&&(thread_in_system==0))
	      {
		bool is_any_body_far_from_origin = false;
		for(int b = 0 ; b < _sys.nbod(); b ++ )
		  {
		    if(_sys.radius_squared(b) > _params.rmax * _params.rmax )
		      is_any_body_far_from_origin = true;
		  }
		if(!is_any_body_far_from_origin) break;
		bool need_to_log = false;
		for(int b = 0 ; b < _sys.nbod(); b ++ )
		  {
		    if(_sys.radius_squared(b) >= _params.rmax * _params.rmax ) 
		      {
			bool is_far_from_every_body = true;
			for(int bb = 0 ; bb < _sys.nbod(); bb ++ )
			  if(b != bb) 
			    {
			      double r2 = _sys.distance_squared_between(b,bb);
			      if(r2 < _params.rmax*_params.rmax )
				is_far_from_every_body = false;
			    }
			if(is_far_from_every_body) 
			  {
			    condition_met = true;
			    if( is_log_on() )
			      need_full_test = true;
			    if(is_verbose_on() )
			      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);
			  }
		      } // if far from origin
		  } // for bodies
	      }
	    return need_full_test;
	  }
예제 #7
0
  //	GPUAPI void operator () () { 
  GPUAPI void operator () (int thread_in_system) {
	  if(!is_any_on()) return;

		if(thread_in_system==0)
		  {

		bool is_any_body_far_from_origin = false;
		for(int b = 0 ; b < _sys.nbod(); b ++ ){
			if(_sys.radius_squared(b) > _params.rmax * _params.rmax )
				is_any_body_far_from_origin = true;
		}
		if(!is_any_body_far_from_origin) return;
		bool need_to_log = false;
		for(int b = 0 ; b < _sys.nbod(); b ++ ){
			if(_sys.radius_squared(b) >= _params.rmax * _params.rmax ) {
				bool is_far_from_every_body = true;
				for(int bb = 0 ; bb < _sys.nbod(); bb ++ )
					if(b != bb) {
						double r2 = _sys.distance_squared_between(b,bb);
						if(r2 < _params.rmax*_params.rmax )
							is_far_from_every_body = false;
					}
				if(is_far_from_every_body) {
				  if(is_verbose_on() )
					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);
				  if(is_log_on() )
				    need_to_log = true;

				  if(is_deactivate_on() )
					a_sys.set_disabled();
				}
			}
		}
		if(need_to_log)
		   log::system(_log, _sys);		  
		  }
  }