/[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 967 by gross, Tue Feb 13 09:40:12 2007 UTC revision 1141 by gross, Tue May 15 04:24:51 2007 UTC
# Line 15  Line 15 
15  #include "DataException.h"  #include "DataException.h"
16  #include "DataConstant.h"  #include "DataConstant.h"
17  #include "DataTagged.h"  #include "DataTagged.h"
18  #include <netcdfcpp.h>  #ifdef USE_NETCDF
19    #include "netcdfcpp.h"
20    #endif
21    
22  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
23    
# Line 269  DataExpanded::toString() const Line 271  DataExpanded::toString() const
271        }        }
272      }      }
273    }    }
274    return temp.str();    return string(temp.str());
275  }  }
276    
277  DataArrayView::ValueType::size_type  DataArrayView::ValueType::size_type
# Line 616  DataExpanded::eigenvalues_and_eigenvecto Line 618  DataExpanded::eigenvalues_and_eigenvecto
618  }  }
619    
620  void  void
621    DataExpanded::setToZero(){
622      int numSamples = getNumSamples();
623      int numDataPointsPerSample = getNumDPPSample();
624      DataArrayView& thisView=getPointDataView();
625      DataArrayView::ValueType::size_type n = thisView.noValues();
626      double* p;
627      int  sampleNo,dataPointNo, i;
628      #pragma omp parallel for private(sampleNo,dataPointNo,p,i) schedule(static)
629      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
630        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
631            p=&(m_data[getPointOffset(sampleNo,dataPointNo)]);
632            for (int i=0; i<n ;++i) p[i]=0.;
633        }
634      }
635    }
636    
637    
638    void
639  DataExpanded::dump(const std::string fileName) const  DataExpanded::dump(const std::string fileName) const
640  {  {
641     #ifdef PASO_MPI     #ifdef PASO_MPI
642     throw DataException("Error - DataExpanded:: dump is not implemented for MPI yet.");     throw DataException("Error - DataExpanded:: dump is not implemented for MPI yet.");
643     #endif     #endif
644       #ifdef USE_NETCDF
645     const int ldims=2+DataArrayView::maxRank;     const int ldims=2+DataArrayView::maxRank;
646     const NcDim* ncdims[ldims];     const NcDim* ncdims[ldims];
647     NcVar *var, *ids;     NcVar *var, *ids;
# Line 628  DataExpanded::dump(const std::string fil Line 649  DataExpanded::dump(const std::string fil
649     int type=  getFunctionSpace().getTypeCode();     int type=  getFunctionSpace().getTypeCode();
650     int ndims =0;     int ndims =0;
651     long dims[ldims];     long dims[ldims];
652       const double* d_ptr=&(m_data[0]);
653     DataArrayView::ShapeType shape = getPointDataView().getShape();     DataArrayView::ShapeType shape = getPointDataView().getShape();
654    
655     // netCDF error handler     // netCDF error handler
# Line 637  DataExpanded::dump(const std::string fil Line 659  DataExpanded::dump(const std::string fil
659     // check if writing was successful     // check if writing was successful
660     if (!dataFile.is_valid())     if (!dataFile.is_valid())
661          throw DataException("Error - DataExpanded:: opening of netCDF file for output failed.");          throw DataException("Error - DataExpanded:: opening of netCDF file for output failed.");
662     if (!dataFile.add_att("type","expanded") )     if (!dataFile.add_att("type_id",2) )
663          throw DataException("Error - DataExpanded:: appending data type to netCDF file failed.");          throw DataException("Error - DataExpanded:: appending data type to netCDF file failed.");
664     if (!dataFile.add_att("rank",rank) )     if (!dataFile.add_att("rank",rank) )
665          throw DataException("Error - DataExpanded:: appending rank attribute to netCDF file failed.");          throw DataException("Error - DataExpanded:: appending rank attribute to netCDF file failed.");
# Line 679  DataExpanded::dump(const std::string fil Line 701  DataExpanded::dump(const std::string fil
701    
702     if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )     if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )
703          throw DataException("Error - DataExpanded:: appending variable to netCDF file failed.");          throw DataException("Error - DataExpanded:: appending variable to netCDF file failed.");
704     if (! (var->put(&m_data[0],dims)) )     if (! (var->put(d_ptr,dims)) )
705          throw DataException("Error - DataExpanded:: copy data to netCDF buffer failed.");          throw DataException("Error - DataExpanded:: copy data to netCDF buffer failed.");
706       #else
707       throw DataException("Error - DataExpanded:: dump is not configured with netCDF. Please contact your installation manager.");
708       #endif
709  }  }
   
   
710  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.967  
changed lines
  Added in v.1141

  ViewVC Help
Powered by ViewVC 1.1.26