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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2086 - (hide annotations)
Mon Nov 24 02:38:50 2008 UTC (11 years, 3 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 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
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 ksteube 1312
14 ksteube 1811
15 jgs 474 #include "DataAbstract.h"
16     #include "DataException.h"
17 jfenwick 2005 #include "DataLazy.h"
18 jgs 82
19     using namespace std;
20    
21     namespace escript {
22    
23 jfenwick 1872 /**
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 jfenwick 2005 bool
54     DataAbstract::isLazy() const
55     {
56     return (dynamic_cast<const DataLazy*>(this)!=0);
57     }
58 jfenwick 1872
59    
60 jfenwick 2005
61 jfenwick 1803 DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
62 jfenwick 1946 m_noSamples(what.getNumSamples()),
63 jgs 82 m_noDataPointsPerSample(what.getNumDPPSample()),
64 jfenwick 1796 m_functionSpace(what),
65     m_shape(shape),
66 jfenwick 1946 m_novalues(DataTypes::noValues(shape)),
67     m_rank(DataTypes::getRank(shape))
68    
69 jgs 82 {
70 jfenwick 1803 m_isempty=isDataEmpty;
71 jfenwick 2086 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 jgs 82 }
79    
80     DataAbstract::~DataAbstract()
81     {
82     }
83    
84    
85 jgs 119 void
86 jgs 82 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 jfenwick 2084 if (!((right.getRank()==0) || (getRank()==0) ||
106 jfenwick 1796 (right.getShape()==getShape())))
107 jgs 82 {
108     stringstream temp;
109     temp << "Error - Right hand argument point data shape: "
110 jfenwick 1796 << DataTypes::shapeToString(right.getShape())
111 jgs 82 << " doesn't match left: "
112 jfenwick 1796 << DataTypes::shapeToString(getShape());
113 jgs 82 throw DataException(temp.str());
114     }
115     }
116    
117 gross 950 void
118     DataAbstract::dump(const std::string fileName) const
119     {
120 jfenwick 1803 throw DataException("Error - DataAbstract::dump: not implemented.");
121 gross 950 }
122    
123    
124    
125 jgs 82 DataAbstract::ValueType::value_type*
126     DataAbstract::getSampleDataByTag(int tag)
127     {
128 jgs 110 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
129 jgs 82 }
130    
131 jfenwick 1796
132     void
133 jgs 82 DataAbstract::setTaggedValue(int tagKey,
134 jfenwick 1796 const DataTypes::ShapeType& pointshape,
135     const DataTypes::ValueType& value,
136     int dataOffset)
137 jgs 82 {
138 jgs 110 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
139 jgs 82 }
140    
141 jfenwick 1796
142 jgs 149 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 jgs 123
150    
151 jgs 126 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 gross 921 void
157 gross 922 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 gross 921 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 jgs 126
167 gross 576 void
168 ksteube 775 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 gross 800 DataAbstract::trace(DataAbstract* ev, int axis_offset)
181 ksteube 775 {
182 gross 800 throw DataException("Error - DataAbstract::trace is not supported.");
183 ksteube 775 }
184    
185     void
186 gross 804 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
187 gross 800 {
188 gross 804 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
189 gross 800 }
190     void
191 ksteube 775 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
192     {
193     throw DataException("Error - DataAbstract::transpose is not supported.");
194     }
195    
196     void
197 gross 576 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 gross 1118 void
208     DataAbstract::setToZero()
209     {
210     throw DataException("Error - DataAbstract:: cannot set values to zero.");
211     }
212 gross 576
213 gross 1487 void
214     DataAbstract::reorderByReferenceIDs(int *reference_ids)
215     {
216 jfenwick 1803 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
217 gross 1487 }
218 gross 576
219    
220 jfenwick 2005 // 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 gross 1487
232    
233 jfenwick 1796
234    
235 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