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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3911 - (show annotations)
Thu Jun 14 01:01:03 2012 UTC (7 years, 5 months ago) by jfenwick
File size: 4511 byte(s)
Copyright changes
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2012 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #include "AbstractTransportProblem.h"
16 #include "TransportProblemException.h"
17 #include "DataTypes.h"
18 #include "Data.h"
19 #include <iostream>
20
21
22 namespace escript {
23
24 AbstractTransportProblem::AbstractTransportProblem() {
25 m_empty=1;
26 }
27
28 AbstractTransportProblem::AbstractTransportProblem(const int blocksize,
29 const FunctionSpace& functionspace)
30 :m_functionspace(functionspace)
31 {
32 if (blocksize<=0)
33 throw TransportProblemException("Error - negative block size of transport problem.");
34
35 m_empty=0;
36 m_blocksize=blocksize;
37 // m_functionspace=functionspace;
38 }
39
40 AbstractTransportProblem::~AbstractTransportProblem() {
41 }
42
43 int AbstractTransportProblem::isEmpty() const {
44 return m_empty;
45 }
46
47
48 Data AbstractTransportProblem::solve(Data& u0, Data& source, const double dt, boost::python::object& options) const
49 {
50 if (isEmpty())
51 throw TransportProblemException("Error - transport problem is empty.");
52 if (dt<=0.)
53 throw TransportProblemException("Error - dt needs to be positive.");
54 if (source.getFunctionSpace()!=getFunctionSpace())
55 throw TransportProblemException("Error - function space of transport problem and function space of source do not match.");
56 if (u0.getFunctionSpace()!=getFunctionSpace())
57 throw TransportProblemException("Error - function space of transport problem and function space of initial value do not match.");
58 if (source.getDataPointSize()!=getBlockSize())
59 throw TransportProblemException("Error - block size of transport problem and source do not match.");
60 if (u0.getDataPointSize()!=getBlockSize())
61 throw TransportProblemException("Error - block size of transport problem and initial value do not match.");
62
63 DataTypes::ShapeType shape;
64 if (getBlockSize()>1) shape.push_back(getBlockSize());
65 Data out=Data(0.,shape,getFunctionSpace(),true);
66 setToSolution(out, u0, source, dt, options);
67 return out;
68 }
69
70 void AbstractTransportProblem::insertConstraint(Data& source, Data& q, Data& r) const
71 {
72 source.expand();
73 if (isEmpty())
74 throw TransportProblemException("Error - transport problem is empty.");
75 if (q.isEmpty()) {
76 return;
77 }
78 if (((getBlockSize()==1) && (q.getDataPointRank()>0)) || (q.getDataPointRank()>1))
79 throw TransportProblemException("Error - illegal rank of constraint location.");
80 if (q.getDataPointSize()!=getBlockSize())
81 throw TransportProblemException("Error - block size of transport problem and constraint location don't match.");
82 Data q2=Data(q,getFunctionSpace());
83
84 if (r.isEmpty()) {
85 Data r2=Data(0.,q.getDataPointShape(),getFunctionSpace());
86 copyConstraint(source,q2,r2);
87 } else {
88 if (((getBlockSize()==1) && (r.getDataPointRank()>0)) || (r.getDataPointRank()>1))
89 throw TransportProblemException("Error - illegal rank of constraint value.");
90 if (r.getDataPointSize()!=getBlockSize())
91 throw TransportProblemException("Error - block size of transport problem and constraint value don't match.");
92 Data r2=Data(r,getFunctionSpace());
93 copyConstraint(source,q2,r2);
94 }
95 }
96
97 void AbstractTransportProblem::copyConstraint(Data& source, Data& q, Data& r) const
98 {
99 throw TransportProblemException("Error - copyConstraint is not available");
100 }
101
102 void AbstractTransportProblem::setToSolution(Data& out, Data &u0, Data& source,const double dt, boost::python::object& options) const
103 {
104 throw TransportProblemException("Error - setToSolution is not available");
105 }
106 void AbstractTransportProblem::resetTransport() const
107 {
108 throw TransportProblemException("Error - resetProblem is not implemented.");
109 }
110 double AbstractTransportProblem::getSafeTimeStepSize() const
111 {
112 throw TransportProblemException("Error - getSafeTimeStepSize is not implemented.");
113 }
114 double AbstractTransportProblem::getUnlimitedTimeStepSize() const
115 {
116 throw TransportProblemException("Error - getUnlimitedTimeStepSize is not implemented.");
117 }
118
119 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26