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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4873 - (show annotations)
Wed Apr 16 06:38:51 2014 UTC (5 years, 5 months ago) by caltinay
File size: 4737 byte(s)
whitespace only changes.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************/
19
20 /* Paso: interface to the direct solvers */
21
22 /****************************************************************************/
23
24 /* Copyrights by ACcESS Australia 2003 */
25 /* Author: Lutz Gross, l.gross@uq.edu.au */
26
27 /****************************************************************************/
28
29 #include "Paso.h"
30 #include "performance.h"
31 #include "Preconditioner.h"
32 #include "Solver.h"
33 #include "MKL.h"
34 #include "UMFPACK.h"
35
36 namespace paso {
37
38 void solve(SystemMatrix_ptr A, double* out, double* in, Options* options)
39 {
40 Performance pp;
41 index_t package;
42 Esys_resetError();
43 if (A->getGlobalNumCols() != A->getGlobalNumRows()
44 || A->col_block_size != A->row_block_size) {
45 Esys_setError(VALUE_ERROR,"solve: matrix has to be a square matrix.");
46 return;
47 }
48 //options->show();
49 Performance_open(&pp, options->verbose);
50 package = Options::getPackage(options->method, options->package, options->symmetric, A->mpi_info);
51 if (Esys_noError()) {
52 switch(package) {
53 case PASO_PASO:
54 Solver(A, out, in, options, &pp);
55 A->solver_package = PASO_PASO;
56 break;
57
58 case PASO_MKL:
59 if (A->mpi_info->size > 1) {
60 Esys_setError(VALUE_ERROR,"solve: MKL package does not support MPI.");
61 return;
62 }
63 options->converged = false;
64 options->time = Esys_timer();
65 Performance_startMonitor(&pp, PERFORMANCE_ALL);
66 MKL_solve(A->mainBlock, out, in, options->reordering,
67 options->refinements, options->verbose);
68 A->solver_package = PASO_MKL;
69 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))
75 options->converged = true;
76 break;
77
78 case PASO_UMFPACK:
79 if (A->mpi_info->size>1) {
80 Esys_setError(VALUE_ERROR,"solve: UMFPACK package does not support MPI.");
81 return;
82 }
83 options->converged = false;
84 options->time = Esys_timer();
85 Performance_startMonitor(&pp, PERFORMANCE_ALL);
86 UMFPACK_solve(A->mainBlock, out, in, options->refinements, options->verbose);
87 A->solver_package = PASO_UMFPACK;
88 Performance_stopMonitor(&pp, PERFORMANCE_ALL);
89 options->time = Esys_timer()-options->time;
90 options->set_up_time = 0;
91 options->residual_norm = 0.;
92 options->num_iter = 0;
93 if (Esys_MPIInfo_noError(A->mpi_info))
94 options->converged = true;
95 break;
96
97 default:
98 Esys_setError(VALUE_ERROR, "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)
109 printf("paso: failed convergence error has been canceled as requested.\n");
110 }
111 }
112 Performance_close(&pp, options->verbose);
113 //options->showDiagnostics();
114 }
115
116 void solve_free(SystemMatrix* in)
117 {
118 if (!in) return;
119
120 switch(in->solver_package) {
121 case PASO_PASO:
122 Solver_free(in);
123 break;
124
125 case PASO_SMOOTHER:
126 Preconditioner_Smoother_free((Preconditioner_Smoother*) in->solver_p);
127 break;
128
129 case PASO_MKL:
130 MKL_free(in->mainBlock.get());
131 break;
132
133 case PASO_UMFPACK:
134 UMFPACK_free(in->mainBlock.get());
135 break;
136 }
137 }
138
139 } // namespace paso
140

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/amg_from_3530/paso/src/solve.cpp:3531-3826 /branches/lapack2681/paso/src/solve.cpp:2682-2741 /branches/pasowrap/paso/src/solve.cpp:3661-3674 /branches/py3_attempt2/paso/src/solve.cpp:3871-3891 /branches/restext/paso/src/solve.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/solve.cpp:3669-3791 /branches/stage3.0/paso/src/solve.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/solve.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/solve.cpp:3517-3974 /release/3.0/paso/src/solve.cpp:2591-2601 /trunk/paso/src/solve.cpp:4257-4344 /trunk/ripley/test/python/paso/src/solve.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26