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/node33.html

184 lines
8.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 2017.2 (Released Jan 23, 2017) -->
<HTML>
<HEAD>
<TITLE>Adding new smoother and solver objects to MLD2P4</TITLE>
<META NAME="description" CONTENT="Adding new smoother and solver objects to MLD2P4">
<META NAME="keywords" CONTENT="userhtml">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="LaTeX2HTML v2017.2">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="userhtml.css">
<LINK REL="next" HREF="node34.html">
<LINK REL="previous" HREF="node18.html">
<LINK REL="up" HREF="userhtml.html">
<LINK REL="next" HREF="node34.html">
</HEAD>
<BODY >
<DIV CLASS="navigation"><!--Navigation Panel-->
<A NAME="tex2html501"
HREF="node34.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
<A NAME="tex2html497"
HREF="userhtml.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
<A NAME="tex2html491"
HREF="node32.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
<A NAME="tex2html499"
HREF="node2.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html502"
HREF="node34.html">Error Handling</A>
<B> Up:</B> <A NAME="tex2html498"
HREF="userhtml.html">userhtml</A>
<B> Previous:</B> <A NAME="tex2html492"
HREF="node32.html">Method: free_wrk</A>
&nbsp; <B> <A NAME="tex2html500"
HREF="node2.html">Contents</A></B>
<BR>
<BR></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION00090000000000000000"></A><A NAME="sec:adding"></A>
<BR>
Adding new smoother and solver objects to MLD2P4
</H1><BIG CLASS="LARGE"><BIG CLASS="LARGE"></BIG></BIG>
<P>
<BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">Developers can add completely new smoother and/or solver classes
derived from the base objects in the library (see Remark&nbsp;2 in Section&nbsp;<A HREF="node20.html#sec:precset">6.2</A>),
without recompiling the library itself.
</BIG></BIG></BIG>
<P>
<BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">To do so, it is necessary first to select the base type to be extended.
In our experience, it is quite likely that the new application needs
only the definition of a &ldquo;solver&rdquo; object, which is almost
always acting only on the local part of the distributed matrix.
The parallel actions required to connect the various solver objects
are most often already provided by the block-Jacobi or the additive
Schwarz smoothers. To define a new solver, the developer will then
have to define its components and methods, perhaps taking one of the
predefined solvers as a starting point, if possible.
</BIG></BIG></BIG>
<P>
<BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">Once the new smoother/solver class has been developed, to use it in
the context of the multilevel preconditioners it is necessary to:
</BIG></BIG></BIG>
<UL>
<LI>declare in the application program a variable of the new type;
</LI>
<LI>pass that variable as the argument to the <code>set</code> routine as in the
following:
<DIV ALIGN="CENTER">
<code>call p%set(smoother,info [,ilev,ilmax,pos])</code>
<BR><code>call p%set(solver,info [,ilev,ilmax,pos])</code>
</DIV>
</LI>
<LI>link the code implementing the various methods into the application executable.
</LI>
</UL><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
The new solver object is then dynamically included in the
preconditioner structure, and acts as a <SPAN CLASS="textit">mold</SPAN> to which the
preconditioner will conform, even though the MLD2P4 library has not
been modified to account for this new development.
</BIG></BIG></BIG>
<P>
<BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">It is possible to define new values for the keyword <code>WHAT</code> in the
<code>set</code> routine; if the library code does not recognize a keyword,
it passes it down the composition hierarchy (levels containing
smoothers containing in turn solvers), so that it can be eventually caught by
the new solver.
</BIG></BIG></BIG>
<P>
<BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">An example is provided in the source code distribution under the
folder <code>tests/newslv</code>. In this example we are implementing a new
incomplete factorization variant (which is simply the ILU(0)
factorization under a new name). Because of the specifics of this case, it is
possible to reuse the basic structure of the ILU solver, with its
L/D/U components and the methods needed to apply the solver; only a
few methods, such as the description and most importantly the build,
need to be ovverridden (rewritten).
</BIG></BIG></BIG>
<P>
<BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">The interfaces for the calls shown above are defined using
</BIG></BIG></BIG>
<DIV ALIGN="CENTER"><BIG CLASS="LARGE"><BIG CLASS="LARGE"></BIG></BIG><TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
<code>smoother</code> </BIG></BIG></BIG></TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=340><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE"> <code>class(mld_x_base_smoother_type)</code> </BIG></BIG></BIG></TD>
</TR>
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
</BIG></BIG></BIG></TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=340><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE"> The user-defined new smoother to be employed in the
preconditioner.</BIG></BIG></BIG></TD>
</TR>
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
<code>solver</code> </BIG></BIG></BIG></TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=340><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE"> <code>class(mld_x_base_solver_type)</code> </BIG></BIG></BIG></TD>
</TR>
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
</BIG></BIG></BIG></TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=340><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE"> The user-defined new solver to be employed in the
preconditioner.
</BIG></BIG></BIG></TD>
</TR>
</TABLE><BIG CLASS="LARGE"><BIG CLASS="LARGE"></BIG></BIG></DIV><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
The other arguments are defined in the way described in
Sec.&nbsp;<A HREF="node20.html#sec:precset">6.2</A>. As an example, in the <code>tests/newslv</code>
code we define a new object of type <code>mld_d_tlu_solver_type</code>, and
we pass it as follows:
</BIG></BIG></BIG><PRE>
! sparse matrix and preconditioner
type(psb_dspmat_type) :: a
type(mld_dprec_type) :: prec
type(mld_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><BIG CLASS="LARGE"><BIG CLASS="LARGE"><BIG CLASS="LARGE">
</BIG></BIG></BIG>
<DIV CLASS="navigation"><HR>
<!--Navigation Panel-->
<A NAME="tex2html501"
HREF="node34.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
<A NAME="tex2html497"
HREF="userhtml.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
<A NAME="tex2html491"
HREF="node32.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
<A NAME="tex2html499"
HREF="node2.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html502"
HREF="node34.html">Error Handling</A>
<B> Up:</B> <A NAME="tex2html498"
HREF="userhtml.html">userhtml</A>
<B> Previous:</B> <A NAME="tex2html492"
HREF="node32.html">Method: free_wrk</A>
&nbsp; <B> <A NAME="tex2html500"
HREF="node2.html">Contents</A></B> </DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>