/[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 121 by jgs, Fri May 6 04:26:16 2005 UTC trunk/escript/src/Data/escriptcpp.cpp revision 391 by gross, Tue Dec 20 05:36:50 2005 UTC
# Line 16  Line 16 
16  ******************************************************************************/  ******************************************************************************/
17    
18  #include "escript/Data/Data.h"  #include "escript/Data/Data.h"
19    #include "escript/Data/DataVariable.h"
20  #include "escript/Data/FunctionSpace.h"  #include "escript/Data/FunctionSpace.h"
21  #include "escript/Data/FunctionSpaceFactory.h"  #include "escript/Data/FunctionSpaceFactory.h"
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 28  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 41  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/epydoc/index.html>Python module documentation (epydoc generated)</a>
48     *
49   */   */
50    
51  /*! \page escript Escript  /*! \page escript Escript
# Line 65  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 73  BOOST_PYTHON_MODULE(escriptcpp) Line 80  BOOST_PYTHON_MODULE(escriptcpp)
80       .def("getX",&escript::AbstractDomain::getX)       .def("getX",&escript::AbstractDomain::getX)
81       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
82       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
83         .def("saveVTK",&escript::AbstractDomain::saveVTK)
84         .def("saveDX",&escript::AbstractDomain::saveDX)
85       .def(self == self)       .def(self == self)
86       .def(self != self);       .def(self != self);
87    
# Line 87  BOOST_PYTHON_MODULE(escriptcpp) Line 96  BOOST_PYTHON_MODULE(escriptcpp)
96    //    //
97    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace>("FunctionSpace",init<>())
98       .def("getDim",&escript::FunctionSpace::getDim)       .def("getDim",&escript::FunctionSpace::getDim)
99         .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())
100       .def("getX",&escript::FunctionSpace::getX)       .def("getX",&escript::FunctionSpace::getX)
101       .def("getNormal",&escript::FunctionSpace::getNormal)       .def("getNormal",&escript::FunctionSpace::getNormal)
102       .def("getSize",&escript::FunctionSpace::getSize)       .def("getSize",&escript::FunctionSpace::getSize)
103       .def("toString",&escript::FunctionSpace::toString)       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)
104         .def("__str__",&escript::FunctionSpace::toString)
105       .def(self == self)       .def(self == self)
106       .def(self != self);       .def(self != self);
107    
108    //    //
109      // Interface for DataVariable
110      //
111      class_<escript::DataVariable>("DataVariable",init<>())
112        .def(init<escript::Data*>())
113        .def("evaluate",&escript::DataVariable::evaluate)
114        .def("sum",&escript::DataVariable::sum)
115        .def("diff",&escript::DataVariable::diff);
116    
117      //
118    // Interface for Data    // Interface for Data
119    //    //
120    class_<escript::Data>("Data",init<>())    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>())
121      // various constructors for Data objects      // various constructors for Data objects
122      .def(init<const numeric::array&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))      .def(init<const numeric::array&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))
123      .def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))      .def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))
# Line 106  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 118  BOOST_PYTHON_MODULE(escriptcpp) Line 138  BOOST_PYTHON_MODULE(escriptcpp)
138      .def("getRefValue",&escript::Data::getRefValue)      .def("getRefValue",&escript::Data::getRefValue)
139      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
140      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
141      .def("saveDX",&escript::Data::saveDX)      .def("copy",&escript::Data::copy)
     .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)
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)
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("log",&escript::Data::log)      .def("_maxval",&escript::Data::maxval)
161      .def("ln",&escript::Data::ln)      .def("_minval",&escript::Data::minval)
162      .def("Lsup",&escript::Data::Lsup)      .def("_wherePositive",&escript::Data::wherePositive)
163      .def("Linf",&escript::Data::Lsup)      .def("_whereNegative",&escript::Data::whereNegative)
164      .def("sup",&escript::Data::sup)      .def("_whereNonNegative",&escript::Data::whereNonNegative)
165      .def("inf",&escript::Data::inf)      .def("_whereNonPositive",&escript::Data::whereNonPositive)
166        .def("_whereZero",&escript::Data::whereZero)
167        .def("_whereNonZero",&escript::Data::whereNonZero)
168        .def("_sin",&escript::Data::sin)
169        .def("_cos",&escript::Data::cos)
170        .def("_tan",&escript::Data::tan)
171        .def("_asin",&escript::Data::asin)
172        .def("_acos",&escript::Data::acos)
173        .def("_atan",&escript::Data::atan)
174        .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 172  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));
# Line 240  BOOST_PYTHON_MODULE(escriptcpp) Line 275  BOOST_PYTHON_MODULE(escriptcpp)
275       .def("solve",&escript::AbstractSystemMatrix::solve)       .def("solve",&escript::AbstractSystemMatrix::solve)
276       .def("of",&escript::AbstractSystemMatrix::vectorMultiply)       .def("of",&escript::AbstractSystemMatrix::vectorMultiply)
277       .def("saveMM",&escript::AbstractSystemMatrix::saveMM)       .def("saveMM",&escript::AbstractSystemMatrix::saveMM)
278       .def("setValue",&escript::AbstractSystemMatrix::setValue)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
279       .def("resetSolver",&escript::AbstractSystemMatrix::resetSolver)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
280       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
281    
282    //    //

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

  ViewVC Help
Powered by ViewVC 1.1.26