/[escript]/trunk/pasowrap/src/SystemMatrixAdapter.h
ViewVC logotype

Contents of /trunk/pasowrap/src/SystemMatrixAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4346 - (show annotations)
Tue Apr 2 04:46:45 2013 UTC (6 years, 4 months ago) by jfenwick
File MIME type: text/plain
File size: 4671 byte(s)
Bringing the changes from doubleplusgood branch.
Can't merge directly because svn doesn't transfer changes to renamed files (mutter grumble).
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 #if !defined SystemMatrixAdapter_20040610_H
18 #define SystemMatrixAdapter_20040610_H
19 #include "system_dep.h"
20
21 #include "paso/SystemMatrix.h"
22 #include "paso/Options.h"
23
24 #include "PasoException.h"
25
26 #include "escript/AbstractSystemMatrix.h"
27 #include "escript/Data.h"
28 #include "escript/UtilC.h"
29
30 #include <boost/python/object.hpp>
31 #include <boost/shared_ptr.hpp>
32 #include <boost/python/extract.hpp>
33
34 namespace paso {
35
36 class SystemMatrixAdapter: public escript::AbstractSystemMatrix {
37
38 /**
39 \brief
40 Wrapper for Paso_SystemMatrix.
41
42 Description:
43 Wrapper for Paso_SystemMatrix.
44 */
45
46 public:
47
48 /**
49 /brief
50 Default Constructor for SystemMatrixAdapter.
51 NB: Only throws an exception.
52 */
53 PASOWRAP_DLL_API
54 SystemMatrixAdapter();
55
56 /**
57 /brief
58 Constructor for SystemMatrixAdapter.
59 */
60 PASOWRAP_DLL_API
61 SystemMatrixAdapter(Paso_SystemMatrix* system_matrix,
62 const int row_blocksize,
63 const escript::FunctionSpace& row_functionspace,
64 const int column_blocksize,
65 const escript::FunctionSpace& colum_functionspace);
66
67
68 /**
69 \brief
70 Destructor for SystemMatrixAdapter. As specified in the constructor
71 this deallocates the pointer given to the constructor.
72 */
73 PASOWRAP_DLL_API
74 ~SystemMatrixAdapter();
75
76 /**
77 \brief
78 Returns the pointer to the system matrix.
79 */
80 PASOWRAP_DLL_API
81 Paso_SystemMatrix* getPaso_SystemMatrix() const;
82
83 /**
84 \brief
85 Returns the system matrix as a const AbstractSystemMatrix&.
86 */
87 inline const escript::AbstractSystemMatrix& asAbstractSystemMatrix() const
88 {
89 return dynamic_cast<const escript::AbstractSystemMatrix&>(*this);
90 }
91
92 /**
93 \brief
94 Returns a system matrix as a const SystemMatrixAdapter&.
95 */
96 inline static const SystemMatrixAdapter& asSystemMatrixAdapter(const AbstractSystemMatrix& systemmatrix)
97 {
98 return dynamic_cast<const SystemMatrixAdapter&>(systemmatrix);
99 }
100
101 /**
102 \brief
103 nullifyRowsAndCols - calls Paso_SystemMatrix_nullifyRowsAndCols.
104 */
105 PASOWRAP_DLL_API
106 void nullifyRowsAndCols(escript::Data& row_q, escript::Data& col_q, const double mdv) const;
107
108 /**
109 \brief writes the matrix to a file using the Matrix Market file format
110 */
111 PASOWRAP_DLL_API
112 virtual void saveMM(const std::string& fileName) const;
113
114 /**
115 \brief writes the matrix to a file using the Harwell-Boeing file format
116 */
117 PASOWRAP_DLL_API
118 virtual void saveHB(const std::string& fileName) const;
119
120 /**
121 \brief sets the matrix entries to zero
122 */
123 PASOWRAP_DLL_API
124 virtual void resetValues() const;
125
126 /**
127 \brief maps escript options onto Paso options
128 */
129 PASOWRAP_DLL_API
130 static int mapOptionToPaso(const int option);
131
132 /**
133 \brief returns the identifier of the matrix type to be used for the global
134 stiffness matrix when the given solver, preconditioner and package is
135 used
136 */
137 PASOWRAP_DLL_API
138 static int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry, Esys_MPIInfo* mpiInfo);
139
140 /**
141 \brief extract paso options from SolutionOptions class
142 */
143
144 PASOWRAP_DLL_API
145 static void escriptToPasoOptions(Paso_Options* paso_options, const boost::python::object& options);
146
147 /**
148 \brief copies diagnostic data back to the solver options
149 */
150
151 PASOWRAP_DLL_API
152 static void pasoToEscriptOptions(const Paso_Options* paso_options, boost::python::object& options);
153
154 /**
155 \brief prints information about a system matrix
156 */
157 PASOWRAP_DLL_API
158 void Print_Matrix_Info(const bool) const;
159
160 protected:
161
162 private:
163
164 /**
165 \brief
166 solves the linear system this*out=in
167 */
168 PASOWRAP_DLL_API
169 virtual void setToSolution(escript::Data& out, escript::Data& in, boost::python::object& options) const;
170
171 /**
172 \brief
173 performs y+=this*x
174 */
175 PASOWRAP_DLL_API
176 virtual void ypAx(escript::Data& y, escript::Data& x) const;
177
178 //
179 // pointer to the externally created system_matrix.
180 //
181 boost::shared_ptr<Paso_SystemMatrix> m_system_matrix;
182
183 };
184
185 } // end of namespace
186 #endif

  ViewVC Help
Powered by ViewVC 1.1.26