GeoscienceAustralia / anuga_core

AnuGA for the simulation of the shallow water equation
https://anuga.anu.edu.au
Other
191 stars 93 forks source link

Update to metis 5 #15

Open stoiver opened 9 years ago

stoiver commented 9 years ago

We are using an old version of metis.

ninnghazad commented 6 years ago
some diff `````` diff --git a/anuga/parallel/distribute_mesh.py b/anuga/parallel/distribute_mesh.py index 88497575..29a5b1bb 100644 --- a/anuga/parallel/distribute_mesh.py +++ b/anuga/parallel/distribute_mesh.py @@ -122,7 +122,9 @@ def reorder_new(quantities, epart_order, proc_sum): #path.append('..' + sep + 'pymetis') try: - from anuga.pymetis.metis_ext import partMeshNodal +# from anuga.pymetis.metis_ext import partMeshNodal + import pymetis + from sets import Set except ImportError: print "***************************************************" print " Metis is probably not compiled." @@ -160,26 +162,34 @@ def pmesh_divide_metis_helper(domain, n_procs): n_tri = len(domain.triangles) if n_procs != 1: #Because metis chokes on it... - n_vert = domain.get_number_of_nodes() - t_list = domain.triangles.copy() - t_list = num.reshape(t_list, (-1,)) - - # The 1 here is for triangular mesh elements. - # FIXME: Should update to Metis 5 - edgecut, epart, npart = partMeshNodal(n_tri, n_vert, t_list, 1, n_procs) - # print edgecut - # print npart - #print epart - del edgecut - del npart + # n_vert = domain.get_number_of_nodes() + # t_list2 = domain.triangles.copy() + # t_list = num.reshape(t_list2, (-1,)) + + # build adjacency list + # neighbours uses negative integer-indices to denote boudary edges. + # pymetis totally cant handle that, so we have to delete these. + neigh = domain.neighbours.tolist() + for i in xrange(len(neigh)): + if neigh[i][2] < 0: + del neigh[i][2] + if neigh[i][1] < 0: + del neigh[i][1] + if neigh[i][0] < 0: + del neigh[i][0] + + cutcount,partvert = pymetis.part_graph(n_procs,neigh) + + #print "cutcount: ",cutcount + #print "partvert: ",len(partvert) + epart = partvert # Sometimes (usu. on x86_64), partMeshNodal returns an array of zero # dimensional arrays. Correct this. + # TODO: Not sure if this can still happen with metis 5 if type(epart[0]) == num.ndarray: epart_new = num.zeros(len(epart), num.int) epart_new[:] = epart[:][0] -# for i in xrange(len(epart)): -# epart_new[i] = epart[i][0] epart = epart_new del epart_new ``````

so this seems to work for me. using latest pymetis from python2.7's pip. just builds adjacency lists from domain-data and feeds that to pymetis. did a few meshes and worked even with ~120mio triangles. whereas old pymetis would crumble somewhere between 50mio and 60mio. per-cpu-blobs look ok when visually checking.

ninnghazad commented 6 years ago

See #153