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.
amg4psblas/docs/html/userhtmlsu6.html

392 lines
20 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
4 years ago
<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
>
4 years ago
<!--l. 107--><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="x14-130004.1"></a><span
4 years ago
class="cmr-12">Examples</span></h4>
<!--l. 109--><p class="noindent" ><span
class="cmr-12">The code reported in Figure</span><span
class="cmr-12">&#x00A0;</span><a
href="#x14-130011"><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">&#x00A0;</span><a
href="userhtmlse4.html#x13-120151"><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="obeylines-h"><span class="verb"><span
class="cmtt-12">&#8217;ML&#8217;</span></span></span> <span
class="cmr-12">as the</span>
<span
class="cmr-12">second argument of </span><span class="obeylines-h"><span class="verb"><span
class="cmtt-12">P%init</span></span></span> <span
class="cmr-12">(a call to </span><span class="obeylines-h"><span class="verb"><span
class="cmtt-12">P%set</span></span></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="obeylines-h"><span class="verb"><span
class="cmtt-12">psb_base_mod</span></span></span><span
class="cmr-12">, </span><span class="obeylines-h"><span class="verb"><span
class="cmtt-12">amg_prec_mod</span></span></span> <span
class="cmr-12">and </span><span class="obeylines-h"><span class="verb"><span
class="cmtt-12">psb_krylov_mod</span></span></span> <span
class="cmr-12">must be used by the example</span>
<span
class="cmr-12">program.</span>
<!--l. 119--><p class="indent" > <span
class="cmr-12">The part of the code concerning the reading and assembling of the sparse matrix</span>
<span
class="cmr-12">and the right-hand side vector, performed through the PSBLAS routines for sparse</span>
<span
class="cmr-12">matrix and vector management, is not reported here for brevity; the statements</span>
<span
class="cmr-12">concerning the deallocation of the PSBLAS data structure are neglected too. The</span>
<span
class="cmr-12">complete code can be found in the 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</span>
<span
class="cmr-12">directory </span><span class="obeylines-h"><span class="verb"><span
class="cmtt-12">examples/fileread</span></span></span> <span
class="cmr-12">of the AMG4PSBLAS implementation (see</span>
<span
class="cmr-12">Section</span><span
class="cmr-12">&#x00A0;</span><a
href="userhtmlsu5.html#x12-110003.5"><span
class="cmr-12">3.5</span><!--tex4ht:ref: sec:ex_and_test --></a><span
class="cmr-12">). A sample test problem along 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 the use of the PSBLAS routines, see the</span>
<span
class="cmr-12">PSBLAS User&#8217;s Guide</span><span
class="cmr-12">&#x00A0;</span><span class="cite"><span
class="cmr-12">[</span><a
href="userhtmlli4.html#XPSBLASGUIDE"><span
class="cmr-12">16</span></a><span
class="cmr-12">]</span></span><span
class="cmr-12">.</span>
<!--l. 131--><p class="indent" > <span
class="cmr-12">The setup and application of the default multilevel preconditioner for the real single</span>
4 years ago
<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">&#x00A0;</span><a
href="userhtmlse5.html#x15-140005"><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. 137--><p class="indent" > <hr class="figure"><div class="figure"
>
<a
4 years ago
id="x14-130011"></a>
<div class="center"
>
4 years ago
<!--l. 138--><p class="noindent" >
<div class="minipage"><div class="verbatim" id="verbatim-5">
4 years ago
&#x00A0;&#x00A0;use&#x00A0;psb_base_mod
&#x00A0;<br />&#x00A0;&#x00A0;use&#x00A0;amg_prec_mod
&#x00A0;<br />&#x00A0;&#x00A0;use&#x00A0;psb_krylov_mod
&#x00A0;<br />...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;sparse&#x00A0;matrix
&#x00A0;<br />&#x00A0;&#x00A0;type(psb_dspmat_type)&#x00A0;::&#x00A0;A
&#x00A0;<br />!&#x00A0;sparse&#x00A0;matrix&#x00A0;descriptor
&#x00A0;<br />&#x00A0;&#x00A0;type(psb_desc_type)&#x00A0;&#x00A0;&#x00A0;::&#x00A0;desc_A
&#x00A0;<br />!&#x00A0;preconditioner
&#x00A0;<br />&#x00A0;&#x00A0;type(amg_dprec_type)&#x00A0;&#x00A0;::&#x00A0;P
&#x00A0;<br />!&#x00A0;right-hand&#x00A0;side&#x00A0;and&#x00A0;solution&#x00A0;vectors
&#x00A0;<br />&#x00A0;&#x00A0;type(psb_d_vect_type)&#x00A0;::&#x00A0;b,&#x00A0;x
&#x00A0;<br />...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;initialize&#x00A0;the&#x00A0;parallel&#x00A0;environment
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;psb_init(ictxt)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;psb_info(ictxt,iam,np)
&#x00A0;<br />...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;read&#x00A0;and&#x00A0;assemble&#x00A0;the&#x00A0;spd&#x00A0;matrix&#x00A0;A&#x00A0;and&#x00A0;the&#x00A0;right-hand&#x00A0;side&#x00A0;b
&#x00A0;<br />!&#x00A0;using&#x00A0;PSBLAS&#x00A0;routines&#x00A0;for&#x00A0;sparse&#x00A0;matrix&#x00A0;/&#x00A0;vector&#x00A0;management
&#x00A0;<br />...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;initialize&#x00A0;the&#x00A0;default&#x00A0;multilevel&#x00A0;preconditioner,&#x00A0;i.e.&#x00A0;V-cycle
&#x00A0;<br />!&#x00A0;with&#x00A0;basic&#x00A0;smoothed&#x00A0;aggregation,&#x00A0;1&#x00A0;hybrid&#x00A0;forward/backward
&#x00A0;<br />!&#x00A0;GS&#x00A0;sweep&#x00A0;as&#x00A0;pre/post-smoother&#x00A0;and&#x00A0;UMFPACK&#x00A0;as&#x00A0;coarsest-level
&#x00A0;<br />!&#x00A0;solver
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%init(&#8217;ML&#8217;,info)
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;build&#x00A0;the&#x00A0;preconditioner
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%hierarchy_build(A,desc_A,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%smoothers_build(A,desc_A,info)
&#x00A0;<br />
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;set&#x00A0;the&#x00A0;solver&#x00A0;parameters&#x00A0;and&#x00A0;the&#x00A0;initial&#x00A0;guess
&#x00A0;<br />&#x00A0;&#x00A0;...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;solve&#x00A0;Ax=b&#x00A0;with&#x00A0;preconditioned&#x00A0;CG
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;psb_krylov(&#8217;CG&#8217;,A,P,b,x,tol,desc_A,info)
&#x00A0;<br />&#x00A0;&#x00A0;...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;deallocate&#x00A0;the&#x00A0;preconditioner
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%free(info)
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;deallocate&#x00A0;other&#x00A0;data&#x00A0;structures
&#x00A0;<br />&#x00A0;&#x00A0;...&#x00A0;...
&#x00A0;<br />!
&#x00A0;<br />!&#x00A0;exit&#x00A0;the&#x00A0;parallel&#x00A0;environment
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;psb_exit(ictxt)
&#x00A0;<br />&#x00A0;&#x00A0;stop
</div>
4 years ago
<!--l. 193--><p class="nopar" >
</div>
<br /> <div class="caption"
><span class="id">Figure&#x00A0;1: </span><span
4 years ago
class="content">setup and application of the default multilevel preconditioner (example 1). </span></div><!--tex4ht:label?: x14-130011 -->
</div>
4 years ago
<!--l. 199--><p class="indent" > </div><hr class="endfigure">
<!--l. 201--><p class="indent" > <span
class="cmr-12">Different versions of the multilevel preconditioner can be obtained by changing the</span>
<span
4 years ago
class="cmr-12">default values of the preconditioner parameters. The code reported in Figure</span><span
class="cmr-12">&#x00A0;</span><a
href="#x14-130022"><span
class="cmr-12">2</span><!--tex4ht:ref: fig:ex2 --></a> <span
class="cmr-12">shows</span>
<span
4 years ago
class="cmr-12">how to set a V-cycle preconditioner which applies 1 block-Jacobi sweep as pre- and</span>
<span
4 years ago
class="cmr-12">post-smoother, and solves the coarsest-level system with 8 block-Jacobi sweeps. Note</span>
<span
class="cmr-12">that the ILU(0) factorization (plus triangular solve) is used as local solver for the</span>
<span
class="cmr-12">block-Jacobi sweeps, since this is the default associated with block-Jacobi</span>
<span
class="cmr-12">and set by</span><span
class="cmr-12">&#x00A0;</span><span class="obeylines-h"><span class="verb"><span
class="cmtt-12">P%init</span></span></span><span
class="cmr-12">. Furthermore, specifying block-Jacobi as coarsest-level</span>
<span
class="cmr-12">solver implies that the coarsest-level matrix is distributed among the processes.</span>
<span
4 years ago
class="cmr-12">Figure</span><span
class="cmr-12">&#x00A0;</span><a
4 years ago
href="#x14-130033"><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 Coarsening</span>
<span
4 years ago
class="cmr-12">based on Compatible Weighted Matching. It applies 2 hybrid Gauss-Seidel</span>
<span
4 years ago
class="cmr-12">sweeps as pre- and post-smoother, and solves the coarsest-level system with the</span>
<span
4 years ago
class="cmr-12">multifrontal LU factorization implemented in MUMPS. It is specified that the</span>
<span
4 years ago
class="cmr-12">coarsest-level matrix is distributed, since MUMPS can be used on both replicated and</span>
<span
4 years ago
class="cmr-12">distributed matrices, and by default it is used on replicated ones. The code</span>
<span
class="cmr-12">fragments shown in Figures</span><span
class="cmr-12">&#x00A0;</span><a
href="#x14-130022"><span
class="cmr-12">2</span><!--tex4ht:ref: fig:ex2 --></a> <span
class="cmr-12">and </span><a
href="#x14-130033"><span
class="cmr-12">3</span><!--tex4ht:ref: fig:ex3 --></a> <span
class="cmr-12">are included in the 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">too. </span><span
class="cmbx-12">DA CORREGGERE NEL CODICE ESEMPIO</span>
<span
class="cmbx-12">3</span>
<!--l. 225--><p class="indent" > <span
class="cmr-12">Finally, Figure</span><span
class="cmr-12">&#x00A0;</span><a
href="#x14-130044"><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>
4 years ago
<!--l. 232--><p class="indent" > <span
class="cmr-12">For all the previous preconditioners, example programs where the sparse matrix and</span>
<span
class="cmr-12">the right-hand side are generated by discretizing a PDE with Dirichlet boundary</span>
<span
class="cmr-12">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. 236--><p class="indent" > <hr class="figure"><div class="figure"
>
<a
id="x14-130022"></a>
<div class="center"
>
<!--l. 237--><p class="noindent" >
<div class="minipage"><div class="verbatim" id="verbatim-6">
4 years ago
...&#x00A0;...
&#x00A0;<br />!&#x00A0;build&#x00A0;a&#x00A0;V-cycle&#x00A0;preconditioner&#x00A0;with&#x00A0;1&#x00A0;block-Jacobi&#x00A0;sweep&#x00A0;(with
&#x00A0;<br />!&#x00A0;ILU(0)&#x00A0;on&#x00A0;the&#x00A0;blocks)&#x00A0;as&#x00A0;pre-&#x00A0;and&#x00A0;post-smoother,&#x00A0;and&#x00A0;8&#x00A0;&#x00A0;block-Jacobi
&#x00A0;<br />!&#x00A0;sweeps&#x00A0;(with&#x00A0;ILU(0)&#x00A0;on&#x00A0;the&#x00A0;blocks)&#x00A0;as&#x00A0;coarsest-level&#x00A0;solver
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%init(&#8217;ML&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call_P%set(&#8217;SMOOTHER_TYPE&#8217;,&#8217;BJAC&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;COARSE_SOLVE&#8217;,&#8217;BJAC&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;COARSE_SWEEPS&#8217;,8,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%hierarchy_build(A,desc_A,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%smoothers_build(A,desc_A,info)
&#x00A0;<br />...&#x00A0;...
</div>
4 years ago
<!--l. 252--><p class="nopar" ></div>
<br /><div class="caption"
><span class="id">Figure&#x00A0;2: </span><span
class="content">setup of a multilevel preconditioner based on the default decoupled coarsening</span></div><!--tex4ht:label?: x14-130022 -->
</div>
4 years ago
<!--l. 258--><p class="indent" > </div><hr class="endfigure">
<!--l. 260--><p class="indent" > <hr class="figure"><div class="figure"
>
<a
id="x14-130033"></a>
<div class="center"
>
<!--l. 261--><p class="noindent" >
<div class="minipage"><div class="verbatim" id="verbatim-7">
4 years ago
...&#x00A0;...
&#x00A0;<br />!&#x00A0;build&#x00A0;a&#x00A0;W-cycle&#x00A0;preconditioner&#x00A0;with&#x00A0;2&#x00A0;hybrid&#x00A0;Gauss-Seidel&#x00A0;sweeps
&#x00A0;<br />!&#x00A0;as&#x00A0;pre-&#x00A0;and&#x00A0;post-smoother,&#x00A0;a&#x00A0;distributed&#x00A0;coarsest
&#x00A0;<br />!&#x00A0;matrix,&#x00A0;and&#x00A0;MUMPS&#x00A0;as&#x00A0;coarsest-level&#x00A0;solver
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%init(&#8217;ML&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;PAR_AGGR_ALG&#8217;,&#8217;COUPLED&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;ML_CYCLE&#8217;,&#8217;WCYCLE&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;SMOOTHER_TYPE&#8217;,&#8217;FBGS&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;SMOOTHER_SWEEPS&#8217;,2,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;COARSE_SOLVE&#8217;,&#8217;MUMPS&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;COARSE_MAT&#8217;,&#8217;DIST&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%hierarchy_build(A,desc_A,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%smoothers_build(A,desc_A,info)
&#x00A0;<br />...&#x00A0;...
</div>
4 years ago
<!--l. 279--><p class="nopar" ></div>
<br /> <div class="caption"
><span class="id">Figure&#x00A0;3: </span><span
class="content">setup of a multilevel preconditioner based on the coupled coarsening based
on weighted matching</span></div><!--tex4ht:label?: x14-130033 -->
</div>
<!--l. 284--><p class="indent" > </div><hr class="endfigure">
<!--l. 286--><p class="indent" > <hr class="figure"><div class="figure"
>
<a
id="x14-130044"></a>
<div class="center"
>
<!--l. 287--><p class="noindent" >
<div class="minipage"><div class="verbatim" id="verbatim-8">
4 years ago
...&#x00A0;...
&#x00A0;<br />!&#x00A0;set&#x00A0;RAS&#x00A0;with&#x00A0;overlap&#x00A0;2&#x00A0;and&#x00A0;ILU(0)&#x00A0;on&#x00A0;the&#x00A0;local&#x00A0;blocks
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%init(&#8217;AS&#8217;,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%set(&#8217;SUB_OVR&#8217;,2,info)
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;P%bld(A,desc_A,info)
&#x00A0;<br />...&#x00A0;...
&#x00A0;<br />!&#x00A0;solve&#x00A0;Ax=b&#x00A0;with&#x00A0;preconditioned&#x00A0;BiCGSTAB
&#x00A0;<br />&#x00A0;&#x00A0;call&#x00A0;psb_krylov(&#8217;BICGSTAB&#8217;,A,P,b,x,tol,desc_A,info)
</div>
4 years ago
<!--l. 299--><p class="nopar" ></div>
<br /> <div class="caption"
><span class="id">Figure&#x00A0;4: </span><span
class="content">setup of a one-level Schwarz preconditioner.</span></div><!--tex4ht:label?: x14-130044 -->
</div>
<!--l. 304--><p class="indent" > </div><hr class="endfigure">
<!--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>
4 years ago
<!--l. 1--><p class="indent" > <a
id="tailuserhtmlsu6.html"></a>
</body></html>