Changeset ea465d3
- Timestamp:
- 03/05/11 13:02:43 (2 years ago)
- Branches:
- master, external
- Children:
- e083829
- Parents:
- 04ac0a4
- git-author:
- Oleg Batrashev <ogbash@…> (03/05/11 13:02:43)
- git-committer:
- Oleg Batrashev <ogbash@…> (03/05/11 13:02:43)
- Location:
- src
- Files:
-
- 7 edited
-
coarse/CoarseAllgathers.F90 (modified) (2 diffs)
-
components/Preconditioner_base.F90 (modified) (2 diffs)
-
datatypes/Aggregate_utils.f95 (modified) (1 diff)
-
datatypes/SpMtx/SpMtx_aggregation.F90 (modified) (3 diffs)
-
main/aggr.F90 (modified) (6 diffs)
-
main/geom.F90 (modified) (6 diffs)
-
solvers/pcg.F90 (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/coarse/CoarseAllgathers.F90
r04c1a47 rea465d3 75 75 76 76 type(SendData) :: send !< Auxilliary struct for sending data 77 end type 78 79 type(CoarseData), save :: cdat !<coarse data -- includes overlap 80 type(CoarseData), save :: cdat_vec !<coarse data -- w/o overlap, for vector 81 ! collects 77 end type CoarseData 78 82 79 contains 83 80 subroutine CoarseData_Copy(cdata, cdata2) … … 512 509 end subroutine CleanCoarse 513 510 514 subroutine setup_aggr_cdat( nagrs,n,aggrnum,M)511 subroutine setup_aggr_cdat(cdat, cdat_vec, nagrs,n,aggrnum,M) 515 512 use globals 516 513 !use CoarseAllgathers 517 514 use Mesh_class 518 515 use SpMtx_operation 519 Implicit None 516 implicit none 517 518 type(CoarseData),intent(out) :: cdat 519 type(CoarseData),intent(out) :: cdat_vec 520 520 521 integer :: nagrs ! number of aggregates (may increase here) 521 522 integer, intent(in) :: n ! number of unknowns -
src/components/Preconditioner_base.F90
r364f2eb rea465d3 25 25 use Distribution_mod 26 26 use Partitioning_mod 27 use CoarseAllgathers 27 28 use globals 28 29 29 30 implicit none 31 32 ! -------- Fine preconditioner 30 33 31 34 !> Data for the complete 1-level preconditioner … … 43 46 type(FinePreconditioner_complete),pointer :: complete 44 47 end type FinePreconditioner 48 49 ! -------- Coarse preconditioner 50 51 !> Base type for fine level preconditioner. 52 type CoarsePreconditioner 53 type(CoarseData) :: cdat !<coarse data -- includes overlap 54 type(CoarseData) :: cdat_vec !<coarse data -- w/o overlap, for vector collects 55 56 ! implementations 57 !type(CoarsePreconditioner_smooth),pointer :: smooth 58 end type CoarsePreconditioner 45 59 46 60 contains -
src/datatypes/Aggregate_utils.f95
r63312db rea465d3 112 112 locs, sizes, disps, MPI_INTEGER, & 113 113 0, MPI_COMM_WORLD, ierr) 114 call MPI_Gatherv(cdat %lg_cfmap(fAggr%inner%num), size(fAggr%inner%num), MPI_INTEGER, &114 call MPI_Gatherv(cdata%lg_cfmap(fAggr%inner%num), size(fAggr%inner%num), MPI_INTEGER, & 115 115 nodes, sizes, disps, MPI_INTEGER, & 116 116 0, MPI_COMM_WORLD, ierr) -
src/datatypes/SpMtx/SpMtx_aggregation.F90
rbac5f50 rea465d3 367 367 full_nagrs_new=max(0, maxval(fullaggrnum)) 368 368 call Form_Aggr(aggr%inner,nagrs,n,neighood,nisolated,aggrnum) 369 ! communicate the neighbours' aggregate numbers and renumber:370 if (numprocs>1) then371 call setup_aggr_cdat(nagrs,n,aggrnum,M)372 endif373 369 elseif (toosmall) then ! }{ 374 370 ! build the aggregate reference structure … … 585 581 nisolated=n-naggregatednodes, & 586 582 aggrnum=aggrnum) 587 if (numprocs>1) then588 call setup_aggr_cdat(nagrs_new,n,aggrnum,M)589 endif590 583 deallocate(connweightsums) ! weight sums to each colour! 591 584 deallocate(colsaround) ! lists the colors … … 606 599 deallocate(aggrnum) 607 600 608 if (plot==1.or.plot==3) then609 if (numprocs>1) then610 if (ismaster()) then611 allocate(aggrnum(M%ngf))612 allocate(owner(M%ngf))613 end if614 call Integer_Vect_Gather(aggr%inner%num,aggrnum,M,owner)615 if (ismaster()) then616 call color_print_aggrs(M%ngf,aggrnum,overwrite=.false.,owner=owner)617 deallocate(owner,aggrnum)618 endif619 else620 if (.not.present(aggr_fine)) then621 if (plot==3) then622 call color_print_aggrs(A%nrows,aggr%inner%num,overwrite=.true.)623 else624 write(stream,*)' fine aggregates:'625 call color_print_aggrs(A%nrows,aggr%inner%num)626 if (.not.aggrarefull) then627 write(stream,*)' FULL fine aggregates:'628 call color_print_aggrs(A%nrows,aggr%full%num)629 endif630 endif631 else632 if (plot==3) then633 call color_print_aggrs(size(aggr_fine%full%nodes),aggr_fine%full%num,aggr%inner%num,overwrite=.true.)634 else635 write(stream,*)' coarse aggregates:'636 call color_print_aggrs(size(aggr_fine%full%nodes),aggr_fine%inner%num,aggr%inner%num)637 if (.not.aggrarefull) then638 write(stream,*)' FULL coarse aggregates:'639 call color_print_aggrs(size(aggr_fine%full%nodes),aggr_fine%full%num,aggr%full%num)640 endif641 endif642 endif643 endif644 endif645 if (plot==3) then646 deallocate(moviecols)647 endif601 ! if (plot==1.or.plot==3) then 602 ! if (numprocs>1) then 603 ! if (ismaster()) then 604 ! allocate(aggrnum(M%ngf)) 605 ! allocate(owner(M%ngf)) 606 ! end if 607 ! call Integer_Vect_Gather(aggr%inner%num,aggrnum,M,owner) 608 ! if (ismaster()) then 609 ! call color_print_aggrs(M%ngf,aggrnum,overwrite=.false.,owner=owner) 610 ! deallocate(owner,aggrnum) 611 ! endif 612 ! else 613 ! if (.not.present(aggr_fine)) then 614 ! if (plot==3) then 615 ! call color_print_aggrs(A%nrows,aggr%inner%num,overwrite=.true.) 616 ! else 617 ! write(stream,*)' fine aggregates:' 618 ! call color_print_aggrs(A%nrows,aggr%inner%num) 619 ! if (.not.aggrarefull) then 620 ! write(stream,*)' FULL fine aggregates:' 621 ! call color_print_aggrs(A%nrows,aggr%full%num) 622 ! endif 623 ! endif 624 ! else 625 ! if (plot==3) then 626 ! call color_print_aggrs(size(aggr_fine%full%nodes),aggr_fine%full%num,aggr%inner%num,overwrite=.true.) 627 ! else 628 ! write(stream,*)' coarse aggregates:' 629 ! call color_print_aggrs(size(aggr_fine%full%nodes),aggr_fine%inner%num,aggr%inner%num) 630 ! if (.not.aggrarefull) then 631 ! write(stream,*)' FULL coarse aggregates:' 632 ! call color_print_aggrs(size(aggr_fine%full%nodes),aggr_fine%full%num,aggr%full%num) 633 ! endif 634 ! endif 635 ! endif 636 ! endif 637 ! endif 638 ! if (plot==3) then 639 ! deallocate(moviecols) 640 ! endif 648 641 end subroutine SpMtx_aggregate 649 642 -
src/main/aggr.F90
r364f2eb rea465d3 119 119 type(Partitionings) :: P !< fine and coarse aggregates 120 120 type(FinePreconditioner) :: FP 121 type(CoarsePreconditioner) :: CP 121 122 type(RobustPreconditionMtx) :: C 122 123 type(CoarseSpace) :: CS 124 integer,pointer :: aggrnum(:) 125 integer :: nagr 123 126 ! Parallel coarse level 124 !type(CoarseData) :: cdat -- moved into the module itself...127 !type(CoarseData) :: CP%cdat -- 125 128 126 129 ! Init DOUG … … 156 159 ! Testing coarse matrix and aggregation through it: 157 160 if (numprocs>1) then 161 allocate(aggrnum(D%mesh%nlf)) 162 nagr = P%fAggr%inner%nagr 163 aggrnum = 0 164 aggrnum(1:D%mesh%ninner) = P%fAggr%inner%num 165 call setup_aggr_cdat(CP%cdat, CP%cdat_vec, nagr, D%mesh%ninner,aggrnum,D%mesh) 158 166 159 167 call SpMtx_find_strong(A=D%A,alpha=P%strong_conn1,A_ghost=D%A_ghost) … … 164 172 call IntRestBuild(D%A,P%fAggr%inner,Restrict,D%A_ghost) 165 173 CS = CoarseSpace_Init(Restrict) 166 call CoarseData_Copy( cdat,cdat_vec)167 call CoarseSpace_Expand(CS,Restrict,D%mesh, cdat)168 call CoarseMtxBuild(D%A, cdat%LAC,Restrict,D%mesh%ninner,D%A_ghost)174 call CoarseData_Copy(CP%cdat,CP%cdat_vec) 175 call CoarseSpace_Expand(CS,Restrict,D%mesh,CP%cdat) 176 call CoarseMtxBuild(D%A,CP%cdat%LAC,Restrict,D%mesh%ninner,D%A_ghost) 169 177 call KeepGivenRowIndeces(Restrict, (/(i,i=1,P%fAggr%inner%nagr)/)) 170 178 171 if (sctls%verbose>3.and. cdat%LAC%nnz<400) then179 if (sctls%verbose>3.and.CP%cdat%LAC%nnz<400) then 172 180 write(stream,*)'Restrict (local) is:==================' 173 181 call SpMtx_printRaw(A=Restrict) 174 182 write(stream,*)'A coarse (local) is:==================' 175 call SpMtx_printRaw(A= cdat%LAC)183 call SpMtx_printRaw(A=CP%cdat%LAC) 176 184 endif 177 185 … … 255 263 call FinePreconditioner_InitFull(FP, D, ol) 256 264 call FinePreconditioner_complete_Init(FP) 257 ! call Aggrs_writeFile(M, P%fAggr, cdat, "aggregates.txt")265 ! call Aggrs_writeFile(M, P%fAggr, CP%cdat, "aggregates.txt") 258 266 if (sctls%levels>1) call AggrInfo_Destroy(P%fAggr) 259 267 end if … … 277 285 if (sctls%levels==2) then 278 286 write(stream,*)'calling pcg_weigs with coarse matrix' 279 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP, it=it,cond_num=cond_num, &287 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP,coarsePrec=CP,it=it,cond_num=cond_num, & 280 288 A_interf_=D%A_ghost, & 281 289 CoarseMtx_=AC,Restrict=Restrict, & … … 283 291 else 284 292 write(stream,*)'calling pcg_weigs' 285 call pcg_weigs(D%A, D%rhs, xl, D%mesh,FP, it,cond_num, &293 call pcg_weigs(D%A, D%rhs, xl, D%mesh,FP,CP,it,cond_num, & 286 294 A_interf_=D%A_ghost, refactor_=.true.) 287 295 endif -
src/main/geom.F90
r364f2eb rea465d3 77 77 type(Distribution) :: D !< mesh and matrix distribution 78 78 type(FinePreconditioner) :: FP !< fine preconditioner 79 type(CoarsePreconditioner) :: CP !< coarse level preconditioner 79 80 80 81 ! Aggregation … … 84 85 integer, pointer :: glg_cfmap(:) 85 86 integer, allocatable :: cdisps(:),sends(:) 86 !type(CoarseData) :: cdat -- is defined now inside the module...87 87 88 88 !DEBUG … … 165 165 166 166 if (sctls%verbose>0) write (stream,*) "Building coarse matrix" 167 call CoarseMtxBuild(D%A, cdat%LAC,Restrict,D%mesh%ninner)167 call CoarseMtxBuild(D%A,CP%cdat%LAC,Restrict,D%mesh%ninner) 168 168 169 169 if (sctls%verbose>1) write (stream, *) "Stripping the restriction matrix" … … 172 172 if (sctls%verbose>0) write (stream,*) "Transmitting local-to-global maps" 173 173 174 allocate( cdat%cdisps(D%mesh%nparts+1))175 cdat%send=SendData_New(D%mesh%nparts)176 cdat%lg_cfmap=>LC%lg_fmap177 cdat%gl_cfmap=>LC%gl_fmap178 cdat%nprocs=D%mesh%nparts179 cdat%ngfc=LC%ngfc180 cdat%nlfc=LC%nlfc181 cdat%active=.true.174 allocate(CP%cdat%cdisps(D%mesh%nparts+1)) 175 CP%cdat%send=SendData_New(D%mesh%nparts) 176 CP%cdat%lg_cfmap=>LC%lg_fmap 177 CP%cdat%gl_cfmap=>LC%gl_fmap 178 CP%cdat%nprocs=D%mesh%nparts 179 CP%cdat%ngfc=LC%ngfc 180 CP%cdat%nlfc=LC%nlfc 181 CP%cdat%active=.true. 182 182 183 183 call AllSendCoarselgmap(LC%lg_fmap,LC%nlfc,D%mesh%nparts,& 184 cdat%cdisps,cdat%glg_cfmap,cdat%send)185 call AllRecvCoarselgmap( cdat%send)184 CP%cdat%cdisps,CP%cdat%glg_cfmap,CP%cdat%send) 185 call AllRecvCoarselgmap(CP%cdat%send) 186 186 187 187 if(pstream/=0) write(pstream, "(I0,':coarse time:',F0.3)") myrank, MPI_WTIME()-t1 … … 207 207 if (sctls%input_type==DCTL_INPUT_TYPE_ELEMENTAL .and. & 208 208 sctls%levels==2) then 209 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP, it=it,cond_num=cond_num, &209 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP,coarsePrec=CP,it=it,cond_num=cond_num, & 210 210 A_interf_=D%A_ghost,CoarseMtx_=AC,Restrict=Restrict, & 211 211 refactor_=.true.) 212 ! refactor_=.true., cdat_= cdat)212 ! refactor_=.true., cdat_=CP%cdat) 213 213 else 214 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP, it=it,cond_num=cond_num, &214 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP,coarsePrec=CP,it=it,cond_num=cond_num, & 215 215 A_interf_=D%A_ghost,refactor_=.true.) 216 216 endif … … 277 277 call SpMtx_Destroy(Restrict) 278 278 ! call SpMtx_Destroy(Res_aux) 279 call SendData_Destroy( cdat%send)279 call SendData_Destroy(CP%cdat%send) 280 280 281 281 call CoarseGrid_Destroy(LC) -
src/solvers/pcg.F90
r364f2eb rea465d3 51 51 contains 52 52 53 subroutine prec2Level(prepare,A, sol,rhs,res,CoarseMtx_,Restrict,isFirstIter)53 subroutine prec2Level(prepare,A,CP,sol,rhs,res,CoarseMtx_,Restrict,isFirstIter) 54 54 use CoarseAllgathers 55 55 56 56 logical, intent(in) :: prepare 57 57 type(SpMtx) :: A !< sparse system matrix 58 type(CoarsePreconditioner),intent(inout) :: CP 58 59 real(kind=rk),dimension(:),pointer :: sol !< solution 59 60 real(kind=rk),dimension(:),pointer :: rhs !< right hand side … … 90 91 endif 91 92 92 call AllSendCoarseMtx( cdat%LAC,CoarseMtx_,cdat%lg_cfmap,&93 cdat%ngfc,cdat%nprocs,cdat%send)94 call AllRecvCoarseMtx(CoarseMtx_, cdat%send,add=add) ! Recieve it93 call AllSendCoarseMtx(CP%cdat%LAC,CoarseMtx_,CP%cdat%lg_cfmap,& 94 CP%cdat%ngfc,CP%cdat%nprocs,CP%cdat%send) 95 call AllRecvCoarseMtx(CoarseMtx_,CP%cdat%send,add=add) ! Recieve it 95 96 96 97 end subroutine prec2Level_exchangeMatrix … … 98 99 subroutine prec2Level_prepare() 99 100 if (isFirstIter) then 100 if ( cdat%active) then101 if (CP%cdat%active) then 101 102 ! First iteration - send matrix 102 103 call prec2Level_exchangeMatrix() … … 116 117 endif 117 118 ! allocate memory for vector 118 if ( cdat%active) then119 allocate(clrhs( cdat%nlfc))119 if (CP%cdat%active) then 120 allocate(clrhs(CP%cdat%nlfc)) 120 121 else 121 allocate(clrhs( cdat_vec%nlfc))122 allocate(clrhs(CP%cdat_vec%nlfc)) 122 123 end if 123 124 end if … … 128 129 endif 129 130 130 if (sctls%verbose>6) write(stream,*) "Restricting into local coarse vector", size(clrhs), Restrict%nrows, Restrict%ncols, & 131 cdat%nlfc, cdat%active, cdat_vec%nlfc, cdat_vec%active 132 if (cdat%active) then 131 if (CP%cdat%active) then 132 if (sctls%verbose>6) write(stream,*) "Restricting into local coarse vector", size(clrhs) 133 133 ! Send coarse vector 134 134 call SpMtx_Ax(clrhs,Restrict,rhs,dozero=.true.) ! restrict <RA> 135 if ( cdat_vec%active) then136 call AllSendCoarseVector(clrhs, cdat_vec%nprocs,cdat_vec%cdisps,&137 cdat_vec%send,useprev=.not.isFirstIter)135 if (CP%cdat_vec%active) then 136 call AllSendCoarseVector(clrhs,CP%cdat_vec%nprocs,CP%cdat_vec%cdisps,& 137 CP%cdat_vec%send,useprev=.not.isFirstIter) 138 138 else 139 call AllSendCoarseVector(clrhs, cdat%nprocs,cdat%cdisps,&140 cdat%send,useprev=.not.isFirstIter)139 call AllSendCoarseVector(clrhs,CP%cdat%nprocs,CP%cdat%cdisps,& 140 CP%cdat%send,useprev=.not.isFirstIter) 141 141 endif 142 end if ! cdat%active142 end if ! CP%cdat%active 143 143 end subroutine prec2Level_prepare 144 144 145 145 subroutine prec2Level_solve() 146 if (.not. cdat%active) then ! 1 processor case146 if (.not.CP%cdat%active) then ! 1 processor case 147 147 if (sctls%method>1.and.sctls%method/=5) then ! multiplicative Schwarz 148 148 call SpMtx_Ax(crhs,Restrict,res,dozero=.true.) ! restriction … … 153 153 154 154 !csol=0.0_rk 155 if ( cdat%active) then155 if (CP%cdat%active) then 156 156 ! Recieve the vector for solve 157 if ( cdat_vec%active) then158 call AllRecvCoarseVector(crhs, cdat_vec%nprocs,&159 cdat_vec%cdisps,cdat_vec%glg_cfmap,cdat_vec%send)157 if (CP%cdat_vec%active) then 158 call AllRecvCoarseVector(crhs,CP%cdat_vec%nprocs,& 159 CP%cdat_vec%cdisps,CP%cdat_vec%glg_cfmap,CP%cdat_vec%send) 160 160 else 161 call AllRecvCoarseVector(crhs, cdat%nprocs,&162 cdat%cdisps,cdat%glg_cfmap,cdat%send)161 call AllRecvCoarseVector(crhs,CP%cdat%nprocs,& 162 CP%cdat%cdisps,CP%cdat%glg_cfmap,CP%cdat%send) 163 163 endif 164 164 !call MPI_BARRIER(MPI_COMM_WORLD,i) … … 184 184 end if 185 185 186 if ( cdat_vec%active) then187 call Vect_remap(csol,clrhs, cdat%gl_cfmap,dozero=.true.)186 if (CP%cdat_vec%active) then 187 call Vect_remap(csol,clrhs,CP%cdat%gl_cfmap,dozero=.true.) 188 188 call SpMtx_Ax(tmpsol,Restrict,clrhs,dozero=.true.,transp=.true.) 189 189 190 elseif ( cdat%active) then191 call Vect_remap(csol,clrhs, cdat%gl_cfmap,dozero=.true.)190 elseif (CP%cdat%active) then 191 call Vect_remap(csol,clrhs,CP%cdat%gl_cfmap,dozero=.true.) 192 192 call SpMtx_Ax(tmpsol,Restrict,clrhs,dozero=.true.,transp=.true.) 193 193 else … … 220 220 !> Make preconditioner 221 221 !------------------------------- 222 subroutine preconditioner(sol,A,rhs,M,finePrec, &222 subroutine preconditioner(sol,A,rhs,M,finePrec,coarsePrec,& 223 223 A_ghost,CoarseMtx_,Restrict,refactor,bugtrack_) 224 224 use CoarseAllgathers … … 231 231 type(Mesh),intent(in) :: M !< Mesh 232 232 type(FinePreconditioner),intent(inout) :: finePrec !< fine level preconditioner 233 type(CoarsePreconditioner),intent(inout) :: coarsePrec !< coarse level preconditioner 233 234 real(kind=rk),dimension(:),pointer :: res !< residual vector, allocated 234 235 !! here for multiplicative Schwarz … … 267 268 268 269 if (sctls%levels>1) then 269 call prec2Level(.true.,A, sol,rhs,res,CoarseMtx_,Restrict,isFirstIter)270 call prec2Level(.true.,A,coarsePrec,sol,rhs,res,CoarseMtx_,Restrict,isFirstIter) 270 271 end if 271 272 … … 274 275 275 276 if (sctls%levels>1) then 276 call prec2Level(.false.,A, sol,rhs,res,CoarseMtx_,Restrict,isFirstIter)277 call prec2Level(.false.,A,coarsePrec,sol,rhs,res,CoarseMtx_,Restrict,isFirstIter) 277 278 end if 278 279 … … 298 299 !> Preconditioned conjugent gradient method with eigenvalues 299 300 !-------------------------- 300 subroutine pcg_weigs (A,b,x,Msh,finePrec, it,cond_num,A_interf_,tol_,maxit_, &301 subroutine pcg_weigs (A,b,x,Msh,finePrec,coarsePrec,it,cond_num,A_interf_,tol_,maxit_, & 301 302 x0_,solinf,resvects_,CoarseMtx_,Restrict,refactor_) 302 303 use CoarseAllgathers … … 309 310 type(Mesh),intent(in) :: Msh !< Mesh - aux data for Ax operation 310 311 type(FinePreconditioner),intent(inout) :: finePrec !< fine level preconditioner 312 type(CoarsePreconditioner),intent(inout) :: coarsePrec !< coarse level preconditioner 311 313 312 314 integer,intent(out) :: it … … 425 427 M=Msh, & 426 428 finePrec=finePrec, & 429 coarsePrec=coarsePrec, & 427 430 A_ghost=A_interf_, & 428 431 CoarseMtx_=CoarseMtx_, &
Note: See TracChangeset
for help on using the changeset viewer.
