/[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 4284 by caltinay, Thu Mar 7 00:43:48 2013 UTC revision 4334 by caltinay, Thu Mar 21 06:00:14 2013 UTC
# Line 27  using namespace boost::python; Line 27  using namespace boost::python;
27    
28  namespace ripley {  namespace ripley {
29    
30    void writeBinaryGrid(std::string filename, const escript::Data& d,
31            const char byteorder, const char datatype, const char datasize)
32    {
33        const RipleyDomain* dom=dynamic_cast<const RipleyDomain*>(d.getDomain().get());
34        if (!dom)
35            throw RipleyException("Function space must be on a ripley domain");
36    
37        if (datatype != 'f')
38            throw RipleyException("only float data supported");
39    
40        if (datasize != '4')
41            throw RipleyException("only single-precision data supported");
42    
43        switch (byteorder) {
44            case '=':
45                dom->writeBinaryGrid(d, filename, RIPLEY_BYTE_ORDER);
46                break;
47            case '<':
48                dom->writeBinaryGrid(d, filename, RIPLEY_LITTLE_ENDIAN);
49                break;
50            case '>':
51                dom->writeBinaryGrid(d, filename, RIPLEY_BIG_ENDIAN);
52                break;
53            default:
54                throw RipleyException("unrecognized byte order argument");
55        }
56    }
57    
58  escript::Data readBinaryGrid(std::string filename, escript::FunctionSpace fs,  escript::Data readBinaryGrid(std::string filename, escript::FunctionSpace fs,
59          const object& pyFirst, const object& pyNum, const object& pyMultiplier,          const object& pyFirst, const object& pyNum, const object& pyMultiplier,
60          const object& pyShape, double fill=0.)          const object& pyShape, double fill=0.)
# Line 261  BOOST_PYTHON_MODULE(ripleycpp) Line 289  BOOST_PYTHON_MODULE(ripleycpp)
289    
290      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.));
291    
292        def("_writeBinaryGrid", &ripley::writeBinaryGrid);
293    
294      class_<ripley::RipleyDomain, bases<escript::AbstractContinuousDomain>, boost::noncopyable >      class_<ripley::RipleyDomain, bases<escript::AbstractContinuousDomain>, boost::noncopyable >
295          ("RipleyDomain", "", no_init)          ("RipleyDomain", "", no_init)
296          .def("print_mesh_info", &ripley::RipleyDomain::Print_Mesh_Info, (arg("full")=false),          .def("print_mesh_info", &ripley::RipleyDomain::Print_Mesh_Info, (arg("full")=false),

Legend:
Removed from v.4284  
changed lines
  Added in v.4334

  ViewVC Help
Powered by ViewVC 1.1.26