1 |
// $Id$ |
2 |
/* |
3 |
****************************************************************************** |
4 |
* * |
5 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
6 |
* * |
7 |
* This software is the property of ACcESS. No part of this code * |
8 |
* may be copied in any form or by any means without the expressed written * |
9 |
* consent of ACcESS. Copying, use or modification of this software * |
10 |
* by any unauthorised person is illegal unless that person has a software * |
11 |
* license agreement with ACcESS. * |
12 |
* * |
13 |
****************************************************************************** |
14 |
*/ |
15 |
|
16 |
#if !defined finley_SystemMatrixAdapter_20040610_H |
17 |
#define finley_SystemMatrixAdapter_20040610_H |
18 |
|
19 |
#ifdef MSVC |
20 |
#ifdef FINLEY_EXPORTS |
21 |
#define FINLEY_DLL __declspec(dllexport) |
22 |
#else |
23 |
#define FINLEY_DLL __declspec(dllimport) |
24 |
#endif |
25 |
#else |
26 |
#define FINLEY_DLL |
27 |
#endif |
28 |
#include "finley/CPPAdapter/SystemMatrixAdapter.h" |
29 |
#include "escript/Data/AbstractSystemMatrix.h" |
30 |
#include "escript/Data/Data.h" |
31 |
extern "C" { |
32 |
#include "paso/SystemMatrix.h" |
33 |
} |
34 |
#include <boost/python/dict.hpp> |
35 |
#include <boost/shared_ptr.hpp> |
36 |
|
37 |
namespace finley { |
38 |
|
39 |
class FINLEY_DLL SystemMatrixAdapter:public escript::AbstractSystemMatrix { |
40 |
|
41 |
/** |
42 |
\brief |
43 |
Wrapper for Paso_SystemMatrix. |
44 |
|
45 |
Description: |
46 |
Wrapper for Paso_SystemMatrix. |
47 |
*/ |
48 |
|
49 |
public: |
50 |
|
51 |
/** |
52 |
/brief |
53 |
Default Constructor for SystemMatrixAdapter. |
54 |
NB: Only throws an exception. |
55 |
*/ |
56 |
SystemMatrixAdapter(); |
57 |
|
58 |
/** |
59 |
/brief |
60 |
Constructor for SystemMatrixAdapter. |
61 |
*/ |
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 |
~SystemMatrixAdapter(); |
75 |
|
76 |
/** |
77 |
\brief |
78 |
Returns the pointer to the system matrix. |
79 |
*/ |
80 |
Paso_SystemMatrix* getPaso_SystemMatrix() const; |
81 |
|
82 |
/** |
83 |
\brief |
84 |
Returns the system matrix as a const AbstractSystemMatrix&. |
85 |
*/ |
86 |
inline const escript::AbstractSystemMatrix& asAbstractSystemMatrix() const |
87 |
{ |
88 |
return dynamic_cast<const escript::AbstractSystemMatrix&>(*this); |
89 |
} |
90 |
|
91 |
/** |
92 |
\brief |
93 |
Returns a system matrix as a const SystemMatrixAdapter&. |
94 |
*/ |
95 |
inline static const SystemMatrixAdapter& asSystemMatrixAdapter(const AbstractSystemMatrix& systemmatrix) |
96 |
{ |
97 |
return dynamic_cast<const SystemMatrixAdapter&>(systemmatrix); |
98 |
} |
99 |
|
100 |
/** |
101 |
\brief |
102 |
nullifyRowsAndCols - calls Paso_SystemMatrix_nullifyRowsAndCols. |
103 |
*/ |
104 |
void nullifyRowsAndCols(escript::Data& row_q, escript::Data& col_q, const double mdv) const; |
105 |
|
106 |
/** |
107 |
\brief writes the matrix to a file using the Matrix Market file format |
108 |
*/ |
109 |
virtual void saveMM(const std::string& fileName) const; |
110 |
|
111 |
/** |
112 |
\brief writes the matrix to a file using the Harwell-Boeing file format |
113 |
*/ |
114 |
virtual void saveHB(const std::string& fileName) const; |
115 |
|
116 |
/** |
117 |
\brief sets the matrix entries to zero |
118 |
*/ |
119 |
virtual void resetValues() const; |
120 |
|
121 |
/** |
122 |
\brief maps escript options onto Paso options: |
123 |
*/ |
124 |
static int mapOptionToPaso(const int option); |
125 |
|
126 |
protected: |
127 |
|
128 |
private: |
129 |
|
130 |
/** |
131 |
\brief |
132 |
solves the linear system this*out=in |
133 |
*/ |
134 |
virtual void setToSolution(escript::Data& out, escript::Data& in, const boost::python::dict& options) const; |
135 |
|
136 |
/** |
137 |
\brief |
138 |
performs y+=this*x |
139 |
*/ |
140 |
virtual void ypAx(escript::Data& y, escript::Data& x) const; |
141 |
|
142 |
// |
143 |
// pointer to the externally created finley mesh - system_matrix. |
144 |
// |
145 |
boost::shared_ptr<Paso_SystemMatrix> m_system_matrix; |
146 |
|
147 |
}; |
148 |
|
149 |
} // end of namespace |
150 |
#endif |