52 (elmdist, eptr, eind, elmwgt, wgtflag, numflag, ncon, &
53 ncommonnodes, nparts, tpwgts, ubvec, options, edgecut, part) &
54 bind(c, name=
'ParMETIS_V3_PartMeshKway_wrapper')
55 use,
intrinsic :: iso_c_binding
58 type(c_ptr),
value :: elmdist, eptr, eind, elmwgt, wgtflag, &
59 numflag, ncon, ncommonnodes, nparts, options, edgecut, part
61 type(c_ptr),
value :: tpwgts, ubvec
112 type(
mesh_t),
intent(inout) :: msh
114 type(
mesh_fld_t),
intent(in),
optional :: weights
115 integer,
intent(in),
optional :: nprts
116 integer(kind=M_INT),
target :: wgtflag, numflag, ncon, ncommonnodes
117 integer(kind=M_INT),
target :: nparts, options(3), edgecut, rcode
118 real(kind=m_real),
allocatable,
target,
dimension(:) :: tpwgts, ubvec
119 integer(kind=M_INT),
allocatable,
target,
dimension(:) :: &
120 elmdist, eptr, eind, elmwgt, part
121 integer :: i, j, k, ierr
128 ncommonnodes = 2**(msh%gdim - 1)
134 if (
present(nprts))
then
140 allocate(elmdist(0:
pe_size), eptr(0:msh%nelv))
141 allocate(eind(0:(msh%nelv * msh%npts)), part(msh%nelv))
142 allocate(elmwgt(msh%nelv), tpwgts(ncon * nparts), ubvec(ncon))
146 if (
present(weights))
then
147 call parmetis_wgt(msh, elmwgt, tpwgts, ubvec, nparts, ncon, weights)
149 call parmetis_wgt(msh, elmwgt, tpwgts, ubvec, nparts, ncon)
154 eptr(i) = parmetis_idx(eptr(i - 1) + msh%npts)
160 eind(k) = parmetis_idx(msh%elements(i)%e%pts(j)%p%id() - 1)
166 c_loc(elmwgt), c_loc(wgtflag), c_loc(numflag), c_loc(ncon), &
167 c_loc(ncommonnodes), c_loc(nparts), c_loc(tpwgts), c_loc(ubvec),&
168 c_loc(options), c_loc(edgecut), c_loc(part))
176 deallocate(elmdist, eptr, eind, part, elmwgt, tpwgts, ubvec)
183 type(
mesh_t),
intent(inout) :: msh
185 integer(kind=M_INT),
target :: ndims
186 real(kind=m_real),
allocatable,
target,
dimension(:) :: xyz
187 integer(kind=M_INT),
allocatable,
target,
dimension(:) :: vtxdist, part
189 integer :: i, j, ierr, rcode
193 allocate(part(msh%nelv), xyz(ndims * msh%nelv))
200 c = msh%elements(j)%e%centroid()
201 xyz(i) = parmetis_real(c%x(1))
202 xyz(i + 1) = parmetis_real(c%x(2))
203 xyz(i + 2) = parmetis_real(c%x(3))
208 c_loc(xyz), c_loc(part))
216 deallocate(part, xyz, vtxdist)
237 type(
mesh_t),
intent(in) :: msh
238 integer(kind=M_INT),
allocatable,
intent(inout) :: wgt(:)
239 real(kind=m_real),
allocatable,
intent(inout) :: tpwgts(:)
240 real(kind=m_real),
allocatable,
intent(inout) :: ubvec(:)
241 integer,
intent(in) :: nparts, ncon
242 type(
mesh_fld_t),
intent(in),
optional :: weight
245 if (
present(weight))
then
247 wgt(i) = parmetis_idx(weight%data(i))
250 wgt = parmetis_idx(1)
253 do i = 1, (ncon * nparts)
254 tpwgts(i) = parmetis_real(1) / parmetis_real(nparts)
258 ubvec(i) = parmetis_real(1.05d0)
subroutine, public parmetis_partmeshkway(msh, parts, weights, nprts)
Compute a k-way partitioning of a mesh msh.
subroutine parmetis_wgt(msh, wgt, tpwgts, ubvec, nparts, ncon, weight)
Setup weights and balance constraints for the dual graph.