/[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/escript/src/Data/escriptcpp.cpp revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC trunk/escript/src/escriptcpp.cpp revision 595 by gross, Tue Mar 14 23:52:45 2006 UTC
# Line 15  Line 15 
15    
16  ******************************************************************************/  ******************************************************************************/
17    
18  #include "escript/Data/Data.h"  #include "Data.h"
19  #include "escript/Data/DataVariable.h"  #include "DataVariable.h"
20  #include "escript/Data/FunctionSpace.h"  #include "FunctionSpace.h"
21  #include "escript/Data/FunctionSpaceFactory.h"  #include "FunctionSpaceFactory.h"
22  #include "escript/Data/DataFactory.h"  #include "DataFactory.h"
23  #include "escript/Data/AbstractContinuousDomain.h"  #include "AbstractContinuousDomain.h"
24  #include "escript/Data/AbstractDomain.h"  #include "AbstractDomain.h"
25  #include "esysUtils/esysExceptionTranslator.h"  #include "Utils.h"
26    #include "AbstractSystemMatrix.h"
27    
28    #include "esysExceptionTranslator.h"
29    
30  #include <boost/python.hpp>  #include <boost/python.hpp>
31  #include <boost/python/module.hpp>  #include <boost/python/module.hpp>
32  #include <boost/python/def.hpp>  #include <boost/python/def.hpp>
33  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
34  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
35                                                                                                                                              #include <boost/python/numeric.hpp>
36    
37  using namespace boost::python;  using namespace boost::python;
38    
39  /*! \mainpage Esys Documentation  /*! \mainpage Esys Documentation
# Line 42  using namespace boost::python; Line 46  using namespace boost::python;
46   *   *
47   * - \ref finley   * - \ref finley
48   *   *
49   * - <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>
50   *   *
51   */   */
52    
# Line 68  using namespace boost::python; Line 72  using namespace boost::python;
72    
73  BOOST_PYTHON_MODULE(escriptcpp)  BOOST_PYTHON_MODULE(escriptcpp)
74  {  {
75      def("setNumberOfThreads",escript::setNumberOfThreads);
76      def("getNumberOfThreads",escript::getNumberOfThreads);
77    
78    //    //
79    // Interface for AbstractDomain    // Interface for AbstractDomain
# Line 100  BOOST_PYTHON_MODULE(escriptcpp) Line 106  BOOST_PYTHON_MODULE(escriptcpp)
106       .def("__str__",&escript::FunctionSpace::toString)       .def("__str__",&escript::FunctionSpace::toString)
107       .def(self == self)       .def(self == self)
108       .def(self != self);       .def(self != self);
   
   //  
   // Interface for DataVariable  
   //  
   class_<escript::DataVariable>("DataVariable",init<>())  
     .def(init<escript::Data*>())  
     .def("evaluate",&escript::DataVariable::evaluate)  
     .def("sum",&escript::DataVariable::sum)  
     .def("diff",&escript::DataVariable::diff);  
   
109    //    //
110    // Interface for Data    // Interface for Data
111    //    //
# Line 122  BOOST_PYTHON_MODULE(escriptcpp) Line 118  BOOST_PYTHON_MODULE(escriptcpp)
118      .def(init<const escript::Data&>())      .def(init<const escript::Data&>())
119      // 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
120      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
121      .def("toString",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
122      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
123      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())
124      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
# Line 135  BOOST_PYTHON_MODULE(escriptcpp) Line 131  BOOST_PYTHON_MODULE(escriptcpp)
131      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
132      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
133      .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)  
134      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("convertToNumArray",&escript::Data::convertToNumArray)
135      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)
136      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)
137      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("fillFromNumArray",&escript::Data::fillFromNumArray)
138        .def("interpolate",&escript::Data::interpolate)
139        .def("mindp",&escript::Data::mindp)
140        .def("saveDX",&escript::Data::saveDX)
141        .def("saveVTK",&escript::Data::saveVTK)
142      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
143      .def("archiveData",&escript::Data::archiveData)      .def("archiveData",&escript::Data::archiveData)
144      .def("extractData",&escript::Data::extractData)      .def("extractData",&escript::Data::extractData)
145      .def("integrate",&escript::Data::integrate)      // Unary functions for Data
146      .def("transpose",&escript::Data::transpose)      .def("_interpolate",&escript::Data::interpolate)
147      .def("trace",&escript::Data::trace)      .def("_grad",&escript::Data::gradOn)
148      .def("sin",&escript::Data::sin)      .def("_grad",&escript::Data::grad)
149      .def("cos",&escript::Data::cos)      .def("_transpose",&escript::Data::transpose)
150      .def("tan",&escript::Data::tan)      .def("_trace",&escript::Data::trace)
151      .def("asin",&escript::Data::asin)      .def("_maxval",&escript::Data::maxval)
152      .def("acos",&escript::Data::acos)      .def("_minval",&escript::Data::minval)
153      .def("atan",&escript::Data::atan)      .def("_wherePositive",&escript::Data::wherePositive,(arg("tol")=0.0))
154      .def("sinh",&escript::Data::sinh)      .def("_whereNegative",&escript::Data::whereNegative,(arg("tol")=0.0))
155      .def("cosh",&escript::Data::cosh)      .def("_whereNonNegative",&escript::Data::whereNonNegative,(arg("tol")=0.0))
156      .def("tanh",&escript::Data::tanh)      .def("_whereNonPositive",&escript::Data::whereNonPositive,(arg("tol")=0.0))
157      .def("asinh",&escript::Data::asinh)      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
158      .def("acosh",&escript::Data::acosh)      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
159      .def("atanh",&escript::Data::atanh)      .def("_sin",&escript::Data::sin)
160      .def("log",&escript::Data::log)      .def("_cos",&escript::Data::cos)
161      .def("ln",&escript::Data::ln)      .def("_tan",&escript::Data::tan)
162      .def("Lsup",&escript::Data::Lsup)      .def("_asin",&escript::Data::asin)
163      .def("Linf",&escript::Data::Lsup)      .def("_acos",&escript::Data::acos)
164      .def("sup",&escript::Data::sup)      .def("_atan",&escript::Data::atan)
165      .def("inf",&escript::Data::inf)      .def("_sinh",&escript::Data::sinh)
166        .def("_cosh",&escript::Data::cosh)
167        .def("_tanh",&escript::Data::tanh)
168        .def("_asinh",&escript::Data::asinh)
169        .def("_acosh",&escript::Data::acosh)
170        .def("_atanh",&escript::Data::atanh)
171        .def("_exp",&escript::Data::exp)
172        .def("_sqrt",&escript::Data::sqrt)
173        .def("_log10",&escript::Data::log10)
174        .def("_log",&escript::Data::log)
175        .def("_sign",&escript::Data::sign)
176        .def("_eigenvalues",&escript::Data::eigenvalues)
177        .def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13))
178        // functions returning a single real number:
179        .def("_Lsup",&escript::Data::Lsup)
180        .def("_sup",&escript::Data::sup)
181        .def("_inf",&escript::Data::inf)
182        .def("_integrate",&escript::Data::integrate)
183    
184        // following implements the python abs operator
185      .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)  
186      // following implements the python "-" negation operator      // following implements the python "-" negation operator
187      .def("__neg__",&escript::Data::neg)      .def("__neg__",&escript::Data::neg)
     .def("neg",&escript::Data::neg)  
