escript  Revision_
AbstractSystemMatrix.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2018 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 
34 typedef POINTER_WRAPPER_CLASS(AbstractSystemMatrix) ASM_ptr;
35 typedef POINTER_WRAPPER_CLASS(const AbstractSystemMatrix) const_ASM_ptr;
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 
91  inline FunctionSpace getColumnFunctionSpace() const
92  {
93  if (isEmpty())
94  throw SystemMatrixException("Error - Matrix is empty.");
95  return m_column_functionspace;
96  }
97 
102  inline FunctionSpace getRowFunctionSpace() const
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;
178  int m_column_blocksize;
179  int m_row_blocksize;
180  FunctionSpace m_row_functionspace;
181  FunctionSpace m_column_functionspace;
182 };
183 
185 Data operator*(const AbstractSystemMatrix& left, const Data& right);
186 
187 } // end of namespace
188 
189 #endif // __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
190 
escript::AbstractSystemMatrix::saveMM
virtual void saveMM(const std::string &filename) const
writes the matrix to a file using the Matrix Market file format
Definition: AbstractSystemMatrix.cpp:130
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:28
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1163
POINTER_WRAPPER_CLASS
#define POINTER_WRAPPER_CLASS(x)
Definition: Pointers.h:31
escript::AbstractSystemMatrix::isEmpty
bool isEmpty() const
returns true if the matrix is empty
Definition: AbstractSystemMatrix.h:96
escript::AbstractSystemMatrix::saveHB
virtual void saveHB(const std::string &filename) const
writes the matrix to a file using the Harwell-Boeing file format
Definition: AbstractSystemMatrix.cpp:135
escript::AbstractSystemMatrix::AbstractSystemMatrix
AbstractSystemMatrix()
Default constructor for AbstractSystemMatrix.
Definition: AbstractSystemMatrix.h:61
escript::AbstractSystemMatrix::setToSolution
virtual void setToSolution(Data &out, Data &in, boost::python::object &options) const
solves the linear system this*out=in
Definition: AbstractSystemMatrix.cpp:117
escript::const_ASM_ptr
boost::shared_ptr< const AbstractSystemMatrix > const_ASM_ptr
Definition: AbstractSystemMatrix.h:46
escript::AbstractSystemMatrix::vectorMultiply
Data vectorMultiply(const Data &right) const
returns the matrix-vector product this*right
Definition: AbstractSystemMatrix.cpp:75
escript::AbstractSystemMatrix::getColumnFunctionSpace
FunctionSpace getColumnFunctionSpace() const
returns the column function space
Definition: AbstractSystemMatrix.h:102
escript::Data::getDataPointSize
int getDataPointSize() const
Return the size of the data point. It is the product of the data point shape dimensions.
Definition: Data.cpp:1363
escript::FunctionSpace
Definition: FunctionSpace.h:45
REFCOUNT_BASE_CLASS
#define REFCOUNT_BASE_CLASS(x)
Definition: Pointers.h:29
system_dep.h
escript::AbstractSystemMatrix::resetValues
virtual void resetValues(bool preserveSolverData=false)
resets the matrix entries
Definition: AbstractSystemMatrix.cpp:140
escript::AbstractSystemMatrix::nullifyRowsAndCols
virtual void nullifyRowsAndCols(Data &row_q, Data &col_q, double mdv)
sets matrix entries to zero in specified rows and columns. The rows and columns are marked by positiv...
Definition: AbstractSystemMatrix.cpp:123
Pointers.h
Typedefs and macros for reference counted storage.
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:62
escript::DataException
Definition: DataException.h:37
escript::AbstractSystemMatrix::getPtr
ASM_ptr getPtr()
Returns smart pointer which is managing this object. If one does not exist yet it creates one.
Definition: AbstractSystemMatrix.cpp:52
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:65
escript::AbstractSystemMatrix
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:53
escript::AbstractSystemMatrix::solve
Data solve(const Data &in, boost::python::object &options) const
returns the solution u of the linear system this*u=in
Definition: AbstractSystemMatrix.cpp:99
escript::SystemMatrixException
SystemMatrixException exception class.
Definition: SystemMatrixException.h:45
SystemMatrixException.h
escript::operator*
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition: AbstractSystemMatrix.cpp:70
escript::AbstractSystemMatrix::ypAx
virtual void ypAx(Data &y, Data &x) const
performs y+=this*x
Definition: AbstractSystemMatrix.cpp:94
escript
Definition: AbstractContinuousDomain.cpp:22
DataTypes.h
escript::AbstractSystemMatrix::getRowFunctionSpace
FunctionSpace getRowFunctionSpace() const
returns the row function space
Definition: AbstractSystemMatrix.h:113
AbstractSystemMatrix.h
Data.h
escript::ASM_ptr
boost::shared_ptr< AbstractSystemMatrix > ASM_ptr
Definition: AbstractSystemMatrix.h:43
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:76
escript::AbstractSystemMatrix::getRowBlockSize
int getRowBlockSize() const
returns the row block size
Definition: AbstractSystemMatrix.h:124
escript::AbstractSystemMatrix::getColumnBlockSize
int getColumnBlockSize() const
returns the column block size
Definition: AbstractSystemMatrix.h:135
DataException.h
FunctionSpace.h