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

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

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

revision 856 by gross, Tue Sep 26 01:00:36 2006 UTC revision 921 by gross, Fri Jan 5 00:54:37 2007 UTC
# Line 373  DataExpanded::extractData(ifstream& arch Line 373  DataExpanded::extractData(ifstream& arch
373    return(m_data.extractData(archiveFile, noValues));    return(m_data.extractData(archiveFile, noValues));
374  }  }
375    
376    void
377    DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value) {
378      //
379      // Get the number of samples and data-points per sample.
380      int numSamples = getNumSamples();
381      int numDataPointsPerSample = getNumDPPSample();
382      int dataPointRank = getPointDataView().getRank();
383      ShapeType dataPointShape = getPointDataView().getShape();
384      //
385      // check rank:
386      if (value.getrank()!=dataPointRank)
387           throw DataException("Rank of numarray does not match Data object rank");
388      if (numSamples*numDataPointsPerSample > 0) {
389         //TODO: global error handling
390         if (sampleNo >= numSamples or sampleNo < 0 ) {
391              throw DataException("Error - DataExpanded::copyDataPoint invalid sampleNo.");
392         }
393         if (dataPointNo >= numDataPointsPerSample or dataPointNo < 0) {
394               throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
395         }
396         DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
397         if (dataPointRank==0) {
398             dataPointView()=extract<double>(value[0]);
399         } else if (dataPointRank==1) {
400            for (int i=0; i<dataPointShape[0]; i++) {
401                dataPointView(i)=extract<double>(value[i]);
402            }
403         } else if (dataPointRank==2) {
404            for (int i=0; i<dataPointShape[0]; i++) {
405               for (int j=0; j<dataPointShape[1]; j++) {
406                  dataPointView(i,j)=extract<double>(value[i][j]);
407               }
408            }
409         } else if (dataPointRank==3) {
410            for (int i=0; i<dataPointShape[0]; i++) {
411               for (int j=0; j<dataPointShape[1]; j++) {
412                  for (int k=0; k<dataPointShape[2]; k++) {
413                     dataPointView(i,j,k)=extract<double>(value[i][j][k]);
414                  }
415               }
416            }
417         } else if (dataPointRank==4) {
418             for (int i=0; i<dataPointShape[0]; i++) {
419               for (int j=0; j<dataPointShape[1]; j++) {
420                 for (int k=0; k<dataPointShape[2]; k++) {
421                   for (int l=0; l<dataPointShape[3]; l++) {
422                      dataPointView(i,j,k,l)=extract<double>(value[i][j][k][l]);
423                   }
424                 }
425               }
426             }
427         }
428      }
429    }
430  void  void
431  DataExpanded::copyAll(const boost::python::numeric::array& value) {  DataExpanded::copyAll(const boost::python::numeric::array& value) {
432    //    //

Legend:
Removed from v.856  
changed lines
  Added in v.921

  ViewVC Help
Powered by ViewVC 1.1.26