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.
264 lines
13 KiB
HTML
264 lines
13 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
<html >
|
|
<head><title>Adding new smoother and solver objects to AMG4PSBLAS</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<meta name="generator" content="TeX4ht (https://tug.org/tex4ht/)">
|
|
<meta name="originator" content="TeX4ht (https://tug.org/tex4ht/)">
|
|
<!-- html,3 -->
|
|
<meta name="src" content="userhtml.tex">
|
|
<link rel="stylesheet" type="text/css" href="userhtml.css">
|
|
</head><body
|
|
>
|
|
<!--l. 4--><div class="crosslinks"><p class="noindent"><span
|
|
class="cmr-12">[</span><a
|
|
href="userhtmlse7.html" ><span
|
|
class="cmr-12">next</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse5.html" ><span
|
|
class="cmr-12">prev</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse5.html#tailuserhtmlse5.html" ><span
|
|
class="cmr-12">prev-tail</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="#tailuserhtmlse6.html"><span
|
|
class="cmr-12">tail</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtml.html#userhtmlse6.html" ><span
|
|
class="cmr-12">up</span></a><span
|
|
class="cmr-12">] </span></p></div>
|
|
<h3 class="sectionHead"><span class="titlemark"><span
|
|
class="cmr-12">6 </span></span> <a
|
|
id="x25-290006"></a><span
|
|
class="cmr-12">Adding new smoother and solver objects to AMG4PSBLAS</span></h3>
|
|
<!--l. 6--><p class="noindent" ><span
|
|
class="cmr-12">Developers can add completely new smoother and/or solver classes derived from the</span>
|
|
<span
|
|
class="cmr-12">base objects in the library (see Remark</span><span
|
|
class="cmr-12"> 2 in Section</span><span
|
|
class="cmr-12"> </span><a
|
|
href="userhtmlsu8.html#x17-160005.2"><span
|
|
class="cmr-12">5.2</span><!--tex4ht:ref: sec:precset --></a><span
|
|
class="cmr-12">), without recompiling the</span>
|
|
<span
|
|
class="cmr-12">library itself.</span>
|
|
<!--l. 10--><p class="indent" > <span
|
|
class="cmr-12">To do so, it is necessary first to select the base type to be extended. In our</span>
|
|
<span
|
|
class="cmr-12">experience, it is quite likely that the new application needs only the definition of a</span>
|
|
<span
|
|
class="cmr-12">“solver” object, which is almost always acting only on the local part of the distributed</span>
|
|
<span
|
|
class="cmr-12">matrix. The parallel actions required to connect the various solver objects are most</span>
|
|
<span
|
|
class="cmr-12">often already provided by the block-Jacobi or the additive Schwarz smoothers. To</span>
|
|
<span
|
|
class="cmr-12">define a new solver, the developer will then have to define its components and</span>
|
|
<span
|
|
class="cmr-12">methods, perhaps taking one of the predefined solvers as a starting point, if</span>
|
|
<span
|
|
class="cmr-12">possible.</span>
|
|
<!--l. 20--><p class="indent" > <span
|
|
class="cmr-12">Once the new smoother/solver class has been developed, to use it in the context of</span>
|
|
<span
|
|
class="cmr-12">the multilevel preconditioners it is necessary to:</span>
|
|
<ul class="itemize1">
|
|
<li class="itemize"><span
|
|
class="cmr-12">declare in the application program a variable of the new type;</span>
|
|
</li>
|
|
<li class="itemize"><span
|
|
class="cmr-12">pass that variable as the argument to the </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">set</span></span></span> <span
|
|
class="cmr-12">routine as in the following:</span>
|
|
<div class="center"
|
|
>
|
|
<!--l. 26--><p class="noindent" >
|
|
<!--l. 27--><p class="noindent" ><span class="lstinline"></span><span
|
|
class="cmtt-12">call</span><span
|
|
class="cmtt-12"> </span><span
|
|
class="cmtt-12">p</span><span
|
|
class="cmtt-12">%</span><span
|
|
class="cmtt-12">set</span><span
|
|
class="cmtt-12">(</span><span
|
|
class="cmtt-12">smoother</span><span
|
|
class="cmtt-12">,</span><span
|
|
class="cmtt-12">info</span><span
|
|
class="cmtt-12"> </span><span
|
|
class="cmtt-12">[,</span><span
|
|
class="cmtt-12">ilev</span><span
|
|
class="cmtt-12">,</span><span
|
|
class="cmtt-12">ilmax</span><span
|
|
class="cmtt-12">,</span><span
|
|
class="cmtt-12">pos</span><span
|
|
class="cmtt-12">])</span><br />
|
|
<span class="lstinline"></span><span
|
|
class="cmtt-12">call</span><span
|
|
class="cmtt-12"> </span><span
|
|
class="cmtt-12">p</span><span
|
|
class="cmtt-12">%</span><span
|
|
class="cmtt-12">set</span><span
|
|
class="cmtt-12">(</span><span
|
|
class="cmtt-12">solver</span><span
|
|
class="cmtt-12">,</span><span
|
|
class="cmtt-12">info</span><span
|
|
class="cmtt-12"> </span><span
|
|
class="cmtt-12">[,</span><span
|
|
class="cmtt-12">ilev</span><span
|
|
class="cmtt-12">,</span><span
|
|
class="cmtt-12">ilmax</span><span
|
|
class="cmtt-12">,</span><span
|
|
class="cmtt-12">pos</span><span
|
|
class="cmtt-12">])</span></div>
|
|
</li>
|
|
<li class="itemize"><span
|
|
class="cmr-12">link the code implementing the various methods into the application</span>
|
|
<span
|
|
class="cmr-12">executable.</span></li></ul>
|
|
<!--l. 32--><p class="noindent" ><span
|
|
class="cmr-12">The new solver object is then dynamically included in the preconditioner structure,</span>
|
|
<span
|
|
class="cmr-12">and acts as a </span><span
|
|
class="cmti-12">mold </span><span
|
|
class="cmr-12">to which the preconditioner will conform, even though</span>
|
|
<span
|
|
class="cmr-12">the AMG4PSBLAS library has not been modified to account for this new</span>
|
|
<span
|
|
class="cmr-12">development.</span>
|
|
|
|
|
|
|
|
<!--l. 37--><p class="indent" > <span
|
|
class="cmr-12">It is possible to define new values for the keyword </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">WHAT</span></span></span> <span
|
|
class="cmr-12">in the </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">set</span></span></span> <span
|
|
class="cmr-12">routine; if the</span>
|
|
<span
|
|
class="cmr-12">library code does not recognize a keyword, it passes it down the composition hierarchy</span>
|
|
<span
|
|
class="cmr-12">(levels containing smoothers containing in turn solvers), so that it can be eventually</span>
|
|
<span
|
|
class="cmr-12">caught by the new solver. By the same token, any keyword/value pair that does not</span>
|
|
<span
|
|
class="cmr-12">pertain to a given smoother should be passed down to the contained solver, and</span>
|
|
<span
|
|
class="cmr-12">any keyword/value pair that does not pertain to a given solver is by default</span>
|
|
<span
|
|
class="cmr-12">ignored.</span>
|
|
<!--l. 46--><p class="indent" > <span
|
|
class="cmr-12">An example is provided in the source code distribution under the folder</span>
|
|
<span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">tests/newslv</span></span></span><span
|
|
class="cmr-12">. In this example we are implementing a new incomplete factorization</span>
|
|
<span
|
|
class="cmr-12">variant (which is simply the ILU(0) factorization under a new name). Because of the</span>
|
|
<span
|
|
class="cmr-12">specifics of this case, it is possible to reuse the basic structure of the ILU solver, with</span>
|
|
<span
|
|
class="cmr-12">its L/D/U components and the methods needed to apply the solver; only a few</span>
|
|
<span
|
|
class="cmr-12">methods, such as the description and most importantly the build, need to be</span>
|
|
<span
|
|
class="cmr-12">ovverridden (rewritten).</span>
|
|
<!--l. 55--><p class="indent" > <span
|
|
class="cmr-12">The interfaces for the calls shown above are defined using</span>
|
|
<div class="center"
|
|
>
|
|
<!--l. 56--><p class="noindent" >
|
|
<div class="tabular"> <table id="TBL-20" class="tabular"
|
|
cellspacing="0" cellpadding="0"
|
|
><colgroup id="TBL-20-1g"><col
|
|
id="TBL-20-1"><col
|
|
id="TBL-20-2"></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-20-1-"><td style="white-space:normal; text-align:left;" id="TBL-20-1-1"
|
|
class="td11"><!--l. 58--><p class="noindent" ><span class="lstinline"></span><span
|
|
class="cmtt-12">smoother</span> </td><td style="white-space:normal; text-align:left;" id="TBL-20-1-2"
|
|
class="td11"><!--l. 58--><p class="noindent" ><span class="lstinline"></span><span
|
|
class="cmtt-12">class</span><span
|
|
class="cmtt-12">(</span><span
|
|
class="cmtt-12">amg_x_base_smoother_type</span><span
|
|
class="cmtt-12">)</span> </td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-20-2-"><td style="white-space:normal; text-align:left;" id="TBL-20-2-1"
|
|
class="td11"><!--l. 59--><p class="noindent" > </td><td style="white-space:normal; text-align:left;" id="TBL-20-2-2"
|
|
class="td11"><!--l. 59--><p class="noindent" ><span
|
|
class="cmr-12">The user-defined new smoother to be employed in the</span>
|
|
<span
|
|
class="cmr-12">preconditioner.</span> </td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-20-3-"><td style="white-space:normal; text-align:left;" id="TBL-20-3-1"
|
|
class="td11"><!--l. 61--><p class="noindent" ><span class="lstinline"></span><span
|
|
class="cmtt-12">solver</span> </td><td style="white-space:normal; text-align:left;" id="TBL-20-3-2"
|
|
class="td11"><!--l. 61--><p class="noindent" ><span class="lstinline"></span><span
|
|
class="cmtt-12">class</span><span
|
|
class="cmtt-12">(</span><span
|
|
class="cmtt-12">amg_x_base_solver_type</span><span
|
|
class="cmtt-12">)</span> </td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-20-4-"><td style="white-space:normal; text-align:left;" id="TBL-20-4-1"
|
|
class="td11"><!--l. 62--><p class="noindent" > </td><td style="white-space:normal; text-align:left;" id="TBL-20-4-2"
|
|
class="td11"><!--l. 62--><p class="noindent" ><span
|
|
class="cmr-12">The user-defined new solver to be employed in the preconditioner.</span></td></tr></table></div></div>
|
|
<!--l. 66--><p class="noindent" ><span
|
|
class="cmr-12">The other arguments are defined in the way described in Sec.</span><span
|
|
class="cmr-12"> </span><a
|
|
href="userhtmlsu8.html#x17-160005.2"><span
|
|
class="cmr-12">5.2</span><!--tex4ht:ref: sec:precset --></a><span
|
|
class="cmr-12">. As an example, in the</span>
|
|
<span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">tests/newslv</span></span></span> <span
|
|
class="cmr-12">code we define a new object of type </span><span class="obeylines-h"><span class="verb"><span
|
|
class="cmtt-12">amg_d_tlu_solver_type</span></span></span><span
|
|
class="cmr-12">, and we</span>
|
|
<span
|
|
class="cmr-12">pass it as follows:</span>
|
|
|
|
|
|
|
|
<pre class="verbatim" id="verbatim-9">
|
|
  ! sparse matrix and preconditioner
