1 |
/* |
2 |
****************************************************************************** |
3 |
* * |
4 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
5 |
* * |
6 |
* This software is the property of ACcESS. No part of this code * |
7 |
* may be copied in any form or by any means without the expressed written * |
8 |
* consent of ACcESS. Copying, use or modification of this software * |
9 |
* by any unauthorised person is illegal unless that person has a software * |
10 |
* license agreement with ACcESS. * |
11 |
* * |
12 |
****************************************************************************** |
13 |
*/ |
14 |
|
15 |
#if !defined finley_SystemMatrixAdapter_20040610_H |
16 |
#define finley_SystemMatrixAdapter_20040610_H |
17 |
|
18 |
#include "finley/CPPAdapter/SystemMatrixAdapter.h" |
19 |
#include "escript/Data/AbstractSystemMatrix.h" |
20 |
#include "escript/Data/Data.h" |
21 |
extern "C" { |
22 |
#include "finley/finleyC/System.h" |
23 |
} |
24 |
#include <boost/python/dict.hpp> |
25 |
#include <boost/shared_ptr.hpp> |
26 |
|
27 |
namespace finley { |
28 |
|
29 |
class SystemMatrixAdapter:public escript::AbstractSystemMatrix { |
30 |
|
31 |
/** |
32 |
\brief |
33 |
Wrapper for Finley_SystemMatrix. |
34 |
|
35 |
Description: |
36 |
Wrapper for Finley_SystemMatrix. |
37 |
*/ |
38 |
|
39 |
public: |
40 |
|
41 |
/** |
42 |
/brief |
43 |
Default Constructor for SystemMatrixAdapter. |
44 |
NB: Only throws an exception. |
45 |
*/ |
46 |
SystemMatrixAdapter(); |
47 |
|
48 |
/** |
49 |
/brief |
50 |
Constructor for SystemMatrixAdapter. |
51 |
*/ |
52 |
SystemMatrixAdapter(const Finley_SystemMatrix* system_matrix, |
53 |
const int row_blocksize, |
54 |
const escript::FunctionSpace& row_functionspace, |
55 |
const int column_blocksize, |
56 |
const escript::FunctionSpace& colum_functionspace); |
57 |
|
58 |
/** |
59 |
\brief |
60 |
Destructor for SystemMatrixAdapter. As specified in the constructor |
61 |
this deallocates the pointer given to the constructor. |
62 |
*/ |
63 |
~SystemMatrixAdapter(); |
64 |
|
65 |
/** |
66 |
\brief |
67 |
Returns the pointer to the system matrix. |
68 |
*/ |
69 |
Finley_SystemMatrix* getFinley_SystemMatrix() const; |
70 |
|
71 |
/** |
72 |
\brief |
73 |
Returns the system matrix as a const AbstractSystemMatrix&. |
74 |
*/ |
75 |
inline const escript::AbstractSystemMatrix& asAbstractSystemMatrix() const |
76 |
{ |
77 |
return dynamic_cast<const escript::AbstractSystemMatrix&>(*this); |
78 |
} |
79 |
|
80 |
/** |
81 |
\brief |
82 |
Returns a system matrix as a const SystemMatrixAdapter&. |
83 |
*/ |
84 |
inline static const SystemMatrixAdapter& asSystemMatrixAdapter(const AbstractSystemMatrix& systemmatrix) |
85 |
{ |
86 |
return dynamic_cast<const SystemMatrixAdapter&>(systemmatrix); |
87 |
} |
88 |
|
89 |
/** |
90 |
\brief |
91 |
nullifyRowsAndCols - calls Finley_SystemMatrix_nullifyRowsAndCols. |
92 |
*/ |
93 |
void nullifyRowsAndCols(const escript::Data& row_q, const escript::Data& col_q, const double mdv) const; |
94 |
|
95 |
protected: |
96 |
|
97 |
private: |
98 |
|
99 |
/** |
100 |
\brief |
101 |
solves the linear system this*out=in |
102 |
*/ |
103 |
virtual void setToSolution(escript::Data& out, const escript::Data& in, const boost::python::dict& options) const; |
104 |
|
105 |
/** |
106 |
\brief |
107 |
performs y+=this*x |
108 |
*/ |
109 |
virtual void ypAx(escript::Data& y, const escript::Data& x) const; |
110 |
|
111 |
// |
112 |
// pointer to the externally created finley mesh - system_matrix. |
113 |
// |
114 |
boost::shared_ptr<Finley_SystemMatrix> m_system_matrix; |
115 |
|
116 |
}; |
117 |
|
118 |
} // end of namespace |
119 |
#endif |