/[escript]/trunk/ripley/src/ripleycpp.cpp
ViewVC logotype

Diff of /trunk/ripley/src/ripleycpp.cpp

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

revision 4356 by caltinay, Fri Mar 22 04:38:36 2013 UTC revision 4357 by caltinay, Thu Apr 11 06:07:14 2013 UTC
# Line 27  using namespace boost::python; Line 27  using namespace boost::python;
27    
28  namespace ripley {  namespace ripley {
29    
 void writeBinaryGrid(std::string filename, const escript::Data& d,  
         const char byteorder, const char datatype, const char datasize)  
 {  
     const RipleyDomain* dom=dynamic_cast<const RipleyDomain*>(d.getDomain().get());  
     if (!dom)  
         throw RipleyException("Function space must be on a ripley domain");  
   
     if (datatype != 'f')  
         throw RipleyException("only float data supported");  
   
     if (datasize != '4')  
         throw RipleyException("only single-precision data supported");  
   
     switch (byteorder) {  
         case '=':  
             dom->writeBinaryGrid(d, filename, RIPLEY_BYTE_ORDER);  
             break;  
         case '<':  
             dom->writeBinaryGrid(d, filename, RIPLEY_LITTLE_ENDIAN);  
             break;  
         case '>':  
             dom->writeBinaryGrid(d, filename, RIPLEY_BIG_ENDIAN);  
             break;  
         default:  
             throw RipleyException("unrecognized byte order argument");  
     }  
 }  
   
30  escript::Data readBinaryGrid(std::string filename, escript::FunctionSpace fs,  escript::Data readBinaryGrid(std::string filename, escript::FunctionSpace fs,
31          const object& pyFirst, const object& pyNum, const object& pyMultiplier,          const object& pyFirst, const object& pyNum, const object& pyMultiplier,
32          const object& pyShape, double fill=0.)          const object& pyShape, double fill=0.)
# Line 248  escript::Domain_ptr _rectangle(double _n Line 220  escript::Domain_ptr _rectangle(double _n
220  }  }
221  std::string _who(){int a[]={_q[0]^42,_q[1]^42,_q[2]^42,0};return (char*)&a[0];}  std::string _who(){int a[]={_q[0]^42,_q[1]^42,_q[2]^42,0};return (char*)&a[0];}
222    
223  } // end of namespace  } // end of namespace ripley
224    
225    
226  BOOST_PYTHON_MODULE(ripleycpp)  BOOST_PYTHON_MODULE(ripleycpp)
# Line 262  BOOST_PYTHON_MODULE(ripleycpp) Line 234  BOOST_PYTHON_MODULE(ripleycpp)
234      register_exception_translator<ripley::RipleyException>(&(esysUtils::esysExceptionTranslator));      register_exception_translator<ripley::RipleyException>(&(esysUtils::esysExceptionTranslator));
235    
236      scope().attr("__doc__") = "To use this module, please import esys.ripley";      scope().attr("__doc__") = "To use this module, please import esys.ripley";
237        scope().attr("BYTEORDER_NATIVE") = (int)ripley::BYTEORDER_NATIVE;
238        scope().attr("BYTEORDER_LITTLE_ENDIAN") = (int)ripley::BYTEORDER_LITTLE_ENDIAN;
239        scope().attr("BYTEORDER_BIG_ENDIAN") = (int)ripley::BYTEORDER_BIG_ENDIAN;
240        scope().attr("DATATYPE_INT32") = (int)ripley::DATATYPE_INT32;
241        scope().attr("DATATYPE_FLOAT32") = (int)ripley::DATATYPE_FLOAT32;
242        scope().attr("DATATYPE_FLOAT64") = (int)ripley::DATATYPE_FLOAT64;
243    
244      def("Brick", ripley::_brick, (arg("n0"),arg("n1"),arg("n2"),arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,arg("d0")=-1,arg("d1")=-1,arg("d2")=-1),      def("Brick", ripley::_brick, (arg("n0"),arg("n1"),arg("n2"),arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,arg("d0")=-1,arg("d1")=-1,arg("d2")=-1),
245  "Creates a hexagonal mesh with n0 x n1 x n2 elements over the brick [0,l0] x [0,l1] x [0,l2].\n\n"  "Creates a hexagonal mesh with n0 x n1 x n2 elements over the brick [0,l0] x [0,l1] x [0,l2].\n\n"
# Line 289  BOOST_PYTHON_MODULE(ripleycpp) Line 267  BOOST_PYTHON_MODULE(ripleycpp)
267    
268      def("_readNcGrid", &ripley::readNcGrid, (arg("filename"), arg("varname"), arg("functionspace"), arg("first"), arg("numValues"), arg("multiplier"), arg("shape"), arg("fill")=0.));      def("_readNcGrid", &ripley::readNcGrid, (arg("filename"), arg("varname"), arg("functionspace"), arg("first"), arg("numValues"), arg("multiplier"), arg("shape"), arg("fill")=0.));
269    
     def("_writeBinaryGrid", &ripley::writeBinaryGrid);  
   
270      class_<ripley::RipleyDomain, bases<escript::AbstractContinuousDomain>, boost::noncopyable >      class_<ripley::RipleyDomain, bases<escript::AbstractContinuousDomain>, boost::noncopyable >
271          ("RipleyDomain", "", no_init)          ("RipleyDomain", "", no_init)
272          .def("print_mesh_info", &ripley::RipleyDomain::Print_Mesh_Info, (arg("full")=false),          .def("print_mesh_info", &ripley::RipleyDomain::Print_Mesh_Info, (arg("full")=false),
273                  "Prints out a summary about the mesh.\n"                  "Prints out a summary about the mesh.\n"
274                  ":param full: whether to output additional data\n:type full: ``bool``")                  ":param full: whether to output additional data\n:type full: ``bool``")
275            .def("writeBinaryGrid", &ripley::RipleyDomain::writeBinaryGrid)
276    
277          .def("dump", &ripley::RipleyDomain::dump, args("filename"),          .def("dump", &ripley::RipleyDomain::dump, args("filename"),
278                  "Dumps the mesh to a file with the given name.")                  "Dumps the mesh to a file with the given name.")
279          .def("getGridParameters", &ripley::RipleyDomain::getGridParameters,          .def("getGridParameters", &ripley::RipleyDomain::getGridParameters,

Legend:
Removed from v.4356  
changed lines
  Added in v.4357

  ViewVC Help
Powered by ViewVC 1.1.26