/[escript]/trunk/paso/src/UMFPACK.c
ViewVC logotype

Contents of /trunk/paso/src/UMFPACK.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 5 months ago) by ksteube
File MIME type: text/plain
File size: 3838 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* Paso: interface to the Intel UMFPACK library */
18
19 /**************************************************************/
20
21 /* Copyrights by ACcESS Australia 2006 */
22 /* Author: gross@@access.edu.au */
23
24 /**************************************************************/
25
26 #include "Paso.h"
27 #include "UMFPACK.h"
28 #ifdef _OPENMP
29 #include <omp.h>
30 #endif
31
32 /**************************************************************/
33
34 /* free any extra stuff possibly used by the UMFPACK library */
35
36 void Paso_UMFPACK_free(Paso_SystemMatrix* A) {
37 Paso_UMFPACK_Handler* pt =NULL;
38 #ifdef UMFPACK
39 if (A->solver!=NULL) {
40 pt=(Paso_UMFPACK_Handler*)(A->solver);
41 umfpack_di_free_symbolic(&(pt->symbolic));
42 umfpack_di_free_numeric(&(pt->numeric));
43 MEMFREE(pt);
44 A->solver=NULL;
45 }
46 #endif
47 }
48 /* call the solver: */
49
50 void Paso_UMFPACK(Paso_SystemMatrix* A,
51 double* out,
52 double* in,
53 Paso_Options* options,
54 Paso_Performance* pp) {
55 #ifdef UMFPACK
56 double time0;
57 double control[UMFPACK_CONTROL], info[UMFPACK_INFO];
58 int error = UMFPACK_OK;
59 Paso_UMFPACK_Handler* pt = NULL;
60
61 if (! (A->type & (MATRIX_FORMAT_OFFSET1 + MATRIX_FORMAT_BLK1)) ) {
62 Paso_setError(TYPE_ERROR,"Paso_UMFPACK: UMFPACK requires CSR format with index offset 1 and block size 1.");
63 return;
64 }
65 Performance_startMonitor(pp,PERFORMANCE_ALL);
66 pt = (Paso_UMFPACK_Handler *)(A->solver);
67 umfpack_di_defaults(control);
68
69 if (pt==NULL) {
70 int n = A->mainBlock->numRows;
71 pt=MEMALLOC(1,Paso_UMFPACK_Handler);
72 if (Paso_checkPtr(pt)) return;
73 A->solver=(void*) pt;
74 time0=Paso_timer();
75 /* call LDU symbolic factorization: */
76 error=umfpack_di_symbolic(n,n,A->mainBlock->pattern->ptr,A->mainBlock->pattern->index,A->mainBlock->val,&(pt->symbolic),control,info);
77 if (error != UMFPACK_OK) {
78 Paso_setError(VALUE_ERROR,"symbolic factorization failed.");
79 Paso_UMFPACK_free(A);
80 } else {
81 /* call LDU factorization: */
82 error= umfpack_di_numeric(A->mainBlock->pattern->ptr,A->mainBlock->pattern->index,A->mainBlock->val,pt->symbolic,&(pt->numeric),control,info);
83 if (error != UMFPACK_OK) {
84 Paso_setError(ZERO_DIVISION_ERROR,"factorization failed. Most likely the matrix is singular.");
85 Paso_UMFPACK_free(A);
86 }
87 if (options->verbose) printf("timing UMFPACK: LDU factorization: %.4e sec.\n",Paso_timer()-time0);
88 }
89 }
90 if (Paso_noError()) {
91 time0=Paso_timer();
92 /* call forward backward substitution: */
93 control[UMFPACK_IRSTEP]=2; /* number of refinement steps */
94 error=umfpack_di_solve(UMFPACK_A,A->mainBlock->pattern->ptr,A->mainBlock->pattern->index,A->mainBlock->val,out,in,pt->numeric,control,info);
95 if (options->verbose) printf("timing UMFPACK: solve: %.4e sec\n",Paso_timer()-time0);
96 if (error != UMFPACK_OK) {
97 Paso_setError(VALUE_ERROR,"forward/backward substition failed. Most likely the matrix is singular.");
98 }
99 }
100 Performance_stopMonitor(pp,PERFORMANCE_ALL);
101 #else
102 Paso_setError(SYSTEM_ERROR,"Paso_UMFPACK:UMFPACK is not avialble.");
103 #endif
104
105 }

  ViewVC Help
Powered by ViewVC 1.1.26