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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 804 by gross, Thu Aug 10 01:12:16 2006 UTC revision 2005 by jfenwick, Mon Nov 10 01:21:39 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /*******************************************************
3   ************************************************************  *
4   *          Copyright 2006 by ACcESS MNRF                   *  * Copyright (c) 2003-2008 by University of Queensland
5   *                                                          *  * Earth Systems Science Computational Center (ESSCC)
6   *              http://www.access.edu.au                    *  * http://www.uq.edu.au/esscc
7   *       Primary Business: Queensland, Australia            *  *
8   *  Licensed under the Open Software License version 3.0    *  * Primary Business: Queensland, Australia
9   *     http://www.opensource.org/licenses/osl-3.0.php       *  * 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"  #include "DataAbstract.h"
16  #include "DataException.h"  #include "DataException.h"
17    #include "DataLazy.h"
18    
19  using namespace std;  using namespace std;
20    
21  namespace escript {  namespace escript {
22    
23  DataAbstract::DataAbstract(const FunctionSpace& what):  /**
24      m_noDataPointsPerSample(what.getNumDPPSample()),  \brief Returns smart pointer which is managing this object.
25      m_noSamples(what.getNumSamples()),  If one does not exist yet it creates one.
26      m_functionSpace(what)  
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  DataAbstract::~DataAbstract()  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  void  bool
54  DataAbstract::setPointDataView(const DataArrayView& input)  DataAbstract::isLazy() const
55  {  {
56      m_pointDataView.reset(new DataArrayView(input.getData(),input.getShape(),input.getOffset()));      return (dynamic_cast<const DataLazy*>(this)!=0);
57  }  }
58    
59  void  
60  DataAbstract::resetPointDataView()  
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_pointDataView.reset(new DataArrayView());      m_isempty=isDataEmpty;
71  }  }
72    
73    DataAbstract::~DataAbstract()
74    {
75    }
76    
77    
78  void  void
79  DataAbstract::operandCheck(const DataAbstract& right) const  DataAbstract::operandCheck(const DataAbstract& right) const
80  {  {
# Line 61  DataAbstract::operandCheck(const DataAbs Line 95  DataAbstract::operandCheck(const DataAbs
95    
96      //      //
97      // Check the shape of the point data, a rank of 0(scalar) is okay      // Check the shape of the point data, a rank of 0(scalar) is okay
98      if (!((right.getPointDataView().getRank()==0) ||      if (!((right.getRank()==0) ||
99        (right.getPointDataView().getShape()==getPointDataView().getShape())))        (right.getShape()==getShape())))
100        {        {
101          stringstream temp;          stringstream temp;
102      temp << "Error - Right hand argument point data shape: "      temp << "Error - Right hand argument point data shape: "
103           << DataArrayView::shapeToString(right.getPointDataView().getShape())           << DataTypes::shapeToString(right.getShape())
104           << " doesn't match left: "           << " doesn't match left: "
105           << DataArrayView::shapeToString(getPointDataView().getShape());           << DataTypes::shapeToString(getShape());
106      throw DataException(temp.str());      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*  DataAbstract::ValueType::value_type*
119  DataAbstract::getSampleDataByTag(int tag)  DataAbstract::getSampleDataByTag(int tag)
120  {  {
121      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
122  }  }
123    
124  void  
125    void  
126  DataAbstract::setTaggedValue(int tagKey,  DataAbstract::setTaggedValue(int tagKey,
127                               const DataArrayView& value)             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.");      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
132  }  }
133    
134    
135  int  int
136  DataAbstract::getTagNumber(int dpno)  DataAbstract::getTagNumber(int dpno)
137  {  {
# Line 93  DataAbstract::getTagNumber(int dpno) Line 139  DataAbstract::getTagNumber(int dpno)
139      return (0);      return (0);
140  }  }
141    
 void  
 DataAbstract::setRefValue(int ref,  
                           const DataArray& value)  
 {  
     throw DataException("Error - DataAbstract::setRefValue: Data type cannot be accessed by reference values.");  
 }  
142    
 void  
 DataAbstract::getRefValue(int ref,  
                           DataArray& value)  
 {  
     throw DataException("Error - DataAbstract::getRefValue: Data type cannot be accessed by reference values.");  
 }  
143    
144  int  void
145  DataAbstract::archiveData(ofstream& archiveFile,  DataAbstract::copyAll(const boost::python::numeric::array& value)
                           const ValueType::size_type noValues) const  
146  {  {
147    return 0;      throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
148  }  }
149    void
150  int  DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
 DataAbstract::extractData(ifstream& archiveFile,  
                           const ValueType::size_type noValues)  
151  {  {
152    return 0;      throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
153  }  }
   
154  void  void
155  DataAbstract::copyAll(const boost::python::numeric::array& value)  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 is not supported.");      throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
158  }  }
159    
160  void  void
# Line 160  void Line 190  void
190  DataAbstract::eigenvalues(DataAbstract* ev)  DataAbstract::eigenvalues(DataAbstract* ev)
191  {  {
192      throw DataException("Error - DataAbstract::eigenvalues is not supported.");      throw DataException("Error - DataAbstract::eigenvalues is not supported.");
   
193  }  }
194  void  void
195  DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)  DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
# Line 168  DataAbstract::eigenvalues_and_eigenvecto Line 197  DataAbstract::eigenvalues_and_eigenvecto
197      throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");      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    

Legend:
Removed from v.804  
changed lines
  Added in v.2005

  ViewVC Help
Powered by ViewVC 1.1.26