16 namespace IT = Input::Type;
19 "Different algorithms to make the sparse graph with weighted edges\n"
20 "from the multidimensional mesh. Main difference is dealing with \n"
21 "neighborings of elements of different dimension.")
22 .
add_value(any_neighboring,
"any_neighboring",
"Add edge for any pair of neighboring elements.")
23 .
add_value(any_weight_lower_dim_cuts,
"any_wight_lower_dim_cuts",
"Same as before and assign higher weight to cuts of lower dimension in order to make them stick to one face.")
24 .
add_value(same_dimension_neighboring,
"same_dimension_neghboring",
"Add edge for any pair of neighboring elements of same dimension (bad for matrix multiply).")
28 =
IT::Selection(
"PartTool",
"Select the partitioning tool to use.")
29 .
add_value(PETSc,
"PETSc",
"Use PETSc interface to various partitioning tools.")
30 .
add_value(METIS,
"METIS",
"Use direct interface to Metis.")
34 =
IT::Record(
"Partition",
"Setting for various types of mesh partitioning." )
35 .
declare_key(
"tool", Partitioning::tool_sel,
IT::Default(
"METIS"),
"Software package used for partitioning. See corresponding selection.")
36 .
declare_key(
"graph_type", Partitioning::graph_type_sel,
IT::Default(
"any_neighboring"),
"Algorithm for generating graph and its weights from a multidimensional mesh.")
42 : mesh_(mesh), in_(in), graph_(NULL), loc_part_(NULL), init_el_ds_(NULL)
77 int li, e_idx, i_neigh;
100 if (e_idx != ele.index()) {
109 for (i_neigh = 0; i_neigh < ele->n_neighs_vb; i_neigh++) {
110 n_s = ele->neigh_vb[i_neigh]->edge()->n_sides;
111 for (i_s = 0; i_s < n_s; i_s++) {
161 Distribution * &new_ds,
int * &id_4_loc,
int * &new_4_id) {
163 IS part, new_numbering;
164 unsigned int size = old_ds.
size();
165 int new_counts[old_ds.
np()];
173 ISCreateGeneral(PETSC_COMM_WORLD, old_ds.
lsize(), loc_part, PETSC_COPY_VALUES, &part);
174 ISPartitioningCount(part, old_ds.
np(), new_counts);
176 new_ds =
new Distribution((
unsigned int *) new_counts, PETSC_COMM_WORLD);
177 ISPartitioningToNumbering(part, &new_numbering);
183 old_4_new = (
int *)
xmalloc(size *
sizeof(
int));
184 id_4_loc = (
int *)
xmalloc(new_ds->lsize() *
sizeof(int));
185 new_4_id = (
int *)
xmalloc((n_ids + 1) *
sizeof(int));
189 AOCreateBasicIS(new_numbering, PETSC_NULL, &new_old_ao);
190 for (
unsigned int i = 0; i < size; i++)
192 AOApplicationToPetsc(new_old_ao, size, old_4_new);
193 AODestroy(&(new_old_ao));
201 for (
unsigned int i_new = new_ds->begin(); i_new < new_ds->end(); i_new++) {
203 id_4_loc[i_loc++] = id_4_old[old_4_new[i_new]];
207 for (i_loc = 0; i_loc <= n_ids; i_loc++)
208 new_4_id[i_loc] = -1;
209 for (
unsigned int i_new = 0; i_new < size; i_new++)
210 new_4_id[id_4_old[old_4_new[i_new]]] = i_new;