1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, PartialEq)]
7pub enum FlowDirection {
8 In,
9 Out,
10}
11
12#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
14pub struct FeedFlow {
15 pub flow: f64,
16 pub position: usize,
17 pub output_position: Option<usize>,
18}
19
20#[derive(Default, Clone, Serialize, Deserialize)]
22pub struct ParsedFeeds {
23 pub liq: HashMap<String, FeedFlow>,
24 pub gas: HashMap<String, FeedFlow>,
25}
26
27#[derive(Default, Clone, Serialize, Deserialize)]
30pub struct DomainInfo {
31 pub(crate) compartment_cumsum: HashMap<String, usize>,
33 pub(crate) total_number_compartment: usize,
34 pub(crate) pfr_names: Vec<String>,
36 pub(crate) is_two_phase_flow: bool,
37}
38impl DomainInfo {
39 pub fn get_relative_compartment_number(
40 &self,
41 reactor_id: &str,
42 relative_index: usize,
43 ) -> Option<usize> {
44 self.compartment_cumsum
45 .get(reactor_id)
46 .map(|cum_sum| relative_index + *cum_sum)
47 }
48
49 pub fn get_total_number_compartment(&self) -> usize {
50 self.total_number_compartment
51 }
52}
53
54#[derive(Clone, Serialize, Deserialize, Default)]
57pub struct DomainData {
58 pub(crate) info: DomainInfo,
60 pub(crate) feeds: Option<ParsedFeeds>,
62 pub(crate) case_path: String,
63 pub run_id: String,
64}
65
66impl DomainData {
67 pub fn feeds(&self) -> &Option<ParsedFeeds> {
68 &self.feeds
69 }
70
71 pub fn info(&self) -> &DomainInfo {
72 &self.info
73 }
74
75 pub fn get_case_path(&self) -> impl AsRef<std::path::Path> {
76 &self.case_path
77 }
78}