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.
398 lines
20 KiB
HTML
398 lines
20 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
<html >
|
|
<head><title>Examples</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)">
|
|
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)">
|
|
<!-- html,3 -->
|
|
<meta name="src" content="userhtml.tex">
|
|
<link rel="stylesheet" type="text/css" href="userhtml.css">
|
|
</head><body
|
|
>
|
|
<!--l. 114--><div class="crosslinks"><p class="noindent"><span
|
|
class="cmr-12">[</span><a
|
|
href="#tailuserhtmlsu6.html"><span
|
|
class="cmr-12">tail</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse4.html#userhtmlsu6.html" ><span
|
|
class="cmr-12">up</span></a><span
|
|
class="cmr-12">] </span></p></div>
|
|
<h4 class="subsectionHead"><span class="titlemark"><span
|
|
class="cmr-12">4.1 </span></span> <a
|
|
id="x15-140004.1"></a><span
|
|
class="cmr-12">Examples</span></h4>
|
|
<!--l. 116--><p class="noindent" ><span
|
|
class="cmr-12">The code reported in Figure</span><span
|
|
class="cmr-12"> </span><a
|
|
href="#x15-14001r1"><span
|
|
class="cmr-12">1</span><!--tex4ht:ref: fig:ex1 --></a> <span
|
|
class="cmr-12">shows how to set and apply the default multilevel</span>
|
|
<span
|
|
class="cmr-12">preconditioner available in the real double precision version of AMG4PSBLAS</span>
|
|
<span
|
|
class="cmr-12">(see Table</span><span
|
|
class="cmr-12"> </span><a
|
|
href="userhtmlse4.html#x14-13015r1"><span
|
|
class="cmr-12">1</span><!--tex4ht:ref: tab:precinit --></a><span
|
|
class="cmr-12">). This preconditioner is chosen by simply specifying </span><span class="lstinline"></span><span
|
|
class="cmtt-12">’</span><span
|
|
class="cmtt-12">ML</span><span
|
|
class="cmtt-12">’</span> <span
|
|
class="cmr-12">as the</span>
|
|
<span
|
|
class="cmr-12">second argument of </span><span class="lstinline"></span><span
|
|
class="cmtt-12">P</span><span
|
|
class="cmtt-12">%</span><span
|
|
class="cmtt-12">init</span> <span
|
|
class="cmr-12">(a call to </span><span class="lstinline"></span><span
|
|
class="cmtt-12">P</span><span
|
|
class="cmtt-12">%</span><span
|
|
class="cmtt-12">set</span> <span
|
|
class="cmr-12">is not needed) and is applied</span>
|
|
<span
|
|
class="cmr-12">with the CG solver provided by PSBLAS (the matrix of the system to be</span>
|
|
<span
|
|
class="cmr-12">solved is assumed to be positive definite). As previously observed, the modules</span>
|
|
<span class="lstinline"></span><span
|
|
class="cmtt-12">psb_base_mod</span><span
|
|
class="cmr-12">, </span><span class="lstinline"></span><span
|
|
class="cmtt-12">amg_prec_mod</span> <span
|
|
class="cmr-12">and </span><span class="lstinline"></span><span
|
|
class="cmtt-12">psb_krylov_mod</span> <span
|
|
class="cmr-12">must be used by the example</span>
|
|
<span
|
|
class="cmr-12">program.</span>
|
|
<!--l. 126--><p class="indent" > <span
|
|
class="cmr-12">The part of the code dealing with reading and assembling the sparse matrix and the</span>
|
|
<span
|
|
class="cmr-12">right-hand side vector and the deallocation of the relevant data structures, performed</span>
|
|
<span
|
|
class="cmr-12">through the PSBLAS routines for sparse matrix and vector management, is not</span>
|
|
<span
|
|
class="cmr-12">reported here for the sake of conciseness. The complete code can be found in the</span>
|
|
<span
|
|
class="cmr-12">example program file </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">amg_dexample_ml.f90</span></span></span><span
|
|
class="cmr-12">, in the directory </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">examples/fileread</span></span></span> <span
|
|
class="cmr-12">of</span>
|
|
<span
|
|
class="cmr-12">the AMG4PSBLAS implementation (see Section</span><span
|
|
class="cmr-12"> </span><a
|
|
href="userhtmlsu5.html#x13-120003.5"><span
|
|
class="cmr-12">3.5</span><!--tex4ht:ref: sec:ex_and_test --></a><span
|
|
class="cmr-12">). A sample test problem along</span>
|
|
<span
|
|
class="cmr-12">with the relevant input data is available in </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">examples/fileread/runs</span></span></span><span
|
|
class="cmr-12">. For details on</span>
|
|
<span
|
|
class="cmr-12">the use of the PSBLAS routines, see the PSBLAS User’s Guide</span><span
|
|
class="cmr-12"> </span><span class="cite"><span
|
|
class="cmr-12">[</span><a
|
|
href="userhtmlli5.html#XPSBLASGUIDE"><span
|
|
class="cmr-12">18</span></a><span
|
|
class="cmr-12">]</span></span><span
|
|
class="cmr-12">.</span>
|
|
<!--l. 138--><p class="indent" > <span
|
|
class="cmr-12">The setup and application of the default multilevel preconditioner for the real single</span>
|
|
<span
|
|
class="cmr-12">precision and the complex, single and double precision, versions are obtained</span>
|
|
|
|
|
|
|
|
<span
|
|
class="cmr-12">with straightforward modifications of the previous example (see Section</span><span
|
|
class="cmr-12"> </span><a
|
|
href="userhtmlse5.html#x16-150005"><span
|
|
class="cmr-12">5</span><!--tex4ht:ref: sec:userinterface --></a> <span
|
|
class="cmr-12">for</span>
|
|
<span
|
|
class="cmr-12">details). If these versions are installed, the corresponding codes are available in</span>
|
|
<span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">examples/fileread/</span></span></span><span
|
|
class="cmr-12">.</span>
|
|
|
|
|
|
|
|
<!--l. 144--><p class="indent" > <a
|
|
id="x15-14001r1"></a><hr class="float"><div class="float"
|
|
>
|
|
|
|
|
|
|
|
<div class="center"
|
|
>
|
|
<!--l. 145--><p class="noindent" >
|
|
|
|
|
|
|
|
<div class="minipage"><div class="verbatim" id="verbatim-6">
|
|
  use psb_base_mod
