pub struct FunctionSpaceImpl<'a, T: RlstScalar, TMesh: RlstScalar, E: Debug + PartialEq + Eq + Clone + Copy + Hash, G: Mesh<EntityDescriptor = E, T = TMesh>, F: MappedFiniteElement<CellType = E, T = T>> { /* private fields */ }Expand description
Function space.
Implementations§
Source§impl<'a, T: RlstScalar, TMesh: RlstScalar, G: Mesh<EntityDescriptor = ReferenceCellType, T = TMesh>, F: MappedFiniteElement<CellType = ReferenceCellType, T = T>> FunctionSpaceImpl<'a, T, TMesh, ReferenceCellType, G, F>
impl<'a, T: RlstScalar, TMesh: RlstScalar, G: Mesh<EntityDescriptor = ReferenceCellType, T = TMesh>, F: MappedFiniteElement<CellType = ReferenceCellType, T = T>> FunctionSpaceImpl<'a, T, TMesh, ReferenceCellType, G, F>
Sourcepub fn new<EF: ElementFamily<FiniteElement = F, CellType = ReferenceCellType>>(
mesh: &'a G,
family: &EF,
) -> Self
pub fn new<EF: ElementFamily<FiniteElement = F, CellType = ReferenceCellType>>( mesh: &'a G, family: &EF, ) -> Self
Create a new serial function space
Examples found in repository?
ndfunctionspace/examples/test_parallel_space.rs (line 30)
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}More examples
ndfunctionspace/examples/test_mass_matrix.rs (line 23)
18fn test_lagrange_mass_matrix() {
19 let mesh = regular_sphere(0, ReferenceCellType::Triangle);
20
21 let family =
22 LagrangeElementFamily::<f64>::new(1, Continuity::Standard, LagrangeVariant::Equispaced);
23 let space = FunctionSpaceImpl::new(&mesh, &family);
24
25 let mut mass_matrix = rlst_dynamic_array!(f64, [space.process_size(), space.process_size()]);
26
27 let element = &space.elements()[0];
28
29 let (p, w) = single_integral_quadrature(
30 QuadratureRule::XiaoGimbutas,
31 Domain::Triangle,
32 2 * element.lagrange_superdegree(),
33 )
34 .unwrap();
35 let npts = w.len();
36 let mut pts = rlst_dynamic_array!(f64, [2, npts]);
37 for i in 0..w.len() {
38 for j in 0..2 {
39 *pts.get_mut([j, i]).unwrap() = p[3 * i + j];
40 }
41 }
42 let wts = w.iter().map(|i| *i / 2.0).collect::<Vec<_>>();
43
44 let mut table = DynArray::<f64, 4>::from_shape(element.tabulate_array_shape(0, npts));
45 element.tabulate(&pts, 0, &mut table);
46
47 let gmap = mesh.geometry_map(ReferenceCellType::Triangle, 1, &pts);
48 let mut jacobians = rlst_dynamic_array!(f64, [mesh.geometry_dim(), mesh.topology_dim(), npts]);
49 let mut jinv = rlst_dynamic_array!(f64, [mesh.topology_dim(), mesh.geometry_dim(), npts]);
50 let mut jdets = vec![0.0; npts];
51
52 for cell in mesh.entity_iter(ReferenceCellType::Triangle) {
53 let dofs = space
54 .entity_closure_dofs(ReferenceCellType::Triangle, cell.local_index())
55 .unwrap();
56 gmap.jacobians_inverses_dets(cell.local_index(), &mut jacobians, &mut jinv, &mut jdets);
57 for (test_i, test_dof) in dofs.iter().enumerate() {
58 for (trial_i, trial_dof) in dofs.iter().enumerate() {
59 *mass_matrix.get_mut([*test_dof, *trial_dof]).unwrap() += wts
60 .iter()
61 .enumerate()
62 .map(|(i, w)| {
63 jdets[i]
64 * *w
65 * *table.get([0, i, test_i, 0]).unwrap()
66 * *table.get([0, i, trial_i, 0]).unwrap()
67 })
68 .sum::<f64>();
69 }
70 }
71 }
72
73 // Compare matrix entries to values from Bempp
74 for i in 0..6 {
75 assert_relative_eq!(mass_matrix[[i, i]], 0.5773502691896255, epsilon = 1e-10);
76 }
77 for i in 0..6 {
78 for j in 0..6 {
79 if i != j && mass_matrix[[i, j]].abs() > 0.001 {
80 assert_relative_eq!(mass_matrix[[i, j]], 0.1443375672974061, epsilon = 1e-10);
81 }
82 }
83 }
84}
85
86/// Test values in Raviart-Thomas mass matrix
87fn test_rt_mass_matrix() {
88 let mesh = regular_sphere(0, ReferenceCellType::Triangle);
89
90 let family = RaviartThomasElementFamily::<f64>::new(1, Continuity::Standard);
91 let space = FunctionSpaceImpl::new(&mesh, &family);
92
93 let mut mass_matrix = rlst_dynamic_array!(f64, [space.process_size(), space.process_size()]);
94
95 let element = &space.elements()[0];
96
97 let (p, w) = single_integral_quadrature(
98 QuadratureRule::XiaoGimbutas,
99 Domain::Triangle,
100 2 * element.lagrange_superdegree(),
101 )
102 .unwrap();
103 let npts = w.len();
104 let mut pts = rlst_dynamic_array!(f64, [2, npts]);
105 for i in 0..w.len() {
106 for j in 0..2 {
107 *pts.get_mut([j, i]).unwrap() = p[3 * i + j];
108 }
109 }
110 let wts = w.iter().map(|i| *i / 2.0).collect::<Vec<_>>();
111
112 let mut table = DynArray::<f64, 4>::from_shape(element.tabulate_array_shape(0, npts));
113 element.tabulate(&pts, 0, &mut table);
114 let mut pushed_table = rlst_dynamic_array!(
115 f64,
116 [table.shape()[0], table.shape()[1], table.shape()[2], 3]
117 );
118
119 let gmap = mesh.geometry_map(ReferenceCellType::Triangle, 1, &pts);
120 let mut jacobians = rlst_dynamic_array!(f64, [mesh.geometry_dim(), mesh.topology_dim(), npts]);
121 let mut jinv = rlst_dynamic_array!(f64, [mesh.topology_dim(), mesh.geometry_dim(), npts]);
122 let mut jdets = vec![0.0; npts];
123
124 for cell in mesh.entity_iter(ReferenceCellType::Triangle) {
125 let dofs = space
126 .entity_closure_dofs(ReferenceCellType::Triangle, cell.local_index())
127 .unwrap();
128 gmap.jacobians_inverses_dets(cell.local_index(), &mut jacobians, &mut jinv, &mut jdets);
129 element.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut pushed_table);
130
131 for (test_i, test_dof) in dofs.iter().enumerate() {
132 for (trial_i, trial_dof) in dofs.iter().enumerate() {
133 *mass_matrix.get_mut([*test_dof, *trial_dof]).unwrap() += wts
134 .iter()
135 .enumerate()
136 .map(|(i, w)| {
137 jdets[i]
138 * *w
139 * (0..3)
140 .map(|j| {
141 *pushed_table.get([0, i, test_i, j]).unwrap()
142 * *pushed_table.get([0, i, trial_i, j]).unwrap()
143 })
144 .sum::<f64>()
145 })
146 .sum::<f64>();
147 }
148 }
149 }
150
151 // Compare matrix entries to FEniCS
152 for i in 0..12 {
153 assert_relative_eq!(mass_matrix[[i, i]], 0.4811252243246884, epsilon = 1e-10);
154 }
155 for i in 0..12 {
156 for j in 0..12 {
157 if i != j && mass_matrix[[i, j]].abs() > 0.001 {
158 assert_relative_eq!(
159 mass_matrix[[i, j]].abs(),
160 0.0481125224324689,
161 epsilon = 1e-10
162 );
163 }
164 }
165 }
166}Trait Implementations§
Source§impl<'a, T: RlstScalar, TMesh: RlstScalar, E: Debug + PartialEq + Eq + Clone + Copy + Hash, G: Mesh<EntityDescriptor = E, T = TMesh>, F: MappedFiniteElement<CellType = E, T = T>> FunctionSpace for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T: RlstScalar, TMesh: RlstScalar, E: Debug + PartialEq + Eq + Clone + Copy + Hash, G: Mesh<EntityDescriptor = E, T = TMesh>, F: MappedFiniteElement<CellType = E, T = T>> FunctionSpace for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
Source§type EntityDescriptor = E
type EntityDescriptor = E
Type used as identifier of different entity types
Source§type FiniteElement = F
type FiniteElement = F
The type for the finite element this mesh is defined by
Source§fn entities_by_element(&self, element_index: usize) -> Option<&[usize]>
fn entities_by_element(&self, element_index: usize) -> Option<&[usize]>
A list of entity indices that use the element with the given index
Source§fn entity_dofs(&self, entity_type: E, entity_number: usize) -> Option<&[usize]>
fn entity_dofs(&self, entity_type: E, entity_number: usize) -> Option<&[usize]>
Get the process DOF numbers associated with the given entity
Source§fn entity_closure_dofs(
&self,
entity_type: E,
entity_number: usize,
) -> Option<&[usize]>
fn entity_closure_dofs( &self, entity_type: E, entity_number: usize, ) -> Option<&[usize]>
Get the process DOF numbers associated with the closure of the given entity Read more
Source§fn process_size(&self) -> usize
fn process_size(&self) -> usize
Get the number of process DOFs Read more
Source§fn process_owned_size(&self) -> usize
fn process_owned_size(&self) -> usize
Get the number of owned process DOFs
Source§fn global_size(&self) -> usize
fn global_size(&self) -> usize
Get the number of DOFs on all processes
Source§fn global_dof_index(&self, process_dof_index: usize) -> usize
fn global_dof_index(&self, process_dof_index: usize) -> usize
Get the global DOF index associated with a process DOF index
Auto Trait Implementations§
impl<'a, T, TMesh, E, G, F> Freeze for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T, TMesh, E, G, F> RefUnwindSafe for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T, TMesh, E, G, F> Send for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T, TMesh, E, G, F> Sync for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T, TMesh, E, G, F> Unpin for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T, TMesh, E, G, F> UnsafeUnpin for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
impl<'a, T, TMesh, E, G, F> UnwindSafe for FunctionSpaceImpl<'a, T, TMesh, E, G, F>
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.§impl<Src> TryFrom<Src> for Src
impl<Src> TryFrom<Src> for Src
§impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
§impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
§fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
§impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
§fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.