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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1704 - (show annotations)
Thu Aug 14 05:35:32 2008 UTC (12 years, 2 months ago) by jfenwick
File size: 5443 byte(s)
Branch commit:

DataTagged::addTag() = Add a tag with default value. (All uses that I can find 
apart from test code only require this anyway).

DataAbstract now knows its own shape, rank and number of values and have accessors 
for them.
Data Objects also have acessors for these but query their DataAbstracts for the 
answers.

Data::getDataAtOffset() = access to a particular point in the underlying array. (At 
the moment this call references the DataArrayView, but that will change when I have 
everything else working).

DataTagged::getDataByTag() = same but search by tag.
DataTagged::getDefaultValue() = returns default value without obvious reference to 
DataArrayView


C_GeneralTensorProduct_J  is my temporary copy of C_GeneralTensorProduct for 
experimentation.
It and a number of other temporary functions live in JoelMods.cpp_ for now.


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):
24 m_noDataPointsPerSample(what.getNumDPPSample()),
25 m_noSamples(what.getNumSamples()),
26 m_functionSpace(what),
27 m_rank(0)
28 {
29 setShape(DataTypes::ShapeType());
30 }
31
32 DataAbstract::~DataAbstract()
33 {
34 }
35
36 void
37 DataAbstract::setPointDataView(const DataArrayView& input)
38 {
39 m_pointDataView.reset(new DataArrayView(input.getData(),input.getShape(),input.getOffset()));
40
41 // until we get rid of m_pointDataView, we need to keep m_shape in sync
42 setShape(input.getShape());
43 }
44
45 void
46 DataAbstract::setShape(const DataTypes::ShapeType& s)
47 {
48 m_shape=s;
49 m_rank=DataTypes::getRank(s);
50 m_novalues=DataTypes::noValues(s);
51 }
52
53
54 void
55 DataAbstract::resetPointDataView()
56 {
57 m_pointDataView.reset(new DataArrayView());
58 m_shape.clear();
59 m_rank=0;
60 m_novalues=1;
61 }
62
63 void
64 DataAbstract::operandCheck(const DataAbstract& right) const
65 {
66 if ((right.getNumDPPSample()!=getNumDPPSample()) ||
67 (right.getNumSamples()!=getNumSamples()) ||
68 (right.getFunctionSpace()!=getFunctionSpace())) {
69 stringstream temp;
70 temp << "Error - Right hand argument sample shape or function space "
71 << "incompatible with left." << endl
72 << "LHS: (" << getNumSamples() << ","
73 << getNumDPPSample() << ") " << getFunctionSpace().toString()
74 << endl
75 << "RHS: (" << right.getNumSamples() << ","
76 << right.getNumDPPSample() << ") "
77 << right.getFunctionSpace().toString();
78 throw DataException(temp.str());
79 }
80
81 //
82 // Check the shape of the point data, a rank of 0(scalar) is okay
83 if (!((right.getPointDataView().getRank()==0) ||
84 (right.getPointDataView().getShape()==getPointDataView().getShape())))
85 {
86 stringstream temp;
87 temp << "Error - Right hand argument point data shape: "
88 << DataTypes::shapeToString(right.getPointDataView().getShape())
89 << " doesn't match left: "
90 << DataTypes::shapeToString(getPointDataView().getShape());
91 throw DataException(temp.str());
92 }
93 }
94
95 void
96 DataAbstract::dump(const std::string fileName) const
97 {
98 throw DataException("Error - DataAbstract:: dump: not implemented.");
99 }
100
101
102
103 DataAbstract::ValueType::value_type*
104 DataAbstract::getSampleDataByTag(int tag)
105 {
106 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
107 }
108
109 void
110 DataAbstract::setTaggedValue(int tagKey,
111 const DataArrayView& value)
112 {
113 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
114 }
115
116 int
117 DataAbstract::getTagNumber(int dpno)
118 {
119 throw DataException("Error - DataAbstract::getTagNumber: Data type cannot be accessed by tag values.");
120 return (0);
121 }
122
123 int
124 DataAbstract::archiveData(ofstream& archiveFile,
125 const ValueType::size_type noValues) const
126 {
127 return 0;
128 }
129
130 int
131 DataAbstract::extractData(ifstream& archiveFile,
132 const ValueType::size_type noValues)
133 {
134 return 0;
135 }
136
137 void
138 DataAbstract::copyAll(const boost::python::numeric::array& value)
139 {
140 throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
141 }
142 void
143 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
144 {
145 throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
146 }
147 void
148 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
149 {
150 throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
151 }
152
153 void
154 DataAbstract::symmetric(DataAbstract* ev)
155 {
156 throw DataException("Error - DataAbstract::symmetric is not supported.");
157 }
158
159 void
160 DataAbstract::nonsymmetric(DataAbstract* ev)
161 {
162 throw DataException("Error - DataAbstract::nonsymmetric is not supported.");
163 }
164
165 void
166 DataAbstract::trace(DataAbstract* ev, int axis_offset)
167 {
168 throw DataException("Error - DataAbstract::trace is not supported.");
169 }
170
171 void
172 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
173 {
174 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
175 }
176 void
177 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
178 {
179 throw DataException("Error - DataAbstract::transpose is not supported.");
180 }
181
182 void
183 DataAbstract::eigenvalues(DataAbstract* ev)
184 {
185 throw DataException("Error - DataAbstract::eigenvalues is not supported.");
186 }
187 void
188 DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
189 {
190 throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
191
192 }
193 void
194 DataAbstract::setToZero()
195 {
196 throw DataException("Error - DataAbstract:: cannot set values to zero.");
197 }
198
199 void
200 DataAbstract::reorderByReferenceIDs(int *reference_ids)
201 {
202 }
203
204
205
206
207 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26