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 
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:120
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1160
escript::AbstractSystemMatrix::m_column_functionspace
FunctionSpace m_column_functionspace
Definition: AbstractSystemMatrix.h:182
POINTER_WRAPPER_CLASS
#define POINTER_WRAPPER_CLASS(x)
Definition: Pointers.h:33
escript::AbstractSystemMatrix::isEmpty
bool isEmpty() const
returns true if the matrix is empty
Definition: AbstractSystemMatrix.h:86
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:125
escript::AbstractSystemMatrix::AbstractSystemMatrix
AbstractSystemMatrix()
Default constructor for AbstractSystemMatrix.
Definition: AbstractSystemMatrix.h:51
escript::AbstractSystemMatrix::m_column_blocksize
int m_column_blocksize
Definition: AbstractSystemMatrix.h:179
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:107
escript::const_ASM_ptr
boost::shared_ptr< const AbstractSystemMatrix > const_ASM_ptr
Definition: AbstractSystemMatrix.h:36
escript::AbstractSystemMatrix::vectorMultiply
Data vectorMultiply(const Data &right) const
returns the matrix-vector product this*right
Definition: AbstractSystemMatrix.cpp:65
escript::AbstractSystemMatrix::getColumnFunctionSpace
FunctionSpace getColumnFunctionSpace() const
returns the column function space
Definition: AbstractSystemMatrix.h:92
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:1360
escript::FunctionSpace
Definition: FunctionSpace.h:36
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
REFCOUNT_BASE_CLASS
#define REFCOUNT_BASE_CLASS(x)
Definition: Pointers.h:31
escript::AbstractSystemMatrix::resetValues
virtual void resetValues(bool preserveSolverData=false)
resets the matrix entries
Definition: AbstractSystemMatrix.cpp:130
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:113
escript::AbstractSystemMatrix::~AbstractSystemMatrix
virtual ~AbstractSystemMatrix()
Destructor.
Definition: AbstractSystemMatrix.h:62
Pointers.h
Typedefs and macros for reference counted storage.
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
escript::DataException
Definition: DataException.h:28
escript::AbstractSystemMatrix::m_row_functionspace
FunctionSpace m_row_functionspace
Definition: AbstractSystemMatrix.h:181
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:42
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:44
escript::AbstractSystemMatrix
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:44
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:89
escript::SystemMatrixException
SystemMatrixException exception class.
Definition: SystemMatrixException.h:36
SystemMatrixException.h
escript::operator*
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition: AbstractSystemMatrix.cpp:60
escript::AbstractSystemMatrix::m_row_blocksize
int m_row_blocksize
Definition: AbstractSystemMatrix.h:180
escript::AbstractSystemMatrix::ypAx
virtual void ypAx(Data &y, Data &x) const
performs y+=this*x
Definition: AbstractSystemMatrix.cpp:84
escript
Definition: AbstractContinuousDomain.cpp:23
DataTypes.h
escript::AbstractSystemMatrix::getRowFunctionSpace
FunctionSpace getRowFunctionSpace() const
returns the row function space
Definition: AbstractSystemMatrix.h:103
AbstractSystemMatrix.h
Data.h
escript::ASM_ptr
boost::shared_ptr< AbstractSystemMatrix > ASM_ptr
Definition: AbstractSystemMatrix.h:33
system_dep.h
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:55
escript::AbstractSystemMatrix::getRowBlockSize
int getRowBlockSize() const
returns the row block size
Definition: AbstractSystemMatrix.h:114
escript::AbstractSystemMatrix::getColumnBlockSize
int getColumnBlockSize() const
returns the column block size
Definition: AbstractSystemMatrix.h:125
escript::AbstractSystemMatrix::m_empty
bool m_empty
Definition: AbstractSystemMatrix.h:178
DataException.h
FunctionSpace.h