/[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 119 by jgs, Tue Apr 12 04:45:05 2005 UTC trunk/escript/src/escriptcpp.cpp revision 480 by jgs, Wed Feb 1 05:15:12 2006 UTC
# Line 15  Line 15 
15    
16  ******************************************************************************/  ******************************************************************************/
17    
18  #include "escript/Data/Data.h"  #include "Data.h"
19  #include "escript/Data/FunctionSpace.h"  #include "DataVariable.h"
20  #include "escript/Data/FunctionSpaceFactory.h"  #include "FunctionSpace.h"
21  #include "escript/Data/DataFactory.h"  #include "FunctionSpaceFactory.h"
22  #include "escript/Data/AbstractContinuousDomain.h"  #include "DataFactory.h"
23  #include "escript/Data/AbstractDomain.h"  #include "AbstractContinuousDomain.h"
24  #include "esysUtils/esysExceptionTranslator.h"  #include "AbstractDomain.h"
25    #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>
 using namespace boost::python;  
   
 /**  
    @memo  
    escript is the python module that contains the interfaces  
    to the C++ side of escript.  
   
    @version 1.0.0  
   
    @doc  
36    
37     Class Description:  using namespace boost::python;
    Data  
   
    Class Limitations:  
    None  
   
    Class Conditions of Use:  
    None  
   
    Throws:  
    None  
38    
39  */  /*! \mainpage Esys Documentation
40     *
41     * \version 1.0.0
42     *
43     * - \ref escript
44     *
45     * - \ref esys_exception "Esys Exception"
46     *
47     * - \ref finley
48     *
49     * - <a href=http://iservo.edu.au/esys/epydoc/index.html>Python module documentation (epydoc generated)</a>
50     *
51     */
52    
53    /*! \page escript Escript
54     * Escript is the python module that contains the interfaces
55     * to the C++ side of escript.
56     *
57     * \version 1.0.0
58     *
59     * \section class_desc Class Description:
60     * Data
61     *
62     * \section class_limits Class Limitations:
63     * None
64     *
65     * \section class_conds Class Conditions of Use:
66     * None
67     *
68     * \section class_throws Throws:
69     * None
70     *
71     */
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 64  BOOST_PYTHON_MODULE(escriptcpp) Line 82  BOOST_PYTHON_MODULE(escriptcpp)
82       .def("getX",&escript::AbstractDomain::getX)       .def("getX",&escript::AbstractDomain::getX)
83       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
84       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
85         .def("saveVTK",&escript::AbstractDomain::saveVTK)
86         .def("saveDX",&escript::AbstractDomain::saveDX)
87       .def(self == self)       .def(self == self)
88       .def(self != self);       .def(self != self);
89    
# Line 78  BOOST_PYTHON_MODULE(escriptcpp) Line 98  BOOST_PYTHON_MODULE(escriptcpp)
98    //    //
99    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace>("FunctionSpace",init<>())
100       .def("getDim",&escript::FunctionSpace::getDim)       .def("getDim",&escript::FunctionSpace::getDim)
101         .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())
102       .def("getX",&escript::FunctionSpace::getX)       .def("getX",&escript::FunctionSpace::getX)
103       .def("getNormal",&escript::FunctionSpace::getNormal)       .def("getNormal",&escript::FunctionSpace::getNormal)
104       .def("getSize",&escript::FunctionSpace::getSize)       .def("getSize",&escript::FunctionSpace::getSize)
105       .def("toString",&escript::FunctionSpace::toString)       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)
106         .def("__str__",&escript::FunctionSpace::toString)
107       .def(self == self)       .def(self == self)
108       .def(self != self);       .def(self != self);
109    
110    //    //
111      // Interface for DataVariable
112      //
113      class_<escript::DataVariable>("DataVariable",init<>())
114        .def(init<escript::Data*>())
115        .def("evaluate",&escript::DataVariable::evaluate)
116        .def("sum",&escript::DataVariable::sum)
117        .def("diff",&escript::DataVariable::diff);
118    
119      //
120    // Interface for Data    // Interface for Data
121    //    //
122    class_<escript::Data>("Data",init<>())    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>())
123      // various constructors for Data objects      // various constructors for Data objects
124      .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")))
125      .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 97  BOOST_PYTHON_MODULE(escriptcpp) Line 128  BOOST_PYTHON_MODULE(escriptcpp)
128      .def(init<const escript::Data&>())      .def(init<const escript::Data&>())
129      // 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
130      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
131      .def("toString",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
132      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
133      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())
134      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
# Line 109  BOOST_PYTHON_MODULE(escriptcpp) Line 140  BOOST_PYTHON_MODULE(escriptcpp)
140      .def("getRefValue",&escript::Data::getRefValue)      .def("getRefValue",&escript::Data::getRefValue)
141      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
142      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
143        .def("copy",&escript::Data::copy)
144        .def("convertToNumArray",&escript::Data::convertToNumArray)
145        .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)
146        .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)
147        .def("fillFromNumArray",&escript::Data::fillFromNumArray)
148        .def("interpolate",&escript::Data::interpolate)
149        .def("mindp",&escript::Data::mindp)
150    
151      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
152      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
153      .def("wherePositive",&escript::Data::wherePositive)      .def("getTagNumber",&escript::Data::getTagNumber)
     .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)  
     .def("convertToNumArray",&escript::Data::convertToNumArray)  
