SPEED
MESH_PARTITIONING.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine mesh_partitioning (mpi_file, nelem, nnode, nparts, conn, w_yn
 Makes mesh partitioning using METIS.
 

Function/Subroutine Documentation

◆ mesh_partitioning()

subroutine mesh_partitioning ( character*70  mpi_file,
integer*4, intent(inout)  nelem,
integer*4, intent(inout)  nnode,
integer*4, intent(inout)  nparts,
integer*4, dimension(nelem,9), intent(in)  conn,
integer*4  w_yn 
)

Makes mesh partitioning using METIS.

Date
September, 2013
Version
1.0
Warning
Mesh partitioning is made using metis-4.0.3 library. At the moment we have problems in using metis-5.0.2 library.
Todo:
Switch to other mesh partitioner or to ParMetis library.
Parameters
[in]mpi_filefolder name given in SPEED.input (MPIFILE keyword)
[in]nelemnumber of elements
[in]nnodenumber of mesh nodes
[in]npartsnumber of processors (number of parts of the partition)
[in]connconnectivity matrix: i = element number conn(i,1) = Matrial /Block label conn(i,2),...,conn(i,9) = nodes of the hex
[in]wcontrol parameter 1 - different weights for the elements 0 - same weight for all elements (for metis-5.0.2 version)
[out]elemdomain.mpifile containing elements partitioning

Definition at line 37 of file MESH_PARTITIONING.f90.

38
39
40 implicit none
41
42
43 character*70 :: mpi_file,u_name
44 integer*4 :: ie,i,ic,u_mpi, w_yn, trash
45 integer*4 :: ncommon, objval, edgecut
46
47 integer*4, intent(inout) :: nelem, nnode, nparts
48 integer*4, dimension(nelem,9), intent(in) :: conn
49
50 integer*4, dimension(nnode) :: npart
51 integer*4, dimension(nelem) :: epart
52 integer*4, dimension(nelem) :: vwgt
53
54 integer*4, pointer :: vsize(:) => null()
55
56 integer*4, dimension(nelem+1) :: eptr
57 integer*4, dimension(nelem*8) :: eind
58
59 integer*4 :: options(40) ! see METIS_NOPTIONS in metis.h
60 integer*4, parameter :: METIS_OPTION_PTYPE = 1, metis_option_objtype = 2, metis_option_ctype = 3, &
61 metis_option_iptype = 4, metis_option_rtype = 5, metis_option_dbglvl = 6, &
62 metis_option_niter = 7, metis_option_ncuts = 8, metis_option_seed = 9, &
63 metis_option_no2hop = 10, &
64 metis_option_minconn = 11, metis_option_contig = 12, metis_option_compress = 13, &
65 metis_option_ccorder = 14, metis_option_pfactor = 15, metis_option_nseps = 16, &
66 metis_option_ufactor = 17, metis_option_numbering = 18
67
68 real*8, pointer :: tpwgts(:) => null()
69
70 eptr(1) = 1
71 ic = 1
72 do ie = 1, nelem
73 eptr(ie+1) = eptr(ie) + 8
74 do i = 2, 9
75 eind(ic) = conn(ie,i)
76 ic = ic +1
77 enddo
78 enddo
79
80 eptr = eptr -1
81 eind = eind - 1
82
83 !!!---------- METIS-4.0.3 ------------------------------------!!!
84 eind = eind +1
85 call metis_partmeshdual(nelem,nnode,eind,3,1,nparts,edgecut,&
86 epart,npart)
87 epart = epart - 1
88
89 !!!---------- METIS-5.1.0 ------------------------------------!!!
90 !ncommon = 4
91 !eptr = eptr + 1
92 !eind = eind + 1
93 !if(w_yn .eq. 0) then
94 ! vwgt = 1
95 !else
96 ! u_name = 'element.wgt'
97 ! u_mpi = 40
98 ! open(u_mpi,file=u_name)
99 ! read(u_mpi,*) nelem
100 !
101 ! do i = 1, nelem
102 ! read(u_mpi,*) trash, vwgt(i)
103 ! enddo
104 ! close(u_mpi)
105 !endif
106
107 !! Setting the Fortran numbering scheme
108 !call metis_setdefaultoptions(options) !INPUT
109 !options(metis_option_numbering) = 1
110
111 !call metis_partmeshdual(nelem, nnode, eptr, eind, vwgt, vsize, &
112 ! ncommon, nparts, tpwgts, options, objval, &
113 ! epart, npart)
114 ! epart = epart - 1
115
116 !!!--------------------------------------------------------------------!!!
117
118
119 ! if(w_yn .eq. 0) then
120 if(len_trim(mpi_file) .ne. 70) then
121 u_name = mpi_file(1:len_trim(mpi_file)) // '/elemdomain.mpi'
122 else
123 u_name = 'elemdomain.mpi'
124 endif
125
126 u_mpi = 400
127 open(u_mpi,file=u_name)
128 write(u_mpi,*) nelem
129 do i = 1, nelem
130 write(u_mpi,*) i, epart(i)
131 enddo
132 close(u_mpi)
133
134! else
135!
136! if(len_trim(mpi_file) .ne. 70) then
137! u_name = mpi_file(1:len_trim(mpi_file)) // '/final.part'
138! else
139! u_name = 'final.part'
140! endif
141!
142! u_mpi = 400
143! open(u_mpi,file=u_name)
144! write(u_mpi,*) nelem
145! do i = 1, nelem
146! write(u_mpi,*) i, epart(i)
147! enddo
148! close(u_mpi)
149
150 ! endif
151
152 return
153