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

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

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

trunk/esys2/escript/src/Data/DataConstant.cpp revision 119 by jgs, Tue Apr 12 04:45:05 2005 UTC trunk/escript/src/DataConstant.cpp revision 474 by jgs, Mon Jan 30 04:23:44 2006 UTC
# Line 13  Line 13 
13   ******************************************************************************   ******************************************************************************
14  */  */
15    
16  #include "escript/Data/DataConstant.h"  #include "DataConstant.h"
17  #include "escript/Data/DataException.h"  #include "DataException.h"
18  #include "esysUtils/EsysAssert.h"  #include "EsysAssert.h"
19    
20  #include <iostream>  #include <iostream>
21  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
# Line 72  DataConstant::DataConstant(const DataCon Line 72  DataConstant::DataConstant(const DataCon
72    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
73    //    //
74    // allocate space for this new DataConstant's data    // allocate space for this new DataConstant's data
75    m_data.resize(DataArrayView::noValues(shape));    int len = DataArrayView::noValues(shape);
76      m_data.resize(len,0.,len);
77    //    //
78    // create a view of the data with the correct shape    // create a view of the data with the correct shape
79    DataArrayView tempView(m_data,shape);    DataArrayView tempView(m_data,shape);
# Line 109  DataConstant::getPointOffset(int sampleN Line 110  DataConstant::getPointOffset(int sampleN
110  {  {
111    EsysAssert((validSamplePointNo(dataPointNo) && validSampleNo(sampleNo)),    EsysAssert((validSamplePointNo(dataPointNo) && validSampleNo(sampleNo)),
112                "Invalid index, sampleNo: " << sampleNo << " dataPointNo: " << dataPointNo);                "Invalid index, sampleNo: " << sampleNo << " dataPointNo: " << dataPointNo);
113      //
114      // Whatever the coord's always return the same value as this is constant data.
115    return 0;    return 0;
116  }  }
117    
# Line 168  DataConstant::reshapeDataPoint(const Dat Line 171  DataConstant::reshapeDataPoint(const Dat
171           << "This Data has data points with rank: " << getPointDataView().getRank();           << "This Data has data points with rank: " << getPointDataView().getRank();
172      throw DataException(temp.str());      throw DataException(temp.str());
173    }    }
174    m_data.resize(DataArrayView::noValues(shape),getPointDataView()());    int len = DataArrayView::noValues(shape);
175      m_data.resize(len,getPointDataView()(),len);
176    DataArrayView newView(m_data,shape);    DataArrayView newView(m_data,shape);
177    setPointDataView(newView);    setPointDataView(newView);
178  }  }
179    
180    int
181    DataConstant::archiveData(ofstream& archiveFile,
182                              const DataArrayView::ValueType::size_type noValues) const
183    {
184      return(m_data.archiveData(archiveFile, noValues));
185    }
186    
187    int
188    DataConstant::extractData(ifstream& archiveFile,
189                              const DataArrayView::ValueType::size_type noValues)
190    {
191      return(m_data.extractData(archiveFile, noValues));
192    }
193    
194  }  // end of namespace  }  // end of namespace

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

  ViewVC Help
Powered by ViewVC 1.1.26