31 name = str(format(
"%s/%s-%s-%s.dat") % outDir %
ensemble % _type % _data);
34 bakname = str(format(
"%s/%s-%s-%s.bak") % outDir %
ensemble % _type % _data);
37 exists_ = filesystem::exists(name);
67 rwfile.open(name.c_str(), mode);
69 cerr <<
"Unable to process file: " << name << endl;
83 rwfile.open(_name.c_str(), mode);
85 cerr <<
"Unable to process file: " << _name << endl;
102 open(ios::out|ios::trunc,bakname);
121 filesystem::rename(bakname.c_str(), name.c_str());
143 initName = _initName;
144 fixedName = _fixedName;
151 dataName = str(format(
"%06.3f-%07.3f-%+08.3f-%7.5f-%s") %
constants()->T()
156 dataName = str(format(
"%06.3f-%04d-%06.3f-%7.5f-%s") %
constants()->T()
164 filesystem::path outputPath(baseDir);
165 filesystem::create_directory(outputPath);
168 if (
constants()->extPotentialType().find(
"tube") != string::npos) {
169 filesystem::path cylPath(baseDir +
"/CYLINDER");
170 filesystem::create_directory(cylPath);
174 header = str(format(
"# PIMCID: %s\n") %
constants()->
id());
179 mode = ios::out|ios::app;
189 void Communicator::initFile(
string type) {
192 if (type.find(
"init") != string::npos ) {
196 string stateName =
"state";
200 stateName += stateName.substr(4,string::npos);
205 file_.insert(type,
new File(stateName,dataName,
ensemble,baseDir));
207 file_.insert(type,
new File(initName));
209 file_.at(type).open(ios::in);
212 else if (type ==
"fixed") {
213 file_.insert(type,
new File(fixedName));
214 file_.at(type).open(ios::in);
218 string outDir = baseDir;
222 if (type.find(
"cyl_") != string::npos) {
223 outDir = baseDir +
"/CYLINDER";
228 file_.insert(type,
new File(ctype,dataName,
ensemble,outDir));
229 file_.at(type).open(mode);
232 if (!file_.at(type).exists())
233 file_.at(type).stream() << header;
246 dataName = str(format(
"%06.3f-%07.3f-%+08.3f-%7.5f-%s") %
constants()->T()
250 dataName = str(format(
"%06.3f-%04d-%06.3f-%7.5f-%s") %
constants()->T()
257 for (
auto const& [key, filePtr] : file_)
260 string oldName(filePtr->name);
264 filePtr->name.replace(filePtr->name.end()-dataName.length()-4,filePtr->name.end()-4,dataName);
265 filePtr->bakname.replace(filePtr->bakname.end()-dataName.length()-4,filePtr->bakname.end()-4,dataName);
268 filesystem::rename(oldName.c_str(), filePtr->name.c_str());
void init(double, bool, string, string)
Initialize the output files.
static Communicator * getInstance()
This public method gets an instance of the Communicator object, only one can ever exist at a time.
void updateNames()
Update the data name and rename any existing files.
A basic input/output file class.
void reset()
Reset a file.
void rename()
Rename a file.
File(string, string, string, string)
Constructor.
void close()
Close the file.
void open(ios_base::openmode)
Open the file.
ensemble
Each move can operate on only the digaonal ensemble, only the off-diagonal ensemble,...
Class definitions for all file input/output.
ConstantParameters * constants()
Global public access to the constants.