|
|
 <br />  use amg_prec_mod
|
|
 <br />  use psb_krylov_mod
|
|
 <br />... ...
|
|
 <br />!
|
|
 <br />! sparse matrix
|
|
 <br />  type(psb_dspmat_type) :: A
|
|
 <br />! sparse matrix descriptor
|
|
 <br />  type(psb_desc_type)   :: desc_A
|
|
 <br />! preconditioner
|
|
 <br />  type(amg_dprec_type)  :: P
|
|
 <br />! right-hand side and solution vectors
|
|
 <br />  type(psb_d_vect_type) :: b, x
|
|
 <br />... ...
|
|
 <br />!
|
|
 <br />! initialize the parallel environment
|
|
 <br />  call psb_init(ctxt)
|
|
 <br />  call psb_info(ctxt,iam,np)
|
|
 <br />... ...
|
|
 <br />!
|
|
 <br />! read and assemble the spd matrix A and the right-hand side b
|
|
 <br />! using PSBLAS routines for sparse matrix / vector management
|
|
 <br />... ...
|
|
 <br />!
|
|
 <br />! initialize the default multilevel preconditioner, i.e. V-cycle
|
|
 <br />! with basic smoothed aggregation, 1 hybrid forward/backward
|
|
 <br />! GS sweep as pre/post-smoother and UMFPACK as coarsest-level
|
|
 <br />! solver
|
|
 <br />  call P%init(’ML’,info)
