/[escript]/release/3.4.2/pasowrap/src/SystemMatrixAdapter.h
ViewVC logotype

Contents of /release/3.4.2/pasowrap/src/SystemMatrixAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4919 - (show annotations)
Wed Apr 30 06:25:55 2014 UTC (6 years ago) by jfenwick
File MIME type: text/plain
File size: 4433 byte(s)
Because we've got to!

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 #if !defined SystemMatrixAdapter_20040610_H
19 #define SystemMatrixAdapter_20040610_H
20 #include "system_dep.h"
21
22 #include "paso/SystemMatrix.h"
23 #include "paso/Options.h"
24
25 #include "PasoException.h"
26
27 #include "escript/AbstractSystemMatrix.h"
28 #include "escript/Data.h"
29 #include "escript/UtilC.h"
30
31 #include <boost/python/object.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/python/extract.hpp>
34
35 namespace paso {
36
37 PASOWRAP_DLL_API
38 class SystemMatrixAdapter: public escript::AbstractSystemMatrix
39 {
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(SystemMatrix_ptr 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 SystemMatrix_ptr 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 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 /**
127 \brief returns the identifier of the matrix type to be used for the global
128 stiffness matrix when the given solver, preconditioner and package is
129 used
130 */
131 static int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry, Esys_MPIInfo* mpiInfo);
132
133 /**
134 \brief extract paso options from SolutionOptions class
135 */
136
137 static void escriptToPasoOptions(Options* paso_options, const boost::python::object& options);
138
139 /**
140 \brief copies diagnostic data back to the solver options
141 */
142
143 static void pasoToEscriptOptions(const Options* paso_options, boost::python::object& options);
144
145 /**
146 \brief prints information about a system matrix
147 */
148 void Print_Matrix_Info(const bool) const;
149
150 protected:
151
152 private:
153
154 /**
155 \brief
156 solves the linear system this*out=in
157 */
158 virtual void setToSolution(escript::Data& out, escript::Data& in, boost::python::object& options) const;
159
160 /**
161 \brief
162 performs y+=this*x
163 */
164 virtual void ypAx(escript::Data& y, escript::Data& x) const;
165
166 //
167 // pointer to the externally created system_matrix.
168 //
169 SystemMatrix_ptr m_system_matrix;
170
171 };
172
173 } // end of namespace
174 #endif

  ViewVC Help
Powered by ViewVC 1.1.26