Skip to main content

FlowMapTransitioner

Trait FlowMapTransitioner 

Source
pub trait FlowMapTransitioner {
    // Required methods
    fn advance(&mut self, current_time: f64, time_step: f64) -> &IterationState;
    fn advance_arc(
        &mut self,
        current_time: f64,
        time_step: f64,
    ) -> Arc<IterationState>;
    fn need_advance(&self, current_time: f64, time_step: f64) -> bool;
    fn get_at(&self, idx: usize) -> Option<Arc<IterationState>>;
    fn get_current_arc(&self) -> Arc<IterationState>;
    fn get_current(&self) -> &IterationState;
    fn size(&self) -> usize;
    fn new(time_per_flomap: f64, buffer: FlowMapBuffer) -> Self;

    // Provided method
    fn from_case(root: &str, case: &CMCase) -> Result<Self, DataError>
       where Self: Sized { ... }
}
Expand description

A trait describing an abstraction over time-indexed flow-map states.

FlowMapTransitioner provides a unified interface to:

  • step forward in time (advance, advance_arc)
  • check whether a transition is required (need_advance)
  • access specific stored states (get_at, get_current, get_current_arc)
  • query the number of available flow-map entries (size)
  • build the transitioner from a FlowMapBuffer or from input case data (new, from_case)

§Semantics

A FlowMapTransitioner maintains an time iteration Calling advance() or advance_arc() advances this index if need_advance() returns true

Implementations may optimize state caching to minimize Arc cloning or recomputation.

§Errors

from_case() returns a DataError if the underlying descriptors cannot be read or if the flow-map buffer cannot be constructed.

§Example

let transitioner = MyTransitioner::from_case("root/path", &case)?;
let state = transitioner.advance(12.0, 0.1);
println!("Current state: {:?}", state);

Required Methods§

Source

fn advance(&mut self, current_time: f64, time_step: f64) -> &IterationState

Advances the internal state according to current_time and time_step, and returns a borrowed reference to the active IterationState.

Implementations must not clone or allocate here

Source

fn advance_arc( &mut self, current_time: f64, time_step: f64, ) -> Arc<IterationState>

Same as [advance], but returns an owned Arc<IterationState>.

Implementations should minimize Arc cloning and may cache the currently active state to avoid atomic operations inside tight loops.

Source

fn need_advance(&self, current_time: f64, time_step: f64) -> bool

Returns true if the flow-map index should advance when evaluating the given current_time and time_step.

This does not mutate internal state.

Source

fn get_at(&self, idx: usize) -> Option<Arc<IterationState>>

Retrieves the state at the given buffer index as an owned Arc.

Returns None if idx exceeds the buffer size.

Source

fn get_current_arc(&self) -> Arc<IterationState>

Returns the current state as an owned Arc<IterationState>.

Source

fn get_current(&self) -> &IterationState

Returns the current state as a borrowed reference.

Source

fn size(&self) -> usize

Returns the number of flow-map states stored in this transitioner.

Source

fn new(time_per_flomap: f64, buffer: FlowMapBuffer) -> Self

Constructs a new transitioner from the duration of each flow-map (time_per_flomap) and a validated FlowMapBuffer.

The buffer must already satisfy the invariant that either all entries contain gas descriptors or none do.

Provided Methods§

Source

fn from_case(root: &str, case: &CMCase) -> Result<Self, DataError>
where Self: Sized,

Constructs a transitioner by loading flow-map descriptors from disk using the provided case definition.

For recursive cases, all flow-map descriptor folders are gathered and combined into a multi-entry FlowMapBuffer. For non-recursive cases, only the root folder is read.

§Errors

Returns DataError if descriptor reading fails or if the produced FlowMapBuffer violates flow-map invariants.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§