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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2987 - (show annotations)
Tue Mar 16 01:32:43 2010 UTC (9 years, 7 months ago) by gross
File size: 4750 byte(s)
FCT solver rewritten
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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 bool useBackwardEuler, 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 m_useBackwardEuler=useBackwardEuler;
39 }
40
41 AbstractTransportProblem::~AbstractTransportProblem() {
42 }
43
44 int AbstractTransportProblem::isEmpty() const {
45 return m_empty;
46 }
47
48
49 Data AbstractTransportProblem::solve(Data& u0, Data& source, const double dt, boost::python::object& options) const
50 {
51 if (isEmpty())
52 throw TransportProblemException("Error - transport problem is empty.");
53 if (dt<=0.)
54 throw TransportProblemException("Error - dt needs to be positive.");
55 if (source.getFunctionSpace()!=getFunctionSpace())
56 throw TransportProblemException("Error - function space of transport problem and function space of source do not match.");
57 if (u0.getFunctionSpace()!=getFunctionSpace())
58 throw TransportProblemException("Error - function space of transport problem and function space of initial value do not match.");
59 if (source.getDataPointSize()!=getBlockSize())
60 throw TransportProblemException("Error - block size of transport problem and source do not match.");
61 if (u0.getDataPointSize()!=getBlockSize())
62 throw TransportProblemException("Error - block size of transport problem and initial value do not match.");
63
64 DataTypes::ShapeType shape;
65 if (getBlockSize()>1) shape.push_back(getBlockSize());
66 Data out=Data(0.,shape,getFunctionSpace(),true);
67 setToSolution(out, u0, source, dt, options);
68 return out;
69 }
70
71 void AbstractTransportProblem::insertConstraint(Data& source, Data& q, Data& r, const double factor) const
72 {
73 if (factor <= 0.)
74 throw TransportProblemException("Error - weighting factor must be positive.");
75 source.expand();
76 if (isEmpty())
77 throw TransportProblemException("Error - transport problem is empty.");
78 if (q.isEmpty()) {
79 return;
80 }
81 if (((getBlockSize()==1) && (q.getDataPointRank()>0)) || (q.getDataPointRank()>1))
82 throw TransportProblemException("Error - illegal rank of constraint location.");
83 if (q.getDataPointSize()!=getBlockSize())
84 throw TransportProblemException("Error - block size of transport problem and constraint location don't match.");
85 Data q2=Data(q,getFunctionSpace());
86
87 if (r.isEmpty()) {
88 Data r2=Data(0.,q.getDataPointShape(),getFunctionSpace());
89 copyConstraint(source,q2,r2, factor);
90 } else {
91 if (((getBlockSize()==1) && (r.getDataPointRank()>0)) || (r.getDataPointRank()>1))
92 throw TransportProblemException("Error - illegal rank of constraint value.");
93 if (r.getDataPointSize()!=getBlockSize())
94 throw TransportProblemException("Error - block size of transport problem and constraint value don't match.");
95 Data r2=Data(r,getFunctionSpace());
96 copyConstraint(source,q2,r2, factor);
97 }
98 }
99
100 void AbstractTransportProblem::copyConstraint(Data& source, Data& q, Data& r, const double factor) const
101 {
102 throw TransportProblemException("Error - copyConstraint is not available");
103 }
104
105 void AbstractTransportProblem::setToSolution(Data& out, Data &u0, Data& source,const double dt, boost::python::object& options) const
106 {
107 throw TransportProblemException("Error - setToSolution is not available");
108 }
109 void AbstractTransportProblem::resetTransport() const
110 {
111 throw TransportProblemException("Error - resetProblem is not implemented.");
112 }
113 double AbstractTransportProblem::getSafeTimeStepSize() const
114 {
115 throw TransportProblemException("Error - getSafeTimeStepSize is not implemented.");
116 }
117 double AbstractTransportProblem::getUnlimitedTimeStepSize() const
118 {
119 throw TransportProblemException("Error - getUnlimitedTimeStepSize is not implemented.");
120 }
121
122 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26