MixedGridBuilder

Struct MixedGridBuilder 

Source
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>

Source

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>

Source§

type Grid = MixedGrid<T, CiarletElement<T, IdentityMap, T>>

The type of the grid that the builder creates
Source§

type T = T

The floating point type used for coordinates
Source§

type CellData<'a> = (ReferenceCellType, usize, &'a [usize])

The type of the data that is input to add a cell
Source§

type EntityDescriptor = ReferenceCellType

Type used as identifier of different entity types
Source§

fn add_point(&mut self, id: usize, data: &[T])

Add a point to the grid
Source§

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, )

Add a cell to the grid
Source§

fn create_grid(&self) -> MixedGrid<T, CiarletElement<T, IdentityMap, T>>

Create the grid
Source§

fn point_count(&self) -> usize

Number of points
Source§

fn cell_count(&self) -> usize

Number of cells
Source§

fn point_indices_to_ids(&self) -> &[usize]

Get the insertion ids of each point
Source§

fn cell_indices_to_ids(&self) -> &[usize]

Get the insertion ids of each cell
Source§

fn cell_points(&self, index: usize) -> &[usize]

Get the indices of the points of a cell
Source§

fn cell_vertices(&self, index: usize) -> &[usize]

Get the indices of the points of a cell
Source§

fn point(&self, index: usize) -> &[T]

Get the coordinates of a point
Source§

fn points(&self) -> &[T]

Get all points
Source§

fn cell_type(&self, index: usize) -> ReferenceCellType

Get the type of a cell
Source§

fn cell_degree(&self, index: usize) -> usize

Get the degree of a cell’s geometry
Source§

fn gdim(&self) -> usize

Geometric dimension
Source§

fn tdim(&self) -> usize

Topoligical dimension
Source§

fn npts(&self, cell_type: Self::EntityDescriptor, degree: usize) -> usize

Number of points in a cell with the given type and degree
Source§

impl<T: Debug + Scalar> Debug for MixedGridBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

§

type Err = NoError

The error type produced by a failed conversion.
§

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 Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, Dst> ConvAsUtil<Dst> for T

§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
§

impl<T> ConvUtil for T

§

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,

Approximate the subject to a given type with a specific scheme.
§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, B> GmshImport for B
where T: FromStr + FromBytes + Debug, <T as FromBytes>::Bytes: Sized, B: Builder<T = T, EntityDescriptor = ReferenceCellType>,

Source§

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)

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, )

Generate grid from a Gmsh v2 binary
Source§

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, )

Generate grid from a Gmsh v4 binary
Source§

fn import_from_gmsh(&mut self, filename: &str)

Generate grid from Gmsh
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
§

impl<Src> TryFrom<Src> for Src

§

type Err = NoError

The error type produced by a failed conversion.
§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<Src> ValueFrom<Src> for Src

§

type Err = NoError

The error type produced by a failed conversion.
§

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 Src
where Dst: ValueFrom<Src>,

§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T, U> Imply<T> for U