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 
18 #ifndef __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
19 #define __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
20 
21 #include "system_dep.h"
22 #include "FunctionSpace.h"
23 #include "SystemMatrixException.h"
24 #include <boost/python/object.hpp>
25 
26 
27 namespace escript {
28 
29 //
30 // Forward declaration
31 class Data;
32 
38 {
39 public:
40 
45  AbstractSystemMatrix() : m_empty(true) {}
46 
47  AbstractSystemMatrix(int row_blocksize,
48  const FunctionSpace& row_functionspace,
49  int column_blocksize,
50  const FunctionSpace& column_functionspace);
51 
56  virtual ~AbstractSystemMatrix() {}
57 
62  Data vectorMultiply(const Data& right) const;
63 
68  bool isEmpty() const { return m_empty; }
69 
75  {
76  if (isEmpty())
77  throw SystemMatrixException("Error - Matrix is empty.");
78  return m_column_functionspace;
79  }
80 
86  {
87  if (isEmpty())
88  throw SystemMatrixException("Error - Matrix is empty.");
89  return m_row_functionspace;
90  }
91 
96  inline int getRowBlockSize() const
97  {
98  if (isEmpty())
99  throw SystemMatrixException("Error - Matrix is empty.");
100  return m_row_blocksize;
101  }
102 
107  inline int getColumnBlockSize() const
108  {
109  if (isEmpty())
110  throw SystemMatrixException("Error - Matrix is empty.");
111  return m_column_blocksize;
112  }
113 
118  Data solve(const Data& in, boost::python::object& options) const;
119 
127  virtual void nullifyRowsAndCols(Data& row_q, Data& col_q, double mdv);
128 
129 
133  virtual void saveMM(const std::string& filename) const;
134 
138  virtual void saveHB(const std::string& filename) const;
139 
143  virtual void resetValues();
144 
145 private:
146 
151  virtual void setToSolution(Data& out, Data& in,
152  boost::python::object& options) const;
153 
158  virtual void ypAx(Data& y, Data& x) const;
159 
160  bool m_empty;
165 };
166 
168 Data operator*(const AbstractSystemMatrix& left, const Data& right);
169 
170 typedef boost::shared_ptr<AbstractSystemMatrix> ASM_ptr;
171 
172 } // end of namespace
173 
174 #endif // __ESCRIPT_ABSTRACTSYSTEMMATRIX_H__
175 
Definition: FunctionSpace.h:34
void solve(SystemMatrix_ptr A, double *out, double *in, Options *options)
Definition: solve.cpp:38
int m_column_blocksize
Definition: AbstractSystemMatrix.h:161
Definition: AbstractContinuousDomain.cpp:24
int getColumnBlockSize() const
returns the column block size
Definition: AbstractSystemMatrix.h:107
SystemMatrixException exception class.
Definition: SystemMatrixException.h:35
FunctionSpace m_column_functionspace
Definition: AbstractSystemMatrix.h:164
int isEmpty(const escript::Data *data)
Returns the true if the data are empty or data is NULL.
Definition: DataC.cpp:110
bool m_empty
Definition: AbstractSystemMatrix.h:160
AbstractSystemMatrix()
Default constructor for AbstractSystemMatrix.
Definition: AbstractSystemMatrix.h:45
int m_row_blocksize
Definition: AbstractSystemMatrix.h:162
int getRowBlockSize() const
returns the row block size
Definition: AbstractSystemMatrix.h:96
FunctionSpace getRowFunctionSpace() const
returns the row function space
Definition: AbstractSystemMatrix.h:85
Data represents a collection of datapoints.
Definition: Data.h:68
virtual ~AbstractSystemMatrix()
Destructor.
Definition: AbstractSystemMatrix.h:56
FunctionSpace m_row_functionspace
Definition: AbstractSystemMatrix.h:163
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:54
bool isEmpty() const
returns true if the matrix is empty
Definition: AbstractSystemMatrix.h:68
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition: AbstractSystemMatrix.cpp:43
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:37
boost::shared_ptr< AbstractSystemMatrix > ASM_ptr
Definition: AbstractSystemMatrix.h:170
FunctionSpace getColumnFunctionSpace() const
returns the column function space
Definition: AbstractSystemMatrix.h:74