|
|
 <br />!
|
|
 <br />! build the preconditioner
|
|
 <br />  call P%hierarchy_build(A,desc_A,info)
|
|
 <br />  call P%smoothers_build(A,desc_A,info)
|
|
 <br />
|
|
 <br />!
|
|
 <br />! set the solver parameters and the initial guess
|
|
 <br />  ... ...
|
|
 <br />!
|
|
 <br />! solve Ax=b with preconditioned CG
|
|
 <br />  call psb_krylov(’CG’,A,P,b,x,tol,desc_A,info)
|
|
 <br />  ... ...
|
|
 <br />!
|
|
 <br />! deallocate the preconditioner
|
|
 <br />  call P%free(info)
|
|
 <br />!
|
|
 <br />! deallocate other data structures
|
|
 <br />  ... ...
|
|
 <br />!
|
|
 <br />! exit the parallel environment
|
|
 <br />  call psb_exit(ctxt)
|
|
 <br />  stop
|
|
</div>
|
|
<!--l. 255--><p class="nopar" >
|
|
|
|
|
|
</div>
|
|
<br /> <div class="caption"
|
|
><span class="id">Listing 1: </span><span
|
|
class="content">setup and application of the default multilevel preconditioner (example 1).
|
|
</span></div><!--tex4ht:label?: x15-14001r1 -->
|
|
</div>
|
|
|
|
|
|
|
|
</div><hr class="endfloat" />
|
|
<!--l. 264--><p class="indent" > <span
|
|
class="cmr-12">Different versions of the multilevel preconditioner can be obtained by changing the</span>
|
|
<span
|
|
class="cmr-12">default values of the preconditioner parameters. The code reported in Figure</span><span
|
|
class="cmr-12"> </span><a
|
|
href="#x15-14002r2"><span
|
|
class="cmr-12">2</span><!--tex4ht:ref: fig:ex2 --></a> <span
|
|
class="cmr-12">shows</span>
|
|
<span
|
|
class="cmr-12">how to set a V-cycle preconditioner which applies 1 block-Jacobi sweep as pre-</span>
|
|
<span
|
|
class="cmr-12">and post-smoother, and solves the coarsest-level system with 8 block-Jacobi</span>
|
|
<span
|
|
class="cmr-12">sweeps. Note that the ILU(0) factorization (plus triangular solve) is used as</span>
|
|
<span
|
|
class="cmr-12">local solver for the block-Jacobi sweeps, since this is the default associated</span>
|
|
<span
|
|
class="cmr-12">with block-Jacobi and set by</span><span
|
|
class="cmr-12"> </span><span class="lstinline"></span><span
|
|
class="cmtt-12">P</span><span
|
|
class="cmtt-12">%</span><span
|
|
class="cmtt-12">init</span><span
|
|
class="cmr-12">. Furthermore, specifying block-Jacobi as</span>
|
|
<span
|
|
class="cmr-12">coarsest-level solver implies that the coarsest-level matrix is distributed among</span>
|
|
<span
|
|
class="cmr-12">the processes. Figure</span><span
|
|
class="cmr-12"> </span><a
|
|
href="#x15-14003r3"><span
|
|
class="cmr-12">3</span><!--tex4ht:ref: fig:ex3 --></a> <span
|
|
class="cmr-12">shows how to set a W-cycle preconditioner using the</span>
|
|
<span
|
|
class="cmr-12">Coarsening based on Compatible Weighted Matching, aggregates of size at</span>
|
|
<span
|
|
class="cmr-12">most 8 and smoothed prolongators. It applies 2 hybrid Gauss-Seidel sweeps as</span>
|
|
<span
|
|
class="cmr-12">pre- and post-smoother, and solves the coarsest-level system with the parallel</span>
|
|
<span
|
|
class="cmr-12">flexible Conjugate Gradient method (KRM) coupled with the block-Jacobi</span>
|
|
<span
|
|
class="cmr-12">preconditioner having ILU(0) on the blocks. Default parameters are used for stopping</span>
|
|
<span
|
|
class="cmr-12">criterion of the coarsest solver. Note that, also in this case, specifying KRM as</span>
|
|
<span
|
|
class="cmr-12">coarsest-level solver implies that the coarsest-level matrix is distributed among the</span>
|
|
<span
|
|
class="cmr-12">processes.</span>
|
|
<!--l. 291--><p class="indent" > <span
|
|
class="cmr-12">The code fragments shown in Figures</span><span
|
|
class="cmr-12"> </span><a
|
|
href="#x15-14002r2"><span
|
|
class="cmr-12">2</span><!--tex4ht:ref: fig:ex2 --></a> <span
|
|
class="cmr-12">and </span><a
|
|
href="#x15-14003r3"><span
|
|
class="cmr-12">3</span><!--tex4ht:ref: fig:ex3 --></a> <span
|
|
class="cmr-12">are included in the example program</span>
|
|
<span
|
|
class="cmr-12">file </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">amg_dexample_ml.f90</span></span></span> <span
|
|
class="cmr-12">too.</span>
|
|
<!--l. 294--><p class="indent" > <span
|
|
class="cmr-12">Finally, Figure</span><span
|
|
class="cmr-12"> </span><a
|
|
href="#x15-14004r4"><span
|
|
class="cmr-12">4</span><!--tex4ht:ref: fig:ex4 --></a> <span
|
|
class="cmr-12">shows the setup of a one-level additive Schwarz preconditioner,</span>
|
|
<span
|
|
class="cmr-12">i.e., RAS with overlap 2. Note also that a Krylov method different from CG</span>
|
|
<span
|
|
class="cmr-12">must be used to solve the preconditioned system, since the preconditione in</span>
|
|
<span
|
|
class="cmr-12">nonsymmetric. The corresponding example program is available in the file</span>
|
|
<span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">amg_dexample_1lev.f90</span></span></span><span
|
|
class="cmr-12">.</span>
|
|
<!--l. 301--><p class="indent" > <span
|
|
class="cmr-12">For all the previous preconditioners, example programs where the sparse matrix</span>
|
|
<span
|
|
class="cmr-12">and the right-hand side are generated by discretizing a PDE with Dirichlet</span>
|
|
<span
|
|
class="cmr-12">boundary conditions are also available in the directory </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">examples/pdegen</span></span></span><span
|
|
class="cmr-12">.</span>
|
|
|
|
|
|
|
|
<!--l. 304--><p class="indent" > <a
|
|
id="x15-14002r2"></a><hr class="float"><div class="float"
|
|
>
|
|
|
|
|
|
|
|
<div class="center"
|
|
>
|
|
<!--l. 318--><p class="noindent" >
|
|
<div class="minipage"><div class="verbatim" id="verbatim-7">
|
|
... ...
|
|
 <br />! build a V-cycle preconditioner with 1 block-Jacobi sweep (with
|
|
 <br />! ILU(0) on the blocks) as pre- and post-smoother, and 8  block-Jacobi
