pub struct Mesh<'a> { /* private fields */ }
Expand description
Implementations§
source§impl<'a> Mesh<'a>
impl<'a> Mesh<'a>
sourcepub fn new(
nparts: Idx,
eptr: &'a [Idx],
eind: &'a [Idx],
) -> StdResult<Mesh<'a>, NewMeshError>
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 i
th
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 ofeind
, - 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.
sourcepub unsafe fn new_unchecked(
nn: Idx,
nparts: Idx,
eptr: &'a [Idx],
eind: &'a [Idx],
) -> Mesh<'a>
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, ornparts
is not strictly greater than zero, oreptr
is empty, or- the length of
eind
is different from the last element ofeptr
.
§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.
sourcepub fn set_vwgt(self, vwgt: &'a [Idx]) -> Mesh<'a>
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.
sourcepub fn set_vsize(self, vsize: &'a [Idx]) -> Mesh<'a>
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.
sourcepub fn set_tpwgts(self, tpwgts: &'a [Real]) -> Mesh<'a>
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
.
sourcepub fn set_options(self, options: &[Idx; 40]) -> Mesh<'a>
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.
sourcepub fn set_option<O>(self, option: O) -> Mesh<'a>where
O: Opt,
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.
sourcepub fn part_dual(self, epart: &mut [Idx], npart: &mut [Idx]) -> Result<Idx>
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.
sourcepub fn part_nodal(self, epart: &mut [Idx], npart: &mut [Idx]) -> Result<Idx>
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.