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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5933 - (show annotations)
Wed Feb 17 23:53:30 2016 UTC (21 months, 4 weeks ago) by caltinay
File size: 4769 byte(s)
sync with trunk.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The 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 "Options.h"
31 #include "performance.h"
32 #include "Preconditioner.h"
33 #include "Solver.h"
34 #include "MKL.h"
35 #include "UMFPACK.h"
36
37 namespace paso {
38
39 void SystemMatrix::solve(double* out, double* in, Options* options) const
40 {
41 Performance pp;
42 index_t package;
43 Esys_resetError();
44 if (getGlobalNumCols() != getGlobalNumRows()
45 || col_block_size != row_block_size) {
46 Esys_setError(VALUE_ERROR,"solve: matrix has to be a square matrix.");
47 return;
48 }
49 //options->show();
50 Performance_open(&pp, options->verbose);
51 package = Options::getPackage(options->method, options->package, options->symmetric, mpi_info);
52 if (Esys_noError()) {
53 switch(package) {
54 case PASO_PASO:
55 Solver(boost::const_pointer_cast<SystemMatrix>(shared_from_this()),
56 out, in, options, &pp);
57 solver_package = PASO_PASO;
58 break;
59
60 case PASO_MKL:
61 if (mpi_info->size > 1) {
62 Esys_setError(VALUE_ERROR,"solve: MKL package does not support MPI.");
63 return;
64 }
65 options->converged = false;
66 options->time = Esys_timer();
67 Performance_startMonitor(&pp, PERFORMANCE_ALL);
68 MKL_solve(mainBlock, out, in, options->reordering,
69 options->refinements, options->verbose);
70 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(mpi_info))
77 options->converged = true;
78 break;
79
80 case PASO_UMFPACK:
81 if (mpi_info->size > 1) {
82 Esys_setError(VALUE_ERROR,"solve: UMFPACK package does not support MPI.");
83 return;
84 }
85 options->converged = false;
86 options->time = Esys_timer();
87 Performance_startMonitor(&pp, PERFORMANCE_ALL);
88 UMFPACK_solve(mainBlock, out, in, options->refinements, options->verbose);
89 solver_package = PASO_UMFPACK;
90 Performance_stopMonitor(&pp, PERFORMANCE_ALL);
91 options->time = Esys_timer()-options->time;
92 options->set_up_time = 0;
93 options->residual_norm = 0.;
94 options->num_iter = 0;
95 if (Esys_MPIInfo_noError(mpi_info))
96 options->converged = true;
97 break;
98
99 default:
100 Esys_setError(VALUE_ERROR, "solve: unknown package code");
101 break;
102 }
103 }
104 /*
105 cancel divergence errors
106 */
107 if (options->accept_failed_convergence) {
108 if (Esys_getErrorType() == DIVERGED) {
109 Esys_resetError();
110 if (options->verbose)
111 printf("paso: failed convergence error has been canceled as requested.\n");
112 }
113 }
114 Performance_close(&pp, options->verbose);
115 }
116
117 void solve_free(SystemMatrix* in)
118 {
119 if (!in) return;
120
121 switch(in->solver_package) {
122 case PASO_PASO:
123 Solver_free(in);
124 break;
125
126 case PASO_SMOOTHER:
127 Preconditioner_Smoother_free((Preconditioner_Smoother*) in->solver_p);
128 break;
129
130 case PASO_MKL:
131 MKL_free(in->mainBlock.get());
132 break;
133
134 case PASO_UMFPACK:
135 UMFPACK_free(in->mainBlock.get());
136 break;
137 }
138 }
139
140 } // namespace paso
141

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/paso/src/solve.cpp:5567-5588 /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 /release/4.0/paso/src/solve.cpp:5380-5406 /trunk/paso/src/solve.cpp:4257-4344,5898-5932 /trunk/ripley/test/python/paso/src/solve.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26