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

Revision 1417 - (hide annotations)
Mon Feb 25 04:45:48 2008 UTC (11 years, 6 months ago) by gross
File size: 4904 byte(s)
```some more work on the transport solver.
```
 1 jgs 82 2 gross 1407 /* \$Id\$ */ 3 ksteube 1312 4 /******************************************************* 5 * 6 * Copyright 2007 by University of Queensland 7 * 8 9 * Primary Business: Queensland, Australia 10 * Licensed under the Open Software License version 3.0 11 12 * 13 *******************************************************/ 14 15 gross 1364 #include "AbstractTransportProblem.h" 16 #include "TransportProblemException.h" 17 jgs 474 #include "DataArrayView.h" 18 jgs 480 #include "Data.h" 19 gross 1417 #include 20 jgs 82 21 gross 1417 22 jgs 82 namespace escript { 23 24 gross 1364 AbstractTransportProblem::AbstractTransportProblem() { 25 jgs 82 m_empty=1; 26 } 27 28 gross 1407 AbstractTransportProblem::AbstractTransportProblem(const double theta, const int blocksize, 29 gross 1364 const FunctionSpace& functionspace) 30 jgs 82 { 31 gross 1364 if (blocksize<=0) 32 throw TransportProblemException("Error - negative block size of transport problem."); 33 if ((theta<0.) or (theta>1.)) 34 throw TransportProblemException("Error - theta needs to be between 0. and 1.."); 35 jgs 82 36 m_empty=0; 37 gross 1364 m_blocksize=blocksize; 38 m_functionspace=functionspace; 39 m_theta=theta; 40 jgs 82 } 41 42 gross 1364 AbstractTransportProblem::~AbstractTransportProblem() { 43 jgs 82 } 44 45 gross 1364 int AbstractTransportProblem::isEmpty() const { 46 jgs 82 return m_empty; 47 } 48 49 50 gross 1364 Data AbstractTransportProblem::solve(Data& source, const double dt, const boost::python::dict& options) const 51 jgs 82 { 52 if (isEmpty()) 53 gross 1364 throw TransportProblemException("Error - transport problem is empty."); 54 if (dt<=0.) 55 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 jgs 82 DataArrayView::ShapeType shape; 61 gross 1364 if (getBlockSize()>1) shape.push_back(getBlockSize()); 62 Data out=Data(0.,shape,getFunctionSpace(),true); 63 setToSolution(out,source,dt,options); 64 jgs 82 return out; 65 } 66 67 gross 1364 void AbstractTransportProblem::setInitialValue(Data& u) const 68 jgs 82 { 69 gross 1364 if (isEmpty()) 70 throw TransportProblemException("Error - transport problem is empty."); 71 gross 1417 if (u.isEmpty()) 72 throw TransportProblemException("Error - empty initial value."); 73 74 if ((getBlockSize()==1) and (u.getDataPointRank()>0) or (u.getDataPointRank()>1)) 75 throw TransportProblemException("Error - illegal rank of initial value."); 76 77 gross 1364 if (u.getDataPointSize()!=getBlockSize()) 78 gross 1417 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 jgs 82 } 83 gross 1417 void AbstractTransportProblem::insertConstraint(Data& source, Data& q, Data& r) const 84 { 85 source.expand(); 86 if (isEmpty()) 87 throw TransportProblemException("Error - transport problem is empty."); 88 if (q.isEmpty()) { 89 return; 90 } 91 if ((getBlockSize()==1) and (q.getDataPointRank()>0) or (q.getDataPointRank()>1)) 92 throw TransportProblemException("Error - illegal rank of constraint location."); 93 if (q.getDataPointSize()!=getBlockSize()) 94 throw TransportProblemException("Error - block size of transport problem and constraint location don't match."); 95 Data q2=Data(q,getFunctionSpace()); 96 jgs 82 97 gross 1417 if (r.isEmpty()) { 98 Data r2=Data(0.,q.getDataPointShape(),getFunctionSpace()); 99 copyConstraint(source,q2,r2); 100 } else { 101 if ((getBlockSize()==1) and (r.getDataPointRank()>0) or (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 110 void AbstractTransportProblem::copyConstraint(Data& source, Data& q, Data& r) const 111 { 112 throw TransportProblemException("Error - copyConstraint is not available"); 113 } 114 gross 1364 void AbstractTransportProblem::copyInitialValue(Data& u) const 115 jgs 82 { 116 gross 1364 throw TransportProblemException("Error - copyInitialValue is not available"); 117 jgs 82 } 118 gross 1364 void AbstractTransportProblem::setToSolution(Data& out,Data& source,const double dt, const boost::python::dict& options) const 119 jgs 82 { 120 gross 1364 throw TransportProblemException("Error - setToSolution is not available"); 121 jgs 82 } 122 gross 1364 void AbstractTransportProblem::resetTransport() const 123 jgs 102 { 124 gross 1364 throw TransportProblemException("Error - resetProblem is not implemented."); 125 jgs 102 } 126 gross 1407 double AbstractTransportProblem::getSafeTimeStepSize() const 127 { 128 throw TransportProblemException("Error - getSafeTimeStepSize is not implemented."); 129 } 130 jgs 82 131 } // end of namespace

## Properties

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