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(); }
void close(IFile& file) override { file.close(); file.release(); }