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

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

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

trunk/escript/src/Data/DataTagged.cpp revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC trunk/escript/src/DataTagged.cpp revision 500 by jgs, Tue Feb 7 05:19:07 2006 UTC
# Line 14  Line 14 
14   ******************************************************************************   ******************************************************************************
15  */  */
16    
17  #include "escript/Data/DataTagged.h"  #include "DataTagged.h"
 #include "escript/Data/DataConstant.h"  
 #include "escript/Data/DataExpanded.h"  
 #include "escript/Data/DataException.h"  
18    
19  #include <sstream>  #include "DataConstant.h"
20    #include "DataException.h"
21    
22  using namespace std;  using namespace std;
23    
# Line 59  DataTagged::DataTagged(const TagListType Line 57  DataTagged::DataTagged(const TagListType
57  DataTagged::DataTagged(const FunctionSpace& what,  DataTagged::DataTagged(const FunctionSpace& what,
58                         const DataArrayView::ShapeType &shape,                         const DataArrayView::ShapeType &shape,
59                         const int tags[],                         const int tags[],
60                         const ValueType &data)                         const ValueType& data)
61    : DataAbstract(what)    : DataAbstract(what)
62  {  {
63    // copy the data    // copy the data
# Line 207  DataTagged::getTagNumber(int dpno) Line 205  DataTagged::getTagNumber(int dpno)
205      throw DataException("DataTagged::getTagNumber error: no data-points associated with this object.");      throw DataException("DataTagged::getTagNumber error: no data-points associated with this object.");
206    }    }
207    
208    if (dpno<0 || dpno>numDataPoints) {    if (dpno<0 || dpno>numDataPoints-1) {
209      throw DataException("DataTagged::getTagNumber error: invalid data-point number supplied.");      throw DataException("DataTagged::getTagNumber error: invalid data-point number supplied.");
210    }    }
211    
# Line 344  DataTagged::toString() const Line 342  DataTagged::toString() const
342    return temp.str();    return temp.str();
343  }  }
344    
345  DataArrayView  DataArrayView::ValueType::size_type
346  DataTagged::getDataPointByTag(int tag) const  DataTagged::getPointOffset(int sampleNo,
347                               int dataPointNo) const
348  {  {
349    DataMapType::const_iterator pos(m_offsetLookup.find(tag));    int tagKey=getFunctionSpace().getTagFromSampleNo(sampleNo);
350      DataMapType::const_iterator pos(m_offsetLookup.find(tagKey));
351    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;
352    if (pos!=m_offsetLookup.end()) {    if (pos!=m_offsetLookup.end()) {
353      offset=pos->second;      offset=pos->second;
354    }    }
355    DataArrayView temp(getPointDataView());    return offset;
   temp.setOffset(offset);  
   return temp;  
356  }  }
357    
358  DataArrayView::ValueType::size_type  DataArrayView
359  DataTagged::getPointOffset(int sampleNo,  DataTagged::getDataPointByTag(int tag) const
                            int dataPointNo) const  
360  {  {
361    int tagKey=getFunctionSpace().getTagFromSampleNo(sampleNo);    DataMapType::const_iterator pos(m_offsetLookup.find(tag));
   DataMapType::const_iterator pos(m_offsetLookup.find(tagKey));  
362    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;
363    if (pos!=m_offsetLookup.end()) {    if (pos!=m_offsetLookup.end()) {
364      offset=pos->second;      offset=pos->second;
365    }    }
366    return offset;    DataArrayView temp(getPointDataView());
367      temp.setOffset(offset);
368      return temp;
369  }  }
370    
371  DataArrayView  DataArrayView
# Line 379  DataTagged::getDataPoint(int sampleNo, Line 377  DataTagged::getDataPoint(int sampleNo,
377    return getDataPointByTag(tagKey);    return getDataPointByTag(tagKey);
378  }  }
379    
 const DataTagged::DataMapType&  
 DataTagged::getTagLookup() const  
 {  
   return m_offsetLookup;  
 }  
   
 DataArrayView::ValueType::size_type  
 DataTagged::getLength() const  
 {  
   return m_data.size();  
 }  
   
380  int  int
381  DataTagged::archiveData(ofstream& archiveFile,  DataTagged::archiveData(ofstream& archiveFile,
382                          const DataArrayView::ValueType::size_type noValues) const                          const DataArrayView::ValueType::size_type noValues) const

Legend:
Removed from v.155  
changed lines
  Added in v.500

  ViewVC Help
Powered by ViewVC 1.1.26