# Diff of /trunk/escript/src/AbstractTransportProblem.cpp

trunk/escript/src/AbstractSystemMatrix.cpp revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC trunk/escript/src/AbstractTransportProblem.cpp revision 1364 by gross, Mon Dec 17 07:22:45 2007 UTC
# Line 1  Line 1
1
2  /* \$Id\$ */  /* \$Id:\$ */
3
4  /*******************************************************  /*******************************************************
5   *   *
*           Copyright 2003-2007 by ACceSS MNRF
6   *       Copyright 2007 by University of Queensland   *       Copyright 2007 by University of Queensland
7   *   *
8   *                http://esscc.uq.edu.au   *                http://esscc.uq.edu.au
# Line 13  Line 12
12   *   *
13   *******************************************************/   *******************************************************/
14
15  #include "AbstractSystemMatrix.h"  #include "AbstractTransportProblem.h"
16  #include "DataException.h"  #include "TransportProblemException.h"
17  #include "DataArrayView.h"  #include "DataArrayView.h"
18  #include "Data.h"  #include "Data.h"
19
20  namespace escript {  namespace escript {
21
22  AbstractSystemMatrix::AbstractSystemMatrix() {  AbstractTransportProblem::AbstractTransportProblem() {
//std::cout << "Called default AbstractSystemMatrix constructor" << std::endl;
23      m_empty=1;      m_empty=1;
24  }  }
25
26  AbstractSystemMatrix::AbstractSystemMatrix(const int row_blocksize,  AbstractTransportProblem::AbstractTransportProblem(const double theta,const double dt_max,
27                                             const FunctionSpace& row_functionspace,                                                     const int blocksize,
28                                             const int column_blocksize,                                                     const FunctionSpace& functionspace)
29                                             const FunctionSpace& column_functionspace)  {
30  {    if (blocksize<=0)
31    if (row_blocksize<=0)       throw TransportProblemException("Error - negative block size of transport problem.");
32       throw DataException("Error - negative row block size of system matrix.");    if ((theta<0.) or (theta>1.))
33    if (column_blocksize<=0)       throw TransportProblemException("Error - theta needs to be between 0. and 1..");
throw DataException("Error - negative column block size of system matrix.");
34
35     m_empty=0;     m_empty=0;
36     m_row_blocksize=row_blocksize;     m_blocksize=blocksize;
37     m_column_blocksize=column_blocksize;     m_functionspace=functionspace;
38     m_row_functionspace=row_functionspace;     m_theta=theta;
39     m_column_functionspace=column_functionspace;     m_dt_max=dt_max;
40  }  }
41
42  AbstractSystemMatrix::~AbstractSystemMatrix() {  AbstractTransportProblem::~AbstractTransportProblem() {
43  }  }
44
45  int AbstractSystemMatrix::isEmpty() const {  int AbstractTransportProblem::isEmpty() const {
46     return m_empty;     return m_empty;
47  }  }
48
Data operator*(const AbstractSystemMatrix& left,const Data& right)
{
Data tmp=(Data) right;
return left.vectorMultiply(tmp);
}
49
50  Data AbstractSystemMatrix::vectorMultiply(Data& right) const  Data AbstractTransportProblem::solve(Data& source, const double dt, const boost::python::dict& options) const
51  {  {
52       if (isEmpty())       if (isEmpty())
53            throw SystemMatrixException("Error - Matrix is empty.");            throw TransportProblemException("Error - transport problem is empty.");
54       if (right.getDataPointSize()!=getColumnBlockSize())       if (dt<=0.)
55            throw SystemMatrixException("Error - column block size and input data size do not match.");            throw TransportProblemException("Error - dt needs to be positive.");
56         if (source.getFunctionSpace()!=getFunctionSpace())
57              throw TransportProblemException("Error - function space of transport problem and function space of source do not match.");
58         if (source.getDataPointSize()!=getBlockSize())
59              throw TransportProblemException("Error - block size of transport problem and source do not match.");
60       DataArrayView::ShapeType shape;       DataArrayView::ShapeType shape;
61       if (getRowBlockSize()>1) shape.push_back(getRowBlockSize());       if (getBlockSize()>1) shape.push_back(getBlockSize());
62         Data out=Data(0.,shape,getFunctionSpace(),true);
63       Data out=Data(0.,shape,getRowFunctionSpace(),true);       setToSolution(out,source,dt,options);
Data in=Data(right,getColumnFunctionSpace());
ypAx(out,in);
64       return out;       return out;
65  }  }
66
67  void AbstractSystemMatrix::ypAx(Data& y,Data& x) const  void AbstractTransportProblem::setInitialValue(Data& u) const
{
throw SystemMatrixException("Error - ypAx not available");
}

Data AbstractSystemMatrix::solve(Data& in,const boost::python::dict& options) const
68  {  {
69       if (isEmpty())       if (isEmpty())
70            throw SystemMatrixException("Error - Matrix is empty.");            throw TransportProblemException("Error - transport problem is empty.");
71       if (in.getFunctionSpace()!=getRowFunctionSpace())       if (u.getFunctionSpace()!=getFunctionSpace())
72            throw SystemMatrixException("Error - row function space and function space of right hand side do not match.");            throw TransportProblemException("Error - function space of transport problem and function space of initial value do not match.");
73       if (in.getDataPointSize()!=getRowBlockSize())       if (u.getDataPointSize()!=getBlockSize())
74            throw SystemMatrixException("Error - row block size and right hand side size do not match.");            throw TransportProblemException("Error - block size of transport problem and initial value source do not match.");
75       DataArrayView::ShapeType shape;       copyInitialValue(u);
if (getRowBlockSize()>1) shape.push_back(getColumnBlockSize());
Data out=Data(0.,shape,getColumnFunctionSpace(),true);
setToSolution(out,in,options);
return out;
76  }  }
77  void AbstractSystemMatrix::setToSolution(Data& out,Data& in,const boost::python::dict& options) const
78  {  void AbstractTransportProblem::copyInitialValue(Data& u) const
throw SystemMatrixException("Error - setToSolution not available");
}
void AbstractSystemMatrix::saveMM(const std::string& fileName) const
79  {  {
80      throw SystemMatrixException("Error - Matrix Market interface not available.");      throw TransportProblemException("Error - copyInitialValue is not available");
81  }  }
82  void AbstractSystemMatrix::saveHB(const std::string& fileName) const  void AbstractTransportProblem::setToSolution(Data& out,Data& source,const double dt, const boost::python::dict& options) const
83  {  {
84      throw SystemMatrixException("Error - Harwell-Boeing interface not available.");      throw TransportProblemException("Error - setToSolution is not available");
85  }  }
86  void AbstractSystemMatrix::resetValues() const  void AbstractTransportProblem::resetTransport() const
87  {  {
88      throw SystemMatrixException("Error - setValue is not implemented.");      throw TransportProblemException("Error - resetProblem is not implemented.");
89  }  }
90
91  }  // end of namespace  }  // end of namespace

Legend:
 Removed from v.1312 changed lines Added in v.1364

 ViewVC Help Powered by ViewVC 1.1.26