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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (hide annotations)
Wed Dec 15 03:48:48 2004 UTC (14 years, 10 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/AbstractSystemMatrix.cpp
File size: 3929 byte(s)
*** empty log message ***

1 jgs 82 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14    
15     #include "escript/Data/AbstractSystemMatrix.h"
16     #include "escript/Data/FunctionSpace.h"
17     #include "escript/Data/DataException.h"
18     #include "escript/Data/DataArrayView.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     return left.vectorMultiply(right);
54     }
55    
56     Data AbstractSystemMatrix::vectorMultiply(const Data& right) const
57     {
58     if (isEmpty())
59     throw SystemMatrixException("Error - Matrix is empty.");
60     if (right.getFunctionSpace()!=getColumnFunctionSpace())
61     throw SystemMatrixException("Error - column function space and function space of input data do not match.");
62     if (right.getDataPointSize()!=getColumnBlockSize())
63     throw SystemMatrixException("Error - column block size and input data size do not match.");
64     DataArrayView::ShapeType shape;
65     if (getRowBlockSize()>1) shape.push_back(getRowBlockSize());
66    
67     Data out=Data(0.,shape,getRowFunctionSpace(),true);
68     ypAx(out,right);
69     return out;
70     }
71    
72     void AbstractSystemMatrix::ypAx(Data& y,const Data& x) const
73     {
74     throw SystemMatrixException("Error - ypAx not available");
75     }
76    
77     Data AbstractSystemMatrix::solve(const 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     DataArrayView::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,const Data& in,const boost::python::dict& options) const
92     {
93     throw SystemMatrixException("Error - setToSolution not available");
94     }
95    
96     } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26