escript  Revision_
AbstractSystemMatrix.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 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-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 #ifndef __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
19 #define __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
20 
21 #include "system_dep.h"
22 #include "FunctionSpace.h"
23 #include "Pointers.h"
24 #include "SystemMatrixException.h"
25 
26 #include <boost/python/object.hpp>
27 
28 namespace escript {
29 
30 //
31 // Forward declaration
32 class AbstractSystemMatrix;
33 class Data;
34 
37 
38 
43 class ESCRIPT_DLL_API AbstractSystemMatrix: public REFCOUNT_BASE_CLASS(AbstractSystemMatrix)
44 {
45 public:
46 
51  AbstractSystemMatrix() : m_empty(true) {}
52 
53  AbstractSystemMatrix(int row_blocksize,
54  const FunctionSpace& row_functionspace,
55  int column_blocksize,
56  const FunctionSpace& column_functionspace);
57 
62  virtual ~AbstractSystemMatrix() {}
63 
68  ASM_ptr getPtr();
69 
74  const_ASM_ptr getPtr() const;
75 
80  Data vectorMultiply(const Data& right) const;
81 
86  bool isEmpty() const { return m_empty; }
87 
93  {
94  if (isEmpty())
95  throw SystemMatrixException("Error - Matrix is empty.");
96  return m_column_functionspace;
97  }
98 
104  {
105  if (isEmpty())
106  throw SystemMatrixException("Error - Matrix is empty.");
107  return m_row_functionspace;
108  }
109 
114  inline int getRowBlockSize() const
115  {
116  if (isEmpty())
117  throw SystemMatrixException("Error - Matrix is empty.");
118  return m_row_blocksize;
119  }
120 
125  inline int getColumnBlockSize() const
126  {
127  if (isEmpty())
128  throw SystemMatrixException("Error - Matrix is empty.");
129  return m_column_blocksize;
130  }
131 
136  Data solve(const Data& in, boost::python::object& options) const;
137 
145  virtual void nullifyRowsAndCols(Data& row_q, Data& col_q, double mdv);
146 
147 
151  virtual void saveMM(const std::string& filename) const;
152 
156  virtual void saveHB(const std::string& filename) const;
157 
161  virtual void resetValues(bool preserveSolverData = false);
162 
163 private:
164 
169  virtual void setToSolution(Data& out, Data& in,
170  boost::python::object& options) const;
171 
176  virtual void ypAx(Data& y, Data& x) const;
177 
178  bool m_empty;
183 };
184 
186 Data operator*(const AbstractSystemMatrix& left, const Data& right);
187 
188 } // end of namespace
189 
190 #endif // __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
191 
Typedefs and macros for reference counted storage.
#define POINTER_WRAPPER_CLASS(x)
Definition: Pointers.h:33
#define REFCOUNT_BASE_CLASS(x)
Definition: Pointers.h:31
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:44
bool isEmpty() const
returns true if the matrix is empty
Definition: AbstractSystemMatrix.h:86
FunctionSpace getRowFunctionSpace() const
returns the row function space
Definition: AbstractSystemMatrix.h:103
virtual ~AbstractSystemMatrix()
Destructor.
Definition: AbstractSystemMatrix.h:62
int m_column_blocksize
Definition: AbstractSystemMatrix.h:179
int getColumnBlockSize() const
returns the column block size
Definition: AbstractSystemMatrix.h:125
int getRowBlockSize() const
returns the row block size
Definition: AbstractSystemMatrix.h:114
FunctionSpace m_row_functionspace
Definition: AbstractSystemMatrix.h:181
bool m_empty
Definition: AbstractSystemMatrix.h:178
AbstractSystemMatrix()
Default constructor for AbstractSystemMatrix.
Definition: AbstractSystemMatrix.h:51
FunctionSpace getColumnFunctionSpace() const
returns the column function space
Definition: AbstractSystemMatrix.h:92
FunctionSpace m_column_functionspace
Definition: AbstractSystemMatrix.h:182
int m_row_blocksize
Definition: AbstractSystemMatrix.h:180
Data represents a collection of datapoints.
Definition: Data.h:64
Definition: FunctionSpace.h:36
SystemMatrixException exception class.
Definition: SystemMatrixException.h:36
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
Definition: AbstractContinuousDomain.cpp:23
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition: AbstractSystemMatrix.cpp:60
boost::shared_ptr< AbstractSystemMatrix > ASM_ptr
Definition: AbstractSystemMatrix.h:33
boost::shared_ptr< const AbstractSystemMatrix > const_ASM_ptr
Definition: AbstractSystemMatrix.h:36