154      .def("archiveData",&escript::Data::archiveData)      .def("archiveData",&escript::Data::archiveData)
155      .def("extractData",&escript::Data::extractData)      .def("extractData",&escript::Data::extractData)
156      .def("integrate",&escript::Data::integrate)      // Unary functions for Data
157      .def("transpose",&escript::Data::transpose)      .def("_interpolate",&escript::Data::interpolate)
158      .def("trace",&escript::Data::trace)      .def("_grad",&escript::Data::gradOn)
159      .def("sin",&escript::Data::sin)      .def("_grad",&escript::Data::grad)
160      .def("cos",&escript::Data::cos)      .def("_transpose",&escript::Data::transpose)
161      .def("tan",&escript::Data::tan)      .def("_trace",&escript::Data::trace)
162      .def("log",&escript::Data::log)      .def("_maxval",&escript::Data::maxval)
163      .def("ln",&escript::Data::ln)      .def("_minval",&escript::Data::minval)
164      .def("Lsup",&escript::Data::Lsup)      .def("_wherePositive",&escript::Data::wherePositive)
165      .def("Linf",&escript::Data::Lsup)      .def("_whereNegative",&escript::Data::whereNegative)
166      .def("sup",&escript::Data::sup)      .def("_whereNonNegative",&escript::Data::whereNonNegative)
167      .def("inf",&escript::Data::inf)      .def("_whereNonPositive",&escript::Data::whereNonPositive)
168        .def("_whereZero",&escript::Data::whereZero)
169        .def("_whereNonZero",&escript::Data::whereNonZero)
170        .def("_sin",&escript::Data::sin)
171        .def("_cos",&escript::Data::cos)
172        .def("_tan",&escript::Data::tan)
173        .def("_asin",&escript::Data::asin)
174        .def("_acos",&escript::Data::acos)
175        .def("_atan",&escript::Data::atan)
176        .def("_sinh",&escript::Data::sinh)
177        .def("_cosh",&escript::Data::cosh)
178        .def("_tanh",&escript::Data::tanh)
179        .def("_asinh",&escript::Data::asinh)
180        .def("_acosh",&escript::Data::acosh)
181        .def("_atanh",&escript::Data::atanh)
182        .def("_exp",&escript::Data::exp)
183        .def("_sqrt",&escript::Data::sqrt)
184        .def("_log10",&escript::Data::log10)
185        .def("_log",&escript::Data::log)
186        .def("_sign",&escript::Data::sign)
187        // functions returning a single real number:
188        .def("_Lsup",&escript::Data::Lsup)
189        .def("_sup",&escript::Data::sup)
190        .def("_inf",&escript::Data::inf)
191        .def("_integrate",&escript::Data::integrate)
192    
193        // following implements the python abs operator
194      .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("length",&escript::Data::length)  
     .def("sign",&escript::Data::sign)  
195      // following implements the python "-" negation operator      // following implements the python "-" negation operator
196      .def("__neg__",&escript::Data::neg)      .def("__neg__",&escript::Data::neg)
197      // following implements the python "+" identity operator      // following implements the python "+" identity operator
# Line 157  BOOST_PYTHON_MODULE(escriptcpp) Line 206  BOOST_PYTHON_MODULE(escriptcpp)
206      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
207      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
208      // version will be called.      // version will be called.
     .def(self += other<object>())  
     .def(self += self)  
209      .def(self + other<object>())      .def(self + other<object>())
210      .def(other<object>() + self)      .def(other<object>() + self)
211      .def(self + self)      .def(self + self)
212      .def(self -= other<object>())      .def(self += other<object>())
213      .def(self -= self)      .def(self += self)
214    
215      .def(self - other<object>())      .def(self - other<object>())
216      .def(other<object>() - self)      .def(other<object>() - self)
217      .def(self - self)      .def(self - self)
218      .def(self *= other<object>())      .def(self -= other<object>())
219      .def(self *= self)      .def(self -= self)
220    
221      .def(self * other<object>())      .def(self * other<object>())
222      .def(other<object>() * self)      .def(other<object>() * self)
223      .def(self * self)      .def(self * self)
224      .def(self /= other<object>())      .def(self *= other<object>())
225      .def(self /= self)      .def(self *= self)
226    
227      .def(self / other<object>())      .def(self / other<object>())
228      .def(other<object>() / self)      .def(other<object>() / self)
229      .def(self / self)      .def(self / self)
230        .def(self /= other<object>())
231        .def(self /= self)
232      // Need scope resolution due to a bug either in the compiler or      // Need scope resolution due to a bug either in the compiler or
233      // the boost code. This calls operator << for Data.      // the boost code. This calls operator << for Data.
234      .def(self_ns::str(self));      .def(self_ns::str(self));
# Line 225  BOOST_PYTHON_MODULE(escriptcpp) Line 277  BOOST_PYTHON_MODULE(escriptcpp)
277       .def("solve",&escript::AbstractSystemMatrix::solve)       .def("solve",&escript::AbstractSystemMatrix::solve)
278       .def("of",&escript::AbstractSystemMatrix::vectorMultiply)       .def("of",&escript::AbstractSystemMatrix::vectorMultiply)
279       .def("saveMM",&escript::AbstractSystemMatrix::saveMM)       .def("saveMM",&escript::AbstractSystemMatrix::saveMM)
280       .def("setValue",&escript::AbstractSystemMatrix::setValue)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
281       .def("resetSolver",&escript::AbstractSystemMatrix::resetSolver)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
282       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
283    
284    //    //

Legend:
Removed from v.119  
changed lines
  Added in v.480

  ViewVC Help
Powered by ViewVC 1.1.26