bcore/datamodel/
main_file.rs1use super::{tallies::Tallies, Dim, ResultGroup, Weight};
7use std::collections::HashMap;
8#[derive(Debug)]
10pub struct Misc {
11 pub n_node_thread: u64,
12 pub n_rank: u64,
13}
14
15
16
17#[derive(Debug)]
19pub struct MainRecords {
20 pub concentration_liquid: Vec<f64>,
21 pub volume_liquid: Vec<f64>,
22 pub concentration_gas: Option<Vec<f64>>,
23 pub volume_gas: Option<Vec<f64>>,
24 pub mtr: Option<Vec<f64>>,
25 pub tallies: Option<Tallies>,
26 pub dim: Dim,
27 pub time: Vec<f64>,
28}
29
30#[derive(Debug)]
32pub struct MainInitial {
33 pub delta_time: f64,
34 pub final_time: f64,
35 pub initial_biomass_concentration: f64,
36 pub initial_weight: f64,
37 pub n_map: usize,
38 pub number_compartment: usize,
39 pub number_particles: u64,
40 pub t_per_flow_map: f64,
41}
42
43#[derive(Debug)]
45pub struct MainFInal {
46 pub events: Option<HashMap<String, u64>>,
47 pub number_particles: u64,
48}
49
50#[derive(Debug)]
52pub struct MainResult {
53 pub records: MainRecords,
54 pub initial: MainInitial,
55 pub cfinal: Option<MainFInal>, pub misc: Misc,
57 pub weight: Weight,
58}
59
60impl MainResult {
61 pub fn read(name: &str) -> hdf5::Result<MainResult> {
62 let file = hdf5::File::open_as(name, hdf5::file::OpenMode::Read)?;
63
64 let m_ds = file.group("initial_parameters")?;
65 let initial = ResultGroup::<MainInitial>::read_g(&m_ds)?;
66
67 let m_ds = file.group("misc")?;
68 let misc = ResultGroup::<Misc>::read_g(&m_ds)?;
69
70 let m_ds = file.group("records")?;
71 let records = ResultGroup::<MainRecords>::read_g(&m_ds)?;
72
73 let mut cfinal = None;
74 if let Ok(m_ds) = file.group("final_result")
75 {
76 cfinal= Some(ResultGroup::<MainFInal>::read_g(&m_ds)?);
77 }
78
79 let weight = Weight::Single(initial.initial_weight); Ok(MainResult {
82 records,
83 initial,
84 cfinal,
85 misc,
86 weight,
87 })
88 }
89
90 pub fn time(&self) -> &[f64] {
91 &self.records.time
92 }
93}