escript  Revision_
AbstractSystemMatrix.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
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 #ifndef __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
18 #define __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
19 
20 #include "system_dep.h"
21 #include "FunctionSpace.h"
22 #include "Pointers.h"
23 #include "SystemMatrixException.h"
24 
25 #include <boost/python/object.hpp>
26 
27 namespace escript {
28 
29 //
30 // Forward declaration
31 class AbstractSystemMatrix;
32 class Data;
33 
36 
37 
42 class ESCRIPT_DLL_API AbstractSystemMatrix: public REFCOUNT_BASE_CLASS(AbstractSystemMatrix)
43 {
44 public:
45 
50  AbstractSystemMatrix() : m_empty(true) {}
51 
52  AbstractSystemMatrix(int row_blocksize,
53  const FunctionSpace& row_functionspace,
54  int column_blocksize,
55  const FunctionSpace& column_functionspace);
56 
61  virtual ~AbstractSystemMatrix() {}
62 
67  ASM_ptr getPtr();
68 
73  const_ASM_ptr getPtr() const;
74 
79  Data vectorMultiply(const Data& right) const;
80 
85  bool isEmpty() const { return m_empty; }
86 
92  {
93  if (isEmpty())
94  throw SystemMatrixException("Error - Matrix is empty.");
95  return m_column_functionspace;
96  }
97 
103  {
104  if (isEmpty())
105  throw SystemMatrixException("Error - Matrix is empty.");
106  return m_row_functionspace;
107  }
108 
113  inline int getRowBlockSize() const
114  {
115  if (isEmpty())
116  throw SystemMatrixException("Error - Matrix is empty.");
117  return m_row_blocksize;
118  }
119 
124  inline int getColumnBlockSize() const
125  {
126  if (isEmpty())
127  throw SystemMatrixException("Error - Matrix is empty.");
128  return m_column_blocksize;
129  }
130 
135  Data solve(const Data& in, boost::python::object& options) const;
136 
144  virtual void nullifyRowsAndCols(Data& row_q, Data& col_q, double mdv);
145 
146 
150  virtual void saveMM(const std::string& filename) const;
151 
155  virtual void saveHB(const std::string& filename) const;
156 
160  virtual void resetValues(bool preserveSolverData = false);
161 
162 private:
163 
168  virtual void setToSolution(Data& out, Data& in,
169  boost::python::object& options) const;
170 
175  virtual void ypAx(Data& y, Data& x) const;
176 
177  bool m_empty;
182 };
183 
185 Data operator*(const AbstractSystemMatrix& left, const Data& right);
186 
187 } // end of namespace
188 
189 #endif // __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
190 
Definition: FunctionSpace.h:34
#define POINTER_WRAPPER_CLASS(x)
Definition: Pointers.h:32
int m_column_blocksize
Definition: AbstractSystemMatrix.h:178
Definition: AbstractContinuousDomain.cpp:22
bool isEmpty() const
returns true if the matrix is empty
Definition: AbstractSystemMatrix.h:85
#define REFCOUNT_BASE_CLASS(x)
Definition: Pointers.h:30
boost::shared_ptr< const AbstractSystemMatrix > const_ASM_ptr
Definition: AbstractSystemMatrix.h:35
SystemMatrixException exception class.
Definition: SystemMatrixException.h:34
FunctionSpace m_column_functionspace
Definition: AbstractSystemMatrix.h:181
bool m_empty
Definition: AbstractSystemMatrix.h:177
Typedefs and macros for reference counted storage.
AbstractSystemMatrix()
Default constructor for AbstractSystemMatrix.
Definition: AbstractSystemMatrix.h:50
int m_row_blocksize
Definition: AbstractSystemMatrix.h:179
Data represents a collection of datapoints.
Definition: Data.h:63
virtual ~AbstractSystemMatrix()
Destructor.
Definition: AbstractSystemMatrix.h:61
FunctionSpace getRowFunctionSpace() const
returns the row function space
Definition: AbstractSystemMatrix.h:102
FunctionSpace m_row_functionspace
Definition: AbstractSystemMatrix.h:180
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition: AbstractSystemMatrix.cpp:59
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:42
int getRowBlockSize() const
returns the row block size
Definition: AbstractSystemMatrix.h:113
boost::shared_ptr< AbstractSystemMatrix > ASM_ptr
Definition: AbstractSystemMatrix.h:32
FunctionSpace getColumnFunctionSpace() const
returns the column function space
Definition: AbstractSystemMatrix.h:91
int getColumnBlockSize() const
returns the column block size
Definition: AbstractSystemMatrix.h:124