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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2086 - (show annotations)
Mon Nov 24 02:38:50 2008 UTC (10 years, 11 months ago) by jfenwick
File size: 5935 byte(s)
Added checks in C_GeneralTensorProduct (Data:: and Delayed forms) as 
well as the DataAbstract Constructor to prevent Objects with Rank>4 
being created.

Moved the relevant #define into systemdep.

Removed some comments.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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 "DataAbstract.h"
16 #include "DataException.h"
17 #include "DataLazy.h"
18
19 using namespace std;
20
21 namespace escript {
22
23 /**
24 \brief Returns smart pointer which is managing this object.
25 If one does not exist yet it creates one.
26
27 Note: This is _not_ equivalent to weak_ptr::lock.
28 */
29 DataAbstract_ptr DataAbstract::getPtr()
30 {
31 if (_internal_weak_this.expired())
32 {
33 return DataAbstract_ptr(this);
34 }
35 else
36 {
37 return shared_from_this();
38 }
39 }
40
41 const_DataAbstract_ptr DataAbstract::getPtr() const
42 {
43 if (_internal_weak_this.expired())
44 {
45 return const_DataAbstract_ptr(this);
46 }
47 else
48 {
49 return shared_from_this();
50 }
51 }
52
53 bool
54 DataAbstract::isLazy() const
55 {
56 return (dynamic_cast<const DataLazy*>(this)!=0);
57 }
58
59
60
61 DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
62 m_noSamples(what.getNumSamples()),
63 m_noDataPointsPerSample(what.getNumDPPSample()),
64 m_functionSpace(what),
65 m_shape(shape),
66 m_novalues(DataTypes::noValues(shape)),
67 m_rank(DataTypes::getRank(shape))
68
69 {
70 m_isempty=isDataEmpty;
71 if (m_rank>ESCRIPT_MAX_DATA_RANK)
72 {
73 ostringstream os;
74 os << "Error - Attempt to create a rank " << m_rank
75 << " object. The maximum rank is " << ESCRIPT_MAX_DATA_RANK << ".";
76 throw DataException(os.str());
77 }
78 }
79
80 DataAbstract::~DataAbstract()
81 {
82 }
83
84
85 void
86 DataAbstract::operandCheck(const DataAbstract& right) const
87 {
88 if ((right.getNumDPPSample()!=getNumDPPSample()) ||
89 (right.getNumSamples()!=getNumSamples()) ||
90 (right.getFunctionSpace()!=getFunctionSpace())) {
91 stringstream temp;
92 temp << "Error - Right hand argument sample shape or function space "
93 << "incompatible with left." << endl
94 << "LHS: (" << getNumSamples() << ","
95 << getNumDPPSample() << ") " << getFunctionSpace().toString()
96 << endl
97 << "RHS: (" << right.getNumSamples() << ","
98 << right.getNumDPPSample() << ") "
99 << right.getFunctionSpace().toString();
100 throw DataException(temp.str());
101 }
102
103 //
104 // Check the shape of the point data, a rank of 0(scalar) is okay
105 if (!((right.getRank()==0) || (getRank()==0) ||
106 (right.getShape()==getShape())))
107 {
108 stringstream temp;
109 temp << "Error - Right hand argument point data shape: "
110 << DataTypes::shapeToString(right.getShape())
111 << " doesn't match left: "
112 << DataTypes::shapeToString(getShape());
113 throw DataException(temp.str());
114 }
115 }
116
117 void
118 DataAbstract::dump(const std::string fileName) const
119 {
120 throw DataException("Error - DataAbstract::dump: not implemented.");
121 }
122
123
124
125 DataAbstract::ValueType::value_type*
126 DataAbstract::getSampleDataByTag(int tag)
127 {
128 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
129 }
130
131
132 void
133 DataAbstract::setTaggedValue(int tagKey,
134 const DataTypes::ShapeType& pointshape,
135 const DataTypes::ValueType& value,
136 int dataOffset)
137 {
138 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
139 }
140
141
142 int
143 DataAbstract::getTagNumber(int dpno)
144 {
145 throw DataException("Error - DataAbstract::getTagNumber: Data type cannot be accessed by tag values.");
146 return (0);
147 }
148
149
150
151 void
152 DataAbstract::copyAll(const boost::python::numeric::array& value)
153 {
154 throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
155 }
156 void
157 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
158 {
159 throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
160 }
161 void
162 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
163 {
164 throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
165 }
166
167 void
168 DataAbstract::symmetric(DataAbstract* ev)
169 {
170 throw DataException("Error - DataAbstract::symmetric is not supported.");
171 }
172
173 void
174 DataAbstract::nonsymmetric(DataAbstract* ev)
175 {
176 throw DataException("Error - DataAbstract::nonsymmetric is not supported.");
177 }
178
179 void
180 DataAbstract::trace(DataAbstract* ev, int axis_offset)
181 {
182 throw DataException("Error - DataAbstract::trace is not supported.");
183 }
184
185 void
186 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
187 {
188 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
189 }
190 void
191 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
192 {
193 throw DataException("Error - DataAbstract::transpose is not supported.");
194 }
195
196 void
197 DataAbstract::eigenvalues(DataAbstract* ev)
198 {
199 throw DataException("Error - DataAbstract::eigenvalues is not supported.");
200 }
201 void
202 DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
203 {
204 throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
205
206 }
207 void
208 DataAbstract::setToZero()
209 {
210 throw DataException("Error - DataAbstract:: cannot set values to zero.");
211 }
212
213 void
214 DataAbstract::reorderByReferenceIDs(int *reference_ids)
215 {
216 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
217 }
218
219
220 // DataTypes::ValueType&
221 // DataAbstract::getVector()
222 // {
223 // throw DataException("Error - DataAbstract:: does not have a DataVector.");
224 // }
225 //
226 // const DataTypes::ValueType&
227 // DataAbstract::getVector() const
228 // {
229 // throw DataException("Error - DataAbstract:: does not have a DataVector.");
230 // }
231
232
233
234
235 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26