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

Annotation of /trunk/paso/src/solve.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3642 - (hide annotations)
Thu Oct 27 03:41:51 2011 UTC (7 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 4214 byte(s)
Assorted spelling/comment fixes in paso.

1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 dhawcroft 631
14 ksteube 1811
15 jgs 150 /**************************************************************/
16    
17 caltinay 3642 /* Paso: interface to the direct solvers */
18 jgs 150
19     /**************************************************************/
20    
21 caltinay 3642 /* Copyrights by ACcESS Australia 2003 */
22     /* Author: Lutz Gross, l.gross@uq.edu.au */
23 jgs 150
24     /**************************************************************/
25    
26     #include "Paso.h"
27 gross 584 #include "performance.h"
28 gross 3283 #include "Preconditioner.h"
29 gross 700 #include "Solver.h"
30 gross 411 #include "MKL.h"
31     #include "UMFPACK.h"
32 jgs 150
33     /**************************************************************/
34    
35     void Paso_solve(Paso_SystemMatrix* A,
36 gross 1361 double* out,
37     double* in,
38     Paso_Options* options) {
39 ksteube 1312
40 gross 584 Paso_Performance pp;
41 gross 1028 index_t package;
42 jfenwick 3259 Esys_resetError();
43 ksteube 1312 if (Paso_SystemMatrix_getGlobalNumCols(A) != Paso_SystemMatrix_getGlobalNumRows(A)
44     || A->col_block_size!=A->row_block_size) {
45 jfenwick 3259 Esys_setError(VALUE_ERROR,"Paso_solve: matrix has to be a square matrix.");
46 jgs 150 return;
47     }
48 gross 2479 /* Paso_Options_show(options); */
49 gross 584 Performance_open(&pp,options->verbose);
50 gross 2315 package=Paso_Options_getPackage(options->method,options->package,options->symmetric, A->mpi_info);
51 jfenwick 3259 if (Esys_noError()) {
52 jgs 150 switch(package) {
53    
54     case PASO_PASO:
55 gross 584 Paso_Solver(A,out,in,options,&pp);
56 gross 727 A->solver_package=PASO_PASO;
57 jgs 150 break;
58    
59     case PASO_MKL:
60 ksteube 1312 if (A->mpi_info->size>1) {
61 jfenwick 3259 Esys_setError(VALUE_ERROR,"Paso_solve: MKL package does not support MPI.");
62 ksteube 1312 return;
63     }
64 gross 3283 options->converged=FALSE;
65     options->time=Esys_timer();
66     Performance_startMonitor(&pp,PERFORMANCE_ALL);
67     Paso_MKL(A->mainBlock, out, in, options->reordering, options->refinements, options->verbose);
68 gross 3440 A->solver_package=PASO_MKL;
69 gross 3283 Performance_stopMonitor(&pp,PERFORMANCE_ALL);
70     options->time=Esys_timer()-options->time;
71     options->set_up_time=0;
72     options->residual_norm=0.;
73     options->num_iter=0;
74     if (Esys_MPIInfo_noError(A->mpi_info)) options->converged=TRUE;
75 jgs 150 break;
76    
77 gross 3283 case PASO_UMFPACK:
78     if (A->mpi_info->size>1) {
79     Esys_setError(VALUE_ERROR,"Paso_solve: UMFPACK package does not support MPI.");
80     return;
81     }
82     options->converged=FALSE;
83     options->time=Esys_timer();
84     Performance_startMonitor(&pp,PERFORMANCE_ALL);
85     Paso_UMFPACK(A->mainBlock, out, in, options->refinements, options->verbose);
86 gross 3440 A->solver_package=PASO_UMFPACK;
87 gross 3283 Performance_stopMonitor(&pp,PERFORMANCE_ALL);
88     options->time=Esys_timer()-options->time;
89     options->set_up_time=0;
90     options->residual_norm=0.;
91     options->num_iter=0;
92     if (Esys_MPIInfo_noError(A->mpi_info)) options->converged=TRUE;
93     break;
94 jgs 150
95     default:
96 jfenwick 3259 Esys_setError(VALUE_ERROR,"Paso_solve: unknown package code");
97 gross 584 break;
98 jgs 150 }
99 gross 2484 }
100     /*
101     cancel divergence errors
102     */
103     if (options->accept_failed_convergence) {
104 jfenwick 3259 if (Esys_getErrorType() == DIVERGED) {
105     Esys_resetError();
106 caltinay 3642 if (options->verbose) printf("PASO: failed convergence error has been canceled as requested.\n");
107 gross 2479 }
108 jgs 150 }
109 gross 584 Performance_close(&pp,options->verbose);
110 gross 2502 /* Paso_Options_showDiagnostics(options); */
111 jgs 150 return;
112     }
113    
114 caltinay 3642 /* free memory possibly reserved for a recall */
115 jgs 150
116     void Paso_solve_free(Paso_SystemMatrix* in) {
117 gross 727
118 gross 1417 if (in==NULL) return;
119    
120 gross 425 switch(in->solver_package) {
121    
122     case PASO_PASO:
123 jgs 150 Paso_Solver_free(in);
124 gross 425 break;
125    
126 gross 3283 case PASO_SMOOTHER:
127     Paso_Preconditioner_Smoother_free((Paso_Preconditioner_Smoother*) in->solver_p);
128     break;
129    
130 gross 425 case PASO_MKL:
131 gross 3283 Paso_MKL_free(in->mainBlock);
132 gross 425 break;
133    
134     case PASO_UMFPACK:
135 gross 3283 Paso_UMFPACK_free(in->mainBlock);
136 gross 425 break;
137 ksteube 1312
138 gross 425 }
139 jgs 150 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26