|
|
  type(psb_dspmat_type) :: a
|
|
  type(amg_dprec_type)  :: prec
|
|
  type(amg_d_tlu_solver_type) :: tlusv
|
|
......
|
|
  !
|
|
  !  prepare the preconditioner: an ML with defaults, but with TLU solver at
|
|
  !  intermediate levels. All other parameters are at default values.
|
|
  !
|
|
  call prec%init(’ML’,       info)
|
|
  call prec%hierarchy_build(a,desc_a,info)
|
|
  nlv = prec%get_nlevs()
|
|
  call prec%set(tlusv,   info,ilev=1,ilmax=max(1,nlv-1))
|
|
  call prec%smoothers_build(a,desc_a,info)
|
|
</pre>
|
|
<!--l. 107--><p class="nopar" >
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--l. 1--><div class="crosslinks"><p class="noindent"><span
|
|
class="cmr-12">[</span><a
|
|
href="userhtmlse7.html" ><span
|
|
class="cmr-12">next</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse5.html" ><span
|
|
class="cmr-12">prev</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse5.html#tailuserhtmlse5.html" ><span
|
|
class="cmr-12">prev-tail</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtmlse6.html" ><span
|
|
class="cmr-12">front</span></a><span
|
|
class="cmr-12">] [</span><a
|
|
href="userhtml.html#userhtmlse6.html" ><span
|
|
class="cmr-12">up</span></a><span
|
|
class="cmr-12">] </span></p></div>
|
|
<!--l. 1--><p class="indent" > <a
|
|
id="tailuserhtmlse6.html"></a>
|
|
</body></html>
|