1 /*! |
1 /*! |
2 Simple disrete gradient operators |
2 Simple disrete gradient operators |
3 */ |
3 */ |
4 use numeric_literals::replace_float_literals; |
4 use numeric_literals::replace_float_literals; |
|
5 use serde::{Serialize, Deserialize}; |
5 use nalgebra::{ |
6 use nalgebra::{ |
6 DVector, Matrix, U1, Storage, StorageMut, Dyn |
7 DVector, Matrix, U1, Storage, StorageMut, Dyn |
7 }; |
8 }; |
8 use crate::types::Float; |
9 use crate::types::Float; |
9 use crate::instance::Instance; |
10 use crate::instance::Instance; |
10 use crate::linops::{Mapping, Linear, BoundedLinear, Adjointable, GEMV}; |
11 use crate::linops::{Mapping, Linear, BoundedLinear, Adjointable, GEMV}; |
11 use crate::norms::{Norm, L2}; |
12 use crate::norms::{Norm, L2}; |
12 |
13 |
13 #[derive(Copy, Clone, Debug)] |
14 #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
14 /// Forward differences with Neumann boundary conditions |
15 /// Forward differences with Neumann boundary conditions |
15 pub struct ForwardNeumann; |
16 pub struct ForwardNeumann; |
16 |
17 |
17 #[derive(Copy, Clone, Debug)] |
18 #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
18 /// Forward differences with Dirichlet boundary conditions |
19 /// Forward differences with Dirichlet boundary conditions |
19 pub struct ForwardDirichlet; |
20 pub struct ForwardDirichlet; |
20 |
21 |
21 #[derive(Copy, Clone, Debug)] |
22 #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
22 /// Backward differences with Dirichlet boundary conditions |
23 /// Backward differences with Dirichlet boundary conditions |
23 pub struct BackwardDirichlet; |
24 pub struct BackwardDirichlet; |
24 |
25 |
25 #[derive(Copy, Clone, Debug)] |
26 #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
26 /// Backward differences with Neumann boundary conditions |
27 /// Backward differences with Neumann boundary conditions |
27 pub struct BackwardNeumann; |
28 pub struct BackwardNeumann; |
28 |
29 |
29 /// Finite differences gradient |
30 /// Finite differences gradient |
|
31 #[derive(Clone, Debug, Serialize, Deserialize)] |
|
32 #[serde(bound( |
|
33 serialize = "[usize; N] : Serialize, |
|
34 B : Serialize, |
|
35 F : Serialize,", |
|
36 deserialize = "[usize; N] : for<'a> Deserialize<'a>, |
|
37 B : for<'a> Deserialize<'a>, |
|
38 F : for<'a> Deserialize<'a>," |
|
39 ))] |
30 pub struct Grad< |
40 pub struct Grad< |
31 F : Float + nalgebra::RealField, |
41 F : Float + nalgebra::RealField, |
32 B : Discretisation<F>, |
42 B : Discretisation<F>, |
33 const N : usize |
43 const N : usize |
34 > { |
44 > { |