/[escript]/trunk/escript/src/AbstractSystemMatrix.cpp
ViewVC logotype

Contents of /trunk/escript/src/AbstractSystemMatrix.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 9 months ago) by ksteube
File size: 3680 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #include "AbstractSystemMatrix.h"
16 #include "DataException.h"
17 #include "Data.h"
18 #include "DataTypes.h"
19
20 namespace escript {
21
22 AbstractSystemMatrix::AbstractSystemMatrix() {
23 //std::cout << "Called default AbstractSystemMatrix constructor" << std::endl;
24 m_empty=1;
25 }
26
27 AbstractSystemMatrix::AbstractSystemMatrix(const int row_blocksize,
28 const FunctionSpace& row_functionspace,
29 const int column_blocksize,
30 const FunctionSpace& column_functionspace)
31 {
32 if (row_blocksize<=0)
33 throw DataException("Error - negative row block size of system matrix.");
34 if (column_blocksize<=0)
35 throw DataException("Error - negative column block size of system matrix.");
36
37 m_empty=0;
38 m_row_blocksize=row_blocksize;
39 m_column_blocksize=column_blocksize;
40 m_row_functionspace=row_functionspace;
41 m_column_functionspace=column_functionspace;
42 }
43
44 AbstractSystemMatrix::~AbstractSystemMatrix() {
45 }
46
47 int AbstractSystemMatrix::isEmpty() const {
48 return m_empty;
49 }
50
51 Data operator*(const AbstractSystemMatrix& left,const Data& right)
52 {
53 Data tmp=(Data) right;
54 return left.vectorMultiply(tmp);
55 }
56
57 Data AbstractSystemMatrix::vectorMultiply(Data& right) const
58 {
59 if (isEmpty())
60 throw SystemMatrixException("Error - Matrix is empty.");
61 if (right.getDataPointSize()!=getColumnBlockSize())
62 throw SystemMatrixException("Error - column block size and input data size do not match.");
63 DataTypes::ShapeType shape;
64 if (getRowBlockSize()>1) shape.push_back(getRowBlockSize());
65
66 Data out=Data(0.,shape,getRowFunctionSpace(),true);
67 Data in=Data(right,getColumnFunctionSpace());
68 ypAx(out,in);
69 return out;
70 }
71
72 void AbstractSystemMatrix::ypAx(Data& y,Data& x) const
73 {
74 throw SystemMatrixException("Error - ypAx not available");
75 }
76
77 Data AbstractSystemMatrix::solve(Data& in,const boost::python::dict& options) const
78 {
79 if (isEmpty())
80 throw SystemMatrixException("Error - Matrix is empty.");
81 if (in.getFunctionSpace()!=getRowFunctionSpace())
82 throw SystemMatrixException("Error - row function space and function space of right hand side do not match.");
83 if (in.getDataPointSize()!=getRowBlockSize())
84 throw SystemMatrixException("Error - row block size and right hand side size do not match.");
85 DataTypes::ShapeType shape;
86 if (getRowBlockSize()>1) shape.push_back(getColumnBlockSize());
87 Data out=Data(0.,shape,getColumnFunctionSpace(),true);
88 setToSolution(out,in,options);
89 return out;
90 }
91 void AbstractSystemMatrix::setToSolution(Data& out,Data& in,const boost::python::dict& options) const
92 {
93 throw SystemMatrixException("Error - setToSolution not available");
94 }
95 void AbstractSystemMatrix::saveMM(const std::string& fileName) const
96 {
97 throw SystemMatrixException("Error - Matrix Market interface not available.");
98 }
99 void AbstractSystemMatrix::saveHB(const std::string& fileName) const
100 {
101 throw SystemMatrixException("Error - Harwell-Boeing interface not available.");
102 }
103 void AbstractSystemMatrix::resetValues() const
104 {
105 throw SystemMatrixException("Error - setValue is not implemented.");
106 }
107
108 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26