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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3283 - (show annotations)
Mon Oct 18 22:39:28 2010 UTC (8 years, 11 months ago) by gross
File MIME type: text/plain
File size: 4166 byte(s)
AMG reengineered, BUG is Smoother fixed.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26