File: MatCreateShell.html

package info (click to toggle)
petsc 3.4.2.dfsg1-8.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 129,104 kB
  • ctags: 516,422
  • sloc: ansic: 395,939; cpp: 47,201; python: 34,788; makefile: 17,193; fortran: 16,251; f90: 1,592; objc: 954; sh: 822; xml: 621; java: 381; lisp: 293; csh: 241
file content (130 lines) | stat: -rw-r--r-- 5,870 bytes parent folder | download
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
<!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.4.2 2013-07-02</b></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,&amp;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: The context can only be an integer or a <A HREF="../Sys/PetscObject.html#PetscObject">PetscObject</A>
unfortunately it cannot be a Fortran array or derived type.
<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,&amp;y);
</pre>
<pre>
    <A HREF="../Vec/VecCreateMPI.html#VecCreateMPI">VecCreateMPI</A>(comm,<A HREF="../Sys/PETSC_DECIDE.html#PETSC_DECIDE">PETSC_DECIDE</A>,N,&amp;x);
</pre>
<pre>
    <A HREF="../Vec/VecGetLocalSize.html#VecGetLocalSize">VecGetLocalSize</A>(y,&amp;m);
</pre>
<pre>
    <A HREF="../Vec/VecGetLocalSize.html#VecGetLocalSize">VecGetLocalSize</A>(x,&amp;n);
</pre>
<pre>
    <A HREF="../Mat/MatCreateShell.html#MatCreateShell">MatCreateShell</A>(comm,m,n,M,N,ctx,&amp;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>
</BODY></HTML>