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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1803 - (show annotations)
Wed Sep 24 06:20:29 2008 UTC (10 years, 11 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
2 /* $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 #include "DataAbstract.h"
17 #include "DataException.h"
18
19 using namespace std;
20
21 namespace escript {
22
23 DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
24 m_noDataPointsPerSample(what.getNumDPPSample()),
25 m_noSamples(what.getNumSamples()),
26 m_functionSpace(what),
27 m_shape(shape),
28 m_rank(DataTypes::getRank(shape)),
29 m_novalues(DataTypes::noValues(shape))
30 {
31 m_isempty=isDataEmpty;
32 }
33
34 DataAbstract::~DataAbstract()
35 {
36 }
37
38
39 void
40 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 if (!((right.getRank()==0) ||
60 (right.getShape()==getShape())))
61 {
62 stringstream temp;
63 temp << "Error - Right hand argument point data shape: "
64 << DataTypes::shapeToString(right.getShape())
65 << " doesn't match left: "
66 << DataTypes::shapeToString(getShape());
67 throw DataException(temp.str());
68 }
69 }
70
71 void
72 DataAbstract::dump(const std::string fileName) const
73 {
74 throw DataException("Error - DataAbstract::dump: not implemented.");
75 }
76
77
78
79 DataAbstract::ValueType::value_type*
80 DataAbstract::getSampleDataByTag(int tag)
81 {
82 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
83 }
84
85
86 void
87 DataAbstract::setTaggedValue(int tagKey,
88 const DataTypes::ShapeType& pointshape,
89 const DataTypes::ValueType& value,
90 int dataOffset)
91 {
92 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
93 }
94
95
96 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
104
105 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 void
111 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 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
121 void
122 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 DataAbstract::trace(DataAbstract* ev, int axis_offset)
135 {
136 throw DataException("Error - DataAbstract::trace is not supported.");
137 }
138
139 void
140 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
141 {
142 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
143 }
144 void
145 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
146 {
147 throw DataException("Error - DataAbstract::transpose is not supported.");
148 }
149
150 void
151 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 void
162 DataAbstract::setToZero()
163 {
164 throw DataException("Error - DataAbstract:: cannot set values to zero.");
165 }
166
167 void
168 DataAbstract::reorderByReferenceIDs(int *reference_ids)
169 {
170 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
171 }
172
173
174 DataTypes::ValueType&
175 DataAbstract::getVector()
176 {
177 throw DataException("Error - DataAbstract:: does not have a DataVector.");
178 }
179
180 const DataTypes::ValueType&
181 DataAbstract::getVector() const
182 {
183 throw DataException("Error - DataAbstract:: does not have a DataVector.");
184 }
185
186
187
188
189 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26