/[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

revision 108 by jgs, Thu Jan 27 06:21:59 2005 UTC revision 119 by jgs, Tue Apr 12 04:45:05 2005 UTC
# Line 41  DataTagged::DataTagged(const TagListType Line 41  DataTagged::DataTagged(const TagListType
41    : DataAbstract(what)    : DataAbstract(what)
42  {  {
43    //    //
44      // Initialise the array of data values
45    // The default value is always the first item in the values list    // The default value is always the first item in the values list
46    m_data.insert(m_data.end(), &defaultValue.getData(0), &defaultValue.getData(defaultValue.noValues()) );    m_data.insert(m_data.end(), &defaultValue.getData(0), &defaultValue.getData(defaultValue.noValues()) );
47      // create the data view
48    DataArrayView temp(m_data,defaultValue.getShape());    DataArrayView temp(m_data,defaultValue.getShape());
49    setPointDataView(temp);    setPointDataView(temp);
50    // add remaining tags and values    // add remaining tags and values
51    addTaggedValues(tagKeys,values);    addTaggedValues(tagKeys,values);
52  }  }
53    
54    DataTagged::DataTagged(const FunctionSpace& what,
55                           const DataArrayView::ShapeType &shape,
56                           const int tags[],
57                           const DataArrayView::ValueType &data)
58      : DataAbstract(what)
59    {
60      //
61      // copy the data in the correct format
62      m_data=data;
63      //
64      // create the view of the data
65      DataArrayView tempView(m_data,shape);
66      setPointDataView(tempView);
67      //
68      // create the tag lookup map
69      for (int sampleNo=0; sampleNo<getNumSamples(); sampleNo++) {
70        m_offsetLookup.insert(DataMapType::value_type(sampleNo,tags[sampleNo]));
71      }
72    }
73    
74  DataTagged::DataTagged(const DataTagged& other)  DataTagged::DataTagged(const DataTagged& other)
75    : DataAbstract(other.getFunctionSpace()),    : DataAbstract(other.getFunctionSpace()),
76    m_data(other.m_data),    m_data(other.m_data),
77    m_offsetLookup(other.m_offsetLookup)    m_offsetLookup(other.m_offsetLookup)
78  {  {
79      // create the data view
80    DataArrayView temp(m_data,other.getPointDataView().getShape());    DataArrayView temp(m_data,other.getPointDataView().getShape());
81    setPointDataView(temp);    setPointDataView(temp);
82  }  }
# Line 65  DataTagged::DataTagged(const DataConstan Line 88  DataTagged::DataTagged(const DataConstan
88    // Fill the default value with the constant value item from other    // Fill the default value with the constant value item from other
89    const DataArrayView& value=other.getPointDataView();    const DataArrayView& value=other.getPointDataView();
90    m_data.insert(m_data.end(), &value.getData(0), &value.getData(value.noValues()) );    m_data.insert(m_data.end(), &value.getData(0), &value.getData(value.noValues()) );
91      // create the data view
92    DataArrayView temp(m_data,value.getShape());    DataArrayView temp(m_data,value.getShape());
93    setPointDataView(temp);    setPointDataView(temp);
94  }  }
# Line 79  DataTagged::DataTagged(const DataTagged& Line 103  DataTagged::DataTagged(const DataTagged&
103    DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);    DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
104    // allocate enough space for all values    // allocate enough space for all values
105    m_data.resize(DataArrayView::noValues(shape)*(other.m_offsetLookup.size()+1));    m_data.resize(DataArrayView::noValues(shape)*(other.m_offsetLookup.size()+1));
106      // create the data view
107    DataArrayView temp(m_data,shape);    DataArrayView temp(m_data,shape);
108    setPointDataView(temp);    setPointDataView(temp);
109      // copy the default value
110    getDefaultValue().copySlice(other.getDefaultValue(),region_loop_range);    getDefaultValue().copySlice(other.getDefaultValue(),region_loop_range);
111    //    //
112    // Loop through the tag values    // Loop through the tag values copying these
113    DataMapType::const_iterator pos;    DataMapType::const_iterator pos;
114    DataArrayView::ValueType::size_type tagOffset=getPointDataView().noValues();    DataArrayView::ValueType::size_type tagOffset=getPointDataView().noValues();
115    for (pos=other.m_offsetLookup.begin();pos!=other.m_offsetLookup.end();++pos){    for (pos=other.m_offsetLookup.begin();pos!=other.m_offsetLookup.end();++pos){

Legend:
Removed from v.108  
changed lines
  Added in v.119

  ViewVC Help
Powered by ViewVC 1.1.26