示例#1
0
int Sisim::execute( GsTL_project* ) {

  // Initialize the global random number generator
  Global_random_number_generator::instance()->seed( seed_ );
  
  // Set up a progress notifier	
  int total_steps = simul_grid_->size() * (nb_of_realizations_);
  int frequency = std::max( total_steps / 20, 1 );
  SmartPtr<Progress_notifier> progress_notifier = 
    utils::create_notifier( "Running Sisim", 
			    total_steps, frequency );

  // work on the fine grid
  if( dynamic_cast<Strati_grid*>( simul_grid_ ) ) {
    Strati_grid* sgrid = dynamic_cast<Strati_grid*>( simul_grid_ );
    sgrid->set_level( 1 );
  }

  // compute the random path
  simul_grid_->init_random_path();

  if( do_median_ik_ ) {
    return median_ik( progress_notifier.raw_ptr() );
  }
  else
    return full_ik( progress_notifier.raw_ptr() );
}
int Indicator_kriging::execute( GsTL_project* ) {
  // Set up a progress notifier	
  SmartPtr<Progress_notifier> progress_notifier = 
    utils::create_notifier( "Running Indicator Kriging", 
			    simul_grid_->size() + 1,  
			    std::max( simul_grid_->size() / 100, 1 ) );

  if( do_median_ik_ ) 
    return median_ik( progress_notifier.raw_ptr() );
  else
    return full_ik( progress_notifier.raw_ptr() );
}
int Cosisim::execute( GsTL_project* ) {
  // Initialize the global random number generator
  Global_random_number_generator::instance()->seed( seed_ );

  // Set up a progress notifier	
  int total_steps = simul_grid_->size() * (nb_of_realizations_);
  int frequency = std::max( total_steps / 20, 1 );
  SmartPtr<Progress_notifier> progress_notifier = 
    utils::create_notifier( "Running CoSisim", 
			    total_steps, frequency );


  simul_grid_->init_random_path();

  // loop on all realizations
  for( int nreal = 0; nreal < nb_of_realizations_ ; nreal ++ ) {

    // update the progress notifier
    progress_notifier->message() << "working on realization " 
                                 << nreal+1 << gstlIO::end;
    if( !progress_notifier->notify() ) return 1;


    // Create a new property to hold the realization and tell the simulation 
    // grid to use it as the current property 
    appli_message( "Creating new realization" );
    Grid_continuous_property* prop = multireal_property_->new_realization();
    prop->set_parameters(parameters_);
    simul_grid_->select_property( prop->name() );

    typedef Geostat_grid::random_path_iterator RandomPathIterator;
    RandomPathIterator path_begin = simul_grid_->random_path_begin();
    RandomPathIterator path_end = simul_grid_->random_path_end();

    int status = 0;
    if( do_median_ik_ )
      status = median_ik( path_begin, path_end, progress_notifier.raw_ptr() );
    else
      status = full_ik( path_begin, path_end, progress_notifier.raw_ptr() );

    reset_indicator_properties();

    // check if the simulation was aborted
    if( status == 1 ) {
      clean( prop );
      return 1;
    }

  } // end loop on realizations

  remove_temporary_properties();
  return 0;
}