RONImportParallel

Trait RONImportParallel 

Source
pub trait RONImportParallel<'a, C: Communicator + 'a>: Sized + ParallelGrid<C = C>
where Self::LocalGrid: RONImport, Self: 'a,
{ // Required method fn create_from_ron_info(comm: &'a C, local_grid: Self::LocalGrid) -> Self; // Provided method fn import_from_ron(comm: &'a C, filename: &str) -> Self { ... } }
Expand description

Parallel grid import for RON

Required Methods§

Source

fn create_from_ron_info(comm: &'a C, local_grid: Self::LocalGrid) -> Self

Create parallel grid from comm and local_grid

Provided Methods§

Source

fn import_from_ron(comm: &'a C, filename: &str) -> Self

Export as RON

Examples found in repository?
ndgrid/examples/test_parallel_io.rs (lines 64-66)
57fn test_parallel_import<C: Communicator>(comm: &C) {
58    use ndgrid::traits::ParallelGrid;
59
60    let size = comm.size();
61
62    let filename = format!("_examples_parallel_io_{size}ranks.ron");
63    let grid =
64        ParallelGridImpl::<'_, C, SingleElementGrid<f64, CiarletElement<f64, IdentityMap>>>::import_from_ron(
65            comm, &filename,
66        );
67
68    let n = 10;
69    let grid2 = example_single_element_grid(comm, n);
70
71    assert_eq!(
72        grid.local_grid().entity_count(ReferenceCellType::Point),
73        grid2.local_grid().entity_count(ReferenceCellType::Point)
74    );
75}
More examples
Hide additional examples
ndgrid/examples/parallel_io.rs (line 40)
17fn main() {
18    let universe: Universe = mpi::initialize().unwrap();
19    let comm = universe.world();
20    let rank = comm.rank();
21
22    let g = if rank == 0 {
23        // Create a grid using the shapes module: unit_cube_boundary will mesh the surface of a cube
24        let serial_g = shapes::unit_cube_boundary::<f64>(4, 5, 4, ReferenceCellType::Triangle);
25
26        // Distribute this grid across processes
27        serial_g.distribute(&comm, GraphPartitioner::None)
28    } else {
29        let b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
30        b.create_parallel_grid(&comm, 0)
31    };
32
33    // If the serde option is used, the raw grid data can be exported in RON format
34    g.export_as_ron("_unit_cube_boundary_parallel.ron");
35
36    // Wait for export to finish
37    comm.barrier();
38
39    // A grid can be re-imported from raw RON data. Note that it must be imported on the same number of processes as it was exported using
40    let g2 = ParallelGridImpl::<'_, _, SingleElementGrid::<f64, CiarletElement<f64, IdentityMap>>>::import_from_ron(&comm, "_unit_cube_boundary_parallel.ron");
41
42    // Print the first 5 cells of each grid on process 0
43    if rank == 0 {
44        println!("The first 5 cells of the grids");
45        for (cell, cell2) in izip!(
46            g.local_grid().entity_iter(ReferenceCellType::Triangle),
47            g2.local_grid().entity_iter(ReferenceCellType::Triangle)
48        )
49        .take(5)
50        {
51            println!(
52                "{:?} {:?}",
53                cell.topology()
54                    .sub_entity_iter(ReferenceCellType::Point)
55                    .collect::<Vec<_>>(),
56                cell2
57                    .topology()
58                    .sub_entity_iter(ReferenceCellType::Point)
59                    .collect::<Vec<_>>(),
60            );
61        }
62    }
63}

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§

Source§

impl<'a, EntityDescriptor, C: Communicator + 'a, G: Grid<EntityDescriptor = EntityDescriptor> + Sync + ConvertToSerializable> RONImportParallel<'a, C> for ParallelGridImpl<'a, C, G>
where for<'de2> <G as ConvertToSerializable>::SerializableType: Deserialize<'de2>, for<'de2> EntityDescriptor: Deserialize<'de2> + Debug + PartialEq + Eq + Clone + Copy + Hash + Serialize, Self: 'a,

Available on crate feature serde only.