/[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

revision 2064 by jfenwick, Thu Nov 20 04:06:34 2008 UTC revision 2482 by jfenwick, Fri Jun 19 05:56:20 2009 UTC
# Line 24  Line 24 
24  #include "DataVector.h"  #include "DataVector.h"
25  #include "paso/Paso_MPI.h"  #include "paso/Paso_MPI.h"
26  #include "EscriptParams.h"  #include "EscriptParams.h"
27    #include "TestDomain.h"
28    
29    
30  extern "C" {  extern "C" {
31  #include "escript/blocktimer.h"  #include "esysUtils/blocktimer.h"
32  }  }
33    
34  #include "esysUtils/esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
35    
36    #include <boost/version.hpp>
37  #include <boost/python.hpp>  #include <boost/python.hpp>
38  #include <boost/python/module.hpp>  #include <boost/python/module.hpp>
39  #include <boost/python/def.hpp>  #include <boost/python/def.hpp>
# Line 45  using namespace boost::python; Line 47  using namespace boost::python;
47    
48  /*! \mainpage Esys Documentation  /*! \mainpage Esys Documentation
49   *   *
50   * \version 1.0.0   * \version 2.9.0
51   *   *
52   * - \ref escript   * - \ref escript
53   *   *
# Line 53  using namespace boost::python; Line 55  using namespace boost::python;
55   *   *
56   * - \ref finley   * - \ref finley
57   *   *
58   * - <a href=http://iservo.edu.au/esys/epydoc/index.html>Python module documentation (epydoc generated)</a>   * - <a href="../../epydoc/index.html">Python module documentation (epydoc generated)</a>
59   *   *
60   */   */
61    
# Line 61  using namespace boost::python; Line 63  using namespace boost::python;
63   * Escript is the python module that contains the interfaces   * Escript is the python module that contains the interfaces
64   * to the C++ side of escript.   * to the C++ side of escript.
65   *   *
66   * \version 1.0.0   *
67   *   *
68   * \section class_desc Class Description:   * \section class_desc Class Description:
69   * Data   * Data
# Line 80  using namespace boost::python; Line 82  using namespace boost::python;
82  BOOST_PYTHON_MODULE(escriptcpp)  BOOST_PYTHON_MODULE(escriptcpp)
83  {  {
84  // This feature was added in boost v1.34  // This feature was added in boost v1.34
85  #if ((BOOST_VERSION/100)%1000 > 33) || (BOOST_VERSION/100000 >1)  #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
86  //#if ((BOOST_VERSION/100)%1000) > 33  //#if ((BOOST_VERSION/100)%1000) > 34
87    // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures    // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
88      #if BOOST_VERSION > 103399
89    docstring_options docopt(true, true, false);    docstring_options docopt(true, true, false);
90      #endif
91  #endif  #endif
92    
93    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
# Line 98  BOOST_PYTHON_MODULE(escriptcpp) Line 102  BOOST_PYTHON_MODULE(escriptcpp)
102    def("printParallelThreadCounts",escript::printParallelThreadCnt);    def("printParallelThreadCounts",escript::printParallelThreadCnt);
103    def("getMPISizeWorld",escript::getMPISizeWorld);    def("getMPISizeWorld",escript::getMPISizeWorld);
104    def("getMPIRankWorld",escript::getMPIRankWorld);    def("getMPIRankWorld",escript::getMPIRankWorld);
105      def("MPIBarrierWorld",escript::MPIBarrierWorld);
106      def("getMPIWorldMax",escript::getMPIWorldMax);
107      def("getMachinePrecision",escript::getMachinePrecision);
108      def("getMaxFloat",escript::getMaxFloat);
109    //    //
110    // Interface for AbstractDomain    // Interface for AbstractDomain
111    //    //
# Line 113  BOOST_PYTHON_MODULE(escriptcpp) Line 119  BOOST_PYTHON_MODULE(escriptcpp)
119       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
120       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
121       .def("saveVTK",&escript::AbstractDomain::saveVTK)       .def("saveVTK",&escript::AbstractDomain::saveVTK)
122         .def("dump",&escript::AbstractDomain::dump)
123       .def("saveDX",&escript::AbstractDomain::saveDX)       .def("saveDX",&escript::AbstractDomain::saveDX)
124       .def("getMPISize",&escript::AbstractDomain::getMPISize)       .def("getMPISize",&escript::AbstractDomain::getMPISize)
125       .def("getMPIRank",&escript::AbstractDomain::getMPIRank)       .def("getMPIRank",&escript::AbstractDomain::getMPIRank)
# Line 129  BOOST_PYTHON_MODULE(escriptcpp) Line 136  BOOST_PYTHON_MODULE(escriptcpp)
136         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId)         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId)
137         .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId);         .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId);
138    
139    
140      //
141      // Interface for TestDomain
142      //
143      class_ <escript::TestDomain, bases<escript::AbstractDomain> >("TestDomain", "Test Class for domains with no structure. May be removed from future releases without notice.", init<int,int>());
144    
145      // This is the only python visible way to get a TestDomain
146      def("getTestDomainFunctionSpace",&escript::getTestDomainFunctionSpace, "For testing only. May be removed without notice.");
147    
148    //    //
149    // Interface for FunctionSpace    // Interface for FunctionSpace
150    //    //
# Line 153  BOOST_PYTHON_MODULE(escriptcpp) Line 169  BOOST_PYTHON_MODULE(escriptcpp)
169    //    //
170    class_<escript::Data>("Data","Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() )    class_<escript::Data>("Data","Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() )
171      // various constructors for Data objects      // various constructors for Data objects
     .def(init<const numeric::array&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))  
