/[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 1872 by jfenwick, Mon Oct 13 00:18:55 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"
# Line 18  using namespace std; Line 19  using namespace std;
19    
20  namespace escript {  namespace escript {
21    
22  DataAbstract::DataAbstract(const FunctionSpace& what):  /**
23      m_noDataPointsPerSample(what.getNumDPPSample()),  \brief Returns smart pointer which is managing this object.
24      m_noSamples(what.getNumSamples()),  If one does not exist yet it creates one.
25      m_functionSpace(what)  
26    Note: This is _not_ equivalent to weak_ptr::lock.
27    */
28    DataAbstract_ptr DataAbstract::getPtr()
29  {  {
30      if (_internal_weak_this.expired())
31      {
32        return DataAbstract_ptr(this);  
33      }
34      else
35      {
36        return shared_from_this();
37      }
38  }  }
39    
40  DataAbstract::~DataAbstract()  const_DataAbstract_ptr DataAbstract::getPtr() const
41  {  {
42      if (_internal_weak_this.expired())
43      {
44        return const_DataAbstract_ptr(this);
45      }
46      else
47      {
48        return shared_from_this();
49      }
50  }  }
51    
52  void  
53  DataAbstract::setPointDataView(const DataArrayView& input)  
54    DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
55        m_noDataPointsPerSample(what.getNumDPPSample()),
56        m_noSamples(what.getNumSamples()),
57        m_functionSpace(what),
58        m_shape(shape),
59        m_rank(DataTypes::getRank(shape)),
60        m_novalues(DataTypes::noValues(shape))
61  {  {
62      m_pointDataView.reset(new DataArrayView(input.getData(),input.getShape(),input.getOffset()));      m_isempty=isDataEmpty;
63  }  }
64    
65  void  DataAbstract::~DataAbstract()
 DataAbstract::resetPointDataView()  
66  {  {
     m_pointDataView.reset(new DataArrayView());  
67  }  }
68    
69    
70  void  void
71  DataAbstract::operandCheck(const DataAbstract& right) const  DataAbstract::operandCheck(const DataAbstract& right) const
72  {  {
# Line 61  DataAbstract::operandCheck(const DataAbs Line 87  DataAbstract::operandCheck(const DataAbs
87    
88      //      //
89      // 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
90      if (!((right.getPointDataView().getRank()==0) ||      if (!((right.getRank()==0) ||
91        (right.getPointDataView().getShape()==getPointDataView().getShape())))        (right.getShape()==getShape())))
92        {        {
93          stringstream temp;          stringstream temp;
94      temp << "Error - Right hand argument point data shape: "      temp << "Error - Right hand argument point data shape: "
95           << DataArrayView::shapeToString(right.getPointDataView().getShape())           << DataTypes::shapeToString(right.getShape())
96           << " doesn't match left: "           << " doesn't match left: "
97           << DataArrayView::shapeToString(getPointDataView().getShape());           << DataTypes::shapeToString(getShape());
98      throw DataException(temp.str());      throw DataException(temp.str());
99        }        }
100  }  }
101    
102    void
103    DataAbstract::dump(const std::string fileName) const
104    {
105        throw DataException("Error - DataAbstract::dump: not implemented.");
106    }
107    
108    
109    
110  DataAbstract::ValueType::value_type*  DataAbstract::ValueType::value_type*
111  DataAbstract::getSampleDataByTag(int tag)  DataAbstract::getSampleDataByTag(int tag)
112  {  {
113      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
114  }  }
115    
116  void  
117    void  
118  DataAbstract::setTaggedValue(int tagKey,  DataAbstract::setTaggedValue(int tagKey,
119                               const DataArrayView& value)             const DataTypes::ShapeType& pointshape,
120                   const DataTypes::ValueType& value,
121               int dataOffset)
122  {  {
123      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
124  }  }
125    
126    
127  int  int
128  DataAbstract::getTagNumber(int dpno)  DataAbstract::getTagNumber(int dpno)
129  {  {
# Line 93  DataAbstract::getTagNumber(int dpno) Line 131  DataAbstract::getTagNumber(int dpno)
131      return (0);      return (0);
132  }  }
133    
 void  
 DataAbstract::setRefValue(int ref,  
                           const DataArray& value)  
 {  
     throw DataException("Error - DataAbstract::setRefValue: Data type cannot be accessed by reference values.");  
 }  
134    
 void  
 DataAbstract::getRefValue(int ref,  
                           DataArray& value)  
 {  
     throw DataException("Error - DataAbstract::getRefValue: Data type cannot be accessed by reference values.");  
 }  
135    
136  int  void
137  DataAbstract::archiveData(ofstream& archiveFile,  DataAbstract::copyAll(const boost::python::numeric::array& value)
                           const ValueType::size_type noValues) const  
138  {  {
139    return 0;      throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
140  }  }
141    void
142  int  DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
 DataAbstract::extractData(ifstream& archiveFile,  
                           const ValueType::size_type noValues)  
143  {  {
144    return 0;      throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
145  }  }
   
146  void  void
147  DataAbstract::copyAll(const boost::python::numeric::array& value)  DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
148  {  {
149      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.");
150  }  }
151    
152  void  void
# Line 160  void Line 182  void
182  DataAbstract::eigenvalues(DataAbstract* ev)  DataAbstract::eigenvalues(DataAbstract* ev)
183  {  {
184      throw DataException("Error - DataAbstract::eigenvalues is not supported.");      throw DataException("Error - DataAbstract::eigenvalues is not supported.");
   
185  }  }
186  void  void
187  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 189  DataAbstract::eigenvalues_and_eigenvecto
189      throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");      throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
190    
191  }  }
192    void
193    DataAbstract::setToZero()
194    {
195        throw DataException("Error - DataAbstract:: cannot set values to zero.");
196    }
197    
198    void
199    DataAbstract::reorderByReferenceIDs(int *reference_ids)
200    {
201        throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
202    }
203    
204    
205    DataTypes::ValueType&
206    DataAbstract::getVector()
207    {
208       throw DataException("Error - DataAbstract:: does not have a DataVector.");
209    }
210    
211    const DataTypes::ValueType&
212    DataAbstract::getVector() const
213    {
214       throw DataException("Error - DataAbstract:: does not have a DataVector.");
215    }
216    
217    
218    
219    

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

  ViewVC Help
Powered by ViewVC 1.1.26