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

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

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

revision 2642 by jfenwick, Tue Sep 1 04:15:50 2009 UTC revision 2644 by jfenwick, Wed Sep 2 04:14:03 2009 UTC
# Line 173  ESCRIPT_DLL_API void MPIBarrierWorld() { Line 173  ESCRIPT_DLL_API void MPIBarrierWorld() {
173  }  }
174    
175    
 /*  
 ESCRIPT_DLL_API  
 void  
 saveDataCSV(const std::string& filename, boost::python::dict arg, const std::string& sep, const std::string& csep,  
 bool append)  
 {  
     boost::python::list keys=arg.keys();  
     int numdata = boost::python::extract<int>(arg.attr("__len__")());  
     bool hasmask=arg.has_key("mask");  
     Data mask;  
     if (hasmask)  
     {  
     mask=boost::python::extract<escript::Data>(arg["mask"]);  
     keys.remove("mask");  
         if (mask.getDataPointRank()!=0)  
     {  
         throw DataException("saveDataCSVcpp: masks must be scalar.");  
     }  
     }  
     if (numdata<1)  
     {  
     throw DataException("saveDataCSVcpp: no data to save specified.");  
     }  
     std::vector<std::string> names(numdata);  
     std::vector<Data> data(numdata);  
     std::vector<int> fstypes(numdata);      // FunctionSpace types for each data  
   
     if (hasmask)  
     {  
     numdata--;  
     }  
   
     // We need to interpret the samples correctly even if they are different types  
     // for this reason, we should interate over samples  
     for (int i=0;i<numdata;++i)  
     {  
     names[i]=boost::python::extract<std::string>(keys[i]);  
     data[i]=boost::python::extract<escript::Data>(arg[keys[i]]);  
     fstypes[i]=data[i].getFunctionSpace().getTypeCode();  
     if (i>0)  
     {  
         if (data[i].getDomain()!=data[i-1].getDomain())  
         {  
         throw DataException("saveDataCSVcpp: all data must be on the same domain.");  
         }  
     }  
     }  
     const_Domain_ptr dom0=data[0].getDomain();  
     if (hasmask)  
     {  
     if (dom0!=mask.getDomain())  
     {  
         throw DataException("saveDataCSVcpp: mask be on the same FunctionSpace as data.");  
     }  
     fstypes[numdata]=mask.getFunctionSpace().getTypeCode();  
     names[numdata]="mask";  
     data[numdata]=mask;  
     }  
     int bestfnspace=0;  
     if (!dom0->commonFunctionSpace(fstypes, bestfnspace))  
     {  
     throw DataException("saveDataCSVcpp: FunctionSpaces of data are incompatible");  
     }  
     // now we interpolate all data to the same type  
     FunctionSpace best(dom0,bestfnspace);  
     for (int i=0;i<data.size();++i)  
     {  
     data[i]=data[i].interpolate(best);  
     }  
     dom0->saveDataCSV(filename, data, names, sep, csep, append, hasmask);  
 }  
 */  
   
   
176  ESCRIPT_DLL_API  ESCRIPT_DLL_API
177  void  void
178  saveDataCSV(const std::string& filename, boost::python::dict arg, const std::string& sep, const std::string& csep,  saveDataCSV(const std::string& filename, boost::python::dict arg, const std::string& sep, const std::string& csep,
# Line 279  bool append) Line 205  bool append)
205      std::vector<int> offset(numdata);      std::vector<int> offset(numdata);
206      std::vector<int> fstypes(numdata);      // FunctionSpace types for each data      std::vector<int> fstypes(numdata);      // FunctionSpace types for each data
207    
208        keys.sort();    // to get some predictable order to things
209    
210      // We need to interpret the samples correctly even if they are different types      // We need to interpret the samples correctly even if they are different types
211      // for this reason, we should interate over samples      // for this reason, we should interate over samples
212      for (int i=0;i<numdata;++i)      for (int i=0;i<numdata;++i)

Legend:
Removed from v.2642  
changed lines
  Added in v.2644

  ViewVC Help
Powered by ViewVC 1.1.26