/[escript]/branches/split/weipa/src/DataVar.cpp
ViewVC logotype

Diff of /branches/split/weipa/src/DataVar.cpp

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

trunk/dataexporter/src/DataVar.cpp revision 2940 by caltinay, Fri Feb 19 00:38:45 2010 UTC trunk/weipa/src/DataVar.cpp revision 3092 by caltinay, Fri Aug 13 07:55:03 2010 UTC
# Line 11  Line 11 
11  *  *
12  *******************************************************/  *******************************************************/
13    
14  #include <escriptexport/DataVar.h>  #include <weipa/DataVar.h>
15  #include <escriptexport/ElementData.h>  #include <weipa/ElementData.h>
16  #include <escriptexport/FinleyMesh.h>  #include <weipa/FinleyMesh.h>
17  #include <escriptexport/NodeData.h>  #include <weipa/NodeData.h>
18  #ifndef VISIT_PLUGIN  #ifndef VISIT_PLUGIN
19  #include <escript/Data.h>  #include <escript/Data.h>
20  #endif  #endif
# Line 27  Line 27 
27  #include <silo.h>  #include <silo.h>
28  #endif  #endif
29    
30    #include <numeric> // for accumulate
31    
32  using namespace std;  using namespace std;
33    
34  namespace escriptexport {  namespace weipa {
35            
36  enum {  enum {
37      NODE_CENTERED = 1,      NODE_CENTERED = 1,
# Line 473  bool DataVar::reorderSamples() Line 475  bool DataVar::reorderSamples()
475  //  //
476  //  //
477  //  //
478    int DataVar::getNumberOfComponents() const
479    {
480        return (rank == 0 ? 1 : accumulate(shape.begin(), shape.end(), 0));
481    }
482    
483    //
484    //
485    //
486    float* DataVar::getDataFlat() const
487    {
488        int totalSize = numSamples * getNumberOfComponents();
489        float* res = new float[totalSize];
490        if (rank == 0) {
491            copy(dataArray[0], dataArray[0]+numSamples, res);
492        } else if (rank == 1) {
493            float *dest = res;
494            for (size_t c=0; c<numSamples; c++) {
495                for (size_t i=0; i<shape[0]; i++) {
496                    *dest++ = dataArray[i][c];
497                }
498            }
499        } else if (rank == 2) {
500            float *dest = res;
501            for (size_t c=0; c<numSamples; c++) {
502                for (int i=0; i<shape[1]; i++) {
503                    for (int j=0; j<shape[0]; j++) {
504                        *dest++ = dataArray[i*shape[0]+j][c];
505                    }
506                }
507            }
508        }
509    
510        return res;
511    }
512    
513    //
514    //
515    //
516  void DataVar::sampleToStream(ostream& os, int index)  void DataVar::sampleToStream(ostream& os, int index)
517  {  {
518      if (rank == 0) {      if (rank == 0) {
# Line 657  bool DataVar::writeToSilo(DBfile* dbfile Line 697  bool DataVar::writeToSilo(DBfile* dbfile
697  #endif  #endif
698  }  }
699    
700  } // namespace escriptexport  } // namespace weipa
701    

Legend:
Removed from v.2940  
changed lines
  Added in v.3092

  ViewVC Help
Powered by ViewVC 1.1.26