172      .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")))
173      .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))      .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))
174      .def(init<const escript::Data&, const escript::FunctionSpace&>(args("value","what")))      .def(init<const escript::Data&, const escript::FunctionSpace&>(args("value","what")))
# Line 161  BOOST_PYTHON_MODULE(escriptcpp) Line 176  BOOST_PYTHON_MODULE(escriptcpp)
176      // 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
177      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
178      .def("__str__",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
 //     .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())  
179      .def("getDomain",&escript::Data::getDomainPython)      .def("getDomain",&escript::Data::getDomainPython)
180      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>())      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>())
181      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
# Line 170  BOOST_PYTHON_MODULE(escriptcpp) Line 184  BOOST_PYTHON_MODULE(escriptcpp)
184      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
185      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
186      .def("dump",&escript::Data::dump)      .def("dump",&escript::Data::dump)
187        .def("toListOfTuples",&escript::Data::toListOfTuples, (arg("scalarastuple")=true))
188      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
189      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
190      .def("setTaggedValue",&escript::Data::setTaggedValueByName)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
# Line 183  BOOST_PYTHON_MODULE(escriptcpp) Line 198  BOOST_PYTHON_MODULE(escriptcpp)
198      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
199      .def("resolve",&escript::Data::resolve)      .def("resolve",&escript::Data::resolve)
200      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
201      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())      .def("copy",&escript::Data::copySelf)
202      .def("delay",&escript::Data::delay)      .def("delay",&escript::Data::delay)
203      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
204      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
205      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
206      .def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint)      .def("getTupleForDataPoint",&escript::Data::getValueOfDataPointAsTuple)
207      .def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint)      .def("getTupleForGlobalDataPoint",&escript::Data::getValueOfGlobalDataPointAsTuple)
208      .def("setToZero",&escript::Data::setToZero)      .def("setToZero",&escript::Data::setToZero)
209      .def("interpolate",&escript::Data::interpolate)      .def("interpolate",&escript::Data::interpolate)
210      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
211        .def("maxGlobalDataPoint",&escript::Data::maxGlobalDataPoint)
212      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
213      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
214      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
# Line 238  BOOST_PYTHON_MODULE(escriptcpp) Line 254  BOOST_PYTHON_MODULE(escriptcpp)
254      .def("_Lsup",&escript::Data::Lsup)      .def("_Lsup",&escript::Data::Lsup)
255      .def("_sup",&escript::Data::sup)      .def("_sup",&escript::Data::sup)
256      .def("_inf",&escript::Data::inf)      .def("_inf",&escript::Data::inf)
257      .def("_integrate",&escript::Data::integrate)      .def("_integrateToTuple",&escript::Data::integrateToTuple)
258    
259      // following implements the python abs operator      // following implements the python abs operator
260      .def("__abs__",&escript::Data::abs)      .def("__abs__",&escript::Data::abs)
# Line 365  BOOST_PYTHON_MODULE(escriptcpp) Line 381  BOOST_PYTHON_MODULE(escriptcpp)
381        (arg("value")=0));        (arg("value")=0));
382    def("getEscriptParamInt",escript::getEscriptParamInt,    def("getEscriptParamInt",escript::getEscriptParamInt,
383        (arg("sentinel")=0));        (arg("sentinel")=0));
384      def("listEscriptParams",escript::listEscriptParams);
385    
386    //    //
387    // Register esysExceptionTranslator    // Register esysExceptionTranslator
388    //    //
389    register_exception_translator<esysUtils::EsysException>(&esysUtils::esysExceptionTranslator);    register_exception_translator<esysUtils::EsysException>(&esysUtils::esysExceptionTranslator);
   
390  }  }

Legend:
Removed from v.2064  
changed lines
  Added in v.2482

  ViewVC Help
Powered by ViewVC 1.1.26