1 |
|
2 |
/******************************************************* |
3 |
* |
4 |
* Copyright (c) 2003-2008 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 escript_AbstractSystemMatrix_20040628_H |
16 |
#define escript_AbstractSystemMatrix_20040628_H |
17 |
#include "system_dep.h" |
18 |
|
19 |
#include "FunctionSpace.h" |
20 |
#include "SystemMatrixException.h" |
21 |
|
22 |
#include <boost/python/dict.hpp> |
23 |
|
24 |
// |
25 |
// Forward declaration |
26 |
class Data; |
27 |
|
28 |
namespace escript { |
29 |
|
30 |
/** |
31 |
\brief |
32 |
Give a short description of what AbstractSystemMatrix does. |
33 |
|
34 |
Description: |
35 |
Give a detailed description of AbstractSystemMatrix |
36 |
|
37 |
Template Parameters: |
38 |
For templates describe any conditions that the parameters used in the |
39 |
template must satisfy |
40 |
*/ |
41 |
class AbstractSystemMatrix { |
42 |
|
43 |
public: |
44 |
|
45 |
/** |
46 |
\brief |
47 |
Default constructor for AbstractSystemMatrix |
48 |
|
49 |
Description: |
50 |
Default constructor for AbstractSystemMatrix |
51 |
|
52 |
Preconditions: |
53 |
Describe any preconditions |
54 |
|
55 |
Throws: |
56 |
Describe any exceptions thrown |
57 |
*/ |
58 |
ESCRIPT_DLL_API |
59 |
AbstractSystemMatrix(); |
60 |
|
61 |
ESCRIPT_DLL_API |
62 |
AbstractSystemMatrix(const int row_blocksize, |
63 |
const FunctionSpace& row_functionspace, |
64 |
const int column_blocksize, |
65 |
const FunctionSpace& column_functionspace); |
66 |
/** |
67 |
\brief |
68 |
Destructor. |
69 |
*/ |
70 |
ESCRIPT_DLL_API |
71 |
virtual ~AbstractSystemMatrix(); |
72 |
|
73 |
/** |
74 |
\brief |
75 |
matrix*vector multiplication |
76 |
*/ |
77 |
ESCRIPT_DLL_API |
78 |
Data vectorMultiply(Data& right) const; |
79 |
|
80 |
/** |
81 |
\brief |
82 |
returns true if the matrix is empty |
83 |
*/ |
84 |
ESCRIPT_DLL_API |
85 |
int isEmpty() const; |
86 |
|
87 |
/** |
88 |
\brief |
89 |
returns the column function space |
90 |
*/ |
91 |
ESCRIPT_DLL_API |
92 |
inline FunctionSpace getColumnFunctionSpace() const |
93 |
{ |
94 |
if (isEmpty()) |
95 |
throw SystemMatrixException("Error - Matrix is empty."); |
96 |
return m_column_functionspace; |
97 |
} |
98 |
|
99 |
/** |
100 |
\brief |
101 |
returns the row function space |
102 |
*/ |
103 |
ESCRIPT_DLL_API |
104 |
inline FunctionSpace getRowFunctionSpace() const |
105 |
{ |
106 |
if (isEmpty()) |
107 |
throw SystemMatrixException("Error - Matrix is empty."); |
108 |
return m_row_functionspace; |
109 |
} |
110 |
|
111 |
/** |
112 |
\brief |
113 |
returns the row block size |
114 |
*/ |
115 |
ESCRIPT_DLL_API |
116 |
inline int getRowBlockSize() const |
117 |
{ |
118 |
if (isEmpty()) |
119 |
throw SystemMatrixException("Error - Matrix is empty."); |
120 |
return m_row_blocksize; |
121 |
} |
122 |
|
123 |
/** |
124 |
\brief |
125 |
returns the column block size |
126 |
*/ |
127 |
ESCRIPT_DLL_API |
128 |
inline int getColumnBlockSize() const |
129 |
{ |
130 |
if (isEmpty()) |
131 |
throw SystemMatrixException("Error - Matrix is empty."); |
132 |
return m_column_blocksize; |
133 |
} |
134 |
|
135 |
/** |
136 |
\brief |
137 |
returns the solution u of the linear system this*u=in |
138 |
*/ |
139 |
ESCRIPT_DLL_API |
140 |
Data solve(Data& in,const boost::python::dict& options) const; |
141 |
|
142 |
/** |
143 |
\brief writes the matrix to a file using the Matrix Market file format |
144 |
*/ |
145 |
ESCRIPT_DLL_API |
146 |
virtual void saveMM(const std::string& fileName) const; |
147 |
|
148 |
/** |
149 |
\brief writes the matrix to a file using the Harwell-Boeing file format |
150 |
*/ |
151 |
ESCRIPT_DLL_API |
152 |
virtual void saveHB(const std::string& fileName) const; |
153 |
|
154 |
/** |
155 |
\brief resets the matrix entries |
156 |
*/ |
157 |
ESCRIPT_DLL_API |
158 |
virtual void resetValues() const; |
159 |
|
160 |
protected: |
161 |
|
162 |
private: |
163 |
|
164 |
/** |
165 |
\brief |
166 |
solves the linear system this*out=in |
167 |
*/ |
168 |
ESCRIPT_DLL_API |
169 |
virtual void setToSolution(Data& out,Data& in,const boost::python::dict& options) const; |
170 |
|
171 |
/** |
172 |
\brief |
173 |
performs y+=this*x |
174 |
*/ |
175 |
ESCRIPT_DLL_API |
176 |
virtual void ypAx(Data& y,Data& x) const; |
177 |
|
178 |
int m_empty; |
179 |
int m_column_blocksize; |
180 |
int m_row_blocksize; |
181 |
FunctionSpace m_row_functionspace; |
182 |
FunctionSpace m_column_functionspace; |
183 |
|
184 |
|
185 |
}; |
186 |
|
187 |
ESCRIPT_DLL_API Data operator*(const AbstractSystemMatrix& left,const Data& right) ; |
188 |
|
189 |
|
190 |
|
191 |
} // end of namespace |
192 |
#endif |