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

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

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

trunk/esys2/escript/src/Data/escriptcpp.cpp revision 153 by jgs, Tue Oct 25 01:51:20 2005 UTC trunk/escript/src/Data/escriptcpp.cpp revision 391 by gross, Tue Dec 20 05:36:50 2005 UTC
# Line 22  Line 22 
22  #include "escript/Data/DataFactory.h"  #include "escript/Data/DataFactory.h"
23  #include "escript/Data/AbstractContinuousDomain.h"  #include "escript/Data/AbstractContinuousDomain.h"
24  #include "escript/Data/AbstractDomain.h"  #include "escript/Data/AbstractDomain.h"
25    #include "escript/Data/Utils.h"
26  #include "esysUtils/esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
27    
28  #include <boost/python.hpp>  #include <boost/python.hpp>
# Line 29  Line 30 
30  #include <boost/python/def.hpp>  #include <boost/python/def.hpp>
31  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
32  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
33                                                                                                                                              #include <boost/python/numeric.hpp>
34    
35  using namespace boost::python;  using namespace boost::python;
36    
37  /*! \mainpage Esys Documentation  /*! \mainpage Esys Documentation
# Line 42  using namespace boost::python; Line 44  using namespace boost::python;
44   *   *
45   * - \ref finley   * - \ref finley
46   *   *
47   * - <a href=http://iservo.edu.au/esys/esys_python_doc/index.html>Python module documentation (epydoc generated)</a>   * - <a href=http://iservo.edu.au/esys/epydoc/index.html>Python module documentation (epydoc generated)</a>
48   *   *
49   */   */
50    
# Line 68  using namespace boost::python; Line 70  using namespace boost::python;
70    
71  BOOST_PYTHON_MODULE(escriptcpp)  BOOST_PYTHON_MODULE(escriptcpp)
72  {  {
73      def("setNumberOfThreads",escript::setNumberOfThreads);
74      def("getNumberOfThreads",escript::getNumberOfThreads);
75    
76    //    //
77    // Interface for AbstractDomain    // Interface for AbstractDomain
# Line 122  BOOST_PYTHON_MODULE(escriptcpp) Line 126  BOOST_PYTHON_MODULE(escriptcpp)
126      .def(init<const escript::Data&>())      .def(init<const escript::Data&>())
127      // Note for Lutz, Need to specify the call policy in order to return a      // Note for Lutz, Need to specify the call policy in order to return a
128      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
129      .def("toString",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
130      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
131      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())
132      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
# Line 135  BOOST_PYTHON_MODULE(escriptcpp) Line 139  BOOST_PYTHON_MODULE(escriptcpp)
139      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
140      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
141      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
     .def("saveDX",&escript::Data::saveDX)  
     .def("saveVTK",&escript::Data::saveVTK)  
     .def("wherePositive",&escript::Data::wherePositive)  
     .def("whereNegative",&escript::Data::whereNegative)  
     .def("whereNonNegative",&escript::Data::whereNonNegative)  
     .def("whereNonPositive",&escript::Data::whereNonPositive)  
     .def("whereZero",&escript::Data::whereZero)  
     .def("whereNonZero",&escript::Data::whereNonZero)  
     // Unary functions for Data  
     .def("interpolate",&escript::Data::interpolate)  
     .def("grad",&escript::Data::gradOn)  
     .def("grad",&escript::Data::grad)  
142      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("convertToNumArray",&escript::Data::convertToNumArray)
143      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)
144      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)
145      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("fillFromNumArray",&escript::Data::fillFromNumArray)
146        .def("interpolate",&escript::Data::interpolate)
147        .def("mindp",&escript::Data::mindp)
148    
149        .def("saveDX",&escript::Data::saveDX)
150        .def("saveVTK",&escript::Data::saveVTK)
151      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
152      .def("archiveData",&escript::Data::archiveData)      .def("archiveData",&escript::Data::archiveData)
153      .def("extractData",&escript::Data::extractData)      .def("extractData",&escript::Data::extractData)
154      .def("integrate",&escript::Data::integrate)      // Unary functions for Data
155      .def("transpose",&escript::Data::transpose)      .def("_interpolate",&escript::Data::interpolate)
156      .def("trace",&escript::Data::trace)      .def("_grad",&escript::Data::gradOn)
157      .def("sin",&escript::Data::sin)      .def("_grad",&escript::Data::grad)
158      .def("cos",&escript::Data::cos)      .def("_transpose",&escript::Data::transpose)
159      .def("tan",&escript::Data::tan)      .def("_trace",&escript::Data::trace)
160      .def("asin",&escript::Data::asin)      .def("_maxval",&escript::Data::maxval)
161      .def("acos",&escript::Data::acos)      .def("_minval",&escript::Data::minval)
162      .def("atan",&escript::Data::atan)      .def("_wherePositive",&escript::Data::wherePositive)
163      .def("sinh",&escript::Data::sinh)      .def("_whereNegative",&escript::Data::whereNegative)
164      .def("cosh",&escript::Data::cosh)      .def("_whereNonNegative",&escript::Data::whereNonNegative)
165      .def("tanh",&escript::Data::tanh)      .def("_whereNonPositive",&escript::Data::whereNonPositive)
166      .def("asinh",&escript::Data::asinh)      .def("_whereZero",&escript::Data::whereZero)
167      .def("acosh",&escript::Data::acosh)      .def("_whereNonZero",&escript::Data::whereNonZero)
168      .def("atanh",&escript::Data::atanh)      .def("_sin",&escript::Data::sin)
169      .def("log",&escript::Data::log)      .def("_cos",&escript::Data::cos)
170      .def("ln",&escript::Data::ln)      .def("_tan",&escript::Data::tan)
171      .def("Lsup",&escript::Data::Lsup)      .def("_asin",&escript::Data::asin)
172      .def("Linf",&escript::Data::Lsup)      .def("_acos",&escript::Data::acos)
173      .def("sup",&escript::Data::sup)      .def("_atan",&escript::Data::atan)
174      .def("inf",&escript::Data::inf)      .def("_sinh",&escript::Data::sinh)
175        .def("_cosh",&escript::Data::cosh)
176        .def("_tanh",&escript::Data::tanh)
177        .def("_asinh",&escript::Data::asinh)
178        .def("_acosh",&escript::Data::acosh)
179        .def("_atanh",&escript::Data::atanh)
180        .def("_exp",&escript::Data::exp)
181        .def("_sqrt",&escript::Data::sqrt)
182        .def("_log10",&escript::Data::log10)
183        .def("_log",&escript::Data::log)
184        .def("_sign",&escript::Data::sign)
185        // functions returning a single real number:
186        .def("_Lsup",&escript::Data::Lsup)
187        .def("_sup",&escript::Data::sup)
188        .def("_inf",&escript::Data::inf)
189        .def("_integrate",&escript::Data::integrate)
190    
191        // following implements the python abs operator
192      .def("__abs__",&escript::Data::abs)      .def("__abs__",&escript::Data::abs)
     .def("abs",&escript::Data::abs)  
     .def("exp",&escript::Data::exp)  
     .def("sqrt",&escript::Data::sqrt)  
     .def("maxval",&escript::Data::maxval)  
     .def("minval",&escript::Data::minval)  
     .def("mindp",&escript::Data::mindp)  
     .def("length",&escript::Data::length)  
     .def("sign",&escript::Data::sign)  
