Skip to main content

test_parallel_space/
test_parallel_space.rs

1use mpi::{environment::Universe, traits::Communicator};
2use ndelement::{
3    ciarlet::{LagrangeElementFamily, LagrangeVariant},
4    types::{Continuity, ReferenceCellType},
5};
6use ndfunctionspace::{
7    FunctionSpaceImpl, ParallelFunctionSpaceImpl,
8    traits::{FunctionSpace, ParallelFunctionSpace},
9};
10use ndmesh::{
11    shapes::{unit_cube, unit_cube_distributed},
12    types::GraphPartitioner,
13};
14
15/// Test parallel function space
16fn test_parallel_function_space<C: Communicator>(comm: &C) {
17    let mesh = unit_cube_distributed::<f64, _>(
18        comm,
19        GraphPartitioner::None,
20        4,
21        4,
22        4,
23        ReferenceCellType::Tetrahedron,
24    );
25
26    let family =
27        LagrangeElementFamily::<f64>::new(2, Continuity::Standard, LagrangeVariant::Equispaced);
28    let space = ParallelFunctionSpaceImpl::new(&mesh, &family);
29    let serial_mesh = unit_cube::<f64>(4, 4, 4, ReferenceCellType::Tetrahedron);
30    let serial_space = FunctionSpaceImpl::new(&serial_mesh, &family);
31
32    assert_eq!(space.global_size(), serial_space.global_size());
33}
34
35/// Run tests
36fn main() {
37    let universe: Universe = mpi::initialize().unwrap();
38    let world = universe.world();
39    let rank = world.rank();
40
41    if rank == 0 {
42        println!("Testing parallel function space");
43    }
44    test_parallel_function_space(&world);
45}