pub struct MixedGridBuilder<T: Scalar> { /* private fields */ }Expand description
Grid builder for a grid with a mixture of element types
Implementations§
Source§impl<T: Scalar> MixedGridBuilder<T>
impl<T: Scalar> MixedGridBuilder<T>
Sourcepub fn new(gdim: usize) -> Self
pub fn new(gdim: usize) -> Self
Create a new grid builder
Examples found in repository?
ndgrid/examples/mixed_grid.rs (line 11)
9fn main() {
10 // When creating the grid builder, we give the physical/geometric dimension (3)
11 let mut b = MixedGridBuilder::<f64>::new(2);
12 // Add nine points with ids 0 to 8
13 b.add_point(0, &[0.0, 0.0]);
14 b.add_point(1, &[0.5, -0.3]);
15 b.add_point(2, &[1.0, 0.0]);
16 b.add_point(3, &[2.0, 0.0]);
17 b.add_point(4, &[-0.3, 0.5]);
18 b.add_point(5, &[0.5, 0.5]);
19 b.add_point(6, &[0.0, 1.0]);
20 b.add_point(7, &[1.0, 1.0]);
21 b.add_point(8, &[2.0, 1.0]);
22 // Add a linear triangle cell. The inputs to add_cell are
23 // (id, (cell type, cell degree, vertices))
24 b.add_cell(0, (ReferenceCellType::Triangle, 1, &[2, 7, 6]));
25 // Add a quadratic triangle cell. The edge that is shared with cell 0 is straight to ensure
26 // that there are no discontinuities in the grid.
27 b.add_cell(1, (ReferenceCellType::Triangle, 2, &[0, 2, 6, 5, 4, 1]));
28 // Add a quadrilateral cell
29 b.add_cell(2, (ReferenceCellType::Quadrilateral, 1, &[2, 3, 7, 8]));
30 // Create the grid
31 let grid = b.create_grid();
32
33 // Print the vertices of each triangle cell: this will only include the three points
34 // for each cell as these are the topological vertices (ie the 0-dimensional entities at
35 // each corner of the cell), not the geometric points
36 for cell in grid.entity_iter(ReferenceCellType::Triangle) {
37 println!(
38 "triangle cell {}: {:?}",
39 cell.local_index(),
40 cell.topology()
41 .sub_entity_iter(ReferenceCellType::Point)
42 .collect::<Vec<_>>(),
43 );
44 }
45 // Print the geometric points that definie each cells position in space. Note that
46 // The indexing of these points may differ from the indexing used for the topological vertices.
47 let mut coords = vec![0.0; 2];
48 for cell in grid.entity_iter(ReferenceCellType::Triangle) {
49 println!("triangle cell {}:", cell.local_index());
50 for p in cell.geometry().points() {
51 p.coords(&mut coords);
52 println!(" point {}: {:?}", p.index(), coords);
53 }
54 }
55 // Print the vertices of each quadrilateral cell
56 for cell in grid.entity_iter(ReferenceCellType::Quadrilateral) {
57 println!(
58 "quadrilateral cell {}: {:?} ",
59 cell.local_index(),
60 cell.topology()
61 .sub_entity_iter(ReferenceCellType::Point)
62 .collect::<Vec<_>>()
63 );
64 }
65
66 // Export the mesh in Gmsh format
67 grid.export_as_gmsh("_mixed.msh");
68}Trait Implementations§
Source§impl<T: Scalar> Builder for MixedGridBuilder<T>
impl<T: Scalar> Builder for MixedGridBuilder<T>
Source§type Grid = MixedGrid<T, CiarletElement<T, IdentityMap, T>>
type Grid = MixedGrid<T, CiarletElement<T, IdentityMap, T>>
The type of the grid that the builder creates
Source§type CellData<'a> = (ReferenceCellType, usize, &'a [usize])
type CellData<'a> = (ReferenceCellType, usize, &'a [usize])
The type of the data that is input to add a cell
Source§type EntityDescriptor = ReferenceCellType
type EntityDescriptor = ReferenceCellType
Type used as identifier of different entity types
Source§fn add_cell(
&mut self,
id: usize,
cell_data: (ReferenceCellType, usize, &[usize]),
)
fn add_cell( &mut self, id: usize, cell_data: (ReferenceCellType, usize, &[usize]), )
Add a cell to the grid
Source§fn add_cell_from_nodes_and_type(
&mut self,
id: usize,
nodes: &[usize],
cell_type: ReferenceCellType,
cell_degree: usize,
)
fn add_cell_from_nodes_and_type( &mut self, id: usize, nodes: &[usize], cell_type: ReferenceCellType, cell_degree: usize, )
Add a cell to the grid
Source§fn create_grid(&self) -> MixedGrid<T, CiarletElement<T, IdentityMap, T>>
fn create_grid(&self) -> MixedGrid<T, CiarletElement<T, IdentityMap, T>>
Create the grid
Source§fn point_count(&self) -> usize
fn point_count(&self) -> usize
Number of points
Source§fn cell_count(&self) -> usize
fn cell_count(&self) -> usize
Number of cells
Source§fn point_indices_to_ids(&self) -> &[usize]
fn point_indices_to_ids(&self) -> &[usize]
Get the insertion ids of each point
Source§fn cell_indices_to_ids(&self) -> &[usize]
fn cell_indices_to_ids(&self) -> &[usize]
Get the insertion ids of each cell
Source§fn cell_points(&self, index: usize) -> &[usize]
fn cell_points(&self, index: usize) -> &[usize]
Get the indices of the points of a cell
Source§fn cell_vertices(&self, index: usize) -> &[usize]
fn cell_vertices(&self, index: usize) -> &[usize]
Get the indices of the points of a cell
Source§fn cell_type(&self, index: usize) -> ReferenceCellType
fn cell_type(&self, index: usize) -> ReferenceCellType
Get the type of a cell
Source§fn cell_degree(&self, index: usize) -> usize
fn cell_degree(&self, index: usize) -> usize
Get the degree of a cell’s geometry
Auto Trait Implementations§
impl<T> Freeze for MixedGridBuilder<T>
impl<T> RefUnwindSafe for MixedGridBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for MixedGridBuilder<T>
impl<T> Sync for MixedGridBuilder<T>
impl<T> Unpin for MixedGridBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for MixedGridBuilder<T>where
T: UnwindSafe,
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<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.
Source§impl<T, B> GmshImport for B
impl<T, B> GmshImport for B
Source§fn import_from_gmsh_v1(&mut self, s: String)
fn import_from_gmsh_v1(&mut self, s: String)
Generate grid from a Gmsh v1 string
Source§fn import_from_gmsh_string_v2(&mut self, s: String)
fn import_from_gmsh_string_v2(&mut self, s: String)
Generate grid from a Gmsh v2 string
Source§fn import_from_gmsh_binary_v2(
&mut self,
reader: BufReader<File>,
data_size: usize,
is_le: bool,
)
fn import_from_gmsh_binary_v2( &mut self, reader: BufReader<File>, data_size: usize, is_le: bool, )
Generate grid from a Gmsh v2 binary
Source§fn import_from_gmsh_string_v4(&mut self, s: String)
fn import_from_gmsh_string_v4(&mut self, s: String)
Generate grid from a Gmsh v4 string
Source§fn import_from_gmsh_binary_v4(
&mut self,
reader: BufReader<File>,
data_size: usize,
is_le: bool,
)
fn import_from_gmsh_binary_v4( &mut self, reader: BufReader<File>, data_size: usize, is_le: bool, )
Generate grid from a Gmsh v4 binary
Source§fn import_from_gmsh(&mut self, filename: &str)
fn import_from_gmsh(&mut self, filename: &str)
Generate grid from Gmsh
§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<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.