Class TextOutput

Inheritance Relationships

Base Type

Class Documentation

class TextOutput : public Output

Configurable plain text output for particle information. This type of output can also be used to generate a .tar.gz file if the library zlib is available. For details see: http://zlib.net/.

Public Types

enum OutputColumn

Values:

enumerator TrajectoryLengthColumn
enumerator ColumnDensityColumn
enumerator RedshiftColumn
enumerator CurrentIdColumn
enumerator CurrentEnergyColumn
enumerator CurrentPositionColumn
enumerator CurrentDirectionColumn
enumerator SourceIdColumn
enumerator SourceEnergyColumn
enumerator SourcePositionColumn
enumerator SourceDirectionColumn
enumerator CreatedIdColumn
enumerator CreatedEnergyColumn
enumerator CreatedPositionColumn
enumerator CreatedDirectionColumn
enumerator CandidateTagColumn
enumerator SerialNumberColumn
enumerator WeightColumn
enumerator TimeColumn
enum OutputType

Values:

enumerator Trajectory1D
enumerator Trajectory3D
enumerator Event1D
enumerator Event3D
enumerator Everything

Public Functions

TextOutput()

Default constructor

TextOutput(OutputType outputType)

Constructor

Parameters:

outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

TextOutput(std::ostream &out)

Constructor

Parameters:

out – output stream

TextOutput(std::ostream &out, OutputType outputType)

Constructor

Parameters:
  • out – output stream

  • outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

TextOutput(const std::string &filename)

Constructor with the default OutputType (everything).

Parameters:

filename – string containing name of output text file

TextOutput(const std::string &filename, OutputType outputType)

Constructor

Parameters:
  • filename – string containing name of output text file

  • outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

~TextOutput()

Destructor

inline void enableRandomSeeds()

Whether to store the random seeds used in the simulation. This enables reproducibility of each realisation of the simulation.

void close()
void gzip()
virtual void process(Candidate *candidate) const

Process function This is the main function to work with, it is called during every ModuleList::run step. Derived functions need to override this overload of process!

Parameters:

candidateCandidate raw pointer

virtual std::string getDescription() const

Returns description, can be overriden by derived class.

virtual void dumpIndexList(std::vector<int> indicies)

write the indices of not started candidates into the output file. Used for interrupting the simulation

Parameters:

indices – list of not started indices

std::string OutputTypeName(OutputType outputtype)
void setEnergyScale(double scale)

Set energy scale.

Parameters:

scale – energy scale (scale = 1 corresponds to 1 Joule)

double getEnergyScale() const
void setLengthScale(double scale)

Set length scale.

Parameters:

scale – length scale (scale = 1 corresponds to 1 meter)

double getLengthScale() const
void setTimeScale(double scale)

Set time scale.

Parameters:

scale – time scale (scale = 1 corresponds to 1 second)

double getTimeScale() const
void setOutputType(OutputType outputType)

Set type of output.

Parameters:

outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

void set(OutputColumn field, bool value)

Determines whether a given column will be displayed in the output.

Parameters:
  • field – name of the field to be added/removed from output

  • value – boolean flag adding (true) or removing (false) the field

void enableProperty(const std::string &property, const Variant &defaultValue, const std::string &comment = "")

Add a property to output. Default value is required to assign a type in the output.

Parameters:
  • property – string containing name of property

  • defaultValue – default value of property

  • comment – string with a comment

void enable(OutputColumn field)

Enable specific column in the output.

Parameters:

field – name of the field to be enabled

void disable(OutputColumn field)

Disable specific column in the output.

Parameters:

field – name of the field to be disabled

void enableAll()

Enable all fields. Essentially a wrapper for set(field, true).

void disableAll()

Disable all fields. Essentially a wrapper for set(field, false).

void set1D(bool value)

If true, output is of 1D type. 3D quantities such as vectors will be reduced to the relevant components (x, by default).

Parameters:

value – boolean flag

size_t size() const

Returns the size of the output

inline void process(ref_ptr<Candidate> candidate) const

Process function Overload for process function to explicitly make a conversion from ref_ptr to a raw pointer

void setDescription(const std::string &description)

Sets description, can be used instead of getDescription in derived class

Parameters:

description – Description string

inline size_t addReference() const
inline size_t removeReference() const
inline int removeReferenceNoDelete() const
inline size_t getReferenceCount() const

Public Members

const std::string outputName

Public Static Functions

static void load(const std::string &filename, ParticleCollector *collector)

Loads a file to a particle collector.

Parameters:
  • filename – string containing the name of the file to be loaded

  • collector – object of type ParticleCollector that will store the information

Protected Functions

void printHeader() const
void modify()

Protected Attributes

std::ostream *out
std::ofstream outfile
std::string filename
bool storeRandomSeeds
double lengthScale
double timeScale
double energyScale
std::bitset<64> fields
std::vector<Property> properties
bool oneDimensional
mutable size_t count
mutable size_t _referenceCount