/[escript]/branches/trilinos_from_5897/escriptcore/src/AbstractSystemMatrix.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/escriptcore/src/AbstractSystemMatrix.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6058 - (show annotations)
Thu Mar 10 06:51:55 2016 UTC (3 years, 1 month ago) by caltinay
File size: 4189 byte(s)
added getPtr() to AbstractSystemMatrix so we can now use shared systemmatrix
pointers rather than circumventing them.

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 Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
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 #include "AbstractSystemMatrix.h"
18 #include "Data.h"
19 #include "DataException.h"
20 #include "DataTypes.h"
21
22 namespace escript {
23
24 AbstractSystemMatrix::AbstractSystemMatrix(int row_blocksize,
25 const FunctionSpace& row_fs,
26 int column_blocksize,
27 const FunctionSpace& column_fs) :
28 m_empty(false),
29 m_column_blocksize(column_blocksize),
30 m_row_blocksize(row_blocksize),
31 m_row_functionspace(row_fs),
32 m_column_functionspace(column_fs)
33 {
34 if (row_blocksize <= 0)
35 throw DataException("Negative row block size of system matrix.");
36 if (column_blocksize <= 0)
37 throw DataException("Negative column block size of system matrix.");
38
39 }
40
41 ASM_ptr AbstractSystemMatrix::getPtr()
42 {
43 try {
44 return shared_from_this();
45 } catch (boost::bad_weak_ptr p) {
46 return ASM_ptr(this);
47 }
48 }
49
50 const_ASM_ptr AbstractSystemMatrix::getPtr() const
51 {
52 try {
53 return shared_from_this();
54 } catch (boost::bad_weak_ptr p) {
55 return const_ASM_ptr(this);
56 }
57 }
58
59 Data operator*(const AbstractSystemMatrix& left, const Data& right)
60 {
61 return left.vectorMultiply(right);
62 }
63
64 Data AbstractSystemMatrix::vectorMultiply(const Data& right) const
65 {
66 if (isEmpty())
67 throw SystemMatrixException("Error - Matrix is empty.");
68 if (right.getDataPointSize()!=getColumnBlockSize())
69 throw SystemMatrixException("Error - column block size and input data size do not match.");
70 DataTypes::ShapeType shape;
71 if (getRowBlockSize() > 1)
72 shape.push_back(getRowBlockSize());
73
74 Data out(0., shape, getRowFunctionSpace(), true);
75 Data in(right, getColumnFunctionSpace());
76 ypAx(out, in);
77 return out;
78 }
79
80 void AbstractSystemMatrix::ypAx(Data& y, Data& x) const
81 {
82 throw SystemMatrixException("ypAx() is not implemented.");
83 }
84
85 Data AbstractSystemMatrix::solve(const Data& in,
86 boost::python::object& options) const
87 {
88 if (isEmpty())
89 throw SystemMatrixException("Matrix is empty.");
90 if (in.getFunctionSpace() != getRowFunctionSpace())
91 throw SystemMatrixException("row function space and function space of right hand side do not match.");
92 if (in.getDataPointSize() != getRowBlockSize())
93 throw SystemMatrixException("row block size and right hand side size do not match.");
94 DataTypes::ShapeType shape;
95 if (getRowBlockSize() > 1)
96 shape.push_back(getColumnBlockSize());
97 Data out(0., shape, getColumnFunctionSpace(), true);
98 setToSolution(out, *const_cast<Data*>(&in), options);
99 return out;
100 }
101 void AbstractSystemMatrix::setToSolution(Data& out, Data& in,
102 boost::python::object& options) const
103 {
104 throw SystemMatrixException("setToSolution() is not implemented");
105 }
106
107 void AbstractSystemMatrix::nullifyRowsAndCols(Data& row_q,
108 Data& col_q,
109 double mdv)
110 {
111 throw SystemMatrixException("nullifyRowsAndCols() is not implemented.");
112 }
113
114 void AbstractSystemMatrix::saveMM(const std::string& filename) const
115 {
116 throw SystemMatrixException("Matrix Market interface not available.");
117 }
118
119 void AbstractSystemMatrix::saveHB(const std::string& fileName) const
120 {
121 throw SystemMatrixException("Harwell-Boeing interface not available.");
122 }
123
124 void AbstractSystemMatrix::resetValues()
125 {
126 throw SystemMatrixException("resetValues() is not implemented.");
127 }
128
129 } // end of namespace
130

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26