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

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

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

trunk/esys2/escript/src/Data/AbstractSystemMatrix.cpp revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC trunk/escript/src/AbstractTransportProblem.cpp revision 1429 by trankine, Wed Feb 27 08:53:20 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /* $Id$ */
3   ******************************************************************************  
4   *                                                                            *  /*******************************************************
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *
6   *                                                                            *   *       Copyright 2007 by University of Queensland
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    *   *                http://esscc.uq.edu.au
9   * consent of ACcESS.  Copying, use or modification of this software          *   *        Primary Business: Queensland, Australia
10   * by any unauthorised person is illegal unless that person has a software    *   *  Licensed under the Open Software License version 3.0
11   * license agreement with ACcESS.                                             *   *     http://www.opensource.org/licenses/osl-3.0.php
12   *                                                                            *   *
13   ******************************************************************************   *******************************************************/
14  */  
15    #include "AbstractTransportProblem.h"
16  #include "escript/Data/AbstractSystemMatrix.h"  #include "TransportProblemException.h"
17  #include "escript/Data/FunctionSpace.h"  #include "DataArrayView.h"
18  #include "escript/Data/DataException.h"  #include "Data.h"
19  #include "escript/Data/DataArrayView.h"  #include <iostream>
20    
21    
22  namespace escript {  namespace escript {
23    
24  AbstractSystemMatrix::AbstractSystemMatrix() {  AbstractTransportProblem::AbstractTransportProblem() {
     //std::cout << "Called default AbstractSystemMatrix constructor" << std::endl;  
25      m_empty=1;      m_empty=1;
26  }  }
27    
28  AbstractSystemMatrix::AbstractSystemMatrix(const int row_blocksize,  AbstractTransportProblem::AbstractTransportProblem(const double theta, const int blocksize,
29                                             const FunctionSpace& row_functionspace,                                                     const FunctionSpace& functionspace)
30                                             const int column_blocksize,  {
31                                             const FunctionSpace& column_functionspace)    if (blocksize<=0)
32  {       throw TransportProblemException("Error - negative block size of transport problem.");
33    if (row_blocksize<=0)    if ((theta<0.) || (theta>1.))
34       throw DataException("Error - negative row block size of system matrix.");       throw TransportProblemException("Error - theta needs to be between 0. and 1..");
   if (column_blocksize<=0)  
      throw DataException("Error - negative column block size of system matrix.");  
35    
36     m_empty=0;     m_empty=0;
37     m_row_blocksize=row_blocksize;     m_blocksize=blocksize;
38     m_column_blocksize=column_blocksize;     m_functionspace=functionspace;
39     m_row_functionspace=row_functionspace;     m_theta=theta;
    m_column_functionspace=column_functionspace;  
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)  
 {  
       return left.vectorMultiply(right);  
 }  
49    
50  Data AbstractSystemMatrix::vectorMultiply(const 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);
      ypAx(out,Data(right,getColumnFunctionSpace()));  
64       return out;       return out;
65  }  }
66    
67  void AbstractSystemMatrix::ypAx(Data& y,const Data& x) const  void AbstractTransportProblem::setInitialValue(Data& u) const
68  {  {
69      throw SystemMatrixException("Error - ypAx not available");       if (isEmpty())
70  }            throw TransportProblemException("Error - transport problem is empty.");
71         if (u.isEmpty())
72              throw TransportProblemException("Error - empty initial value.");
73    
74         if ((getBlockSize()==1) && (u.getDataPointRank()>0) || (u.getDataPointRank()>1))
75              throw TransportProblemException("Error - illegal rank of initial value.");
76    
77  Data AbstractSystemMatrix::solve(const Data& in,const boost::python::dict& options) const       if (u.getDataPointSize()!=getBlockSize())
78              throw TransportProblemException("Error - block size of transport problem and initial value do not match.");
79    
80         Data u2=Data(u,getFunctionSpace());
81         copyInitialValue(u2);
82    }
83    void AbstractTransportProblem::insertConstraint(Data& source, Data& q, Data& r) const
84  {  {
85         source.expand();
86       if (isEmpty())       if (isEmpty())
87            throw SystemMatrixException("Error - Matrix is empty.");            throw TransportProblemException("Error - transport problem is empty.");
88       if (in.getFunctionSpace()!=getRowFunctionSpace())       if (q.isEmpty()) {
89            throw SystemMatrixException("Error - row function space and function space of right hand side do not match.");            return;
90       if (in.getDataPointSize()!=getRowBlockSize())       }
91            throw SystemMatrixException("Error - row block size and right hand side size do not match.");       if ((getBlockSize()==1) && (q.getDataPointRank()>0) || (q.getDataPointRank()>1))
92       DataArrayView::ShapeType shape;            throw TransportProblemException("Error - illegal rank of constraint location.");
93       if (getRowBlockSize()>1) shape.push_back(getColumnBlockSize());       if (q.getDataPointSize()!=getBlockSize())
94       Data out=Data(0.,shape,getColumnFunctionSpace(),true);            throw TransportProblemException("Error - block size of transport problem and constraint location don't match.");
95       setToSolution(out,in,options);       Data q2=Data(q,getFunctionSpace());
96       return out;  
97         if (r.isEmpty()) {
98              Data r2=Data(0.,q.getDataPointShape(),getFunctionSpace());
99              copyConstraint(source,q2,r2);
100         } else {
101            if ((getBlockSize()==1) && (r.getDataPointRank()>0) || (r.getDataPointRank()>1))
102                 throw TransportProblemException("Error - illegal rank of constraint value.");
103            if (r.getDataPointSize()!=getBlockSize())
104                 throw TransportProblemException("Error - block size of transport problem and constraint value don't match.");
105            Data r2=Data(r,getFunctionSpace());
106            copyConstraint(source,q2,r2);
107         }
108  }  }
109  void AbstractSystemMatrix::setToSolution(Data& out,const Data& in,const boost::python::dict& options) const  
110    void AbstractTransportProblem::copyConstraint(Data& source, Data& q, Data& r) const
111  {  {
112      throw SystemMatrixException("Error - setToSolution not available");      throw TransportProblemException("Error - copyConstraint is not available");
113  }  }
114  void AbstractSystemMatrix::saveMM(const std::string& fileName) const  void AbstractTransportProblem::copyInitialValue(Data& u) const
115  {  {
116      throw SystemMatrixException("Error - Matrix Market interface not available.");      throw TransportProblemException("Error - copyInitialValue is not available");
117  }  }
118  void AbstractSystemMatrix::saveHB(const std::string& fileName) const  void AbstractTransportProblem::setToSolution(Data& out,Data& source,const double dt, const boost::python::dict& options) const
119  {  {
120      throw SystemMatrixException("Error - Harwell-Boeing interface not available.");      throw TransportProblemException("Error - setToSolution is not available");
121  }  }
122  void AbstractSystemMatrix::setValue(const double value) const  void AbstractTransportProblem::resetTransport() const
123  {  {
124      throw SystemMatrixException("Error - setValue is not implemented.");      throw TransportProblemException("Error - resetProblem is not implemented.");
125  }  }
126  void AbstractSystemMatrix::resetSolver() const  double AbstractTransportProblem::getSafeTimeStepSize() const
127  {  {
128      throw SystemMatrixException("Error - resetSolver not implemented.");      throw TransportProblemException("Error - getSafeTimeStepSize is not implemented.");
129  }  }
130    
131  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.123  
changed lines
  Added in v.1429

  ViewVC Help
Powered by ViewVC 1.1.26