X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/36bc55ceb7b62569c7604f28b3e53bc2e42cf0ce..refs/heads/master:/o815/sim.cpp diff --git a/o815/sim.cpp b/o815/sim.cpp index b37549a..ec47339 100644 --- a/o815/sim.cpp +++ b/o815/sim.cpp @@ -3,82 +3,73 @@ #include "latlib/hypercache.h" #include "latlib/progress.h" +#include "latlib/datread.h" + o815::sim::sim(o815 *_O815, const int& _confmemSize) { O815 = _O815; log = O815->out->log; hypercache::initC(O815->programid, O815->comargs.nequi, O815->comargs.nskip, O815->comargs.confcache.first, &confMem, _confmemSize, O815->comargs.confcache.second, log); nequi = O815->comargs.nequi; nskip = O815->comargs.nskip; - confmemSize = confmemSize; -} - -void o815::sim::nextConfig() { - bool readnewconfig; - int nequileftReadConfig; - bool skippedInEqui = false; - bool readNoSingleConfig = true; - bool createdNoNewConfigs = true; - - hypercache::readC(readnewconfig, nequileftReadConfig); - - if (readnewconfig) { - nequileft = nequileftReadConfig; - readNoSingleConfig = false; - } - - /* try to find more equilibrated config-file for equilibration including excluded files */ - if ( nequileft > 0 && hypercache::CFilesLeft() > 0 ) { - char *tmpconfig = (char*) malloc(confmemSize); + confmemSize = _confmemSize; - while (true) { - memcpy (tmpconfig, confMem, confmemSize); - hypercache::readC(readnewconfig, nequileftReadConfig); - - if (! readnewconfig) { - *log << "SIM: No more excluded config-files for possible equilibration available." << endl << flush; - break; - } + startConfiguration = NULL; + + if ( O815->comargs.startconfig != "" ) { + *log << "SIM: Fetching startconfig from " << O815->comargs.startconfig << endl; + + datread dataReader(confmemSize); + dataReader.openFile(O815->comargs.startconfig); + + if ( dataReader.fisopen() ) { + startConfiguration = (char*)malloc(confmemSize); - if (nequileftReadConfig <= nequileft) { - *log << "SIM: Found more equilibrated or same equilibrated excluded config-file configuration for equilibration." << endl << flush; - nequileft = nequileftReadConfig; - readNoSingleConfig = false; - } - else if (nequileftReadConfig > nequileft) { - *log << "SIM: Excluded config-file configuration for equilibration is less equilibrated than actual config." << endl << flush; - memcpy (confMem, tmpconfig, confmemSize); - } + if ( dataReader.readFullBlock(startConfiguration) < 0 ) { + *log << "SIM: Error while reading config from " << O815->comargs.startconfig << endl; + delete[] startConfiguration; + startConfiguration = NULL; + } + } + else { + *log << "SIM: Could not open startconfigfile " << O815->comargs.startconfig << endl; } - free(tmpconfig); } + +} + +o815::sim::~sim () +{ + if (startConfiguration != NULL) + delete[] startConfiguration; +} + +void o815::sim::nextConfig() { + bool readAtLeastOneConfig = hypercache::readC(); /* equilibrate if necessary */ - if (nequileft > 0) { + if (hypercache::getNEquiLeft() > 0) { *log << "SIM: Starting equilibration." << endl << flush; - if (nequileft != nequi) - *log << "SIM: " << nequileft << " of " << nequi << " equilibration steps left after virtual equilibration." << endl << flush; - progress equiProg(nequileft); - for ( int iequi=0; iequi= 0) ) { for (int iskip=0; iskip