You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
7.3 KiB
Fortran
197 lines
7.3 KiB
Fortran
8 years ago
|
!
|
||
|
!
|
||
|
! MLD2P4 version 2.1
|
||
|
! MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||
8 years ago
|
! based on PSBLAS (Parallel Sparse BLAS version 3.5)
|
||
8 years ago
|
!
|
||
7 years ago
|
! (C) Copyright 2008-2018
|
||
8 years ago
|
!
|
||
7 years ago
|
! Salvatore Filippone
|
||
|
! Pasqua D'Ambra
|
||
|
! Daniela di Serafino
|
||
8 years ago
|
!
|
||
|
! Redistribution and use in source and binary forms, with or without
|
||
|
! modification, are permitted provided that the following conditions
|
||
|
! are met:
|
||
|
! 1. Redistributions of source code must retain the above copyright
|
||
|
! notice, this list of conditions and the following disclaimer.
|
||
|
! 2. Redistributions in binary form must reproduce the above copyright
|
||
|
! notice, this list of conditions, and the following disclaimer in the
|
||
|
! documentation and/or other materials provided with the distribution.
|
||
|
! 3. The name of the MLD2P4 group or the names of its contributors may
|
||
|
! not be used to endorse or promote products derived from this
|
||
|
! software without specific written permission.
|
||
|
!
|
||
|
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
|
! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||
|
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
|
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS
|
||
|
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
|
! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
|
! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
|
! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
|
! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
|
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
|
! POSSIBILITY OF SUCH DAMAGE.
|
||
|
!
|
||
|
!
|
||
16 years ago
|
! File: mld_saggrmat_nosmth_asb.F90
|
||
17 years ago
|
!
|
||
16 years ago
|
! Subroutine: mld_saggrmat_nosmth_asb
|
||
17 years ago
|
! Version: real
|
||
|
!
|
||
|
! This routine builds a coarse-level matrix A_C from a fine-level matrix A
|
||
16 years ago
|
! by using the Galerkin approach, i.e.
|
||
17 years ago
|
!
|
||
|
! A_C = P_C^T A P_C,
|
||
|
!
|
||
|
! where P_C is the piecewise constant interpolation operator corresponding
|
||
|
! the fine-to-coarse level mapping built by mld_aggrmap_bld.
|
||
|
!
|
||
|
! The coarse-level matrix A_C is distributed among the parallel processes or
|
||
14 years ago
|
! replicated on each of them, according to the value of p%parms%coarse_mat
|
||
13 years ago
|
! specified by the user through mld_sprecinit and mld_zprecset.
|
||
8 years ago
|
! On output from this routine the entries of AC, op_prol, op_restr
|
||
|
! are still in "global numbering" mode; this is fixed in the calling routine
|
||
|
! mld_s_lev_aggrmat_asb.
|
||
17 years ago
|
!
|
||
|
! For details see
|
||
|
! P. D'Ambra, D. di Serafino and S. Filippone, On the development of
|
||
|
! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math.,
|
||
|
! 57 (2007), 1181-1196.
|
||
|
!
|
||
|
!
|
||
|
! Arguments:
|
||
|
! a - type(psb_sspmat_type), input.
|
||
|
! The sparse matrix structure containing the local part of
|
||
|
! the fine-level matrix.
|
||
|
! desc_a - type(psb_desc_type), input.
|
||
|
! The communication descriptor of the fine-level matrix.
|
||
13 years ago
|
! p - type(mld_s_onelev_type), input/output.
|
||
16 years ago
|
! The 'one-level' data structure that will contain the local
|
||
8 years ago
|
! part of the matrix to be built as well as the information
|
||
16 years ago
|
! concerning the prolongator and its transpose.
|
||
8 years ago
|
! parms - type(mld_sml_parms), input
|
||
|
! Parameters controlling the choice of algorithm
|
||
|
! ac - type(psb_sspmat_type), output
|
||
|
! The coarse matrix on output
|
||
|
!
|
||
|
! ilaggr - integer, dimension(:), input
|
||
16 years ago
|
! The mapping between the row indices of the coarse-level
|
||
|
! matrix and the row indices of the fine-level matrix.
|
||
|
! ilaggr(i)=j means that node i in the adjacency graph
|
||
|
! of the fine-level matrix is mapped onto node j in the
|
||
8 years ago
|
! adjacency graph of the coarse-level matrix. Note that the indices
|
||
|
! are assumed to be shifted so as to make sure the ranges on
|
||
|
! the various processes do not overlap.
|
||
|
! nlaggr - integer, dimension(:) input
|
||
16 years ago
|
! nlaggr(i) contains the aggregates held by process i.
|
||
8 years ago
|
! op_prol - type(psb_sspmat_type), input/output
|
||
|
! The tentative prolongator on input, the computed prolongator on output
|
||
|
!
|
||
|
! op_restr - type(psb_sspmat_type), output
|
||
|
! The restrictor operator; normally, it is the transpose of the prolongator.
|
||
|
!
|
||
17 years ago
|
! info - integer, output.
|
||
|
! Error code.
|
||
|
!
|
||
8 years ago
|
!
|
||
13 years ago
|
subroutine mld_saggrmat_nosmth_asb(a,desc_a,ilaggr,nlaggr,parms,ac,op_prol,op_restr,info)
|
||
14 years ago
|
use psb_base_mod
|
||
8 years ago
|
use mld_base_prec_type
|
||
14 years ago
|
use mld_s_inner_mod, mld_protect_name => mld_saggrmat_nosmth_asb
|
||
17 years ago
|
|
||
|
implicit none
|
||
|
|
||
13 years ago
|
! Arguments
|
||
12 years ago
|
type(psb_sspmat_type), intent(in) :: a
|
||
13 years ago
|
type(psb_desc_type), intent(in) :: desc_a
|
||
12 years ago
|
integer(psb_ipk_), intent(inout) :: ilaggr(:), nlaggr(:)
|
||
|
type(mld_sml_parms), intent(inout) :: parms
|
||
8 years ago
|
type(psb_sspmat_type), intent(inout) :: op_prol
|
||
|
type(psb_sspmat_type), intent(out) :: ac,op_restr
|
||
12 years ago
|
integer(psb_ipk_), intent(out) :: info
|
||
17 years ago
|
|
||
14 years ago
|
! Local variables
|
||
12 years ago
|
integer(psb_ipk_) :: err_act
|
||
12 years ago
|
integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo
|
||
12 years ago
|
character(len=20) :: name
|
||
|
integer(psb_ipk_) :: ierr(5)
|
||
7 years ago
|
type(psb_s_coo_sparse_mat) :: ac_coo, tmpcoo
|
||
13 years ago
|
type(psb_s_csr_sparse_mat) :: acsr1, acsr2
|
||
12 years ago
|
integer(psb_ipk_) :: debug_level, debug_unit
|
||
|
integer(psb_ipk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, &
|
||
7 years ago
|
& naggr, nzt, naggrm1, naggrp1, i, k
|
||
17 years ago
|
|
||
16 years ago
|
name='mld_aggrmat_nosmth_asb'
|
||
17 years ago
|
if(psb_get_errstatus().ne.0) return
|
||
15 years ago
|
info=psb_success_
|
||
17 years ago
|
call psb_erractionsave(err_act)
|
||
|
|
||
|
|
||
14 years ago
|
ictxt = desc_a%get_context()
|
||
|
icomm = desc_a%get_mpic()
|
||
17 years ago
|
call psb_info(ictxt, me, np)
|
||
14 years ago
|
nglob = desc_a%get_global_rows()
|
||
|
nrow = desc_a%get_local_rows()
|
||
|
ncol = desc_a%get_local_cols()
|
||
17 years ago
|
|
||
|
|
||
7 years ago
|
naggr = nlaggr(me+1)
|
||
|
ntaggr = sum(nlaggr)
|
||
|
naggrm1 = sum(nlaggr(1:me))
|
||
|
naggrp1 = sum(nlaggr(1:me+1))
|
||
17 years ago
|
|
||
7 years ago
|
|
||
|
call op_prol%cp_to(tmpcoo)
|
||
13 years ago
|
call op_prol%cscnv(info,type='csr',dupl=psb_dupl_add_)
|
||
8 years ago
|
|
||
7 years ago
|
call tmpcoo%transp()
|
||
|
nzl = tmpcoo%get_nzeros()
|
||
|
i=0
|
||
|
!
|
||
|
! Now we have to fix this. The only rows of tmpcoo/op_restr that are correct
|
||
|
! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:)
|
||
|
!
|
||
|
do k=1, nzl
|
||
|
if ((naggrm1 < tmpcoo%ia(k)) .and.(tmpcoo%ia(k) <= naggrp1)) then
|
||
|
i = i+1
|
||
|
tmpcoo%val(i) = tmpcoo%val(k)
|
||
|
tmpcoo%ia(i) = tmpcoo%ia(k)
|
||
|
tmpcoo%ja(i) = tmpcoo%ja(k)
|
||
|
end if
|
||
|
end do
|
||
|
call tmpcoo%set_nzeros(i)
|
||
|
! call tmpcoo%trim()
|
||
|
call op_restr%mv_from(tmpcoo)
|
||
|
call op_restr%cscnv(info,type='csr',dupl=psb_dupl_add_)
|
||
|
|
||
|
if (info /= psb_success_) goto 9999
|
||
|
|
||
11 years ago
|
call a%cp_to(ac_coo)
|
||
14 years ago
|
|
||
13 years ago
|
nzt = ac_coo%get_nzeros()
|
||
11 years ago
|
k = 0
|
||
17 years ago
|
do i=1, nzt
|
||
9 years ago
|
k = k + 1
|
||
|
ac_coo%ia(k) = ilaggr(ac_coo%ia(i))
|
||
|
ac_coo%ja(k) = ilaggr(ac_coo%ja(i))
|
||
|
ac_coo%val(k) = ac_coo%val(i)
|
||
17 years ago
|
enddo
|
||
13 years ago
|
call ac_coo%set_nrows(naggr)
|
||
|
call ac_coo%set_ncols(naggr)
|
||
11 years ago
|
call ac_coo%set_nzeros(k)
|
||
13 years ago
|
call ac_coo%set_dupl(psb_dupl_add_)
|
||
|
call ac_coo%fix(info)
|
||
|
call ac%mv_from(ac_coo)
|
||
17 years ago
|
|
||
|
|
||
|
call psb_erractionrestore(err_act)
|
||
|
return
|
||
|
|
||
10 years ago
|
9999 call psb_error_handler(err_act)
|
||
|
|
||
17 years ago
|
return
|
||
|
|
||
16 years ago
|
end subroutine mld_saggrmat_nosmth_asb
|