1 |
jgs |
97 |
// $Id$ |
2 |
jgs |
82 |
/* |
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 |
|
|
#include "finley/CPPAdapter/SystemMatrixAdapter.h" |
20 |
|
|
#include "escript/Data/AbstractSystemMatrix.h" |
21 |
|
|
#include "escript/Data/Data.h" |
22 |
|
|
extern "C" { |
23 |
|
|
#include "finley/finleyC/System.h" |
24 |
|
|
} |
25 |
|
|
#include <boost/python/dict.hpp> |
26 |
|
|
#include <boost/shared_ptr.hpp> |
27 |
|
|
|
28 |
|
|
namespace finley { |
29 |
|
|
|
30 |
|
|
class SystemMatrixAdapter:public escript::AbstractSystemMatrix { |
31 |
|
|
|
32 |
|
|
/** |
33 |
|
|
\brief |
34 |
|
|
Wrapper for Finley_SystemMatrix. |
35 |
|
|
|
36 |
|
|
Description: |
37 |
|
|
Wrapper for Finley_SystemMatrix. |
38 |
|
|
*/ |
39 |
|
|
|
40 |
|
|
public: |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
/brief |
44 |
|
|
Default Constructor for SystemMatrixAdapter. |
45 |
|
|
NB: Only throws an exception. |
46 |
|
|
*/ |
47 |
|
|
SystemMatrixAdapter(); |
48 |
|
|
|
49 |
|
|
/** |
50 |
|
|
/brief |
51 |
|
|
Constructor for SystemMatrixAdapter. |
52 |
|
|
*/ |
53 |
jgs |
97 |
SystemMatrixAdapter(Finley_SystemMatrix* system_matrix, |
54 |
jgs |
82 |
const int row_blocksize, |
55 |
|
|
const escript::FunctionSpace& row_functionspace, |
56 |
|
|
const int column_blocksize, |
57 |
|
|
const escript::FunctionSpace& colum_functionspace); |
58 |
|
|
|
59 |
jgs |
97 |
|
60 |
jgs |
82 |
/** |
61 |
|
|
\brief |
62 |
|
|
Destructor for SystemMatrixAdapter. As specified in the constructor |
63 |
|
|
this deallocates the pointer given to the constructor. |
64 |
|
|
*/ |
65 |
|
|
~SystemMatrixAdapter(); |
66 |
|
|
|
67 |
|
|
/** |
68 |
|
|
\brief |
69 |
|
|
Returns the pointer to the system matrix. |
70 |
|
|
*/ |
71 |
|
|
Finley_SystemMatrix* getFinley_SystemMatrix() const; |
72 |
|
|
|
73 |
|
|
/** |
74 |
|
|
\brief |
75 |
|
|
Returns the system matrix as a const AbstractSystemMatrix&. |
76 |
|
|
*/ |
77 |
|
|
inline const escript::AbstractSystemMatrix& asAbstractSystemMatrix() const |
78 |
|
|
{ |
79 |
|
|
return dynamic_cast<const escript::AbstractSystemMatrix&>(*this); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
/** |
83 |
|
|
\brief |
84 |
|
|
Returns a system matrix as a const SystemMatrixAdapter&. |
85 |
|
|
*/ |
86 |
|
|
inline static const SystemMatrixAdapter& asSystemMatrixAdapter(const AbstractSystemMatrix& systemmatrix) |
87 |
|
|
{ |
88 |
|
|
return dynamic_cast<const SystemMatrixAdapter&>(systemmatrix); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
/** |
92 |
|
|
\brief |
93 |
|
|
nullifyRowsAndCols - calls Finley_SystemMatrix_nullifyRowsAndCols. |
94 |
|
|
*/ |
95 |
|
|
void nullifyRowsAndCols(const escript::Data& row_q, const escript::Data& col_q, const double mdv) const; |
96 |
|
|
|
97 |
jgs |
97 |
/** |
98 |
|
|
\brief writes the matrix to a file using the Matrix Market file format |
99 |
|
|
*/ |
100 |
|
|
virtual void saveMM(const std::string& fileName) const; |
101 |
|
|
|
102 |
|
|
/** |
103 |
|
|
\brief sets the matrix entries to value |
104 |
|
|
*/ |
105 |
|
|
virtual void setValue(const double value) const; |
106 |
|
|
|
107 |
|
|
|
108 |
jgs |
82 |
protected: |
109 |
|
|
|
110 |
|
|
private: |
111 |
|
|
|
112 |
|
|
/** |
113 |
|
|
\brief |
114 |
|
|
solves the linear system this*out=in |
115 |
|
|
*/ |
116 |
|
|
virtual void setToSolution(escript::Data& out, const escript::Data& in, const boost::python::dict& options) const; |
117 |
|
|
|
118 |
|
|
/** |
119 |
|
|
\brief |
120 |
|
|
performs y+=this*x |
121 |
|
|
*/ |
122 |
|
|
virtual void ypAx(escript::Data& y, const escript::Data& x) const; |
123 |
|
|
|
124 |
|
|
// |
125 |
|
|
// pointer to the externally created finley mesh - system_matrix. |
126 |
|
|
// |
127 |
|
|
boost::shared_ptr<Finley_SystemMatrix> m_system_matrix; |
128 |
|
|
|
129 |
|
|
}; |
130 |
|
|
|
131 |
|
|
} // end of namespace |
132 |
|
|
#endif |