|
|
 <br />! sweeps (with ILU(0) on the blocks) as coarsest-level solver
|
|
 <br />  call P%init(’ML’,info)
|
|
 <br />  call P%set(’SMOOTHER_TYPE’,’BJAC’,info)
|
|
 <br />  call P%set(’COARSE_SOLVE’,’BJAC’,info)
|
|
 <br />  call P%set(’COARSE_SWEEPS’,8,info)
|
|
 <br />  call P%hierarchy_build(A,desc_A,info)
|
|
 <br />  call P%smoothers_build(A,desc_A,info)
|
|
 <br />... ...
|
|
</div>
|
|
<!--l. 333--><p class="nopar" ></div></div>
|
|
<br /><div class="caption"
|
|
><span class="id">Listing 2: </span><span
|
|
class="content">setup of a multilevel preconditioner based on the default decoupled coarsening</span></div><!--tex4ht:label?: x15-14002r2 -->
|
|
|
|
|
|
|
|
</div><hr class="endfloat" />
|
|
|
|
|
|
|
|
<!--l. 340--><p class="indent" > <a
|
|
id="x15-14003r3"></a><hr class="float"><div class="float"
|
|
>
|
|
|
|
|
|
|
|
<div class="center"
|
|
>
|
|
<!--l. 360--><p class="noindent" >
|
|
<div class="minipage"><div class="verbatim" id="verbatim-8">
|
|
... ...
|
|
 <br />! build a W-cycle preconditioner with 2 hybrid Gauss-Seidel sweeps
