/[escript]/branches/doubleplusgood/paso/src/solve.cpp
ViewVC logotype

Contents of /branches/doubleplusgood/paso/src/solve.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4261 - (show annotations)
Wed Feb 27 06:09:33 2013 UTC (6 years, 1 month ago) by jfenwick
File size: 4421 byte(s)
Initial all c++ build.
But ... there are now reinterpret_cast<>'s
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 /************************************************************************************/
18
19 /* Paso: interface to the direct solvers */
20
21 /************************************************************************************/
22
23 /* Copyrights by ACcESS Australia 2003 */
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25
26 /************************************************************************************/
27
28 #include "Paso.h"
29 #include "performance.h"
30 #include "Preconditioner.h"
31 #include "Solver.h"
32 #include "MKL.h"
33 #include "UMFPACK.h"
34
35 /************************************************************************************/
36
37 void Paso_solve(Paso_SystemMatrix* A,
38 double* out,
39 double* in,
40 Paso_Options* options) {
41
42 Paso_Performance pp;
43 index_t package;
44 Esys_resetError();
45 if (Paso_SystemMatrix_getGlobalNumCols(A) != Paso_SystemMatrix_getGlobalNumRows(A)
46 || A->col_block_size!=A->row_block_size) {
47 Esys_setError(VALUE_ERROR,"Paso_solve: matrix has to be a square matrix.");
48 return;
49 }
50 /* Paso_Options_show(options); */
51 Performance_open(&pp,options->verbose);
52 package=Paso_Options_getPackage(options->method,options->package,options->symmetric, A->mpi_info);
53 if (Esys_noError()) {
54 switch(package) {
55
56 case PASO_PASO:
57 Paso_Solver(A,out,in,options,&pp);
58 A->solver_package=PASO_PASO;
59 break;
60
61 case PASO_MKL:
62 if (A->mpi_info->size>1) {
63 Esys_setError(VALUE_ERROR,"Paso_solve: MKL package does not support MPI.");
64 return;
65 }
66 options->converged=FALSE;
67 options->time=Esys_timer();
68 Performance_startMonitor(&pp,PERFORMANCE_ALL);
69 Paso_MKL(A->mainBlock, out, in, options->reordering, options->refinements, options->verbose);
70 A->solver_package=PASO_MKL;
71 Performance_stopMonitor(&pp,PERFORMANCE_ALL);
72 options->time=Esys_timer()-options->time;
73 options->set_up_time=0;
74 options->residual_norm=0.;
75 options->num_iter=0;
76 if (Esys_MPIInfo_noError(A->mpi_info)) options->converged=TRUE;
77 break;
78
79 case PASO_UMFPACK:
80 if (A->mpi_info->size>1) {
81 Esys_setError(VALUE_ERROR,"Paso_solve: UMFPACK package does not support MPI.");
82 return;
83 }
84 options->converged=FALSE;
85 options->time=Esys_timer();
86 Performance_startMonitor(&pp,PERFORMANCE_ALL);
87 Paso_UMFPACK(A->mainBlock, out, in, options->refinements, options->verbose);
88 A->solver_package=PASO_UMFPACK;
89 Performance_stopMonitor(&pp,PERFORMANCE_ALL);
90 options->time=Esys_timer()-options->time;
91 options->set_up_time=0;
92 options->residual_norm=0.;
93 options->num_iter=0;
94 if (Esys_MPIInfo_noError(A->mpi_info)) options->converged=TRUE;
95 break;
96
97 default:
98 Esys_setError(VALUE_ERROR,"Paso_solve: unknown package code");
99 break;
100 }
101 }
102 /*
103 cancel divergence errors
104 */
105 if (options->accept_failed_convergence) {
106 if (Esys_getErrorType() == DIVERGED) {
107 Esys_resetError();
108 if (options->verbose) printf("PASO: failed convergence error has been canceled as requested.\n");
109 }
110 }
111 Performance_close(&pp,options->verbose);
112 /* Paso_Options_showDiagnostics(options); */
113 return;
114 }
115
116 /* free memory possibly reserved for a recall */
117
118 void Paso_solve_free(Paso_SystemMatrix* in) {
119
120 if (in==NULL) return;
121
122 switch(in->solver_package) {
123
124 case PASO_PASO:
125 Paso_Solver_free(in);
126 break;
127
128 case PASO_SMOOTHER:
129 Paso_Preconditioner_Smoother_free((Paso_Preconditioner_Smoother*) in->solver_p);
130 break;
131
132 case PASO_MKL:
133 Paso_MKL_free(in->mainBlock);
134 break;
135
136 case PASO_UMFPACK:
137 Paso_UMFPACK_free(in->mainBlock);
138 break;
139
140 }
141 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26