Beispiel #1
0
bool CoeffsBase::getIterationCounterAndTimeFromFile(IFile& ifile) {
  bool field_found=false;
  if(ifile.FieldExist(field_time_)) {
    field_found=true;
    double time_tmp;
    ifile.scanField(field_time_,time_tmp);
    time_md=time_tmp;
  }
  if(ifile.FieldExist(field_iteration_)) {
    field_found=true;
    int iter_tmp;
    ifile.scanField(field_iteration_,iter_tmp);
    iteration_opt=(unsigned int) iter_tmp;
  }
  return field_found;
}
Beispiel #2
0
void PammObject::setup( const std::string& filename, const double& reg, const std::vector<std::string>& valnames,
                        const std::vector<bool>& pbcin, const std::vector<std::string>& imin, const std::vector<std::string>& imax,
                        std::string& errorstr ) {
  IFile ifile; regulariser=reg;
  if( !ifile.FileExist(filename) ) {
    errorstr = "could not find file named " + filename;
    return;
  }

  std::vector<std::unique_ptr<Value>> pos;
  pbc.resize( valnames.size() );
  min.resize( valnames.size() );
  max.resize( valnames.size() );
  for(unsigned i=0; i<valnames.size(); ++i) {
    pbc[i]=pbcin[i]; min[i]=imin[i]; max[i]=imax[i];
    pos.emplace_back( new Value() );
    if( !pbc[i] ) pos[i]->setNotPeriodic();
    else pos[i]->setDomain( min[i], max[i] );
  }

  ifile.open(filename); ifile.allowIgnoredFields(); kernels.resize(0);
  for(unsigned k=0;; ++k) {
    std::unique_ptr<KernelFunctions> kk = KernelFunctions::read( &ifile, false, valnames );
    if( !kk ) break ;
    kk->normalize( Tools::unique2raw( pos ) );
    kernels.emplace_back( std::move(kk) );
    ifile.scanField();
  }
  ifile.close();
}
Beispiel #3
0
void CoeffsBase::getCoeffsInfoFromFile(IFile& ifile, const bool ignore_coeffs_info) {
  int int_tmp;
  // label
  std::string coeffs_type_f;
  if(ifile.scanField(field_type_,coeffs_type_f)) {
    // empty for now
  }
  else {
    return;
  }
  // number of dimensions
  unsigned int ndimensions_f = 0;
  if(ifile.scanField(field_ndimensions_,int_tmp)) {
    ndimensions_f=(unsigned int) int_tmp;
  }
  else {
    return;
  }
  // total number of coeffs
  size_t ncoeffs_total_f = 0;
  if(ifile.scanField(field_ncoeffs_total_,int_tmp)) {
    ncoeffs_total_f=(size_t) int_tmp;
  }
  else {
    return;
  }
  // shape of indices
  std::vector<unsigned int> indices_shape_f(numberOfDimensions());
  for(unsigned int k=0; k<numberOfDimensions(); k++) {
    if(ifile.scanField(field_shape_prefix_+getDimensionLabel(k),int_tmp)) {
      indices_shape_f[k]=(unsigned int) int_tmp;
    }
    else {
      return;
    }
  }
  if(!ignore_coeffs_info) {
    std::string msg_header="Error when reading in coeffs from file " + ifile.getPath() + ": ";
    checkCoeffsInfo(msg_header, coeffs_type_f, ndimensions_f, ncoeffs_total_f, indices_shape_f);
  }
}