/[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 1872 by jfenwick, Mon Oct 13 00:18:55 2008 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*=============================================================================  /*******************************************************
3    *
4   ******************************************************************************  * Copyright (c) 2003-2008 by University of Queensland
5   *                                                                            *  * Earth Systems Science Computational Center (ESSCC)
6   *       COPYRIGHT ACcESS 2004 -  All Rights Reserved                         *  * http://www.uq.edu.au/esscc
7   *                                                                            *  *
8   * This software is the property of ACcESS.  No part of this code             *  * Primary Business: Queensland, Australia
9   * may be copied in any form or by any means without the expressed written    *  * Licensed under the Open Software License version 3.0
10   * consent of ACcESS.  Copying, use or modification of this software          *  * http://www.opensource.org/licenses/osl-3.0.php
11   * by any unauthorised person is illegal unless that                          *  *
12   * person has a software license agreement with ACcESS.                       *  *******************************************************/
13   *                                                                            *  
  ******************************************************************************  
   
 ******************************************************************************/  
14    
15  #include "Data.h"  #include "Data.h"
 #include "DataVariable.h"  
16  #include "FunctionSpace.h"  #include "FunctionSpace.h"
17  #include "FunctionSpaceFactory.h"  #include "FunctionSpaceFactory.h"
18  #include "DataFactory.h"  #include "DataFactory.h"
# Line 24  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"
25    #include "paso/Paso_MPI.h"
26    
27    
28    
29  #include "esysExceptionTranslator.h"  extern "C" {
30    #include "escript/blocktimer.h"
31    }
32    
33    #include "esysUtils/esysExceptionTranslator.h"
34    
35  #include <boost/python.hpp>  #include <boost/python.hpp>
36  #include <boost/python/module.hpp>  #include <boost/python/module.hpp>
# Line 33  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 74  BOOST_PYTHON_MODULE(escriptcpp) Line 80  BOOST_PYTHON_MODULE(escriptcpp)
80  {  {
81    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
82    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
83      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)
99         .def("setTagMap",&escript::AbstractDomain::setTagMap)
100         .def("getTag",&escript::AbstractDomain::getTag)
101         .def("isValidTagName",&escript::AbstractDomain::isValidTagName)
102         .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 91  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("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
132       .def("__str__",&escript::FunctionSpace::toString)    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
133       .def(self == self)    fs_definer.def("setTags",&escript::FunctionSpace::setTags);
134       .def(self != self);    fs_definer.def("getTagFromDataPointNo",
135                     &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 119  BOOST_PYTHON_MODULE(escriptcpp) Line 151  BOOST_PYTHON_MODULE(escriptcpp)
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::toString)      .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)
159        .def("setProtection",&escript::Data::setProtection)
160      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
161      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
162        .def("dump",&escript::Data::dump)
163      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
164      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
165      .def("setRefValue",&escript::Data::setRefValue)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
166      .def("getRefValue",&escript::Data::getRefValue)      .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("convertToNumArray",&escript::Data::convertToNumArray)      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())
173      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
174      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
175      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
176        .def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint)
177        .def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint)
178        .def("setToZero",&escript::Data::setToZero)
179      .def("interpolate",&escript::Data::interpolate)      .def("interpolate",&escript::Data::interpolate)
180      .def("mindp",&escript::Data::mindp)      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
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 150  BOOST_PYTHON_MODULE(escriptcpp) Line 189  BOOST_PYTHON_MODULE(escriptcpp)
189      .def("_trace",&escript::Data::trace)      .def("_trace",&escript::Data::trace)
190      .def("_maxval",&escript::Data::maxval)      .def("_maxval",&escript::Data::maxval)
191      .def("_minval",&escript::Data::minval)      .def("_minval",&escript::Data::minval)
192      .def("_wherePositive",&escript::Data::wherePositive,(arg("tol")=0.0))      .def("_wherePositive",&escript::Data::wherePositive)
193      .def("_whereNegative",&escript::Data::whereNegative,(arg("tol")=0.0))      .def("_whereNegative",&escript::Data::whereNegative)
194      .def("_whereNonNegative",&escript::Data::whereNonNegative,(arg("tol")=0.0))      .def("_whereNonNegative",&escript::Data::whereNonNegative)
195      .def("_whereNonPositive",&escript::Data::whereNonPositive,(arg("tol")=0.0))      .def("_whereNonPositive",&escript::Data::whereNonPositive)
196      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
197      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
198        .def("_erf",&escript::Data::erf)
199      .def("_sin",&escript::Data::sin)      .def("_sin",&escript::Data::sin)
200      .def("_cos",&escript::Data::cos)      .def("_cos",&escript::Data::cos)
201      .def("_tan",&escript::Data::tan)      .def("_tan",&escript::Data::tan)
# Line 173  BOOST_PYTHON_MODULE(escriptcpp) Line 213  BOOST_PYTHON_MODULE(escriptcpp)
213      .def("_log10",&escript::Data::log10)      .def("_log10",&escript::Data::log10)
214      .def("_log",&escript::Data::log)      .def("_log",&escript::Data::log)
215      .def("_sign",&escript::Data::sign)      .def("_sign",&escript::Data::sign)
216        .def("_symmetric",&escript::Data::symmetric)
217        .def("_nonsymmetric",&escript::Data::nonsymmetric)
218        .def("_trace",&escript::Data::trace)
219        .def("_swap_axes",&escript::Data::swapaxes)
220      .def("_eigenvalues",&escript::Data::eigenvalues)      .def("_eigenvalues",&escript::Data::eigenvalues)
221      .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))
222      // functions returning a single real number:      // functions returning a single real number:
# Line 194  BOOST_PYTHON_MODULE(escriptcpp) Line 238  BOOST_PYTHON_MODULE(escriptcpp)
238      // following two functions implement the python ** operator      // following two functions implement the python ** operator
239      .def("__pow__",&escript::Data::powO)      .def("__pow__",&escript::Data::powO)
240      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
241        .def("__rpow__",&escript::Data::rpowO)
242      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
243      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
244      // version will be called.      // version will be called.
# Line 228  BOOST_PYTHON_MODULE(escriptcpp) Line 273  BOOST_PYTHON_MODULE(escriptcpp)
273    // Factory methods for function space    // Factory methods for function space
274    //    //
275    def("ContinuousFunction",escript::continuousFunction);    def("ContinuousFunction",escript::continuousFunction);
276      def("ReducedContinuousFunction",escript::reducedContinuousFunction);
277    def("Function",escript::function);    def("Function",escript::function);
278      def("ReducedFunction",escript::reducedFunction);
279    def("FunctionOnBoundary",escript::functionOnBoundary);    def("FunctionOnBoundary",escript::functionOnBoundary);
280      def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary);
281    def("FunctionOnContactZero",escript::functionOnContactZero);    def("FunctionOnContactZero",escript::functionOnContactZero);
282      def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero);
283    def("FunctionOnContactOne",escript::functionOnContactOne);    def("FunctionOnContactOne",escript::functionOnContactOne);
284      def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne);
285    def("Solution",escript::solution);    def("Solution",escript::solution);
286    def("ReducedSolution",escript::reducedSolution);    def("ReducedSolution",escript::reducedSolution);
287    def("DiracDeltaFunction",escript::diracDeltaFunction);    def("DiracDeltaFunction",escript::diracDeltaFunction);
# Line 239  BOOST_PYTHON_MODULE(escriptcpp) Line 289  BOOST_PYTHON_MODULE(escriptcpp)
289    //    //
290    // Factory methods for Data    // Factory methods for Data
291    //    //
292      def("load",escript::load);
293      def("loadIsConfigured",escript::loadConfigured);
294    def("Scalar",escript::Scalar,    def("Scalar",escript::Scalar,
295        (arg("value")=0.0,        (arg("value")=0.0,
296         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 261  BOOST_PYTHON_MODULE(escriptcpp) Line 313  BOOST_PYTHON_MODULE(escriptcpp)
313         arg("expanded")=false));         arg("expanded")=false));
314    
315    //    //
316      // Binary operators
317      //
318      def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
319          (arg("arg0")=escript::Data(),
320           arg("arg1")=escript::Data(),
321           arg("axis_offset")=0,
322           arg("transpose")=0));
323    
324      //
325    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
326    //    //
327    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator",init<>())
# Line 271  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.595  
changed lines
  Added in v.1872

  ViewVC Help
Powered by ViewVC 1.1.26