1 |
|
2 |
/******************************************************* |
3 |
* |
4 |
* Copyright (c) 2003-2009 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 |
#if !defined finley_SystemMatrixAdapter_20040610_H |
16 |
#define finley_SystemMatrixAdapter_20040610_H |
17 |
#include "system_dep.h" |
18 |
|
19 |
extern "C" { |
20 |
#include "paso/SystemMatrix.h" |
21 |
#include "paso/Options.h" |
22 |
} |
23 |
|
24 |
#include "FinleyAdapterException.h" |
25 |
#include "FinleyError.h" |
26 |
|
27 |
#include "escript/AbstractSystemMatrix.h" |
28 |
#include "escript/Data.h" |
29 |
#include "escript/UtilC.h" |
30 |
|
31 |
#include <boost/python/object.hpp> |
32 |
#include <boost/shared_ptr.hpp> |
33 |
#include <boost/python/extract.hpp> |
34 |
|
35 |
namespace finley { |
36 |
|
37 |
class SystemMatrixAdapter:public escript::AbstractSystemMatrix { |
38 |
|
39 |
/** |
40 |
\brief |
41 |
Wrapper for Paso_SystemMatrix. |
42 |
|
43 |
Description: |
44 |
Wrapper for Paso_SystemMatrix. |
45 |
*/ |
46 |
|
47 |
public: |
48 |
|
49 |
/** |
50 |
/brief |
51 |
Default Constructor for SystemMatrixAdapter. |
52 |
NB: Only throws an exception. |
53 |
*/ |
54 |
FINLEY_DLL_API |
55 |
SystemMatrixAdapter(); |
56 |
|
57 |
/** |
58 |
/brief |
59 |
Constructor for SystemMatrixAdapter. |
60 |
*/ |
61 |
FINLEY_DLL_API |
62 |
SystemMatrixAdapter(Paso_SystemMatrix* system_matrix, |
63 |
const int row_blocksize, |
64 |
const escript::FunctionSpace& row_functionspace, |
65 |
const int column_blocksize, |
66 |
const escript::FunctionSpace& colum_functionspace); |
67 |
|
68 |
|
69 |
/** |
70 |
\brief |
71 |
Destructor for SystemMatrixAdapter. As specified in the constructor |
72 |
this deallocates the pointer given to the constructor. |
73 |
*/ |
74 |
FINLEY_DLL_API |
75 |
~SystemMatrixAdapter(); |
76 |
|
77 |
/** |
78 |
\brief |
79 |
Returns the pointer to the system matrix. |
80 |
*/ |
81 |
FINLEY_DLL_API |
82 |
Paso_SystemMatrix* getPaso_SystemMatrix() const; |
83 |
|
84 |
/** |
85 |
\brief |
86 |
Returns the system matrix as a const AbstractSystemMatrix&. |
87 |
*/ |
88 |
inline const escript::AbstractSystemMatrix& asAbstractSystemMatrix() const |
89 |
{ |
90 |
return dynamic_cast<const escript::AbstractSystemMatrix&>(*this); |
91 |
} |
92 |
|
93 |
/** |
94 |
\brief |
95 |
Returns a system matrix as a const SystemMatrixAdapter&. |
96 |
*/ |
97 |
inline static const SystemMatrixAdapter& asSystemMatrixAdapter(const AbstractSystemMatrix& systemmatrix) |
98 |
{ |
99 |
return dynamic_cast<const SystemMatrixAdapter&>(systemmatrix); |
100 |
} |
101 |
|
102 |
/** |
103 |
\brief |
104 |
nullifyRowsAndCols - calls Paso_SystemMatrix_nullifyRowsAndCols. |
105 |
*/ |
106 |
FINLEY_DLL_API |
107 |
void nullifyRowsAndCols(escript::Data& row_q, escript::Data& col_q, const double mdv) const; |
108 |
|
109 |
/** |
110 |
\brief writes the matrix to a file using the Matrix Market file format |
111 |
*/ |
112 |
FINLEY_DLL_API |
113 |
virtual void saveMM(const std::string& fileName) const; |
114 |
|
115 |
/** |
116 |
\brief writes the matrix to a file using the Harwell-Boeing file format |
117 |
*/ |
118 |
FINLEY_DLL_API |
119 |
virtual void saveHB(const std::string& fileName) const; |
120 |
|
121 |
/** |
122 |
\brief sets the matrix entries to zero |
123 |
*/ |
124 |
FINLEY_DLL_API |
125 |
virtual void resetValues() const; |
126 |
|
127 |
/** |
128 |
\brief maps escript options onto Paso options: |
129 |
*/ |
130 |
FINLEY_DLL_API |
131 |
static int mapOptionToPaso(const int option); |
132 |
|
133 |
/** |
134 |
\brief extract paso options from SolutionOptions class |
135 |
*/ |
136 |
|
137 |
FINLEY_DLL_API |
138 |
static void escriptToPasoOptions(Paso_Options* paso_options, const boost::python::object& options); |
139 |
|
140 |
/** |
141 |
\brief copied diagonistic data back to the solver option. |
142 |
*/ |
143 |
|
144 |
FINLEY_DLL_API |
145 |
static void pasoToEscriptOptions(const Paso_Options* paso_options,boost::python::object& options); |
146 |
|
147 |
/** |
148 |
\brief prints information about a system matrix |
149 |
*/ |
150 |
FINLEY_DLL_API |
151 |
void Print_Matrix_Info(const bool) const; |
152 |
|
153 |
protected: |
154 |
|
155 |
private: |
156 |
|
157 |
/** |
158 |
\brief |
159 |
solves the linear system this*out=in |
160 |
*/ |
161 |
FINLEY_DLL_API |
162 |
virtual void setToSolution(escript::Data& out, escript::Data& in, boost::python::object& options) const; |
163 |
|
164 |
/** |
165 |
\brief |
166 |
performs y+=this*x |
167 |
*/ |
168 |
FINLEY_DLL_API |
169 |
virtual void ypAx(escript::Data& y, escript::Data& x) const; |
170 |
|
171 |
// |
172 |
// pointer to the externally created finley mesh - system_matrix. |
173 |
// |
174 |
boost::shared_ptr<Paso_SystemMatrix> m_system_matrix; |
175 |
|
176 |
}; |
177 |
|
178 |
} // end of namespace |
179 |
#endif |