Skip to main content

Bmi

Trait Bmi 

Source
pub trait Bmi {
Show 41 methods // Required methods fn initialize(&mut self, config_file: &str) -> BmiResult<()>; fn update(&mut self) -> BmiResult<()>; fn update_until(&mut self, time: f64) -> BmiResult<()>; fn finalize(&mut self) -> BmiResult<()>; fn get_component_name(&self) -> BmiResult<String>; fn get_input_item_count(&self) -> BmiResult<usize>; fn get_output_item_count(&self) -> BmiResult<usize>; fn get_input_var_names(&self) -> BmiResult<Vec<String>>; fn get_output_var_names(&self) -> BmiResult<Vec<String>>; fn get_var_grid(&self, name: &str) -> BmiResult<i32>; fn get_var_type(&self, name: &str) -> BmiResult<String>; fn get_var_units(&self, name: &str) -> BmiResult<String>; fn get_var_itemsize(&self, name: &str) -> BmiResult<usize>; fn get_var_nbytes(&self, name: &str) -> BmiResult<usize>; fn get_var_location(&self, name: &str) -> BmiResult<Location>; fn get_current_time(&self) -> BmiResult<f64>; fn get_start_time(&self) -> BmiResult<f64>; fn get_end_time(&self) -> BmiResult<f64>; fn get_time_units(&self) -> BmiResult<String>; fn get_time_step(&self) -> BmiResult<f64>; fn get_value(&self, name: &str) -> BmiResult<Values>; fn get_value_ptr(&self, name: &str) -> BmiResult<RefValues<'_>>; fn get_value_at_indices( &self, name: &str, indices: &[usize], ) -> BmiResult<Values>; fn set_value(&mut self, name: &str, src: RefValues<'_>) -> BmiResult<()>; fn set_value_at_indices( &mut self, name: &str, indices: &[usize], src: RefValues<'_>, ) -> BmiResult<()>; fn get_grid_rank(&self, grid: i32) -> BmiResult<usize>; fn get_grid_size(&self, grid: i32) -> BmiResult<usize>; fn get_grid_type(&self, grid: i32) -> BmiResult<GridType>; fn get_grid_shape(&self, grid: i32) -> BmiResult<Vec<usize>>; fn get_grid_spacing(&self, grid: i32) -> BmiResult<Vec<f64>>; fn get_grid_origin(&self, grid: i32) -> BmiResult<Vec<f64>>; fn get_grid_x(&self, grid: i32) -> BmiResult<Vec<f64>>; fn get_grid_y(&self, grid: i32) -> BmiResult<Vec<f64>>; fn get_grid_z(&self, grid: i32) -> BmiResult<Vec<f64>>; fn get_grid_node_count(&self, grid: i32) -> BmiResult<usize>; fn get_grid_edge_count(&self, grid: i32) -> BmiResult<usize>; fn get_grid_face_count(&self, grid: i32) -> BmiResult<usize>; fn get_grid_edge_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>; fn get_grid_face_edges(&self, grid: i32) -> BmiResult<Vec<usize>>; fn get_grid_face_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>; fn get_grid_nodes_per_face(&self, grid: i32) -> BmiResult<Vec<usize>>;
}
Expand description

The CSDMS Basic Model Interface 2.0.

Initialize a model before querying or updating it, and finalize it after use. Variable names follow the model’s advertised input and output names. Grid identifiers are model-defined; indices and sizes use Rust’s usize.

All methods are fallible and required. Implementations should return errors for invalid names, grid identifiers, indices, types, buffer lengths, lifecycle states, and operations unsupported by their grid or storage representation. Setters must validate their inputs before modifying model storage.

This trait is dyn-compatible, so coupling code can use Box<dyn Bmi>.

Required Methods§

Source

fn initialize(&mut self, config_file: &str) -> BmiResult<()>

Load configuration from config_file and allocate model resources. An empty path requests the model’s default configuration, if supported.

Source

fn update(&mut self) -> BmiResult<()>

Advance the model by one time step.

Source

fn update_until(&mut self, time: f64) -> BmiResult<()>

Advance to time, expressed in the model’s time units.

Source

fn finalize(&mut self) -> BmiResult<()>

Release model resources and finish any pending output.

Source

fn get_component_name(&self) -> BmiResult<String>

Return the model’s human-readable component name.

Source

fn get_input_item_count(&self) -> BmiResult<usize>

Return the number of input variables.

Source

fn get_output_item_count(&self) -> BmiResult<usize>

Return the number of output variables.

Source

fn get_input_var_names(&self) -> BmiResult<Vec<String>>

Return the names of variables that can be set.

Source

fn get_output_var_names(&self) -> BmiResult<Vec<String>>

