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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateShell.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>MatCreateShell</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.7.5 2017-01-01</b></div>
<div id="bugreport" align=right><a href="mailto:petsc-maint@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: petsc-3.7.5 v3.7.5 docs/manualpages/Mat/MatCreateShell.html "><small>Report Typos and Errors</small></a></div>
<A NAME="MatCreateShell"><H1>MatCreateShell</H1></A>
Creates a new matrix class for use with a user-defined private data storage format.
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#include "petscmat.h"
PetscErrorCode MatCreateShell(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,void *ctx,Mat *A)
</PRE>
Collective on <A HREF="../Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A>
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>comm </B></TD><TD>- MPI communicator
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>m </B></TD><TD>- number of local rows (must be given)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>n </B></TD><TD>- number of local columns (must be given)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>M </B></TD><TD>- number of global rows (may be <A HREF="../Sys/PETSC_DETERMINE.html#PETSC_DETERMINE">PETSC_DETERMINE</A>)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>N </B></TD><TD>- number of global columns (may be <A HREF="../Sys/PETSC_DETERMINE.html#PETSC_DETERMINE">PETSC_DETERMINE</A>)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ctx </B></TD><TD>- pointer to data needed by the shell matrix routines
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Output Parameter</FONT></H3>
<DT><B>A </B> -the matrix
<br>
<P>
<P>
<H3><FONT COLOR="#CC3333">Usage</FONT></H3>
<pre>
extern int mult(<A HREF="../Mat/Mat.html#Mat">Mat</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>);
</pre>
<pre>
<A HREF="../Mat/MatCreateShell.html#MatCreateShell">MatCreateShell</A>(comm,m,n,M,N,ctx,&mat);
</pre>
<pre>
<A HREF="../Mat/MatShellSetOperation.html#MatShellSetOperation">MatShellSetOperation</A>(mat,MATOP_MULT,(void(*)(void))mult);
</pre>
<pre>
[ Use matrix for operations that have been set ]
</pre>
<pre>
<A HREF="../Mat/MatDestroy.html#MatDestroy">MatDestroy</A>(mat);
</pre>
<P>
<H3><FONT COLOR="#CC3333">Notes</FONT></H3>
The shell matrix type is intended to provide a simple class to use
with <A HREF="../KSP/KSP.html#KSP">KSP</A> (such as, for use with matrix-free methods). You should not
use the shell type if you plan to define a complete matrix class.
<P>
Fortran Notes: To use this from Fortran with a ctx you must write an interface definition for this
function and for <A HREF="../Mat/MatShellGetContext.html#MatShellGetContext">MatShellGetContext</A>() that tells Fortran the Fortran derived data type you are passing
in as the ctx argument.
<P>
PETSc requires that matrices and vectors being used for certain
operations are partitioned accordingly. For example, when
creating a shell matrix, A, that supports parallel matrix-vector
products using <A HREF="../Mat/MatMult.html#MatMult">MatMult</A>(A,x,y) the user should set the number
of local matrix rows to be the number of local elements of the
corresponding result vector, y. Note that this is information is
required for use of the matrix interface routines, even though
the shell matrix may not actually be physically partitioned.
For example,
<P>
<pre>
</pre>
<pre>
<A HREF="../Vec/Vec.html#Vec">Vec</A> x, y
</pre>
<pre>
extern int mult(<A HREF="../Mat/Mat.html#Mat">Mat</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>);
</pre>
<pre>
<A HREF="../Mat/Mat.html#Mat">Mat</A> A
</pre>
<pre>
</pre>
<pre>
<A HREF="../Vec/VecCreateMPI.html#VecCreateMPI">VecCreateMPI</A>(comm,<A HREF="../Sys/PETSC_DECIDE.html#PETSC_DECIDE">PETSC_DECIDE</A>,M,&y);
</pre>
<pre>
<A HREF="../Vec/VecCreateMPI.html#VecCreateMPI">VecCreateMPI</A>(comm,<A HREF="../Sys/PETSC_DECIDE.html#PETSC_DECIDE">PETSC_DECIDE</A>,N,&x);
</pre>
<pre>
<A HREF="../Vec/VecGetLocalSize.html#VecGetLocalSize">VecGetLocalSize</A>(y,&m);
</pre>
<pre>
<A HREF="../Vec/VecGetLocalSize.html#VecGetLocalSize">VecGetLocalSize</A>(x,&n);
</pre>
<pre>
<A HREF="../Mat/MatCreateShell.html#MatCreateShell">MatCreateShell</A>(comm,m,n,M,N,ctx,&A);
</pre>
<pre>
<A HREF="../Mat/MatShellSetOperation.html#MatShellSetOperation">MatShellSetOperation</A>(mat,MATOP_MULT,(void(*)(void))mult);
</pre>
<pre>
<A HREF="../Mat/MatMult.html#MatMult">MatMult</A>(A,x,y);
</pre>
<pre>
<A HREF="../Mat/MatDestroy.html#MatDestroy">MatDestroy</A>(A);
</pre>
<pre>
<A HREF="../Vec/VecDestroy.html#VecDestroy">VecDestroy</A>(y); <A HREF="../Vec/VecDestroy.html#VecDestroy">VecDestroy</A>(x);
</pre>
<pre>
</pre>
<P>
<H3><FONT COLOR="#CC3333">Keywords</FONT></H3>
matrix, shell, create
<BR>
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../Mat/MatShellSetOperation.html#MatShellSetOperation">MatShellSetOperation</A>(), <A HREF="../Mat/MatHasOperation.html#MatHasOperation">MatHasOperation</A>(), <A HREF="../Mat/MatShellGetContext.html#MatShellGetContext">MatShellGetContext</A>(), <A HREF="../Mat/MatShellSetContext.html#MatShellSetContext">MatShellSetContext</A>()
<BR><P><B><P><B><FONT COLOR="#CC3333">Level:</FONT></B>advanced
<BR><FONT COLOR="#CC3333">Location:</FONT></B><A HREF="../../../src/mat/impls/shell/shell.c.html#MatCreateShell">src/mat/impls/shell/shell.c</A>
<BR><A HREF="./index.html">Index of all Mat 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>
<P><H3><FONT COLOR="#CC3333">Examples</FONT></H3>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex14f.F.html">src/ksp/ksp/examples/tutorials/ex14f.F.html</A><BR>
<A HREF="../../../src/ts/examples/tutorials/ex22f_mf.F90.html">src/ts/examples/tutorials/ex22f_mf.F90.html</A><BR>
<A HREF="../../../src/tao/unconstrained/examples/tutorials/eptorsion1.c.html">src/tao/unconstrained/examples/tutorials/eptorsion1.c.html</A><BR>
<A HREF="../../../src/tao/bound/examples/tutorials/plate2.c.html">src/tao/bound/examples/tutorials/plate2.c.html</A><BR>
<A HREF="../../../src/tao/pde_constrained/examples/tutorials/elliptic.c.html">src/tao/pde_constrained/examples/tutorials/elliptic.c.html</A><BR>
<A HREF="../../../src/tao/pde_constrained/examples/tutorials/parabolic.c.html">src/tao/pde_constrained/examples/tutorials/parabolic.c.html</A><BR>
<A HREF="../../../src/tao/pde_constrained/examples/tutorials/hyperbolic.c.html">src/tao/pde_constrained/examples/tutorials/hyperbolic.c.html</A><BR>
</BODY></HTML>
|