xref: /petsc/src/mat/utils/gcreate.c (revision 3b1aa7bf6db2ad751eca3a9bce3a57f8115f8d34)
1 #ifndef lint
2 static char vcid[] = "$Id: gcreate.c,v 1.15 1995/04/27 01:37:47 curfman Exp curfman $";
3 #endif
4 
5 #include "sys.h"
6 #include "options.h"
7 #include "sysio.h"
8 #include "mat.h"
9 
10 /*@C
11    MatCreateInitialMatrix - Creates a matrix, where the type is determined
12    from the options database. Generates a parallel MPI matrix if the
13    communicator has more than one processor.
14 
15    Input Parameters:
16 .  m - number of global rows
17 .  n - number of global columns
18 .  comm - MPI communicator
19 
20    Output Parameter:
21 .  V - location to stash resulting matrix
22 
23    Options Database Keywords:
24 $  -mat_dense : dense type, uses MatCreateSequentialDense()
25 $  -mat_row   : row type, uses MatCreateSequentialRow()
26 $               and MatCreateMPIRow()
27 $  -mat_rowbs : rowbs type (for parallel symmetric matrices),
28 $               uses MatCreateMPIRowbs()
29 $  -mat_bdiag : block diagonal type, uses
30 $               MatCreateSequentialBDiag() and
31 $               MatCreateMPIBDiag()
32 $
33 $  -mpi_objects : uses MPI matrix, even for one processor
34 
35    Notes:
36    The default matrix type is AIJ, using MatCreateSequentialAIJ() and
37    MatCreateMPIAIJ().
38 
39 .keywords: matrix, create, initial
40 
41 .seealso: MatCreateSequentialAIJ((), MatCreateMPIAIJ(),
42           MatCreateSequentialRow(), MatCreateMPIRow(),
43           MatCreateSequentialDense(), MatCreateSequentialBDiag(),
44           MatCreateMPIRowbs()
45 @*/
46 int MatCreateInitialMatrix(MPI_Comm comm,int m,int n,Mat *V)
47 {
48   int numtid;
49   MPI_Comm_size(comm,&numtid);
50   if (OptionsHasName(0,0,"-mat_dense")) {
51     return MatCreateSequentialDense(comm,m,n,V);
52   }
53   if (numtid > 1 || OptionsHasName(0,0,"-mpi_objects")) {
54     if (OptionsHasName(0,0,"-mat_row")) {
55       return MatCreateMPIRow(comm,PETSC_DECIDE,PETSC_DECIDE, m,n,5,0,0,0,V);
56     }
57 #if defined(HAVE_BLOCKSOLVE) && !defined(PETSC_COMPLEX)
58     if (OptionsHasName(0,0,"-mat_rowbs")) {
59       return MatCreateMPIRowbs(comm,PETSC_DECIDE,m,5,0,0,V);
60     }
61 #endif
62     return MatCreateMPIAIJ(comm,PETSC_DECIDE,PETSC_DECIDE, m,n,5,0,0,0,V);
63   }
64   if (OptionsHasName(0,0,"-mat_row")) {
65     return MatCreateSequentialRow(comm,m,n,10,0,V);
66   }
67   return MatCreateSequentialAIJ(comm,m,n,10,0,V);
68 }
69 
70