Пример #1
0
static bool enkf_config_node_has_container(const enkf_config_node_type * node , enkf_fs_type * fs , node_id_type node_id) {
  bool has_container = true;

  for (int inode=0; inode < vector_get_size( node->container_nodes ); inode++) {
    enkf_config_node_type * child_node = vector_iget( node->container_nodes , inode );
    if (!enkf_config_node_has_node( child_node , fs , node_id )) {
      has_container = false;
      break;
    }
  }
  return has_container;
}
Пример #2
0
static void enkf_main_copy_ensemble( const enkf_main_type * enkf_main,
                                     enkf_fs_type * source_case_fs,
                                     int source_report_step,
                                     state_enum source_state,
                                     enkf_fs_type * target_case_fs,
                                     int target_report_step,
                                     state_enum target_state,
                                     const bool_vector_type * iens_mask,
                                     const char * ranking_key , /* It is OK to supply NULL - but if != NULL it must exist */
                                     const stringlist_type * node_list) {

    const int ens_size = enkf_main_get_ensemble_size( enkf_main );
    state_map_type * target_state_map = enkf_fs_get_state_map(target_case_fs);

    {
        int * ranking_permutation;
        int inode , src_iens;

        if (ranking_key != NULL) {
            ranking_table_type * ranking_table = enkf_main_get_ranking_table( enkf_main );
            ranking_permutation = (int *) ranking_table_get_permutation( ranking_table , ranking_key );
        } else {
            ranking_permutation = util_calloc( ens_size , sizeof * ranking_permutation );
            for (src_iens = 0; src_iens < ens_size; src_iens++)
                ranking_permutation[src_iens] = src_iens;
        }

        for (inode =0; inode < stringlist_get_size( node_list ); inode++) {
            enkf_config_node_type * config_node = ensemble_config_get_node( enkf_main_get_ensemble_config(enkf_main) , stringlist_iget( node_list , inode ));
            for (src_iens = 0; src_iens < enkf_main_get_ensemble_size( enkf_main ); src_iens++) {
                if (bool_vector_safe_iget(iens_mask , src_iens)) {
                    int target_iens = ranking_permutation[src_iens];
                    node_id_type src_id    = {.report_step = source_report_step , .iens = src_iens    , .state = source_state };
                    node_id_type target_id = {.report_step = target_report_step , .iens = target_iens , .state = target_state };

                    /* The copy is careful ... */
                    if (enkf_config_node_has_node( config_node , source_case_fs , src_id))
                        enkf_node_copy( config_node ,
                                        source_case_fs , target_case_fs ,
                                        src_id , target_id );

                    if (0 == target_report_step)
                        state_map_iset(target_state_map, target_iens, STATE_INITIALIZED);
                }
            }
        }

        if (ranking_permutation == NULL)
            free( ranking_permutation );
    }
}
Пример #3
0
static bool obs_vector_has_data_at_report_step( const obs_vector_type * obs_vector , const bool_vector_type * active_mask , enkf_fs_type * fs, int report_step) {
  void * obs_node = vector_iget( obs_vector->nodes , report_step );
  if ( obs_node ) {
    node_id_type node_id = {.report_step = report_step };
    for (int iens = 0; iens < bool_vector_size( active_mask ); iens++) {
      if (bool_vector_iget( active_mask , iens)) {
        node_id.iens = iens;
        if (! enkf_config_node_has_node(obs_vector->config_node , fs , node_id ))
          return false;
      }
    }
  }

  /*
     Will return true unconditionally if we do not have observation data at this report step;
     or alternatively if the active_mask is all false.
  */
  return true;
}
Пример #4
0
static bool enkf_main_case_is_initialized__( const enkf_main_type * enkf_main , enkf_fs_type * fs , bool_vector_type * __mask) {
    stringlist_type  * parameter_keys = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
    bool_vector_type * mask;
    bool initialized = true;
    int ikey = 0;
    if (__mask != NULL)
        mask = __mask;
    else
        mask = bool_vector_alloc(0 , true );

    while ((ikey < stringlist_get_size( parameter_keys )) && (initialized)) {
        const enkf_config_node_type * config_node = ensemble_config_get_node( enkf_main->ensemble_config , stringlist_iget( parameter_keys , ikey) );
        int iens = 0;
        do {
            if (bool_vector_safe_iget( mask , iens)) {
                node_id_type node_id = {.report_step = 0 , .iens = iens , .state = ANALYZED };
                initialized = enkf_config_node_has_node( config_node , fs , node_id);
            }
            iens++;
        } while ((iens < enkf_main->ens_size) && (initialized));
        ikey++;
    }

    stringlist_free( parameter_keys );
    if (__mask == NULL)
        bool_vector_free( mask );
    return initialized;
}



bool enkf_main_case_is_initialized( const enkf_main_type * enkf_main , const char * case_name ,  bool_vector_type * __mask) {
    enkf_fs_type * fs = enkf_main_mount_alt_fs(enkf_main , case_name , false );
    if (fs) {
        bool initialized = enkf_main_case_is_initialized__(enkf_main , fs , __mask);
        enkf_fs_decref( fs );
        return initialized;
    } else
        return false;
}