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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/escript/src/Data/AbstractSystemMatrix.cpp revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC trunk/escript/src/AbstractSystemMatrix.cpp revision 1872 by jfenwick, Mon Oct 13 00:18:55 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /*******************************************************
3   ******************************************************************************  *
4   *                                                                            *  * Copyright (c) 2003-2008 by University of Queensland
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  * Earth Systems Science Computational Center (ESSCC)
6   *                                                                            *  * http://www.uq.edu.au/esscc
7   * This software is the property of ACcESS. No part of this code              *  *
8   * may be copied in any form or by any means without the expressed written    *  * Primary Business: Queensland, Australia
9   * consent of ACcESS.  Copying, use or modification of this software          *  * Licensed under the Open Software License version 3.0
10   * by any unauthorised person is illegal unless that person has a software    *  * http://www.opensource.org/licenses/osl-3.0.php
11   * license agreement with ACcESS.                                             *  *
12   *                                                                            *  *******************************************************/
13   ******************************************************************************  
14  */  
15    #include "AbstractSystemMatrix.h"
16  #include "escript/Data/AbstractSystemMatrix.h"  #include "DataException.h"
17  #include "escript/Data/FunctionSpace.h"  #include "Data.h"
18  #include "escript/Data/DataException.h"  #include "DataTypes.h"
 #include "escript/Data/DataArrayView.h"  
19    
20  namespace escript {  namespace escript {
21    
# Line 29  AbstractSystemMatrix::AbstractSystemMatr Line 28  AbstractSystemMatrix::AbstractSystemMatr
28                                             const FunctionSpace& row_functionspace,                                             const FunctionSpace& row_functionspace,
29                                             const int column_blocksize,                                             const int column_blocksize,
30                                             const FunctionSpace& column_functionspace)                                             const FunctionSpace& column_functionspace)
31    :m_row_functionspace(row_functionspace),
32    m_column_functionspace(column_functionspace)
33  {  {
34    if (row_blocksize<=0)    if (row_blocksize<=0)
35       throw DataException("Error - negative row block size of system matrix.");       throw DataException("Error - negative row block size of system matrix.");
# Line 38  AbstractSystemMatrix::AbstractSystemMatr Line 39  AbstractSystemMatrix::AbstractSystemMatr
39     m_empty=0;     m_empty=0;
40     m_row_blocksize=row_blocksize;     m_row_blocksize=row_blocksize;
41     m_column_blocksize=column_blocksize;     m_column_blocksize=column_blocksize;
42     m_row_functionspace=row_functionspace;  //    m_row_functionspace=row_functionspace;
43     m_column_functionspace=column_functionspace;  //    m_column_functionspace=column_functionspace;
44  }  }
45    
46  AbstractSystemMatrix::~AbstractSystemMatrix() {  AbstractSystemMatrix::~AbstractSystemMatrix() {
# Line 49  int AbstractSystemMatrix::isEmpty() cons Line 50  int AbstractSystemMatrix::isEmpty() cons
50     return m_empty;     return m_empty;
51  }  }
52    
53  Data operator*(const AbstractSystemMatrix& left, const Data& right)  Data operator*(const AbstractSystemMatrix& left,const Data& right)
54  {  {
55        return left.vectorMultiply(right);        Data tmp=(Data) right;
56          return left.vectorMultiply(tmp);
57  }  }
58    
59  Data AbstractSystemMatrix::vectorMultiply(const Data& right) const  Data AbstractSystemMatrix::vectorMultiply(Data& right) const
60  {  {
61       if (isEmpty())       if (isEmpty())
62            throw SystemMatrixException("Error - Matrix is empty.");            throw SystemMatrixException("Error - Matrix is empty.");
      if (right.getFunctionSpace()!=getColumnFunctionSpace())  
           throw SystemMatrixException("Error - column function space and function space of input data do not match.");  
63       if (right.getDataPointSize()!=getColumnBlockSize())       if (right.getDataPointSize()!=getColumnBlockSize())
64            throw SystemMatrixException("Error - column block size and input data size do not match.");            throw SystemMatrixException("Error - column block size and input data size do not match.");
65       DataArrayView::ShapeType shape;       DataTypes::ShapeType shape;
66       if (getRowBlockSize()>1) shape.push_back(getRowBlockSize());       if (getRowBlockSize()>1) shape.push_back(getRowBlockSize());
67    
68       Data out=Data(0.,shape,getRowFunctionSpace(),true);       Data out=Data(0.,shape,getRowFunctionSpace(),true);
69       ypAx(out,right);       Data in=Data(right,getColumnFunctionSpace());
70         ypAx(out,in);
71       return out;       return out;
72  }  }
73    
74  void AbstractSystemMatrix::ypAx(Data& y,const Data& x) const  void AbstractSystemMatrix::ypAx(Data& y,Data& x) const
75  {  {
76      throw SystemMatrixException("Error - ypAx not available");      throw SystemMatrixException("Error - ypAx not available");
77  }  }
78    
79  Data AbstractSystemMatrix::solve(const Data& in,const boost::python::dict& options) const  Data AbstractSystemMatrix::solve(Data& in,const boost::python::dict& options) const
80  {  {
81       if (isEmpty())       if (isEmpty())
82            throw SystemMatrixException("Error - Matrix is empty.");            throw SystemMatrixException("Error - Matrix is empty.");
# Line 83  Data AbstractSystemMatrix::solve(const D Line 84  Data AbstractSystemMatrix::solve(const D
84            throw SystemMatrixException("Error - row function space and function space of right hand side do not match.");            throw SystemMatrixException("Error - row function space and function space of right hand side do not match.");
85       if (in.getDataPointSize()!=getRowBlockSize())       if (in.getDataPointSize()!=getRowBlockSize())
86            throw SystemMatrixException("Error - row block size and right hand side size do not match.");            throw SystemMatrixException("Error - row block size and right hand side size do not match.");
87       DataArrayView::ShapeType shape;       DataTypes::ShapeType shape;
88       if (getRowBlockSize()>1) shape.push_back(getColumnBlockSize());       if (getRowBlockSize()>1) shape.push_back(getColumnBlockSize());
89       Data out=Data(0.,shape,getColumnFunctionSpace(),true);       Data out=Data(0.,shape,getColumnFunctionSpace(),true);
90       setToSolution(out,in,options);       setToSolution(out,in,options);
91       return out;       return out;
92  }  }
93  void AbstractSystemMatrix::setToSolution(Data& out,const Data& in,const boost::python::dict& options) const  void AbstractSystemMatrix::setToSolution(Data& out,Data& in,const boost::python::dict& options) const
94  {  {
95      throw SystemMatrixException("Error - setToSolution not available");      throw SystemMatrixException("Error - setToSolution not available");
96  }  }
# Line 97  void AbstractSystemMatrix::saveMM(const Line 98  void AbstractSystemMatrix::saveMM(const
98  {  {
99      throw SystemMatrixException("Error - Matrix Market interface not available.");      throw SystemMatrixException("Error - Matrix Market interface not available.");
100  }  }
101  void AbstractSystemMatrix:: setValue(const double value) const  void AbstractSystemMatrix::saveHB(const std::string& fileName) const
102    {
103        throw SystemMatrixException("Error - Harwell-Boeing interface not available.");
104    }
105    void AbstractSystemMatrix::resetValues() const
106  {  {
107        throw SystemMatrixException("Error - setValue is not implemented.");
108  }  }
109    
110  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.97  
changed lines
  Added in v.1872

  ViewVC Help
Powered by ViewVC 1.1.26