188      // following implements the python "+" identity operator      // following implements the python "+" identity operator
189      .def("__pos__",&escript::Data::pos)      .def("__pos__",&escript::Data::pos)
     .def("pos",&escript::Data::pos)  
190      // following two functions implement the python [] operator      // following two functions implement the python [] operator
191      .def("__getitem__",&escript::Data::getItem)      .def("__getitem__",&escript::Data::getItem)
192      .def("__setitem__",&escript::Data::setItemO)      .def("__setitem__",&escript::Data::setItemO)
# Line 200  BOOST_PYTHON_MODULE(escriptcpp) Line 197  BOOST_PYTHON_MODULE(escriptcpp)
197      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
198      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
199      // version will be called.      // version will be called.
     .def(self += other<object>())  
     .def(self += self)  
200      .def(self + other<object>())      .def(self + other<object>())
201      .def(other<object>() + self)      .def(other<object>() + self)
202      .def(self + self)      .def(self + self)
203      .def(self -= other<object>())      .def(self += other<object>())
204      .def(self -= self)      .def(self += self)
205    
206      .def(self - other<object>())      .def(self - other<object>())
207      .def(other<object>() - self)      .def(other<object>() - self)
208      .def(self - self)      .def(self - self)
209      .def(self *= other<object>())      .def(self -= other<object>())
210      .def(self *= self)      .def(self -= self)
211    
212      .def(self * other<object>())      .def(self * other<object>())
213      .def(other<object>() * self)      .def(other<object>() * self)
214      .def(self * self)      .def(self * self)
215      .def(self /= other<object>())      .def(self *= other<object>())
216      .def(self /= self)      .def(self *= self)
217    
218      .def(self / other<object>())      .def(self / other<object>())
219      .def(other<object>() / self)      .def(other<object>() / self)
220      .def(self / self)      .def(self / self)
221        .def(self /= other<object>())
222        .def(self /= self)
223      // Need scope resolution due to a bug either in the compiler or      // Need scope resolution due to a bug either in the compiler or
224      // the boost code. This calls operator << for Data.      // the boost code. This calls operator << for Data.
225      .def(self_ns::str(self));      .def(self_ns::str(self));

Legend:
Removed from v.155  
changed lines
  Added in v.595

  ViewVC Help
Powered by ViewVC 1.1.26