/[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 595 by gross, Tue Mar 14 23:52:45 2006 UTC revision 1370 by gross, Wed Jan 2 09:21:43 2008 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*=============================================================================  /* $Id$ */
3    
4   ******************************************************************************  /*******************************************************
5   *                                                                            *   *
6   *       COPYRIGHT ACcESS 2004 -  All Rights Reserved                         *   *           Copyright 2003-2007 by ACceSS MNRF
7   *                                                                            *   *       Copyright 2007 by University of Queensland
8   * This software is the property of ACcESS.  No part of this code             *   *
9   * may be copied in any form or by any means without the expressed written    *   *                http://esscc.uq.edu.au
10   * consent of ACcESS.  Copying, use or modification of this software          *   *        Primary Business: Queensland, Australia
11   * by any unauthorised person is illegal unless that                          *   *  Licensed under the Open Software License version 3.0
12   * person has a software license agreement with ACcESS.                       *   *     http://www.opensource.org/licenses/osl-3.0.php
13   *                                                                            *   *
14   ******************************************************************************   *******************************************************/
   
 ******************************************************************************/  
15    
16  #include "Data.h"  #include "Data.h"
 #include "DataVariable.h"  
17  #include "FunctionSpace.h"  #include "FunctionSpace.h"
18  #include "FunctionSpaceFactory.h"  #include "FunctionSpaceFactory.h"
19  #include "DataFactory.h"  #include "DataFactory.h"
# Line 24  Line 21 
21  #include "AbstractDomain.h"  #include "AbstractDomain.h"
22  #include "Utils.h"  #include "Utils.h"
23  #include "AbstractSystemMatrix.h"  #include "AbstractSystemMatrix.h"
24    #include "AbstractTransportProblem.h"
25    #include "DataVector.h"
26    
27    extern "C" {
28    #include "escript/blocktimer.h"
29    }
30    
31  #include "esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
32    
33  #include <boost/python.hpp>  #include <boost/python.hpp>
34  #include <boost/python/module.hpp>  #include <boost/python/module.hpp>
# Line 74  BOOST_PYTHON_MODULE(escriptcpp) Line 77  BOOST_PYTHON_MODULE(escriptcpp)
77  {  {
78    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
79    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
80      def("releaseUnusedMemory",escript::releaseUnusedMemory);
81      def("blocktimer_initialize",blocktimer_initialize);
82      def("blocktimer_reportSortByName",blocktimer_reportSortByName);
83      def("blocktimer_reportSortByTime",blocktimer_reportSortByTime);
84      def("blocktimer_increment",blocktimer_increment);
85      def("blocktimer_time",blocktimer_time);
86      def("getVersion",escript::getSvnVersion);
87    
88    
89    //    //
90    // Interface for AbstractDomain    // Interface for AbstractDomain
91    //    //
92    class_<escript::AbstractDomain>("Domain",no_init)    class_<escript::AbstractDomain>("Domain",no_init)
93         .def("setTagMap",&escript::AbstractDomain::setTagMap)
94         .def("getTag",&escript::AbstractDomain::getTag)
95         .def("isValidTagName",&escript::AbstractDomain::isValidTagName)
96         .def("showTagNames",&escript::AbstractDomain::showTagNames)
97       .def("getX",&escript::AbstractDomain::getX)       .def("getX",&escript::AbstractDomain::getX)
98       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
99       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
100       .def("saveVTK",&escript::AbstractDomain::saveVTK)       .def("saveVTK",&escript::AbstractDomain::saveVTK)
101       .def("saveDX",&escript::AbstractDomain::saveDX)       .def("saveDX",&escript::AbstractDomain::saveDX)
102         .def("getMPISize",&escript::AbstractDomain::getMPISize)
103         .def("getMPIRank",&escript::AbstractDomain::getMPIRank)
104    
105       .def(self == self)       .def(self == self)
106       .def(self != self);       .def(self != self);
107    
# Line 102  BOOST_PYTHON_MODULE(escriptcpp) Line 120  BOOST_PYTHON_MODULE(escriptcpp)
120       .def("getX",&escript::FunctionSpace::getX)       .def("getX",&escript::FunctionSpace::getX)
121       .def("getNormal",&escript::FunctionSpace::getNormal)       .def("getNormal",&escript::FunctionSpace::getNormal)
122       .def("getSize",&escript::FunctionSpace::getSize)       .def("getSize",&escript::FunctionSpace::getSize)
123         .def("setTags",&escript::FunctionSpace::setTags)
124       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)
125       .def("__str__",&escript::FunctionSpace::toString)       .def("__str__",&escript::FunctionSpace::toString)
126       .def(self == self)       .def(self == self)
# Line 122  BOOST_PYTHON_MODULE(escriptcpp) Line 141  BOOST_PYTHON_MODULE(escriptcpp)
141      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
142      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())
143      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
144        .def("isProtected",&escript::Data::isProtected)
145        .def("setProtection",&escript::Data::setProtection)
146      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
147      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
148        .def("dump",&escript::Data::dump)
149      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
150      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
151      .def("setRefValue",&escript::Data::setRefValue)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
152      .def("getRefValue",&escript::Data::getRefValue)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
153        .def("isExpanded",&escript::Data::isExpanded)
154        .def("isTagged",&escript::Data::isTagged)
155      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
156      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
157      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
158      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
159      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
160      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
161      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint)
162        .def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint)
163        .def("setToZero",&escript::Data::setToZero)
164      .def("interpolate",&escript::Data::interpolate)      .def("interpolate",&escript::Data::interpolate)
165      .def("mindp",&escript::Data::mindp)      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
166      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
167      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
168      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
# Line 150  BOOST_PYTHON_MODULE(escriptcpp) Line 176  BOOST_PYTHON_MODULE(escriptcpp)
176      .def("_trace",&escript::Data::trace)      .def("_trace",&escript::Data::trace)
177      .def("_maxval",&escript::Data::maxval)      .def("_maxval",&escript::Data::maxval)
178      .def("_minval",&escript::Data::minval)      .def("_minval",&escript::Data::minval)
179      .def("_wherePositive",&escript::Data::wherePositive,(arg("tol")=0.0))      .def("_wherePositive",&escript::Data::wherePositive)
180      .def("_whereNegative",&escript::Data::whereNegative,(arg("tol")=0.0))      .def("_whereNegative",&escript::Data::whereNegative)
181      .def("_whereNonNegative",&escript::Data::whereNonNegative,(arg("tol")=0.0))      .def("_whereNonNegative",&escript::Data::whereNonNegative)
182      .def("_whereNonPositive",&escript::Data::whereNonPositive,(arg("tol")=0.0))      .def("_whereNonPositive",&escript::Data::whereNonPositive)
183      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
184      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
185        .def("_erf",&escript::Data::erf)
186      .def("_sin",&escript::Data::sin)      .def("_sin",&escript::Data::sin)
187      .def("_cos",&escript::Data::cos)      .def("_cos",&escript::Data::cos)
188      .def("_tan",&escript::Data::tan)      .def("_tan",&escript::Data::tan)
# Line 173  BOOST_PYTHON_MODULE(escriptcpp) Line 200  BOOST_PYTHON_MODULE(escriptcpp)
200      .def("_log10",&escript::Data::log10)      .def("_log10",&escript::Data::log10)
201      .def("_log",&escript::Data::log)      .def("_log",&escript::Data::log)
202      .def("_sign",&escript::Data::sign)      .def("_sign",&escript::Data::sign)
203        .def("_symmetric",&escript::Data::symmetric)
204        .def("_nonsymmetric",&escript::Data::nonsymmetric)
205        .def("_trace",&escript::Data::trace)
206        .def("_swap_axes",&escript::Data::swapaxes)
207      .def("_eigenvalues",&escript::Data::eigenvalues)      .def("_eigenvalues",&escript::Data::eigenvalues)
208      .def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13))      .def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13))
209      // functions returning a single real number:      // functions returning a single real number:
# Line 194  BOOST_PYTHON_MODULE(escriptcpp) Line 225  BOOST_PYTHON_MODULE(escriptcpp)
225      // following two functions implement the python ** operator      // following two functions implement the python ** operator
226      .def("__pow__",&escript::Data::powO)      .def("__pow__",&escript::Data::powO)
227      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
228        .def("__rpow__",&escript::Data::rpowO)
229      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
230      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
231      // version will be called.      // version will be called.
# Line 228  BOOST_PYTHON_MODULE(escriptcpp) Line 260  BOOST_PYTHON_MODULE(escriptcpp)
260    // Factory methods for function space    // Factory methods for function space
261    //    //
262    def("ContinuousFunction",escript::continuousFunction);    def("ContinuousFunction",escript::continuousFunction);
263      def("ReducedContinuousFunction",escript::reducedContinuousFunction);
264    def("Function",escript::function);    def("Function",escript::function);
265      def("ReducedFunction",escript::reducedFunction);
266    def("FunctionOnBoundary",escript::functionOnBoundary);    def("FunctionOnBoundary",escript::functionOnBoundary);
267      def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary);
268    def("FunctionOnContactZero",escript::functionOnContactZero);    def("FunctionOnContactZero",escript::functionOnContactZero);
269      def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero);
270    def("FunctionOnContactOne",escript::functionOnContactOne);    def("FunctionOnContactOne",escript::functionOnContactOne);
271      def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne);
272    def("Solution",escript::solution);    def("Solution",escript::solution);
273    def("ReducedSolution",escript::reducedSolution);    def("ReducedSolution",escript::reducedSolution);
274    def("DiracDeltaFunction",escript::diracDeltaFunction);    def("DiracDeltaFunction",escript::diracDeltaFunction);
# Line 239  BOOST_PYTHON_MODULE(escriptcpp) Line 276  BOOST_PYTHON_MODULE(escriptcpp)
276    //    //
277    // Factory methods for Data    // Factory methods for Data
278    //    //
279      def("load",escript::load);
280      def("loadIsConfigured",escript::loadConfigured);
281    def("Scalar",escript::Scalar,    def("Scalar",escript::Scalar,
282        (arg("value")=0.0,        (arg("value")=0.0,
283         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 261  BOOST_PYTHON_MODULE(escriptcpp) Line 300  BOOST_PYTHON_MODULE(escriptcpp)
300         arg("expanded")=false));         arg("expanded")=false));
301    
302    //    //
303      // Binary operators
304      //
305      def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
306          (arg("arg0")=escript::Data(),
307           arg("arg1")=escript::Data(),
308           arg("axis_offset")=0,
309           arg("transpose")=0));
310    
311      //
312    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
313    //    //
314    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator",init<>())
# Line 271  BOOST_PYTHON_MODULE(escriptcpp) Line 319  BOOST_PYTHON_MODULE(escriptcpp)
319       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
320       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
321       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
322      //
323      // Interface for AbstractTransportProblem
324      //
325      class_<escript::AbstractTransportProblem>("TransportProblem",init<>())
326         .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
327         .def("solve",&escript::AbstractTransportProblem::solve)
328         .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
329         .def("resetTransport",&escript::AbstractTransportProblem::resetTransport);
330    
331    //    //
332    // Register esysExceptionTranslator    // Register esysExceptionTranslator

Legend:
Removed from v.595  
changed lines
  Added in v.1370

  ViewVC Help
Powered by ViewVC 1.1.26