193      // following implements the python "-" negation operator      // following implements the python "-" negation operator
194      .def("__neg__",&escript::Data::neg)      .def("__neg__",&escript::Data::neg)
     .def("neg",&escript::Data::neg)  
195      // following implements the python "+" identity operator      // following implements the python "+" identity operator
196      .def("__pos__",&escript::Data::pos)      .def("__pos__",&escript::Data::pos)
     .def("pos",&escript::Data::pos)  
197      // following two functions implement the python [] operator      // following two functions implement the python [] operator
198      .def("__getitem__",&escript::Data::getItem)      .def("__getitem__",&escript::Data::getItem)
199      .def("__setitem__",&escript::Data::setItemO)      .def("__setitem__",&escript::Data::setItemO)
# Line 200  BOOST_PYTHON_MODULE(escriptcpp) Line 204  BOOST_PYTHON_MODULE(escriptcpp)
204      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
205      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
206      // version will be called.      // version will be called.
     .def(self += other<object>())  
     .def(self += self)  
207      .def(self + other<object>())      .def(self + other<object>())
208      .def(other<object>() + self)      .def(other<object>() + self)
209      .def(self + self)      .def(self + self)
210      .def(self -= other<object>())      .def(self += other<object>())
211      .def(self -= self)      .def(self += self)
212    
213      .def(self - other<object>())      .def(self - other<object>())
214      .def(other<object>() - self)      .def(other<object>() - self)
215      .def(self - self)      .def(self - self)
216      .def(self *= other<object>())      .def(self -= other<object>())
217      .def(self *= self)      .def(self -= self)
218    
219      .def(self * other<object>())      .def(self * other<object>())
220      .def(other<object>() * self)      .def(other<object>() * self)
221      .def(self * self)      .def(self * self)
222      .def(self /= other<object>())      .def(self *= other<object>())
223      .def(self /= self)      .def(self *= self)
224    
225      .def(self / other<object>())      .def(self / other<object>())
226      .def(other<object>() / self)      .def(other<object>() / self)
227      .def(self / self)      .def(self / self)
228        .def(self /= other<object>())
229        .def(self /= self)
230      // Need scope resolution due to a bug either in the compiler or      // Need scope resolution due to a bug either in the compiler or
231      // the boost code. This calls operator << for Data.      // the boost code. This calls operator << for Data.
232      .def(self_ns::str(self));      .def(self_ns::str(self));

Legend:
Removed from v.153  
changed lines
  Added in v.391

  ViewVC Help
Powered by ViewVC 1.1.26