/[escript]/branches/schroedinger_upto1946/escript/src/DataAbstract.cpp
ViewVC logotype

Contents of /branches/schroedinger_upto1946/escript/src/DataAbstract.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1950 - (show annotations)
Thu Oct 30 00:59:34 2008 UTC (10 years, 6 months ago) by jfenwick
File size: 5679 byte(s)
Branch commit
Brought schroedinger merge upto trunk@1946.

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 }
72
73 DataAbstract::~DataAbstract()
74 {
75 }
76
77
78 void
79 DataAbstract::operandCheck(const DataAbstract& right) const
80 {
81 if ((right.getNumDPPSample()!=getNumDPPSample()) ||
82 (right.getNumSamples()!=getNumSamples()) ||
83 (right.getFunctionSpace()!=getFunctionSpace())) {
84 stringstream temp;
85 temp << "Error - Right hand argument sample shape or function space "
86 << "incompatible with left." << endl
87 << "LHS: (" << getNumSamples() << ","
88 << getNumDPPSample() << ") " << getFunctionSpace().toString()
89 << endl
90 << "RHS: (" << right.getNumSamples() << ","
91 << right.getNumDPPSample() << ") "
92 << right.getFunctionSpace().toString();
93 throw DataException(temp.str());
94 }
95
96 //
97 // Check the shape of the point data, a rank of 0(scalar) is okay
98 if (!((right.getRank()==0) ||
99 (right.getShape()==getShape())))
100 {
101 stringstream temp;
102 temp << "Error - Right hand argument point data shape: "
103 << DataTypes::shapeToString(right.getShape())
104 << " doesn't match left: "
105 << DataTypes::shapeToString(getShape());
106 throw DataException(temp.str());
107 }
108 }
109
110 void
111 DataAbstract::dump(const std::string fileName) const
112 {
113 throw DataException("Error - DataAbstract::dump: not implemented.");
114 }
115
116
117
118 DataAbstract::ValueType::value_type*
119 DataAbstract::getSampleDataByTag(int tag)
120 {
121 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
122 }
123
124
125 void
126 DataAbstract::setTaggedValue(int tagKey,
127 const DataTypes::ShapeType& pointshape,
128 const DataTypes::ValueType& value,
129 int dataOffset)
130 {
131 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
132 }
133
134
135 int
136 DataAbstract::getTagNumber(int dpno)
137 {
138 throw DataException("Error - DataAbstract::getTagNumber: Data type cannot be accessed by tag values.");
139 return (0);
140 }
141
142
143
144 void
145 DataAbstract::copyAll(const boost::python::numeric::array& value)
146 {
147 throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
148 }
149 void
150 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
151 {
152 throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
153 }
154 void
155 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
156 {
157 throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
158 }
159
160 void
161 DataAbstract::symmetric(DataAbstract* ev)
162 {
163 throw DataException("Error - DataAbstract::symmetric is not supported.");
164 }
165
166 void
167 DataAbstract::nonsymmetric(DataAbstract* ev)
168 {
169 throw DataException("Error - DataAbstract::nonsymmetric is not supported.");
170 }
171
172 void
173 DataAbstract::trace(DataAbstract* ev, int axis_offset)
174 {
175 throw DataException("Error - DataAbstract::trace is not supported.");
176 }
177
178 void
179 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
180 {
181 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
182 }
183 void
184 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
185 {
186 throw DataException("Error - DataAbstract::transpose is not supported.");
187 }
188
189 void
190 DataAbstract::eigenvalues(DataAbstract* ev)
191 {
192 throw DataException("Error - DataAbstract::eigenvalues is not supported.");
193 }
194 void
195 DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
196 {
197 throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
198
199 }
200 void
201 DataAbstract::setToZero()
202 {
203 throw DataException("Error - DataAbstract:: cannot set values to zero.");
204 }
205
206 void
207 DataAbstract::reorderByReferenceIDs(int *reference_ids)
208 {
209 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
210 }
211
212
213 // DataTypes::ValueType&
214 // DataAbstract::getVector()
215 // {
216 // throw DataException("Error - DataAbstract:: does not have a DataVector.");
217 // }
218 //
219 // const DataTypes::ValueType&
220 // DataAbstract::getVector() const
221 // {
222 // throw DataException("Error - DataAbstract:: does not have a DataVector.");
223 // }
224
225
226
227
228 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26