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

Annotation of /trunk/escript/src/DataAbstract.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1803 - (hide annotations)
Wed Sep 24 06:20:29 2008 UTC (11 years, 5 months ago) by jfenwick
File size: 5057 byte(s)
All about making DataEmpty instances throw.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Exposed getDim from AbstractDomain to python to fix bug.

Added isEmpty member to DataAbstract to allow it to throw is queries are 
made about a DataEmpty instance.


Added exceptions to DataAbstract, DataEmpty and Data to prevent calls 
being made against DataEmpty objects.
The following still work as expected on DataEmpty instances

copy, getDomain, getFunctionSpace, isEmpty, isExpanded, isProtected, 
isTagged, setprotection.

You can also call interpolate, however it should throw if you try to 
change FunctionSpaces.


1 jgs 82
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 474 #include "DataAbstract.h"
17     #include "DataException.h"
18 jgs 82
19     using namespace std;
20    
21     namespace escript {
22    
23 jfenwick 1803 DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
24 jgs 82 m_noDataPointsPerSample(what.getNumDPPSample()),
25     m_noSamples(what.getNumSamples()),
26 jfenwick 1796 m_functionSpace(what),
27     m_shape(shape),
28     m_rank(DataTypes::getRank(shape)),
29     m_novalues(DataTypes::noValues(shape))
30 jgs 82 {
31 jfenwick 1803 m_isempty=isDataEmpty;
32 jgs 82 }
33    
34     DataAbstract::~DataAbstract()
35     {
36     }
37    
38    
39 jgs 119 void
40 jgs 82 DataAbstract::operandCheck(const DataAbstract& right) const
41     {
42     if ((right.getNumDPPSample()!=getNumDPPSample()) ||
43     (right.getNumSamples()!=getNumSamples()) ||
44     (right.getFunctionSpace()!=getFunctionSpace())) {
45     stringstream temp;
46     temp << "Error - Right hand argument sample shape or function space "
47     << "incompatible with left." << endl
48     << "LHS: (" << getNumSamples() << ","
49     << getNumDPPSample() << ") " << getFunctionSpace().toString()
50     << endl
51     << "RHS: (" << right.getNumSamples() << ","
52     << right.getNumDPPSample() << ") "
53     << right.getFunctionSpace().toString();
54     throw DataException(temp.str());
55     }
56    
57     //
58     // Check the shape of the point data, a rank of 0(scalar) is okay
59 jfenwick 1796 if (!((right.getRank()==0) ||
60     (right.getShape()==getShape())))
61 jgs 82 {
62     stringstream temp;
63     temp << "Error - Right hand argument point data shape: "
64 jfenwick 1796 << DataTypes::shapeToString(right.getShape())
65 jgs 82 << " doesn't match left: "
66 jfenwick 1796 << DataTypes::shapeToString(getShape());
67 jgs 82 throw DataException(temp.str());
68     }
69     }
70    
71 gross 950 void
72     DataAbstract::dump(const std::string fileName) const
73     {
74 jfenwick 1803 throw DataException("Error - DataAbstract::dump: not implemented.");
75 gross 950 }
76    
77    
78    
79 jgs 82 DataAbstract::ValueType::value_type*
80     DataAbstract::getSampleDataByTag(int tag)
81     {
82 jgs 110 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
83 jgs 82 }
84    
85 jfenwick 1796
86     void
87 jgs 82 DataAbstract::setTaggedValue(int tagKey,
88 jfenwick 1796 const DataTypes::ShapeType& pointshape,
89     const DataTypes::ValueType& value,
90     int dataOffset)
91 jgs 82 {
92 jgs 110 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
93 jgs 82 }
94    
95 jfenwick 1796
96 jgs 149 int
97     DataAbstract::getTagNumber(int dpno)
98     {
99     throw DataException("Error - DataAbstract::getTagNumber: Data type cannot be accessed by tag values.");
100     return (0);
101     }
102    
103 jgs 123
104    
105 jgs 126 void
106     DataAbstract::copyAll(const boost::python::numeric::array& value)
107     {
108     throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
109     }
110 gross 921 void
111 gross 922 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
112     {
113     throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
114     }
115     void
116 gross 921 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
117     {
118     throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
119     }
120 jgs 126
121 gross 576 void
122 ksteube 775 DataAbstract::symmetric(DataAbstract* ev)
123     {
124     throw DataException("Error - DataAbstract::symmetric is not supported.");
125     }
126    
127     void
128     DataAbstract::nonsymmetric(DataAbstract* ev)
129     {
130     throw DataException("Error - DataAbstract::nonsymmetric is not supported.");
131     }
132    
133     void
134 gross 800 DataAbstract::trace(DataAbstract* ev, int axis_offset)
135 ksteube 775 {
136 gross 800 throw DataException("Error - DataAbstract::trace is not supported.");
137 ksteube 775 }
138    
139     void
140 gross 804 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
141 gross 800 {
142 gross 804 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
143 gross 800 }
144     void
145 ksteube 775 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
146     {
147     throw DataException("Error - DataAbstract::transpose is not supported.");
148     }
149    
150     void
151 gross 576 DataAbstract::eigenvalues(DataAbstract* ev)
152     {
153     throw DataException("Error - DataAbstract::eigenvalues is not supported.");
154     }
155     void
156     DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
157     {
158     throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
159    
160     }
161 gross 1118 void
162     DataAbstract::setToZero()
163     {
164     throw DataException("Error - DataAbstract:: cannot set values to zero.");
165     }
166 gross 576
167 gross 1487 void
168     DataAbstract::reorderByReferenceIDs(int *reference_ids)
169     {
170 jfenwick 1803 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
171 gross 1487 }
172 gross 576
173    
174 jfenwick 1796 DataTypes::ValueType&
175     DataAbstract::getVector()
176     {
177     throw DataException("Error - DataAbstract:: does not have a DataVector.");
178     }
179 gross 1487
180 jfenwick 1796 const DataTypes::ValueType&
181     DataAbstract::getVector() const
182     {
183     throw DataException("Error - DataAbstract:: does not have a DataVector.");
184     }
185 gross 1487
186 jfenwick 1796
187    
188    
189 jgs 82 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26