/[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 1897 by jfenwick, Mon Oct 20 00:32:30 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    #include "EscriptParams.h"
27    
28    
29    
30  #include "esysExceptionTranslator.h"  extern "C" {
31    #include "escript/blocktimer.h"
32    }
33    
34    #include "esysUtils/esysExceptionTranslator.h"
35    
36  #include <boost/python.hpp>  #include <boost/python.hpp>
37  #include <boost/python/module.hpp>  #include <boost/python/module.hpp>
# Line 33  Line 39 
39  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
40  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
41  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
42    #include <boost/smart_ptr.hpp>
43    
44  using namespace boost::python;  using namespace boost::python;
45    
# Line 74  BOOST_PYTHON_MODULE(escriptcpp) Line 81  BOOST_PYTHON_MODULE(escriptcpp)
81  {  {
82    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
83    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
84      def("releaseUnusedMemory",escript::releaseUnusedMemory);
85      def("blocktimer_initialize",blocktimer_initialize);
86      def("blocktimer_reportSortByName",blocktimer_reportSortByName);
87      def("blocktimer_reportSortByTime",blocktimer_reportSortByTime);
88      def("blocktimer_increment",blocktimer_increment);
89      def("blocktimer_time",blocktimer_time);
90      def("getVersion",escript::getSvnVersion);
91      def("printParallelThreadCounts",escript::printParallelThreadCnt);
92      def("getMPISizeWorld",escript::getMPISizeWorld);
93      def("getMPIRankWorld",escript::getMPIRankWorld);
94    
95    
96    //    //
97    // Interface for AbstractDomain    // Interface for AbstractDomain
98    //    //
99    class_<escript::AbstractDomain>("Domain",no_init)    class_<escript::AbstractDomain, escript::Domain_ptr>("Domain",no_init)
100         .def("setTagMap",&escript::AbstractDomain::setTagMap)
101         .def("getTag",&escript::AbstractDomain::getTag)
102         .def("isValidTagName",&escript::AbstractDomain::isValidTagName)
103         .def("showTagNames",&escript::AbstractDomain::showTagNames)
104       .def("getX",&escript::AbstractDomain::getX)       .def("getX",&escript::AbstractDomain::getX)
105         .def("getDim",&escript::AbstractDomain::getDim)
106       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
107       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
108       .def("saveVTK",&escript::AbstractDomain::saveVTK)       .def("saveVTK",&escript::AbstractDomain::saveVTK)
109       .def("saveDX",&escript::AbstractDomain::saveDX)       .def("saveDX",&escript::AbstractDomain::saveDX)
110         .def("getMPISize",&escript::AbstractDomain::getMPISize)
111         .def("getMPIRank",&escript::AbstractDomain::getMPIRank)
112         .def("MPIBarrier",&escript::AbstractDomain::MPIBarrier)
113         .def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor)
114    
115       .def(self == self)       .def(self == self)
116       .def(self != self);       .def(self != self);
117    
# Line 91  BOOST_PYTHON_MODULE(escriptcpp) Line 119  BOOST_PYTHON_MODULE(escriptcpp)
119    // Interface for AbstractContinuousDomain    // Interface for AbstractContinuousDomain
120    //    //
121    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)
122         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId);         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId)
123           .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId);
124    
125    //    //
126    // Interface for FunctionSpace    // Interface for FunctionSpace
127    //    //
128    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace> fs_definer("FunctionSpace",init<>());
129       .def("getDim",&escript::FunctionSpace::getDim)    fs_definer.def("getDim",&escript::FunctionSpace::getDim);
130       .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())  //   fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
131       .def("getX",&escript::FunctionSpace::getX)  //                  return_internal_reference<>());
132       .def("getNormal",&escript::FunctionSpace::getNormal)    fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython);
133       .def("getSize",&escript::FunctionSpace::getSize)    fs_definer.def("getX",&escript::FunctionSpace::getX);
134       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
135       .def("__str__",&escript::FunctionSpace::toString)    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
136       .def(self == self)    fs_definer.def("setTags",&escript::FunctionSpace::setTags);
137       .def(self != self);    fs_definer.def("getTagFromDataPointNo",
138                     &escript::FunctionSpace::getTagFromDataPointNo);
139      fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo);
140      fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags);
141      fs_definer.def("__str__", &escript::FunctionSpace::toString);
142      fs_definer.def(self == self);
143      fs_definer.def(self != self);
144    //    //
145    // Interface for Data    // Interface for Data
146    //    //
147    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>())    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>() )
148      // various constructors for Data objects      // various constructors for Data objects
149      .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")))
150      .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 154  BOOST_PYTHON_MODULE(escriptcpp)
154      // 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
155      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
156      .def("__str__",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
157      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())  //     .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
158      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomainPython)
159        .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>())
160      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
161        .def("isProtected",&escript::Data::isProtected)
162        .def("setProtection",&escript::Data::setProtection)
163      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
164      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
165        .def("dump",&escript::Data::dump)
166      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
167      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
168      .def("setRefValue",&escript::Data::setRefValue)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
169      .def("getRefValue",&escript::Data::getRefValue)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
170        .def("isExpanded",&escript::Data::isExpanded)
171        .def("isTagged",&escript::Data::isTagged)
172      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
173      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
174      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
175      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())
176      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
177      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
178      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
179        .def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint)
180        .def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint)
181        .def("setToZero",&escript::Data::setToZero)
182      .def("interpolate",&escript::Data::interpolate)      .def("interpolate",&escript::Data::interpolate)
183      .def("mindp",&escript::Data::mindp)      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
184      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
185      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
186      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
     .def("archiveData",&escript::Data::archiveData)  
     .def("extractData",&escript::Data::extractData)  
