Path Integral Quantum Monte Carlo
Public Member Functions | Static Public Member Functions | Protected Member Functions
Communicator Class Reference

Performs input/output. More...

#include <communicator.h>

Public Member Functions

void init (double, bool, string, string)
 Initialize the output files. More...
 
Filefile (string type)
 Get method returning file object.
 
void updateNames ()
 Update the data name and rename any existing files.
 

Static Public Member Functions

static CommunicatorgetInstance ()
 This public method gets an instance of the Communicator object, only one can ever exist at a time.
 

Protected Member Functions

 Communicator (const Communicator &)
 Copy constructor.
 
Communicatoroperator= (const Communicator &)
 Singleton equals.
 

Detailed Description

Performs input/output.

Holds information on input and output files that will need to be accessed throughout the simulation and allows their access via the singleton design pattern.

See also
http://en.wikipedia.org/wiki/Singleton_pattern

Definition at line 76 of file communicator.h.

Member Function Documentation

◆ init()

void Communicator::init ( double  _tau,
bool  outputWorldline,
string  _initName,
string  _fixedName 
)

Initialize the output files.

Initialize all input/output files.

If we are in the grand-canonical ensemble, then initialize all output files with the form gce-xxx-T-L-mu-tau-ID.dat, whereas if we are in the canonical ensemble we label as ce-xxx-T-N-n-tau-ID.dat.

Definition at line 137 of file communicator.cpp.

139 {
140 
141  /* Set local class variables */
142  baseDir = "OUTPUT";
143  initName = _initName;
144  fixedName = _fixedName;
145  tau = _tau;
146 
147 
148  /* Determine the ensemble and unique parameter file string or dataname */
149  if (!constants()->canonical()) {
150  ensemble = "gce";
151  dataName = str(format("%06.3f-%07.3f-%+08.3f-%7.5f-%s") % constants()->T()
152  % constants()->L() % constants()->mu() % tau % constants()->id());
153  }
154  else {
155  ensemble = "ce";
156  dataName = str(format("%06.3f-%04d-%06.3f-%7.5f-%s") % constants()->T()
157  % constants()->initialNumParticles()
158  % (1.0*constants()->initialNumParticles()/constants()->V())
159  % tau % constants()->id());
160  }
161 
162  /* Check to make sure the correct directory structure for OUTPUT files is
163  * in place. */
164  filesystem::path outputPath(baseDir);
165  filesystem::create_directory(outputPath);
166 
167  /* If we have cylinder output files, add the required directory. */
168  if (constants()->extPotentialType().find("tube") != string::npos) {
169  filesystem::path cylPath(baseDir + "/CYLINDER");
170  filesystem::create_directory(cylPath);
171  }
172 
173  /* A header line for the files */
174  header = str(format("# PIMCID: %s\n") % constants()->id());
175 
176  /* Depending on whether or not we are restarting the simulations, the open mode
177  * changes. */
178  if (constants()->restart()) {
179  mode = ios::out|ios::app;
180  }
181  else {
182  mode = ios::out;
183  }
184 }
ensemble
Each move can operate on only the digaonal ensemble, only the off-diagonal ensemble,...
Definition: common.h:133
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: