Actual source code: mpisbaijspooles.c
1: /*$Id: mpisbaijspooles.c,v 1.10 2001/08/15 15:56:50 bsmith Exp $*/
2: /*
3: Provides an interface to the Spooles parallel sparse solver (MPI SPOOLES)
4: */
6: #include src/mat/impls/aij/seq/spooles/spooles.h
10: int MatDestroy_MPISBAIJSpooles(Mat A) {
12:
14: /* MPISBAIJ_Spooles isn't really the matrix that USES spooles, */
15: /* rather it is a factory class for creating a symmetric matrix that can */
16: /* invoke Spooles' parallel cholesky solver. */
17: /* As a result, we don't have to clean up the stuff set for use in spooles */
18: /* as in MatDestroy_MPIAIJ_Spooles. */
19: MatConvert_Spooles_Base(A,MATMPISBAIJ,&A);
20: (*A->ops->destroy)(A);
21: return(0);
22: }
26: int MatAssemblyEnd_MPISBAIJSpooles(Mat A,MatAssemblyType mode) {
27: int ierr,bs;
28: Mat_Spooles *lu=(Mat_Spooles *)(A->spptr);
31: (*lu->MatAssemblyEnd)(A,mode);
32: MatGetBlockSize(A,&bs);
33: if (bs > 1) SETERRQ1(1,"Block size %d not supported by Spooles",bs);
34: lu->MatCholeskyFactorSymbolic = A->ops->choleskyfactorsymbolic;
35: A->ops->choleskyfactorsymbolic = MatCholeskyFactorSymbolic_MPISBAIJSpooles;
36: return(0);
37: }
39: /* Note the Petsc r permutation is ignored */
42: int MatCholeskyFactorSymbolic_MPISBAIJSpooles(Mat A,IS r,MatFactorInfo *info,Mat *F)
43: {
44: Mat B;
45: Mat_Spooles *lu;
46: int ierr;
47:
50: /* Create the factorization matrix */
51: MatCreate(A->comm,A->m,A->n,A->M,A->N,&B);
52: MatSetType(B,MATMPIAIJSPOOLES);
53: MatMPIAIJSetPreallocation(B,0,PETSC_NULL,0,PETSC_NULL);
54:
55: B->ops->choleskyfactornumeric = MatFactorNumeric_MPIAIJSpooles;
56: B->factor = FACTOR_CHOLESKY;
58: lu = (Mat_Spooles*)(B->spptr);
59: lu->options.pivotingflag = SPOOLES_NO_PIVOTING;
60: lu->flg = DIFFERENT_NONZERO_PATTERN;
61: lu->options.useQR = PETSC_FALSE;
62: lu->options.symflag = SPOOLES_SYMMETRIC; /* default */
64: MPI_Comm_dup(A->comm,&(lu->comm_spooles));
65: *F = B;
66: return(0);
67: }
69: EXTERN_C_BEGIN
72: int MatConvert_MPISBAIJ_MPISBAIJSpooles(Mat A,MatType type,Mat *newmat) {
73: /* This routine is only called to convert a MATMPISBAIJ matrix */
74: /* to a MATMPISBAIJSPOOLES matrix, so we will ignore 'MatType type'. */
75: int ierr;
76: Mat B=*newmat;
77: Mat_Spooles *lu;
80: if (B != A) {
81: /* This routine is inherited, so we know the type is correct. */
82: MatDuplicate(A,MAT_COPY_VALUES,&B);
83: }
85: PetscNew(Mat_Spooles,&lu);
86: B->spptr = (void*)lu;
88: lu->basetype = MATMPISBAIJ;
89: lu->MatDuplicate = A->ops->duplicate;
90: lu->MatCholeskyFactorSymbolic = A->ops->choleskyfactorsymbolic;
91: lu->MatLUFactorSymbolic = A->ops->lufactorsymbolic;
92: lu->MatView = A->ops->view;
93: lu->MatAssemblyEnd = A->ops->assemblyend;
94: lu->MatDestroy = A->ops->destroy;
95: B->ops->duplicate = MatDuplicate_MPISBAIJSpooles;
96: B->ops->choleskyfactorsymbolic = MatCholeskyFactorSymbolic_MPISBAIJSpooles;
97: B->ops->assemblyend = MatAssemblyEnd_MPISBAIJSpooles;
98: B->ops->destroy = MatDestroy_MPISBAIJSpooles;
100: PetscObjectComposeFunctionDynamic((PetscObject)B,"MatConvert_mpisbaijspooles_mpisbaij_C",
101: "MatConvert_Spooles_Base",MatConvert_Spooles_Base);
102: PetscObjectComposeFunctionDynamic((PetscObject)B,"MatConvert_mpisbaij_mpisbaijspooles_C",
103: "MatConvert_MPISBAIJ_MPISBAIJSpooles",
104: MatConvert_MPISBAIJ_MPISBAIJSpooles);
105: PetscObjectChangeTypeName((PetscObject)B,MATMPISBAIJSPOOLES);
106: *newmat = B;
107: return(0);
108: }
109: EXTERN_C_END
113: int MatDuplicate_MPISBAIJSpooles(Mat A, MatDuplicateOption op, Mat *M) {
116: (*A->ops->duplicate)(A,op,M);
117: MatConvert_MPISBAIJ_MPISBAIJSpooles(*M,MATMPISBAIJSPOOLES,M);
118: return(0);
119: }
121: /*MC
122: MATMPISBAIJSPOOLES - MATMPISBAIJSPOOLES = "mpisbaijspooles" - a matrix type providing direct solvers (Cholesky) for distributed symmetric
123: matrices via the external package Spooles.
125: If Spooles is installed (see the manual for
126: instructions on how to declare the existence of external packages),
127: a matrix type can be constructed which invokes Spooles solvers.
128: After calling MatCreate(...,A), simply call MatSetType(A,MATMPISBAIJSPOOLES).
129: This matrix type is only supported for double precision real.
131: This matrix inherits from MATMPISBAIJ. As a result, MatMPISBAIJSetPreallocation is
132: supported for this matrix type. One can also call MatConvert for an inplace conversion to or from
133: the MATMPISBAIJ type without data copy.
135: Options Database Keys:
136: + -mat_type mpisbaijspooles - sets the matrix type to mpisbaijspooles during a call to MatSetFromOptions()
137: . -mat_spooles_tau <tau> - upper bound on the magnitude of the largest element in L or U
138: . -mat_spooles_seed <seed> - random number seed used for ordering
139: . -mat_spooles_msglvl <msglvl> - message output level
140: . -mat_spooles_ordering <BestOfNDandMS,MMD,MS,ND> - ordering used
141: . -mat_spooles_maxdomainsize <n> - maximum subgraph size used by Spooles orderings
142: . -mat_spooles_maxzeros <n> - maximum number of zeros inside a supernode
143: . -mat_spooles_maxsize <n> - maximum size of a supernode
144: . -mat_spooles_FrontMtxInfo <true,fase> - print Spooles information about the computed factorization
145: . -mat_spooles_symmetryflag <0,1,2> - 0: SPOOLES_SYMMETRIC, 1: SPOOLES_HERMITIAN, 2: SPOOLES_NONSYMMETRIC
146: . -mat_spooles_patchAndGoFlag <0,1,2> - 0: no patch, 1: use PatchAndGo strategy 1, 2: use PatchAndGo strategy 2
147: . -mat_spooles_toosmall <dt> - drop tolerance for PatchAndGo strategy 1
148: . -mat_spooles_storeids <bool integer> - if nonzero, stores row and col numbers where patches were applied in an IV object
149: . -mat_spooles_fudge <delta> - fudge factor for rescaling diagonals with PatchAndGo strategy 2
150: - -mat_spooles_storevalues <bool integer> - if nonzero and PatchAndGo strategy 2 is used, store change in diagonal value in a DV object
152: Level: beginner
154: .seealso: MATSEQSBAIJSPOOLES, MATSEQAIJSPOOLES, MATMPIAIJSPOOLES, PCCHOLESKY
155: M*/
157: EXTERN_C_BEGIN
160: int MatCreate_MPISBAIJSpooles(Mat A) {
164: /* Change type name before calling MatSetType to force proper construction of MPISBAIJ */
165: /* and MPISBAIJSpooles types */
166: PetscObjectChangeTypeName((PetscObject)A,MATMPISBAIJSPOOLES);
167: MatSetType(A,MATMPISBAIJ);
168: MatConvert_MPISBAIJ_MPISBAIJSpooles(A,MATMPISBAIJSPOOLES,&A);
169: return(0);
170: }
171: EXTERN_C_END