/[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 1841 by gross, Fri Oct 3 03:57:52 2008 UTC revision 2064 by jfenwick, Thu Nov 20 04:06:34 2008 UTC
# Line 23  Line 23 
23  #include "AbstractTransportProblem.h"  #include "AbstractTransportProblem.h"
24  #include "DataVector.h"  #include "DataVector.h"
25  #include "paso/Paso_MPI.h"  #include "paso/Paso_MPI.h"
26    #include "EscriptParams.h"
27    
28    
29  extern "C" {  extern "C" {
30  #include "escript/blocktimer.h"  #include "escript/blocktimer.h"
# Line 36  extern "C" { Line 38  extern "C" {
38  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
39  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
40  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
41    #include <boost/smart_ptr.hpp>
42    #include <boost/version.hpp>
43    
44  using namespace boost::python;  using namespace boost::python;
45    
# Line 75  using namespace boost::python; Line 79  using namespace boost::python;
79    
80  BOOST_PYTHON_MODULE(escriptcpp)  BOOST_PYTHON_MODULE(escriptcpp)
81  {  {
82    // This feature was added in boost v1.34
83    #if ((BOOST_VERSION/100)%1000 > 33) || (BOOST_VERSION/100000 >1)
84    //#if ((BOOST_VERSION/100)%1000) > 33
85      // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
86      docstring_options docopt(true, true, false);
87    #endif
88    
89    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
90    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
91    def("releaseUnusedMemory",escript::releaseUnusedMemory);    def("releaseUnusedMemory",escript::releaseUnusedMemory);
# Line 92  BOOST_PYTHON_MODULE(escriptcpp) Line 103  BOOST_PYTHON_MODULE(escriptcpp)
103    //    //
104    // Interface for AbstractDomain    // Interface for AbstractDomain
105    //    //
106    class_<escript::AbstractDomain>("Domain",no_init)    class_<escript::AbstractDomain, escript::Domain_ptr>("Domain","Base class for all domains.",no_init)
107       .def("setTagMap",&escript::AbstractDomain::setTagMap)       .def("setTagMap",&escript::AbstractDomain::setTagMap)
108       .def("getTag",&escript::AbstractDomain::getTag)       .def("getTag",&escript::AbstractDomain::getTag)
109       .def("isValidTagName",&escript::AbstractDomain::isValidTagName)       .def("isValidTagName",&escript::AbstractDomain::isValidTagName)
# Line 105  BOOST_PYTHON_MODULE(escriptcpp) Line 116  BOOST_PYTHON_MODULE(escriptcpp)
116       .def("saveDX",&escript::AbstractDomain::saveDX)       .def("saveDX",&escript::AbstractDomain::saveDX)
117       .def("getMPISize",&escript::AbstractDomain::getMPISize)       .def("getMPISize",&escript::AbstractDomain::getMPISize)
118       .def("getMPIRank",&escript::AbstractDomain::getMPIRank)       .def("getMPIRank",&escript::AbstractDomain::getMPIRank)
119         .def("MPIBarrier",&escript::AbstractDomain::MPIBarrier)
120         .def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor)
121    
122       .def(self == self)       .def(self == self)
123       .def(self != self);       .def(self != self);
# Line 112  BOOST_PYTHON_MODULE(escriptcpp) Line 125  BOOST_PYTHON_MODULE(escriptcpp)
125    //    //
126    // Interface for AbstractContinuousDomain    // Interface for AbstractContinuousDomain
127    //    //
128    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain","Class representing continuous domains",no_init)
129         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId);         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId)
130           .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId);
131    
132    //    //
133    // Interface for FunctionSpace    // Interface for FunctionSpace
134    //    //
135    class_<escript::FunctionSpace> fs_definer("FunctionSpace",init<>());    class_<escript::FunctionSpace> fs_definer("FunctionSpace","",init<>());   // Doco goes in the empty string param
136    fs_definer.def("getDim",&escript::FunctionSpace::getDim);    fs_definer.def("getDim",&escript::FunctionSpace::getDim);
137    fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,  //   fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
138                   return_internal_reference<>());  //                  return_internal_reference<>());
139      fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython);
140    fs_definer.def("getX",&escript::FunctionSpace::getX);    fs_definer.def("getX",&escript::FunctionSpace::getX);
141    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
142    fs_definer.def("getSize",&escript::FunctionSpace::getSize);    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
# Line 136  BOOST_PYTHON_MODULE(escriptcpp) Line 151  BOOST_PYTHON_MODULE(escriptcpp)
151    //    //
152    // Interface for Data    // Interface for Data
153    //    //
154    class_<escript::Data>("Data","TEST 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<>() )
155      // various constructors for Data objects      // various constructors for Data objects
156      .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")))
157      .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 146  BOOST_PYTHON_MODULE(escriptcpp) Line 161  BOOST_PYTHON_MODULE(escriptcpp)
161      // 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
162      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
163      .def("__str__",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
164      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())  //     .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
165      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomainPython)
166        .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>())
167      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
168      .def("isProtected",&escript::Data::isProtected)      .def("isProtected",&escript::Data::isProtected)
169      .def("setProtection",&escript::Data::setProtection)      .def("setProtection",&escript::Data::setProtection)
# Line 160  BOOST_PYTHON_MODULE(escriptcpp) Line 176  BOOST_PYTHON_MODULE(escriptcpp)
176      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
177      .def("isExpanded",&escript::Data::isExpanded)      .def("isExpanded",&escript::Data::isExpanded)
178      .def("isTagged",&escript::Data::isTagged)      .def("isTagged",&escript::Data::isTagged)
179        .def("isConstant",&escript::Data::isConstant)
180        .def("isLazy",&escript::Data::isLazy)
181        .def("isReady",&escript::Data::isReady)
182      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
183      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
184        .def("resolve",&escript::Data::resolve)
185      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
186      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())
187        .def("delay",&escript::Data::delay)
188      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
189      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
190      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
# Line 318  BOOST_PYTHON_MODULE(escriptcpp) Line 339  BOOST_PYTHON_MODULE(escriptcpp)
339    //    //
340    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
341    //    //
342    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator","",init<>())    // Doco goes in the empty string param
343       .def("isEmpty",&escript::AbstractSystemMatrix::isEmpty)       .def("isEmpty",&escript::AbstractSystemMatrix::isEmpty)
344       .def("solve",&escript::AbstractSystemMatrix::solve)       .def("solve",&escript::AbstractSystemMatrix::solve)
345       .def("of",&escript::AbstractSystemMatrix::vectorMultiply)       .def("of",&escript::AbstractSystemMatrix::vectorMultiply)
# Line 329  BOOST_PYTHON_MODULE(escriptcpp) Line 350  BOOST_PYTHON_MODULE(escriptcpp)
350    //    //
351    // Interface for AbstractTransportProblem    // Interface for AbstractTransportProblem
352    //    //
353    class_<escript::AbstractTransportProblem>("TransportProblem",init<>())    class_<escript::AbstractTransportProblem>("TransportProblem","",init<>())    // Doco goes in the empty string param
354       .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)       .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
355       .def("solve",&escript::AbstractTransportProblem::solve)       .def("solve",&escript::AbstractTransportProblem::solve)
356       .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)       .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
357       .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)       .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)
358       .def("reset",&escript::AbstractTransportProblem::resetTransport)       .def("reset",&escript::AbstractTransportProblem::resetTransport)
359       .def("resetValues",&escript::AbstractTransportProblem::resetTransport)       .def("resetValues",&escript::AbstractTransportProblem::resetTransport)
360       .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize);       .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize)
361         .def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize);
362    
363      // Functions to modify global parameters
364      def("setEscriptParamInt",escript::setEscriptParamInt,
365          (arg("value")=0));
366      def("getEscriptParamInt",escript::getEscriptParamInt,
367          (arg("sentinel")=0));
368    
369    
370    //    //
371    // Register esysExceptionTranslator    // Register esysExceptionTranslator

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

  ViewVC Help
Powered by ViewVC 1.1.26