Changeset e083829
- Timestamp:
- 03/05/11 13:48:20 (2 years ago)
- Branches:
- master, external
- Children:
- e8c8f58
- Parents:
- ea465d3
- git-author:
- Oleg Batrashev <ogbash@…> (03/05/11 13:48:20)
- git-committer:
- Oleg Batrashev <ogbash@…> (03/05/11 13:48:20)
- Location:
- src
- Files:
-
- 4 edited
-
components/Preconditioner_base.F90 (modified) (2 diffs)
-
main/aggr.F90 (modified) (9 diffs)
-
main/geom.F90 (modified) (5 diffs)
-
solvers/pcg.F90 (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/components/Preconditioner_base.F90
rea465d3 re083829 48 48 49 49 ! -------- Coarse preconditioner 50 integer,parameter :: COARSE_PRECONDITIONER_TYPE_NONE=0, & 51 COARSE_PRECONDITIONER_TYPE_SMOOTH=1, & 52 COARSE_PRECONDITIONER_TYPE_GEOMETRIC=2, & 53 COARSE_PRECONDITIONER_TYPE_ROBUST=3 50 54 51 55 !> Base type for fine level preconditioner. 52 56 type CoarsePreconditioner 57 integer :: type !< coarse preconditioner type 53 58 type(CoarseData) :: cdat !<coarse data -- includes overlap 54 59 type(CoarseData) :: cdat_vec !<coarse data -- w/o overlap, for vector collects 60 type(SpMtx) :: R !< Restriction matrix 61 type(SpMtx) :: AC !< Coarse matrix 55 62 56 63 ! implementations … … 91 98 end subroutine FinePreconditioner_InitAggrs 92 99 100 function CoarsePreconditioner_New() result (CP) 101 type(CoarsePreconditioner) :: CP 102 103 CP%type = COARSE_PRECONDITIONER_TYPE_NONE 104 105 end function CoarsePreconditioner_New 106 93 107 end module Preconditioner_base_mod -
src/main/aggr.F90
rea465d3 re083829 92 92 #endif 93 93 94 type(SpMtx) :: AC !< coarse matrix95 type(SpMtx) :: Restrict !< Restriction matrix (for operation)96 94 type(SumOfInversedSubMtx) :: B_RCS !< B matrix for the Robust Coarse Spaces 97 95 !type(SpMtx) :: Rest_cmb !< Restriction matrix (for coarse matrix build) … … 124 122 integer,pointer :: aggrnum(:) 125 123 integer :: nagr 126 ! Parallel coarse level127 !type(CoarseData) :: CP%cdat --128 124 129 125 ! Init DOUG … … 157 153 endif 158 154 155 CP = CoarsePreconditioner_New() 159 156 ! Testing coarse matrix and aggregation through it: 160 157 if (numprocs>1) then 158 CP%type = COARSE_PRECONDITIONER_TYPE_SMOOTH 161 159 allocate(aggrnum(D%mesh%nlf)) 162 160 nagr = P%fAggr%inner%nagr … … 170 168 call SpMtx_unscale(D%A) 171 169 172 call IntRestBuild(D%A,P%fAggr%inner, Restrict,D%A_ghost)173 CS = CoarseSpace_Init( Restrict)170 call IntRestBuild(D%A,P%fAggr%inner,CP%R,D%A_ghost) 171 CS = CoarseSpace_Init(CP%R) 174 172 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)177 call KeepGivenRowIndeces( Restrict, (/(i,i=1,P%fAggr%inner%nagr)/))173 call CoarseSpace_Expand(CS,CP%R,D%mesh,CP%cdat) 174 call CoarseMtxBuild(D%A,CP%cdat%LAC,CP%R,D%mesh%ninner,D%A_ghost) 175 call KeepGivenRowIndeces(CP%R, (/(i,i=1,P%fAggr%inner%nagr)/)) 178 176 179 177 if (sctls%verbose>3.and.CP%cdat%LAC%nnz<400) then 180 write(stream,*)' Restrict(local) is:=================='181 call SpMtx_printRaw(A= Restrict)178 write(stream,*)'CP%R (local) is:==================' 179 call SpMtx_printRaw(A=CP%R) 182 180 write(stream,*)'A coarse (local) is:==================' 183 181 call SpMtx_printRaw(A=CP%cdat%LAC) … … 186 184 else 187 185 ! non-parallel 188 call IntRestBuild(D%A,P%fAggr%inner, Restrict)186 call IntRestBuild(D%A,P%fAggr%inner,CP%R) 189 187 190 188 if (sctls%coarse_method<=1) then ! if not specified or ==1 191 call CoarseMtxBuild(D%A,AC,Restrict,D%mesh%ninner) 189 CP%type = COARSE_PRECONDITIONER_TYPE_SMOOTH 190 call CoarseMtxBuild(D%A,CP%AC,CP%R,D%mesh%ninner) 192 191 193 192 else if (sctls%coarse_method==2) then 194 ! use the Robust Coarse Spaces algorithm 195 B_RCS = CoarseProjectionMtxsBuild(D%A,Restrict,P%fAggr%inner%nagr) 193 ! use the Robust Coarse Spaces algorithm 194 CP%type = COARSE_PRECONDITIONER_TYPE_ROBUST 195 196 B_RCS = CoarseProjectionMtxsBuild(D%A,CP%R,P%fAggr%inner%nagr) 196 197 allocate(rhs_1(D%A%nrows)) 197 198 allocate(g(D%A%ncols)) … … 204 205 end if 205 206 206 call RobustRestrictMtxBuild(B_RCS,g, Restrict)207 call CoarseMtxBuild(D%A, AC,Restrict,D%mesh%ninner)207 call RobustRestrictMtxBuild(B_RCS,g,CP%R) 208 call CoarseMtxBuild(D%A,CP%AC,CP%R,D%mesh%ninner) 208 209 209 210 else … … 212 213 endif 213 214 214 if (sctls%verbose>3.and. AC%nnz<400) then215 if (sctls%verbose>3.and.CP%AC%nnz<400) then 215 216 write(stream,*)'A coarse is:==================' 216 call SpMtx_printRaw(A= AC)217 call SpMtx_printRaw(A=CP%AC) 217 218 endif 218 219 endif … … 220 221 ! coarse aggregates 221 222 if (numprocs==1) then 222 call Partitionings_CreateCoarse(P,D, AC)223 call Partitionings_CreateCoarse(P,D,CP%AC) 223 224 !call Aggrs_readFile_coarse(P%cAggr, "aggregates.txt") 224 225 … … 283 284 ! Preconditioned conjugate gradient 284 285 t1 = MPI_WTIME() 285 if (sctls%levels==2) then 286 write(stream,*)'calling pcg_weigs with coarse matrix' 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, & 288 A_interf_=D%A_ghost, & 289 CoarseMtx_=AC,Restrict=Restrict, & 286 write(stream,*)'calling pcg_weigs' 287 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,& 288 finePrec=FP,coarsePrec=CP,& 289 it=it,cond_num=cond_num, A_interf_=D%A_ghost, & 290 290 refactor_=.true.) 291 else292 write(stream,*)'calling pcg_weigs'293 call pcg_weigs(D%A, D%rhs, xl, D%mesh,FP,CP,it,cond_num, &294 A_interf_=D%A_ghost, refactor_=.true.)295 endif296 291 t=MPI_WTIME()-t1 297 292 write(stream,*) 'time spent in pcg():',t -
src/main/geom.F90
rea465d3 re083829 56 56 #endif 57 57 58 type(SpMtx) :: AC ! Coarse matrix59 type(SpMtx) :: Restrict ! Restriction matrix60 61 58 float(kind=rk), dimension(:), pointer :: xl ! local solution vector 62 59 float(kind=rk), dimension(:), pointer :: x ! global solution on master … … 132 129 if (ismaster()) then 133 130 if (sctls%verbose>0) write (stream,*) "Building coarse grid" 134 131 CP = CoarsePreconditioner_New() 132 CP%type = COARSE_PRECONDITIONER_TYPE_GEOMETRIC 133 135 134 call CreateCoarse(D%mesh,C) 136 135 … … 159 158 160 159 if (sctls%verbose>0) write (stream,*) "Creating Restriction matrix" 161 call CreateRestrict(LC,D%mesh, Restrict)160 call CreateRestrict(LC,D%mesh,CP%R) 162 161 163 162 if (sctls%verbose>1) write (stream,*) "Cleaning Restriction matrix" 164 call CleanCoarse(LC, Restrict,D%mesh)163 call CleanCoarse(LC,CP%R,D%mesh) 165 164 166 165 if (sctls%verbose>0) write (stream,*) "Building coarse matrix" 167 call CoarseMtxBuild(D%A,CP%cdat%LAC, Restrict,D%mesh%ninner)166 call CoarseMtxBuild(D%A,CP%cdat%LAC,CP%R,D%mesh%ninner) 168 167 169 168 if (sctls%verbose>1) write (stream, *) "Stripping the restriction matrix" 170 call StripRestrict(D%mesh, Restrict)169 call StripRestrict(D%mesh,CP%R) 171 170 172 171 if (sctls%verbose>0) write (stream,*) "Transmitting local-to-global maps" … … 205 204 t1 = MPI_WTIME() 206 205 207 if (sctls%input_type==DCTL_INPUT_TYPE_ELEMENTAL .and. & 208 sctls%levels==2) then 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 A_interf_=D%A_ghost,CoarseMtx_=AC,Restrict=Restrict, & 211 refactor_=.true.) 212 ! refactor_=.true., cdat_=CP%cdat) 213 else 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 A_interf_=D%A_ghost,refactor_=.true.) 216 endif 206 call pcg_weigs(A=D%A,b=D%rhs,x=xl,Msh=D%mesh,finePrec=FP,coarsePrec=CP,it=it,cond_num=cond_num, & 207 A_interf_=D%A_ghost, & 208 refactor_=.true.) 217 209 218 210 write(stream,*) 'time spent in pcg():',MPI_WTIME()-t1 … … 274 266 275 267 if (sctls%input_type==DCTL_INPUT_TYPE_ELEMENTAL .and. sctls%levels==2) then 276 call SpMtx_Destroy( AC)277 call SpMtx_Destroy( Restrict)268 call SpMtx_Destroy(CP%AC) 269 call SpMtx_Destroy(CP%R) 278 270 ! call SpMtx_Destroy(Res_aux) 279 271 call SendData_Destroy(CP%cdat%send) -
src/solvers/pcg.F90
rea465d3 re083829 51 51 contains 52 52 53 subroutine prec2Level(prepare,A,CP,sol,rhs,res, CoarseMtx_,Restrict,isFirstIter)53 subroutine prec2Level(prepare,A,CP,sol,rhs,res,isFirstIter) 54 54 use CoarseAllgathers 55 55 … … 60 60 real(kind=rk),dimension(:),pointer :: rhs !< right hand side 61 61 real(kind=rk),dimension(:),pointer :: res !< residual vector 62 type(SpMtx) :: CoarseMtx_ !< Coarse matrix63 type(SpMtx) :: Restrict !< Restriction matrix64 62 logical :: isFirstIter 65 63 … … 91 89 endif 92 90 93 call AllSendCoarseMtx(CP%cdat%LAC,C oarseMtx_,CP%cdat%lg_cfmap,&91 call AllSendCoarseMtx(CP%cdat%LAC,CP%AC,CP%cdat%lg_cfmap,& 94 92 CP%cdat%ngfc,CP%cdat%nprocs,CP%cdat%send) 95 call AllRecvCoarseMtx(C oarseMtx_,CP%cdat%send,add=add) ! Recieve it93 call AllRecvCoarseMtx(CP%AC,CP%cdat%send,add=add) ! Recieve it 96 94 97 95 end subroutine prec2Level_exchangeMatrix … … 106 104 ! after coarse matrix is received allocate coarse vectors 107 105 if (associated(crhs)) then 108 if (size(crhs)/=C oarseMtx_%ncols) then106 if (size(crhs)/=CP%AC%ncols) then 109 107 deallocate(csol) 110 108 deallocate(crhs) 111 allocate(crhs(C oarseMtx_%ncols))112 allocate(csol(C oarseMtx_%nrows))109 allocate(crhs(CP%AC%ncols)) 110 allocate(csol(CP%AC%nrows)) 113 111 endif 114 112 else 115 allocate(crhs(C oarseMtx_%ncols))116 allocate(csol(C oarseMtx_%nrows))113 allocate(crhs(CP%AC%ncols)) 114 allocate(csol(CP%AC%nrows)) 117 115 endif 118 116 ! allocate memory for vector … … 132 130 if (sctls%verbose>6) write(stream,*) "Restricting into local coarse vector", size(clrhs) 133 131 ! Send coarse vector 134 call SpMtx_Ax(clrhs, Restrict,rhs,dozero=.true.) ! restrict <RA>132 call SpMtx_Ax(clrhs,CP%R,rhs,dozero=.true.) ! restrict <RA> 135 133 if (CP%cdat_vec%active) then 136 134 call AllSendCoarseVector(clrhs,CP%cdat_vec%nprocs,CP%cdat_vec%cdisps,& … … 146 144 if (.not.CP%cdat%active) then ! 1 processor case 147 145 if (sctls%method>1.and.sctls%method/=5) then ! multiplicative Schwarz 148 call SpMtx_Ax(crhs, Restrict,res,dozero=.true.) ! restriction146 call SpMtx_Ax(crhs,CP%R,res,dozero=.true.) ! restriction 149 147 else 150 call SpMtx_Ax(crhs, Restrict,rhs,dozero=.true.) ! restriction148 call SpMtx_Ax(crhs,CP%R,rhs,dozero=.true.) ! restriction 151 149 endif 152 150 end if … … 167 165 if (isFirstIter) then 168 166 write (stream,*) & 169 'factorising coarse matrix of size',C oarseMtx_%nrows, &170 ' and nnz:',C oarseMtx_%nnz171 C oarseMtx_%subsolve_id=0167 'factorising coarse matrix of size',CP%AC%nrows, & 168 ' and nnz:',CP%AC%nnz 169 CP%AC%subsolve_id=0 172 170 end if 173 171 174 172 ! Coarse solve 175 call sparse_singlesolve(C oarseMtx_%subsolve_id,csol,crhs,&176 nfreds=C oarseMtx_%nrows, &177 nnz=C oarseMtx_%nnz, &178 indi=C oarseMtx_%indi, &179 indj=C oarseMtx_%indj, &180 val=C oarseMtx_%val)173 call sparse_singlesolve(CP%AC%subsolve_id,csol,crhs,& 174 nfreds=CP%AC%nrows, & 175 nnz=CP%AC%nnz, & 176 indi=CP%AC%indi, & 177 indj=CP%AC%indj, & 178 val=CP%AC%val) 181 179 if (isFirstIter) then 182 C oarseMtx_%indi=CoarseMtx_%indi+1183 C oarseMtx_%indj=CoarseMtx_%indj+1180 CP%AC%indi=CP%AC%indi+1 181 CP%AC%indj=CP%AC%indj+1 184 182 end if 185 183 186 184 if (CP%cdat_vec%active) then 187 185 call Vect_remap(csol,clrhs,CP%cdat%gl_cfmap,dozero=.true.) 188 call SpMtx_Ax(tmpsol, Restrict,clrhs,dozero=.true.,transp=.true.)186 call SpMtx_Ax(tmpsol,CP%R,clrhs,dozero=.true.,transp=.true.) 189 187 190 188 elseif (CP%cdat%active) then 191 189 call Vect_remap(csol,clrhs,CP%cdat%gl_cfmap,dozero=.true.) 192 call SpMtx_Ax(tmpsol, Restrict,clrhs,dozero=.true.,transp=.true.)190 call SpMtx_Ax(tmpsol,CP%R,clrhs,dozero=.true.,transp=.true.) 193 191 else 194 call SpMtx_Ax(tmpsol, Restrict,csol,dozero=.true.,transp=.true.) ! interpolation192 call SpMtx_Ax(tmpsol,CP%R,csol,dozero=.true.,transp=.true.) ! interpolation 195 193 endif 196 194 … … 221 219 !------------------------------- 222 220 subroutine preconditioner(sol,A,rhs,M,finePrec,coarsePrec,& 223 A_ghost, CoarseMtx_,Restrict,refactor,bugtrack_)221 A_ghost,refactor,bugtrack_) 224 222 use CoarseAllgathers 225 223 use CoarseMtx_mod … … 235 233 !! here for multiplicative Schwarz 236 234 type(SpMtx),optional :: A_ghost !< matr@interf. 237 type(SpMtx),optional :: CoarseMtx_ !< Coarse matrix238 type(SpMtx),optional :: Restrict !< Restriction matrix239 235 logical,intent(inout),optional :: refactor 240 236 logical,optional :: bugtrack_ … … 268 264 269 265 if (sctls%levels>1) then 270 call prec2Level(.true.,A,coarsePrec,sol,rhs,res, CoarseMtx_,Restrict,isFirstIter)266 call prec2Level(.true.,A,coarsePrec,sol,rhs,res,isFirstIter) 271 267 end if 272 268 … … 275 271 276 272 if (sctls%levels>1) then 277 call prec2Level(.false.,A,coarsePrec,sol,rhs,res, CoarseMtx_,Restrict,isFirstIter)273 call prec2Level(.false.,A,coarsePrec,sol,rhs,res,isFirstIter) 278 274 end if 279 275 … … 300 296 !-------------------------- 301 297 subroutine pcg_weigs (A,b,x,Msh,finePrec,coarsePrec,it,cond_num,A_interf_,tol_,maxit_, & 302 x0_,solinf,resvects_, CoarseMtx_,Restrict,refactor_)298 x0_,solinf,resvects_,refactor_) 303 299 use CoarseAllgathers 304 300 … … 322 318 type(ConvInf), intent(in out), optional :: solinf !< Solution statistics 323 319 logical, intent(in), optional :: resvects_ !< Fill in the 'resvect' or not 324 type(SpMtx),optional :: CoarseMtx_ !< Coarse matrix325 type(SpMtx),optional :: Restrict !< Restriction mtx326 320 logical,intent(in),optional :: refactor_ 327 321 … … 429 423 coarsePrec=coarsePrec, & 430 424 A_ghost=A_interf_, & 431 CoarseMtx_=CoarseMtx_, &432 Restrict=Restrict, &433 425 refactor=refactor, & 434 426 bugtrack_=bugtrack)
Note: See TracChangeset
for help on using the changeset viewer.
