File datafile.hxx¶
Data file handling object definition.
26th Sep 2009: Modified to use varargs
- Author
- B.Dudson
- Date
- April 2009
Defines
-
SAVE_ONCE1
(var)¶ Write this variable once to the grid file.
-
SAVE_ONCE2
(var1, var2)¶
-
SAVE_ONCE3
(var1, var2, var3)¶
-
SAVE_ONCE4
(var1, var2, var3, var4)¶
-
SAVE_ONCE5
(var1, var2, var3, var4, var5)¶
-
SAVE_ONCE6
(var1, var2, var3, var4, var5, var6)¶
-
SAVE_ONCE
(...)¶
-
SAVE_REPEAT1
(var)¶ Write this variable every timestep.
-
SAVE_REPEAT2
(var1, var2)¶
-
SAVE_REPEAT3
(var1, var2, var3)¶
-
SAVE_REPEAT4
(var1, var2, var3, var4)¶
-
SAVE_REPEAT5
(var1, var2, var3, var4, var5)¶
-
SAVE_REPEAT6
(var1, var2, var3, var4, var5, var6)¶
-
SAVE_REPEAT
(...)¶
-
class
Datafile
¶ - #include <datafile.hxx>
Uses a generic interface to file formats (DataFormat) and provides an interface for reading/writing simulation data.
Public Functions
-
~Datafile
()¶
-
bool
openr
(const char *filename, ...)¶
-
bool
openw
(const char *filename, ...)¶
-
bool
opena
(const char *filename, ...)¶
-
bool
isValid
()¶
-
void
close
()¶
-
void
setLowPrecision
()¶ Only output floats.
-
void
add
(int &i, const char *name, bool save_repeat = false)¶
-
void
add
(bool &b, const char *name, bool save_repeat = false)¶
-
bool
read
()¶ Read data into added variables.
-
bool
write
()¶ Write added variables.
-
bool
write
(const char *filename, ...) const¶ Opens, writes, closes file.
-
void
setAttribute
(const std::string &varname, const std::string &attrname, const std::string &text)¶
-
void
setAttribute
(const std::string &varname, const std::string &attrname, int value)¶
Private Functions
-
bool
write_int
(const std::string &name, int *f, bool save_repeat)¶
-
bool
varAdded
(const std::string &name)¶ Check if a variable has already been added.
-
void *
varPtr
(const std::string &name)¶ Get the pointer to the variable, nullptr if not added This is used to check if the same variable is being added
Private Members
-
bool
parallel
= {false}¶
-
bool
flush
= {true}¶
-
bool
guards
= {true}¶
-
bool
floats
= {false}¶
-
bool
openclose
= {true}¶
-
int
Lx
¶
-
int
Ly
¶
-
int
Lz
¶
-
bool
enabled
= {true}¶
-
bool
init_missing
¶
-
bool
shiftOutput
= {false}¶
-
bool
shiftInput
= {false}¶
-
int
flushFrequencyCounter
= {0}¶
-
int
flushFrequency
= {1}¶
-
std::unique_ptr<DataFormat>
file
¶
-
size_t
filenamelen
¶
-
char *
filename
¶
-
bool
writable
= {false}¶
-
bool
appending
= {false}¶
-
bool
first_time
= {true}¶
-
std::vector<VarStr<int>>
int_arr
¶
-
std::vector<VarStr<bool>>
bool_arr
¶
Private Static Attributes
-
const size_t
FILENAMELEN
= 512¶
-
template<class
T
>
structVarStr
¶ A structure to hold a pointer to a class, and associated name and flags.
Public Members
-
T *
ptr
¶ Pointer to the data. Note that this may be a user object, not a copy, so must not be destroyed
-
std::string
name
¶ Name as it appears in the output file.
-
bool
save_repeat
¶ If true, has a time dimension and is saved every time step.
-
bool
covar
¶ For vectors, true if a covariant vector, false if contravariant.
-
T *
-