/[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 1137 by gross, Thu May 10 08:11:31 2007 UTC revision 1872 by jfenwick, Mon Oct 13 00:18:55 2008 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*  /*******************************************************
3   ************************************************************  *
4   *          Copyright 2006 by ACcESS MNRF                   *  * Copyright (c) 2003-2008 by University of Queensland
5   *                                                          *  * Earth Systems Science Computational Center (ESSCC)
6   *              http://www.access.edu.au                    *  * http://www.uq.edu.au/esscc
7   *       Primary Business: Queensland, Australia            *  *
8   *  Licensed under the Open Software License version 3.0    *  * Primary Business: Queensland, Australia
9   *     http://www.opensource.org/licenses/osl-3.0.php       *  * Licensed under the Open Software License version 3.0
10   *                                                          *  * http://www.opensource.org/licenses/osl-3.0.php
11   ************************************************************  *
12  */  *******************************************************/
13    
14    
15  #include "Data.h"  #include "Data.h"
16  #include "FunctionSpace.h"  #include "FunctionSpace.h"
# Line 19  Line 20 
20  #include "AbstractDomain.h"  #include "AbstractDomain.h"
21  #include "Utils.h"  #include "Utils.h"
22  #include "AbstractSystemMatrix.h"  #include "AbstractSystemMatrix.h"
23    #include "AbstractTransportProblem.h"
24  #include "DataVector.h"  #include "DataVector.h"
25    #include "paso/Paso_MPI.h"
26    
27    
28    
29    extern "C" {
30    #include "escript/blocktimer.h"
31    }
32    
33  #include "esysUtils/esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
34    
# Line 29  Line 38 
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    
43  using namespace boost::python;  using namespace boost::python;
44    
# Line 71  BOOST_PYTHON_MODULE(escriptcpp) Line 81  BOOST_PYTHON_MODULE(escriptcpp)
81    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
82    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
83    def("releaseUnusedMemory",escript::releaseUnusedMemory);    def("releaseUnusedMemory",escript::releaseUnusedMemory);
84      def("blocktimer_initialize",blocktimer_initialize);
85      def("blocktimer_reportSortByName",blocktimer_reportSortByName);
86      def("blocktimer_reportSortByTime",blocktimer_reportSortByTime);
87      def("blocktimer_increment",blocktimer_increment);
88      def("blocktimer_time",blocktimer_time);
89      def("getVersion",escript::getSvnVersion);
90      def("printParallelThreadCounts",escript::printParallelThreadCnt);
91      def("getMPISizeWorld",escript::getMPISizeWorld);
92      def("getMPIRankWorld",escript::getMPIRankWorld);
93    
94    
95    //    //
96    // Interface for AbstractDomain    // Interface for AbstractDomain
97    //    //
98    class_<escript::AbstractDomain>("Domain",no_init)    class_<escript::AbstractDomain, escript::Domain_ptr>("Domain",no_init)
      .def("__str__",&escript::AbstractDomain::str)  
99       .def("setTagMap",&escript::AbstractDomain::setTagMap)       .def("setTagMap",&escript::AbstractDomain::setTagMap)
100       .def("getTag",&escript::AbstractDomain::getTag)       .def("getTag",&escript::AbstractDomain::getTag)
101       .def("isValidTagName",&escript::AbstractDomain::isValidTagName)       .def("isValidTagName",&escript::AbstractDomain::isValidTagName)
102       .def("showTagNames",&escript::AbstractDomain::showTagNames)       .def("showTagNames",&escript::AbstractDomain::showTagNames)
103       .def("getX",&escript::AbstractDomain::getX)       .def("getX",&escript::AbstractDomain::getX)
104         .def("getDim",&escript::AbstractDomain::getDim)
105       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
106       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
107       .def("saveVTK",&escript::AbstractDomain::saveVTK)       .def("saveVTK",&escript::AbstractDomain::saveVTK)
108       .def("saveDX",&escript::AbstractDomain::saveDX)       .def("saveDX",&escript::AbstractDomain::saveDX)
109         .def("getMPISize",&escript::AbstractDomain::getMPISize)
110         .def("getMPIRank",&escript::AbstractDomain::getMPIRank)
111    
112       .def(self == self)       .def(self == self)
113       .def(self != self);       .def(self != self);
114    
# Line 94  BOOST_PYTHON_MODULE(escriptcpp) Line 116  BOOST_PYTHON_MODULE(escriptcpp)
116    // Interface for AbstractContinuousDomain    // Interface for AbstractContinuousDomain
117    //    //
118    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)
119         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId);         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId)
120           .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId);
121    
122    //    //
123    // Interface for FunctionSpace    // Interface for FunctionSpace
124    //    //
125    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace> fs_definer("FunctionSpace",init<>());
126       .def("getDim",&escript::FunctionSpace::getDim)    fs_definer.def("getDim",&escript::FunctionSpace::getDim);
127       .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())  //   fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
128       .def("getX",&escript::FunctionSpace::getX)  //                  return_internal_reference<>());
129       .def("getNormal",&escript::FunctionSpace::getNormal)    fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython);
130       .def("getSize",&escript::FunctionSpace::getSize)    fs_definer.def("getX",&escript::FunctionSpace::getX);
131       .def("setTags",&escript::FunctionSpace::setTags)    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
132       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
133       .def("__str__",&escript::FunctionSpace::str)    fs_definer.def("setTags",&escript::FunctionSpace::setTags);
134       .def(self == self)    fs_definer.def("getTagFromDataPointNo",
135       .def(self != self);                   &escript::FunctionSpace::getTagFromDataPointNo);
136      fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo);
137      fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags);
138      fs_definer.def("__str__", &escript::FunctionSpace::toString);
139      fs_definer.def(self == self);
140      fs_definer.def(self != self);
141    //    //
142    // Interface for Data    // Interface for Data
143    //    //
144    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>())    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>() )
145      // various constructors for Data objects      // various constructors for Data objects
146      .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")))
147      .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 122  BOOST_PYTHON_MODULE(escriptcpp) Line 150  BOOST_PYTHON_MODULE(escriptcpp)
150      .def(init<const escript::Data&>())      .def(init<const escript::Data&>())
151      // 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
152      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
153      .def("__str__",&escript::Data::str)      .def("__str__",&escript::Data::toString)
154      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())  //     .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
155      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomainPython)
156        .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>())
157      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
158      .def("isProtected",&escript::Data::isProtected)      .def("isProtected",&escript::Data::isProtected)
159      .def("setProtection",&escript::Data::setProtection)      .def("setProtection",&escript::Data::setProtection)
# Line 135  BOOST_PYTHON_MODULE(escriptcpp) Line 164  BOOST_PYTHON_MODULE(escriptcpp)
164      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
165      .def("setTaggedValue",&escript::Data::setTaggedValueByName)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
166      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
167        .def("isExpanded",&escript::Data::isExpanded)
168        .def("isTagged",&escript::Data::isTagged)
169      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
170      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
171      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
172        .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())
173      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
174      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
175      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
# Line 149  BOOST_PYTHON_MODULE(escriptcpp) Line 181  BOOST_PYTHON_MODULE(escriptcpp)
181      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
182      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
183      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
     .def("archiveData",&escript::Data::archiveData)  
     .def("extractData",&escript::Data::extractData)  
184      // Unary functions for Data      // Unary functions for Data
185      .def("_interpolate",&escript::Data::interpolate)      .def("_interpolate",&escript::Data::interpolate)
186      .def("_grad",&escript::Data::gradOn)      .def("_grad",&escript::Data::gradOn)
# Line 302  BOOST_PYTHON_MODULE(escriptcpp) Line 332  BOOST_PYTHON_MODULE(escriptcpp)
332       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
333       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
334       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
335      //
336      // Interface for AbstractTransportProblem
337      //
338      class_<escript::AbstractTransportProblem>("TransportProblem",init<>())
339         .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
340         .def("solve",&escript::AbstractTransportProblem::solve)
341         .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
342         .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)
343         .def("reset",&escript::AbstractTransportProblem::resetTransport)
344         .def("resetValues",&escript::AbstractTransportProblem::resetTransport)
345         .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize)
346         .def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize);
347    
348    //    //
349    // Register esysExceptionTranslator    // Register esysExceptionTranslator

Legend:
Removed from v.1137  
changed lines
  Added in v.1872

  ViewVC Help
Powered by ViewVC 1.1.26