Struct metis::Mesh

source ·
pub struct Mesh<'a> { /* private fields */ }
Expand description

Builder structure to set up a mesh partition computation.

This structure holds the required arguments for METIS to compute a partition. It also offers methods to easily set any optional argument.

§Example

Usage is fairly similar to Graph. Refer to its documentation for details.

Implementations§

source§

impl<'a> Mesh<'a>

source

pub fn new( nparts: Idx, eptr: &'a [Idx], eind: &'a [Idx], ) -> StdResult<Mesh<'a>, NewMeshError>

Creates a new Mesh object to be partitioned.

nparts is the number of parts wanted in the mesh partition.

§Input format

The length of eptr is n + 1, where n is the number of elements in the mesh. The length of eind is the sum of the number of nodes in all the elements of the mesh. The list of nodes belonging to the ith element of the mesh are stored in consecutive locations of eind starting at position eptr[i] up to (but not including) position eptr[i+1].

§Errors

The following invariants must be held, otherwise this function returns an error:

  • nparts is strictly greater than zero,
  • eptr has at least one element (its length is the one more than the number of mesh elements),
  • eptr is sorted,
  • elements of eptr are positive,
  • the last element of eptr is the length of eind,
  • all the arrays have a length that can be held by an Idx.
§Mutability

Mesh::part_dual and Mesh::part_nodal may mutate the contents of eptr and eind, but should revert all changes before returning.

source

pub unsafe fn new_unchecked( nn: Idx, nparts: Idx, eptr: &'a [Idx], eind: &'a [Idx], ) -> Mesh<'a>

Creates a new Mesh object to be partitioned (unchecked version).

  • nn is the number of nodes in the mesh,
  • nparts is the number of parts wanted in the mesh partition.
§Input format

See Mesh::new.

§Safety

This function still does some checks listed in “Panics” below. However, the caller is reponsible for upholding all invariants listed in the “Errors” section of Mesh::new. Otherwise, the behavior of this function is undefined.

§Panics

This function panics if:

  • any of the arrays have a length that cannot be hold by an Idx, or
  • nn is not strictly greater than zero, or
  • nparts is not strictly greater than zero, or
  • eptr is empty, or
  • the length of eind is different from the last element of eptr.
§Mutability

While nothing should be modified by the Mesh structure, METIS doesn’t specify any const modifier, so everything must be mutable on Rust’s side.

source

pub fn set_vwgt(self, vwgt: &'a [Idx]) -> Mesh<'a>

Sets the computational weights of the elements.

By default, all elements have the same weight.

All elements of vwgt must be positive.

§Panics

This function panics if the length of vwgt is not the number of elements.

source

pub fn set_vsize(self, vsize: &'a [Idx]) -> Mesh<'a>

Sets the communication weights of the elements.

By default, all elements have the same communication weight.

§Panics

This function panics if the length of vsize is not the number of elements.

source

pub fn set_tpwgts(self, tpwgts: &'a [Real]) -> Mesh<'a>

Sets the target partition weights for each part.

By default, the mesh is divided equally.

The sum of the target partition weights must be 1.0.

§Panics

This function panics if the length of tpwgts is not equal to nparts.

source

pub fn set_options(self, options: &[Idx; 40]) -> Mesh<'a>

Sets the fine-tuning parameters for this partitioning.

When few options are to be set, Mesh::set_option might be a better fit.

See the option module for the list of available parameters. Note that not all are applicable to a given partitioning method. Refer to the documentation of METIS (link) for more info on this.

See Graph::set_options for a usage example.

source

pub fn set_option<O>(self, option: O) -> Mesh<'a>
where O: Opt,

Sets a fine-tuning parameter for this partitioning.

When options are to be set in batches, Mesh::set_options might be a better fit.

See the option module for the list of available parameters. Note that not all are applicable to a given partitioning method. Refer to the documentation of METIS (link) for more info on this.

See Graph::set_option for a usage example.

source

pub fn part_dual(self, epart: &mut [Idx], npart: &mut [Idx]) -> Result<Idx>

Partition the mesh using its dual graph.

Returns the edge-cut, the total communication volume of the partitioning solution.

Equivalent of METIS_PartMeshDual.

§Panics

This function panics if the length of epart is not the number of elements, or if nparts’s is not the number of nodes.

source

pub fn part_nodal(self, epart: &mut [Idx], npart: &mut [Idx]) -> Result<Idx>

Partition the mesh using its nodal graph.

Returns the edge-cut, the total communication volume of the partitioning solution.

Previous settings of ncommon are not used by this function.

Equivalent of METIS_PartMeshNodal.

§Panics

This function panics if the length of epart is not the number of elements, or if nparts’s is not the number of nodes.

Trait Implementations§

source§

impl<'a> Debug for Mesh<'a>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> PartialEq for Mesh<'a>

source§

fn eq(&self, other: &Mesh<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> StructuralPartialEq for Mesh<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Mesh<'a>

§

impl<'a> RefUnwindSafe for Mesh<'a>

§

impl<'a> Send for Mesh<'a>

§

impl<'a> Sync for Mesh<'a>

§

impl<'a> Unpin for Mesh<'a>

§

impl<'a> UnwindSafe for Mesh<'a>

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
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
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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