pub(crate) struct Writer {
pub(crate) receiver: Receiver<Vec<f64>>,
write_path: PathBuf,
variable_names: Vec<&'static str>,
file_prefix: String,
}
Expand description
General Information
Writes solution of equation to a given file. Can take a path to write to, names of variables and a prefix for all files. Struct is meant to run on it’s own thread to block as little as possible the execution of DzahuiWindow
Fields
receiver
- A sync_channel receiver to obtain vector values to write to filewrite_path
- A directory to write files invariable_names
- Chosen by a given equation. Normally a vector like [‘x’,‘y’,‘z’] or similarfile_prefix
- To identify files from a single simulation
Fields§
§receiver: Receiver<Vec<f64>>
§write_path: PathBuf
§variable_names: Vec<&'static str>
§file_prefix: String
Implementations§
source§impl Writer
impl Writer
sourcepub(crate) fn new<A, B, C>(
receiver: Receiver<Vec<f64>>,
write_path: B,
file_prefix: A,
variable_names: C,
erase_prev_dir: bool
) -> Result<Self, Error>where
A: AsRef<str>,
B: AsRef<str>,
C: IntoIterator<Item = &'static str>,
pub(crate) fn new<A, B, C>(
receiver: Receiver<Vec<f64>>,
write_path: B,
file_prefix: A,
variable_names: C,
erase_prev_dir: bool
) -> Result<Self, Error>where
A: AsRef<str>,
B: AsRef<str>,
C: IntoIterator<Item = &'static str>,
General Information
Creates a new instance of writer (And there should be only one, but it is not enforced). Can be told to erase previous files on a directory. Will complain if directory is not present
Parameters
receiver
- A receiver to obtain the solution to an equationwrite_path
- The path in which files are created and written tofile_prefix
- Prefix for all files of a given simulationvariable_names
- A vector with all variables of a problem. Chosen by the equation struct in dzahui window. Also determines how many elements from solution vector are taken per lineerase_prev_dir
- Option to erase every file inside dir given. Will not erase nested directories
sourcepub(crate) fn write(&self, id: f64, vals: Vec<f64>) -> Result<(), Error>
pub(crate) fn write(&self, id: f64, vals: Vec<f64>) -> Result<(), Error>
General Information
Writes once to a file created inside. Will create a file for every call. To make every file unique, an id must be passed. Dzahui window will pass the time in milis, but any other unique f64 value will do.
Parameters
&self
- A reference to itself to usewrite_path
andfile_prefix
id
- A unique id for a filevals
- a vector with values to write to file