Exemplo n.º 1
0
void RBEIMEvaluation::legacy_read_offline_data_from_files(const std::string & directory_name,
                                                          bool read_error_bound_data,
                                                          const bool read_binary_data)
{
  LOG_SCOPE("legacy_read_offline_data_from_files()", "RBEIMEvaluation");

  Parent::legacy_read_offline_data_from_files(directory_name, read_error_bound_data);

  // First, find out how many basis functions we had when Greedy terminated
  // This was set in RBSystem::read_offline_data_from_files
  unsigned int n_bfs = this->get_n_basis_functions();

  // The writing mode: DECODE for binary, READ for ASCII
  XdrMODE mode = read_binary_data ? DECODE : READ;

  // The suffix to use for all the files that are written out
  const std::string suffix = read_binary_data ? ".xdr" : ".dat";

  // Stream for creating file names
  std::ostringstream file_name;

  // Read in the interpolation matrix
  file_name.str("");
  file_name << directory_name << "/interpolation_matrix" << suffix;
  assert_file_exists(file_name.str());

  Xdr interpolation_matrix_in(file_name.str(), mode);

  for(unsigned int i=0; i<n_bfs; i++)
    {
      for(unsigned int j=0; j<=i; j++)
        {
          Number value;
          interpolation_matrix_in >> value;
          interpolation_matrix(i,j) = value;
        }
    }
  interpolation_matrix_in.close();

  // Next read in interpolation_points
  file_name.str("");
  file_name << directory_name << "/interpolation_points" << suffix;
  assert_file_exists(file_name.str());

  Xdr interpolation_points_in(file_name.str(), mode);

  for(unsigned int i=0; i<n_bfs; i++)
    {
      Real x_val, y_val, z_val = 0.;
      interpolation_points_in >> x_val;

      if(LIBMESH_DIM >= 2)
        interpolation_points_in >> y_val;

      if(LIBMESH_DIM >= 3)
        interpolation_points_in >> z_val;

      Point p(x_val, y_val, z_val);
      interpolation_points.push_back(p);
    }
  interpolation_points_in.close();

  // Next read in interpolation_points_var
  file_name.str("");
  file_name << directory_name << "/interpolation_points_var" << suffix;
  assert_file_exists(file_name.str());

  Xdr interpolation_points_var_in(file_name.str(), mode);

  for(unsigned int i=0; i<n_bfs; i++)
    {
      unsigned int var;
      interpolation_points_var_in >> var;
      interpolation_points_var.push_back(var);
    }
  interpolation_points_var_in.close();

  // Read in the elements corresponding to the interpolation points
  legacy_read_in_interpolation_points_elem(directory_name);
}
Exemplo n.º 2
0
void RBEIMEvaluation::read_offline_data_from_files(const std::string& directory_name,
                                                   bool read_error_bound_data,
                                                   const bool read_binary_data)
{
  START_LOG("read_offline_data_from_files()", "RBEIMEvaluation");

  Parent::read_offline_data_from_files(directory_name, read_error_bound_data);

  // First, find out how many basis functions we had when Greedy terminated
  // This was set in RBSystem::read_offline_data_from_files
  unsigned int n_bfs = this->get_n_basis_functions();

  // The writing mode: DECODE for binary, READ for ASCII
  XdrMODE mode = read_binary_data ? DECODE : READ;

  // The suffix to use for all the files that are written out
  const std::string suffix = read_binary_data ? ".xdr" : ".dat";

  // Stream for creating file names
  OStringStream file_name;

  // Read in the interpolation matrix
  file_name.str("");
  file_name << directory_name << "/interpolation_matrix" << suffix;
  Xdr interpolation_matrix_in(file_name.str(), mode);

  for(unsigned int i=0; i<n_bfs; i++)
  {
    for(unsigned int j=0; j<=i; j++)
    {
      Number value;
      interpolation_matrix_in >> value;
      interpolation_matrix(i,j) = value;
    }
  }
  interpolation_matrix_in.close();

  // Also, read in the "extra" row
  file_name.str("");
  file_name << directory_name << "/extra_interpolation_matrix_row" << suffix;
  Xdr extra_interpolation_matrix_row_in(file_name.str(), mode);
  
  for(unsigned int j=0; j<n_bfs; j++)
  {
    Number value;
    extra_interpolation_matrix_row_in >> value;
    extra_interpolation_matrix_row(j) = value;
  }
  extra_interpolation_matrix_row_in.close();

  // Next read in interpolation_points
  file_name.str("");
  file_name << directory_name << "/interpolation_points" << suffix;
  Xdr interpolation_points_in(file_name.str(), mode);
  
  for(unsigned int i=0; i<n_bfs; i++)
  {
    Real x_val, y_val, z_val = 0.;
    interpolation_points_in >> x_val;
    
    if(LIBMESH_DIM >= 2)
      interpolation_points_in >> y_val;

    if(LIBMESH_DIM >= 3)
      interpolation_points_in >> z_val;

    Point p(x_val, y_val, z_val);
    interpolation_points.push_back(p);
  }
  interpolation_points_in.close();

  // Also, read in the extra interpolation point
  file_name.str("");
  file_name << directory_name << "/extra_interpolation_point" << suffix;
  Xdr extra_interpolation_point_in(file_name.str(), mode);
  
  for(unsigned int i=0; i<n_bfs; i++)
  {
    Real x_val, y_val, z_val = 0.;
    extra_interpolation_point_in >> x_val;

    if(LIBMESH_DIM >= 2)
      extra_interpolation_point_in >> y_val;

    if(LIBMESH_DIM >= 3)
      extra_interpolation_point_in >> z_val;

    Point p(x_val, y_val, z_val);
    extra_interpolation_point = p;
  }
  extra_interpolation_point_in.close();


  // Next read in interpolation_points_var
  file_name.str("");
  file_name << directory_name << "/interpolation_points_var" << suffix;
  Xdr interpolation_points_var_in(file_name.str(), mode);
  
  for(unsigned int i=0; i<=n_bfs; i++)
  {
    unsigned int var;
    interpolation_points_var_in >> var;
    interpolation_points_var.push_back(var);
  }
  interpolation_points_var_in.close();

  // Also, read in extra_interpolation_point_var
  file_name.str("");
  file_name << directory_name << "/extra_interpolation_point_var" << suffix;
  Xdr extra_interpolation_point_var_in(file_name.str(), mode);
  
  for(unsigned int i=0; i<=n_bfs; i++)
  {
    unsigned int var;
    extra_interpolation_point_var_in >> var;
    extra_interpolation_point_var = var;
  }
  extra_interpolation_point_var_in.close();

  STOP_LOG("read_offline_data_from_files()", "RBEIMEvaluation");
}