dvcompute_branch/simulation/
point.rs1use crate::simulation::Run;
8
9#[cfg(feature="dist_mode")]
11#[repr(C)]
12#[derive(Clone)]
13pub struct Point<'a> {
14
15    pub run: &'a Run<'a>,
17
18    pub time: f64,
20
21    pub priority: isize,
23
24    pub minimal_priority: isize,
26
27    pub iteration: usize,
29
30    pub phase: i32
32}
33
34#[cfg(feature="dist_mode")]
35impl<'a> Point<'a> {
36
37    #[inline]
39    pub fn with_iteration(&self, n: usize) -> Self {
40        let run = &self.run;
41        let specs = &run.specs;
42        let t0 = specs.start_time;
43        let t2 = specs.stop_time;
44        let dt = specs.dt;
45        let n2 = ((t2 - t0) / dt).floor() as usize;
46        let t  = if n == n2 { t2 } else { t0 + (n as f64) * dt };
47        Point {
48            run: run,
49            time: t,
50            priority: self.priority,
51            minimal_priority: self.minimal_priority,
52            iteration: n,
53            phase: -1
54        }
55    }
56
57    pub fn trace(&self, msg: &str) {
59        println!("t={}: {}", self.time, msg);
60    }
61}
62
63
64#[cfg(any(feature="branch_mode", feature="branch_wasm_mode"))]
66#[repr(C)]
67#[derive(Clone)]
68pub struct Point<'a> {
69
70    pub run: &'a Run,
72
73    pub time: f64,
75
76    pub priority: isize,
78
79    pub minimal_priority: isize,
81
82    pub iteration: usize,
84
85    pub phase: i32
87}
88
89#[cfg(any(feature="branch_mode", feature="branch_wasm_mode"))]
90impl<'a> Point<'a> {
91
92    #[inline]
94    pub fn with_iteration(&self, n: usize) -> Self {
95        let run = &self.run;
96        let specs = &run.specs;
97        let t0 = specs.start_time;
98        let t2 = specs.stop_time;
99        let dt = specs.dt;
100        let n2 = ((t2 - t0) / dt).floor() as usize;
101        let t  = if n == n2 { t2 } else { t0 + (n as f64) * dt };
102        Point {
103            run: run,
104            time: t,
105            priority: self.priority,
106            minimal_priority: self.minimal_priority,
107            iteration: n,
108            phase: -1
109        }
110    }
111
112    pub fn trace(&self, msg: &str) {
114        println!("t={}: {}", self.time, msg);
115    }
116}