|
|
 <br />! as pre- and post-smoother, a distributed coarsest
|
|
 <br />! matrix, and MUMPS as coarsest-level solver
|
|
 <br />  call P%init(’ML’,info)
|
|
 <br />  call P%set(’PAR_AGGR_ALG’,’COUPLED’,info)
|
|
 <br />call P%set(’AGGR_TYPE’,’MATCHBOXP’,info)
|
|
 <br />call P%set(’AGGR_SIZE’,8,info)
|
|
 <br />  call P%set(’ML_CYCLE’,’WCYCLE’,info)
|
|
 <br />  call P%set(’SMOOTHER_TYPE’,’FBGS’,info)
|
|
 <br />  call P%set(’SMOOTHER_SWEEPS’,2,info)
|
|
 <br />  call P%set(’COARSE_SOLVE’,’KRM’,info)
|
|
 <br />  call P%hierarchy_build(A,desc_A,info)
|
|
 <br />  call P%smoothers_build(A,desc_A,info)
|
|
 <br />... ...
|
|
</div>
|
|
<!--l. 379--><p class="nopar" ></div></div>
|
|
<br /> <div class="caption"
|
|
><span class="id">Listing 3: </span><span
|
|
class="content">setup of a multilevel preconditioner based on the coupled coarsening using
|
|
weighted matching</span></div><!--tex4ht:label?: x15-14003r3 -->
|
|
|
|
|
|
|
|
</div><hr class="endfloat" />
|
|
|
|
|
|
|
|
<!--l. 386--><p class="indent" > <a
|
|
id="x15-14004r4"></a><hr class="float"><div class="float"
|
|
>
|
|
|
|
|
|
|
|
<div class="center"
|
|
>
|
|
<!--l. 398--><p class="noindent" >
|
|
<div class="minipage"><div class="verbatim" id="verbatim-9">
|
|
... ...
|
|
 <br />! set RAS with overlap 2 and ILU(0) on the local blocks
|
|
 <br />  call P%init(’AS’,info)
|
|
 <br />  call P%set(’SUB_OVR’,2,info)
|
|
 <br />  call P%bld(A,desc_A,info)
|
|
 <br />... ...
|
|
 <br />! solve Ax=b with preconditioned BiCGSTAB
|
|
 <br />  call psb_krylov(’BICGSTAB’,A,P,b,x,tol,desc_A,info)
|
|
</div>
|
|
<!--l. 410--><p class="nopar" ></div></div>
|
|
<br /> <div class="caption"
|
|
><span class="id">Listing 4: </span><span
|
|
class="content">setup of a one-level Schwarz preconditioner.</span></div><!--tex4ht:label?: x15-14004r4 -->
|
|
|
|
|
|
|
|
</div><hr class="endfloat" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--l. 1--><div class="crosslinks"><p class="noindent"><span
|
|
class="cmr-12">[</span><a
|
|
href="userhtmlsu6.html" ><span
|
|
class="cmr-12">front</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse4.html#userhtmlsu6.html" ><span
|
|
class="cmr-12">up</span></a><span
|
|
class="cmr-12">] </span></p></div>
|
|
<!--l. 1--><p class="indent" > <a
|
|
id="tailuserhtmlsu6.html"></a>
|
|
</body></html>
|