187      // Unary functions for Data      // Unary functions for Data
188      .def("_interpolate",&escript::Data::interpolate)      .def("_interpolate",&escript::Data::interpolate)
189      .def("_grad",&escript::Data::gradOn)      .def("_grad",&escript::Data::gradOn)
# Line 150  BOOST_PYTHON_MODULE(escriptcpp) Line 192  BOOST_PYTHON_MODULE(escriptcpp)
192      .def("_trace",&escript::Data::trace)      .def("_trace",&escript::Data::trace)
193      .def("_maxval",&escript::Data::maxval)      .def("_maxval",&escript::Data::maxval)
194      .def("_minval",&escript::Data::minval)      .def("_minval",&escript::Data::minval)
195      .def("_wherePositive",&escript::Data::wherePositive,(arg("tol")=0.0))      .def("_wherePositive",&escript::Data::wherePositive)
196      .def("_whereNegative",&escript::Data::whereNegative,(arg("tol")=0.0))      .def("_whereNegative",&escript::Data::whereNegative)
197      .def("_whereNonNegative",&escript::Data::whereNonNegative,(arg("tol")=0.0))      .def("_whereNonNegative",&escript::Data::whereNonNegative)
198      .def("_whereNonPositive",&escript::Data::whereNonPositive,(arg("tol")=0.0))      .def("_whereNonPositive",&escript::Data::whereNonPositive)
199      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
200      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
201        .def("_erf",&escript::Data::erf)
202      .def("_sin",&escript::Data::sin)      .def("_sin",&escript::Data::sin)
203      .def("_cos",&escript::Data::cos)      .def("_cos",&escript::Data::cos)
204      .def("_tan",&escript::Data::tan)      .def("_tan",&escript::Data::tan)
# Line 173  BOOST_PYTHON_MODULE(escriptcpp) Line 216  BOOST_PYTHON_MODULE(escriptcpp)
216      .def("_log10",&escript::Data::log10)      .def("_log10",&escript::Data::log10)
217      .def("_log",&escript::Data::log)      .def("_log",&escript::Data::log)
218      .def("_sign",&escript::Data::sign)      .def("_sign",&escript::Data::sign)
219        .def("_symmetric",&escript::Data::symmetric)
220        .def("_nonsymmetric",&escript::Data::nonsymmetric)
221        .def("_trace",&escript::Data::trace)
222        .def("_swap_axes",&escript::Data::swapaxes)
223      .def("_eigenvalues",&escript::Data::eigenvalues)      .def("_eigenvalues",&escript::Data::eigenvalues)
224      .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))
225      // functions returning a single real number:      // functions returning a single real number:
# Line 194  BOOST_PYTHON_MODULE(escriptcpp) Line 241  BOOST_PYTHON_MODULE(escriptcpp)
241      // following two functions implement the python ** operator      // following two functions implement the python ** operator
242      .def("__pow__",&escript::Data::powO)      .def("__pow__",&escript::Data::powO)
243      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
244        .def("__rpow__",&escript::Data::rpowO)
245      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
246      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
247      // version will be called.      // version will be called.
# Line 228  BOOST_PYTHON_MODULE(escriptcpp) Line 276  BOOST_PYTHON_MODULE(escriptcpp)
276    // Factory methods for function space    // Factory methods for function space
277    //    //
278    def("ContinuousFunction",escript::continuousFunction);    def("ContinuousFunction",escript::continuousFunction);
279      def("ReducedContinuousFunction",escript::reducedContinuousFunction);
280    def("Function",escript::function);    def("Function",escript::function);
281      def("ReducedFunction",escript::reducedFunction);
282    def("FunctionOnBoundary",escript::functionOnBoundary);    def("FunctionOnBoundary",escript::functionOnBoundary);
283      def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary);
284    def("FunctionOnContactZero",escript::functionOnContactZero);    def("FunctionOnContactZero",escript::functionOnContactZero);
285      def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero);
286    def("FunctionOnContactOne",escript::functionOnContactOne);    def("FunctionOnContactOne",escript::functionOnContactOne);
287      def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne);
288    def("Solution",escript::solution);    def("Solution",escript::solution);
289    def("ReducedSolution",escript::reducedSolution);    def("ReducedSolution",escript::reducedSolution);
290    def("DiracDeltaFunction",escript::diracDeltaFunction);    def("DiracDeltaFunction",escript::diracDeltaFunction);
# Line 239  BOOST_PYTHON_MODULE(escriptcpp) Line 292  BOOST_PYTHON_MODULE(escriptcpp)
292    //    //
293    // Factory methods for Data    // Factory methods for Data
294    //    //
295      def("load",escript::load);
296      def("loadIsConfigured",escript::loadConfigured);
297    def("Scalar",escript::Scalar,    def("Scalar",escript::Scalar,
298        (arg("value")=0.0,        (arg("value")=0.0,
299         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 261  BOOST_PYTHON_MODULE(escriptcpp) Line 316  BOOST_PYTHON_MODULE(escriptcpp)
316         arg("expanded")=false));         arg("expanded")=false));
317    
318    //    //
319      // Binary operators
320      //
321      def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
322          (arg("arg0")=escript::Data(),
323           arg("arg1")=escript::Data(),
324           arg("axis_offset")=0,
325           arg("transpose")=0));
326    
327      //
328    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
329    //    //
330    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator",init<>())
# Line 271  BOOST_PYTHON_MODULE(escriptcpp) Line 335  BOOST_PYTHON_MODULE(escriptcpp)
335       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
336       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
337       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
338      //
339      // Interface for AbstractTransportProblem
340      //
341      class_<escript::AbstractTransportProblem>("TransportProblem",init<>())
342         .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
343         .def("solve",&escript::AbstractTransportProblem::solve)
344         .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
345         .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)
346         .def("reset",&escript::AbstractTransportProblem::resetTransport)
347         .def("resetValues",&escript::AbstractTransportProblem::resetTransport)
348         .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize)
349         .def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize);
350    
351      // Functions to modify global parameters
352      def("setEscriptParamInt",escript::setEscriptParamInt,
353          (arg("value")=0));
354      def("getEscriptParamInt",escript::getEscriptParamInt,
355          (arg("sentinel")=0));
356    
357    
358    //    //
359    // Register esysExceptionTranslator    // Register esysExceptionTranslator

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

  ViewVC Help
Powered by ViewVC 1.1.26