1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSolve.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>KSPSolve</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.4.2 2013-07-02</b></div>
<A NAME="KSPSolve"><H1>KSPSolve</H1></A>
Solves linear system.
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#include "petscksp.h"
PetscErrorCode KSPSolve(KSP ksp,Vec b,Vec x)
</PRE>
Collective on <A HREF="../KSP/KSP.html#KSP">KSP</A>
<P>
<H3><FONT COLOR="#CC3333">Parameter</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ksp </B></TD><TD>- iterative context obtained from <A HREF="../KSP/KSPCreate.html#KSPCreate">KSPCreate</A>()
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>b </B></TD><TD>- the right hand side vector
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>x </B></TD><TD>- the solution (this may be the same vector as b, then b will be overwritten with answer)
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Options Database Keys</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_compute_eigenvalues </B></TD><TD>- compute preconditioned operators eigenvalues
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_plot_eigenvalues </B></TD><TD>- plot the computed eigenvalues in an X-window
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_compute_eigenvalues_explicitly </B></TD><TD>- compute the eigenvalues by forming the dense operator and useing LAPACK
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_plot_eigenvalues_explicitly </B></TD><TD>- plot the explicitly computing eigenvalues
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view_mat binary </B></TD><TD>- save matrix to the default binary viewer
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view_pmat binary </B></TD><TD>- save matrix used to build preconditioner to the default binary viewer
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view_rhs binary </B></TD><TD>- save right hand side vector to the default binary viewer
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view_solution binary </B></TD><TD>- save computed solution vector to the default binary viewer
(can be read later with src/ksp/examples/tutorials/ex10.c for testing solvers)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view_mat_explicit </B></TD><TD>- for matrix-free operators, computes the matrix entries and views them
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view_preconditioned_operator_explicit </B></TD><TD>- computes the product of the preconditioner and matrix as an explicit matrix and views it
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_converged_reason </B></TD><TD>- print reason for converged or diverged, also prints number of iterations
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_final_residual </B></TD><TD>- print 2-norm of true linear system residual at the end of the solution process
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>-ksp_view </B></TD><TD>- print the ksp data structure at the end of the system solution
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Notes</FONT></H3>
<P>
If one uses <A HREF="../KSP/KSPSetDM.html#KSPSetDM">KSPSetDM</A>() then x or b need not be passed. Use <A HREF="../KSP/KSPGetSolution.html#KSPGetSolution">KSPGetSolution</A>() to access the solution in this case.
<P>
The operator is specified with <A HREF="../KSP/KSPSetOperators.html#KSPSetOperators">KSPSetOperators</A>().
<P>
Call <A HREF="../KSP/KSPGetConvergedReason.html#KSPGetConvergedReason">KSPGetConvergedReason</A>() to determine if the solver converged or failed and
why. The number of iterations can be obtained from <A HREF="../KSP/KSPGetIterationNumber.html#KSPGetIterationNumber">KSPGetIterationNumber</A>().
<P>
If using a direct method (e.g., via the <A HREF="../KSP/KSP.html#KSP">KSP</A> solver
<A HREF="../KSP/KSPPREONLY.html#KSPPREONLY">KSPPREONLY</A> and a preconditioner such as <A HREF="../PC/PCLU.html#PCLU">PCLU</A>/<A HREF="../PC/PCILU.html#PCILU">PCILU</A>),
then its=1. See <A HREF="../KSP/KSPSetTolerances.html#KSPSetTolerances">KSPSetTolerances</A>() and <A HREF="../KSP/KSPDefaultConverged.html#KSPDefaultConverged">KSPDefaultConverged</A>()
for more details.
<P>
<H3><FONT COLOR="#CC3333">Understanding Convergence</FONT></H3>
The routines <A HREF="../KSP/KSPMonitorSet.html#KSPMonitorSet">KSPMonitorSet</A>(), <A HREF="../KSP/KSPComputeEigenvalues.html#KSPComputeEigenvalues">KSPComputeEigenvalues</A>(), and
<A HREF="../KSP/KSPComputeEigenvaluesExplicitly.html#KSPComputeEigenvaluesExplicitly">KSPComputeEigenvaluesExplicitly</A>() provide information on additional
options to monitor convergence and print eigenvalue information.
<P>
<P>
<H3><FONT COLOR="#CC3333">Keywords</FONT></H3>
<A HREF="../KSP/KSP.html#KSP">KSP</A>, solve, linear system
<BR>
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../KSP/KSPCreate.html#KSPCreate">KSPCreate</A>(), <A HREF="../KSP/KSPSetUp.html#KSPSetUp">KSPSetUp</A>(), <A HREF="../KSP/KSPDestroy.html#KSPDestroy">KSPDestroy</A>(), <A HREF="../KSP/KSPSetTolerances.html#KSPSetTolerances">KSPSetTolerances</A>(), <A HREF="../KSP/KSPDefaultConverged.html#KSPDefaultConverged">KSPDefaultConverged</A>(),
<BR><A HREF="../KSP/KSPSolveTranspose.html#KSPSolveTranspose">KSPSolveTranspose</A>(), <A HREF="../KSP/KSPGetIterationNumber.html#KSPGetIterationNumber">KSPGetIterationNumber</A>()
<P><B><P><B><FONT COLOR="#CC3333">Level:</FONT></B>beginner
<BR><FONT COLOR="#CC3333">Location:</FONT></B><A HREF="../../../src/ksp/ksp/interface/itfunc.c.html#KSPSolve">src/ksp/ksp/interface/itfunc.c</A>
<BR><A HREF="./index.html">Index of all KSP routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
<A HREF="../../../src/ksp/pc/examples/tutorials/ex1.c.html">src/ksp/pc/examples/tutorials/ex1.c.html</A><BR>
<A HREF="../../../src/ksp/pc/examples/tutorials/ex2.c.html">src/ksp/pc/examples/tutorials/ex2.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex1.c.html">src/ksp/ksp/examples/tutorials/ex1.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex2.c.html">src/ksp/ksp/examples/tutorials/ex2.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex3.c.html">src/ksp/ksp/examples/tutorials/ex3.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex4.c.html">src/ksp/ksp/examples/tutorials/ex4.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex5.c.html">src/ksp/ksp/examples/tutorials/ex5.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex7.c.html">src/ksp/ksp/examples/tutorials/ex7.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex8.c.html">src/ksp/ksp/examples/tutorials/ex8.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex8g.c.html">src/ksp/ksp/examples/tutorials/ex8g.c.html</A><BR>
</BODY></HTML>
|