Return the names of variables that can be read.

Source

fn get_var_grid(&self, name: &str) -> BmiResult<i32>

Return the grid identifier associated with a variable.

Source

fn get_var_type(&self, name: &str) -> BmiResult<String>

Return the variable’s native type name (for example, float64).

Source

fn get_var_units(&self, name: &str) -> BmiResult<String>

Return the variable’s units, preferably using UDUNITS conventions.

Source

fn get_var_itemsize(&self, name: &str) -> BmiResult<usize>

Return the size of one variable element in bytes.

Source

fn get_var_nbytes(&self, name: &str) -> BmiResult<usize>

Return the total size of a variable’s values in bytes.

Source

fn get_var_location(&self, name: &str) -> BmiResult<Location>

Return whether the variable is defined on nodes, edges, or faces.

Source

fn get_current_time(&self) -> BmiResult<f64>

Return the current simulation time.

Source

fn get_start_time(&self) -> BmiResult<f64>

Return the simulation’s start time.

Source

fn get_end_time(&self) -> BmiResult<f64>

Return the simulation’s end time.

Source

fn get_time_units(&self) -> BmiResult<String>

Return the units used by every time query and update_until.

Source

fn get_time_step(&self) -> BmiResult<f64>

Return the model’s current time-step duration.

Source

fn get_value(&self, name: &str) -> BmiResult<Values>

Return an owned copy of all values, preserving their numeric type.

Source

fn get_value_ptr(&self, name: &str) -> BmiResult<RefValues<'_>>

Borrow the model’s storage without copying it.

The slice cannot outlive the model borrow. Rust prevents mutable calls, including update, set_value, and finalize, while it is still in use. Changes must go through the setters; no mutable raw pointer is exposed.

Source

fn get_value_at_indices( &self, name: &str, indices: &[usize], ) -> BmiResult<Values>

Copy values at zero-based flattened indices, in the requested order. Repeated indices repeat values; an empty index slice returns no values.

Source

fn set_value(&mut self, name: &str, src: RefValues<'_>) -> BmiResult<()>

Copy src into a variable. Its type and length must match the variable.

Source

fn set_value_at_indices( &mut self, name: &str, indices: &[usize], src: RefValues<'_>, ) -> BmiResult<()>

Copy values into zero-based flattened indices. src must match the variable’s type and have one value per index.

Source

fn get_grid_rank(&self, grid: i32) -> BmiResult<usize>

Return the number of spatial dimensions.

Source

fn get_grid_size(&self, grid: i32) -> BmiResult<usize>

Return the total number of grid nodes.

Source

fn get_grid_type(&self, grid: i32) -> BmiResult<GridType>

Return the grid’s topology and geometry category.

Source

fn get_grid_shape(&self, grid: i32) -> BmiResult<Vec<usize>>

Return the node count along each axis, ordered slowest to fastest (z, y, x). The returned length equals the grid rank.

Source

fn get_grid_spacing(&self, grid: i32) -> BmiResult<Vec<f64>>

Return uniform axis spacing, ordered as get_grid_shape.

Source

fn get_grid_origin(&self, grid: i32) -> BmiResult<Vec<f64>>

Return the grid origin, ordered as get_grid_shape.

Source

fn get_grid_x(&self, grid: i32) -> BmiResult<Vec<f64>>

Return x coordinates: axis coordinates for rectilinear grids, otherwise per node.

Source

fn get_grid_y(&self, grid: i32) -> BmiResult<Vec<f64>>

Return y coordinates: axis coordinates for rectilinear grids, otherwise per node.

Source

fn get_grid_z(&self, grid: i32) -> BmiResult<Vec<f64>>

Return z coordinates: axis coordinates for rectilinear grids, otherwise per node.

Source

fn get_grid_node_count(&self, grid: i32) -> BmiResult<usize>

Return the number of nodes in an unstructured grid.

Source

fn get_grid_edge_count(&self, grid: i32) -> BmiResult<usize>

Return the number of edges in an unstructured grid.

Source

fn get_grid_face_count(&self, grid: i32) -> BmiResult<usize>

Return the number of faces in an unstructured grid.

Source

fn get_grid_edge_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>

Return flattened node pairs for edges, with two indices per edge.

Source

fn get_grid_face_edges(&self, grid: i32) -> BmiResult<Vec<usize>>

Return flattened edge indices for faces, grouped in face order.

Source

fn get_grid_face_nodes(&self, grid: i32) -> BmiResult<Vec<usize>>

Return flattened node indices for faces, grouped in face order.

Source

fn get_grid_nodes_per_face(&self, grid: i32) -> BmiResult<Vec<usize>>

Return the node count per face, delimiting the flattened face connectivity arrays.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§