Metis for finite element partitioning

I have a finite element mesh and I need to distribute them among processors using metis. I found one code for partitioning a simple graph and it gives me nodes belonging to each partition. I am looking for something that gives me the element number belonging to each processor and then send chunks of elements to each processors. any help would be appreciated.

let's say this is the connectivity matrix

Elements
1 11 13 7
2 15 12 9
3 9 12 6
4 15 9 14
5 2 1 3
6 14 16 15
7 10 6 12
8 3 7 5
9 5 7 8
10 3 4 2
11 13 14 8
12 8 14 9
13 13 8 7
14 6 2 4
15 4 3 5
16 6 4 9
17 8 9 4
18 5 8 4
End Elements

the first column is the number of element and the rest three columns are the vertices of each triangular element. I expect metis to give me the list of element for each partition and then I want to send these lists to processors.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "includes.h"
#include "typedefs.h"
#include "mesh.h"
#include "node.h"
#include "element.h"
#include "mpi_call.h"
#include "vector"
#include "sparsematrixstructure.h"
#include "sparsematrix.h"
#include "assembler.h"
#include "blas.h"
#include<map>
#include<set>
#include <unordered_map>
#include<metis.h>

int main() {

	idx_t nVertices = 6;
	idx_t nEdges = 7;
	idx_t nWeights = 1;
	idx_t nParts = 2;

	idx_t objval;
	std::vector<idx_t> part(nVertices, 0);
	

	// Indexes of starting points in adjacent array
	std::vector<idx_t> xadj = { 0,2,5,7,9,12,14 };
	std::vector<idx_t> adjncy = { 1,3,0,4,2,1,5,0,4,3,1,5,4,2 };
	std::vector<idx_t> vwgt(nVertices * nWeights, 0);

	int ret = METIS_PartGraphKway(&nVertices, &nWeights, xadj.data(), adjncy.data(),
		NULL, NULL, NULL, &nParts, NULL,
		NULL, NULL, &objval, part.data());

	std::cout << ret << std::endl;
	 
	for (unsigned part_i = 0; part_i < part.size(); part_i++) {
		std::cout << part_i << " " << part[part_i] << std::endl;
	}
}
Last edited on
This is one of those things where I see a post that has been sitting around unanswered for a while (thought it was older than yesterday?) and went to see if I could be of any use whatsoever...

But I'm not. Sorry.

Have you asked over on Stack Overflow?
I am looking for something that gives me the element number belonging to each processor and then send chunks of elements to each processors. any help would be appreciated.


Have you read / searched the documentation for the library you are using?
Yes, I read.
Topic archived. No new replies allowed.