#![cfg(feature = "mpi")]
use super::Decomp2d;
use super::Universe;
use crate::BaseSpace;
use crate::BaseSpaceTransform;
use crate::FloatNum;
use ndarray::{Array, ArrayBase, Data, DataMut, Dim};
pub trait BaseSpaceMpi<A, const N: usize>: Clone + BaseSpace<A, N>
where
A: FloatNum,
{
fn get_universe(&self) -> &Universe;
fn get_nrank(&self) -> usize;
fn get_nprocs(&self) -> usize;
fn get_decomp_from_global_shape(&self, shape: &[usize]) -> &Decomp2d;
fn shape_physical_x_pen(&self) -> [usize; N];
fn shape_physical_y_pen(&self) -> [usize; N];
fn shape_spectral_x_pen(&self) -> [usize; N];
fn shape_spectral_y_pen(&self) -> [usize; N];
fn ndarray_physical_x_pen(
&self,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Physical, Dim<[usize; N]>>;
fn ndarray_physical_y_pen(
&self,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Physical, Dim<[usize; N]>>;
fn ndarray_spectral_x_pen(
&self,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Spectral, Dim<[usize; N]>>;
fn ndarray_spectral_y_pen(
&self,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Spectral, Dim<[usize; N]>>;
fn to_ortho_mpi<S>(
&self,
input: &ArrayBase<S, Dim<[usize; N]>>,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Spectral, Dim<[usize; N]>>
where
S: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>;
fn to_ortho_inplace_mpi<S1, S2>(
&self,
input: &ArrayBase<S1, Dim<[usize; N]>>,
output: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn from_ortho_mpi<S>(
&self,
input: &ArrayBase<S, Dim<[usize; N]>>,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Spectral, Dim<[usize; N]>>
where
S: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>;
fn from_ortho_inplace_mpi<S1, S2>(
&self,
input: &ArrayBase<S1, Dim<[usize; N]>>,
output: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn gradient_mpi<S>(
&self,
input: &ArrayBase<S, Dim<[usize; N]>>,
deriv: [usize; N],
scale: Option<[A; N]>,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Spectral, Dim<[usize; N]>>
where
S: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>;
fn forward_mpi<S>(
&self,
input: &ArrayBase<S, Dim<[usize; N]>>,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Spectral, Dim<[usize; N]>>
where
S: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>;
fn forward_inplace_mpi<S1, S2>(
&self,
input: &ArrayBase<S1, Dim<[usize; N]>>,
output: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn backward_mpi<S>(
&self,
input: &ArrayBase<S, Dim<[usize; N]>>,
) -> Array<<Self as BaseSpaceTransform<A, N>>::Physical, Dim<[usize; N]>>
where
S: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>;
fn backward_inplace_mpi<S1, S2>(
&self,
input: &ArrayBase<S1, Dim<[usize; N]>>,
output: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn gather_from_x_pencil_phys<S1>(&self, pencil_data: &ArrayBase<S1, Dim<[usize; N]>>)
where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>;
fn gather_from_x_pencil_phys_root<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn gather_from_y_pencil_phys<S1>(&self, pencil_data: &ArrayBase<S1, Dim<[usize; N]>>)
where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>;
fn gather_from_y_pencil_phys_root<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn gather_from_x_pencil_spec<S1>(&self, pencil_data: &ArrayBase<S1, Dim<[usize; N]>>)
where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>;
fn gather_from_x_pencil_spec_root<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn gather_from_y_pencil_spec<S1>(&self, pencil_data: &ArrayBase<S1, Dim<[usize; N]>>)
where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>;
fn gather_from_y_pencil_spec_root<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn all_gather_from_x_pencil_phys<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn all_gather_from_y_pencil_phys<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn all_gather_from_x_pencil_spec<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn all_gather_from_y_pencil_spec<S1, S2>(
&self,
pencil_data: &ArrayBase<S1, Dim<[usize; N]>>,
global_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn scatter_to_x_pencil_phys<S2>(&self, pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>)
where
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn scatter_to_x_pencil_phys_root<S1, S2>(
&self,
global_data: &ArrayBase<S1, Dim<[usize; N]>>,
pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn scatter_to_y_pencil_phys<S2>(&self, pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>)
where
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn scatter_to_y_pencil_phys_root<S1, S2>(
&self,
global_data: &ArrayBase<S1, Dim<[usize; N]>>,
pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn scatter_to_x_pencil_spec<S2>(&self, pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>)
where
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn scatter_to_x_pencil_spec_root<S1, S2>(
&self,
global_data: &ArrayBase<S1, Dim<[usize; N]>>,
pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn scatter_to_y_pencil_spec<S2>(&self, pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>)
where
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn scatter_to_y_pencil_spec_root<S1, S2>(
&self,
global_data: &ArrayBase<S1, Dim<[usize; N]>>,
pencil_data: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn transpose_x_to_y_phys<S1, S2>(
&self,
x_pencil: &ArrayBase<S1, Dim<[usize; N]>>,
y_pencil: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn transpose_y_to_x_phys<S1, S2>(
&self,
y_pencil: &ArrayBase<S1, Dim<[usize; N]>>,
x_pencil: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Physical> + DataMut;
fn transpose_x_to_y_spec<S1, S2>(
&self,
x_pencil: &ArrayBase<S1, Dim<[usize; N]>>,
y_pencil: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
fn transpose_y_to_x_spec<S1, S2>(
&self,
y_pencil: &ArrayBase<S1, Dim<[usize; N]>>,
x_pencil: &mut ArrayBase<S2, Dim<[usize; N]>>,
) where
S1: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral>,
S2: Data<Elem = <Self as BaseSpaceTransform<A, N>>::Spectral> + DataMut;
}