/[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 804 by gross, Thu Aug 10 01:12:16 2006 UTC revision 1426 by trankine, Wed Feb 27 06:12:15 2008 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*  /* $Id$ */
3   ************************************************************  
4   *          Copyright 2006 by ACcESS MNRF                   *  /*******************************************************
5   *                                                          *   *
6   *              http://www.access.edu.au                    *   *           Copyright 2003-2007 by ACceSS MNRF
7   *       Primary Business: Queensland, Australia            *   *       Copyright 2007 by University of Queensland
8   *  Licensed under the Open Software License version 3.0    *   *
9   *     http://www.opensource.org/licenses/osl-3.0.php       *   *                http://esscc.uq.edu.au
10   *                                                          *   *        Primary Business: Queensland, Australia
11   ************************************************************   *  Licensed under the Open Software License version 3.0
12  */   *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  #include "Data.h"  #include "Data.h"
17  #include "FunctionSpace.h"  #include "FunctionSpace.h"
# Line 19  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"  #include "DataVector.h"
26    
27    extern "C" {
28    #include "escript/blocktimer.h"
29    }
30    
31  #include "esysUtils/esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
32    
33  #include <boost/python.hpp>  #include <boost/python.hpp>
# Line 71  BOOST_PYTHON_MODULE(escriptcpp) Line 78  BOOST_PYTHON_MODULE(escriptcpp)
78    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
79    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
80    def("releaseUnusedMemory",escript::releaseUnusedMemory);    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 94  BOOST_PYTHON_MODULE(escriptcpp) Line 114  BOOST_PYTHON_MODULE(escriptcpp)
114    //    //
115    // Interface for FunctionSpace    // Interface for FunctionSpace
116    //    //
117    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace> fs_definer("FunctionSpace",init<>());
118       .def("getDim",&escript::FunctionSpace::getDim)    fs_definer.def("getDim",&escript::FunctionSpace::getDim);
119       .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())    fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
120       .def("getX",&escript::FunctionSpace::getX)                   return_internal_reference<>());
121       .def("getNormal",&escript::FunctionSpace::getNormal)    fs_definer.def("getX",&escript::FunctionSpace::getX);
122       .def("getSize",&escript::FunctionSpace::getSize)    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
123       .def("setTags",&escript::FunctionSpace::setTags)    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
124       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)    fs_definer.def("setTags",&escript::FunctionSpace::setTags);
125       .def("__str__",&escript::FunctionSpace::toString)    fs_definer.def("getTagFromDataPointNo",
126       .def(self == self)                   &escript::FunctionSpace::getTagFromDataPointNo);
127       .def(self != self);  #ifdef DEBUG_PY_STRINGS
128      fs_definer.def("__str__",&escript::FunctionSpace::toPyString);
129    #else
130      fs_definer.def("__str__",
131                     &escript::FunctionSpace::toString,
132                     return_value_policy<copy_const_reference>());
133    #endif
134      fs_definer.def(self == self);
135      fs_definer.def(self != self);
136    //    //
137    // Interface for Data    // Interface for Data
138    //    //
# Line 125  BOOST_PYTHON_MODULE(escriptcpp) Line 153  BOOST_PYTHON_MODULE(escriptcpp)
153      .def("setProtection",&escript::Data::setProtection)      .def("setProtection",&escript::Data::setProtection)
154      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
155      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
156        .def("dump",&escript::Data::dump)
157      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
158      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
159      .def("setRefValue",&escript::Data::setRefValue)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
160      .def("getRefValue",&escript::Data::getRefValue)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
161        .def("isExpanded",&escript::Data::isExpanded)
162        .def("isTagged",&escript::Data::isTagged)
163      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
164      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
165      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
166      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
167      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
168      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
169      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint)
170        .def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint)
171        .def("setToZero",&escript::Data::setToZero)
172      .def("interpolate",&escript::Data::interpolate)      .def("interpolate",&escript::Data::interpolate)
173      .def("mindp",&escript::Data::mindp)      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
174      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
175      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
176      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
# Line 157  BOOST_PYTHON_MODULE(escriptcpp) Line 190  BOOST_PYTHON_MODULE(escriptcpp)
190      .def("_whereNonPositive",&escript::Data::whereNonPositive)      .def("_whereNonPositive",&escript::Data::whereNonPositive)
191      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
192      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
193        .def("_erf",&escript::Data::erf)
194      .def("_sin",&escript::Data::sin)      .def("_sin",&escript::Data::sin)
195      .def("_cos",&escript::Data::cos)      .def("_cos",&escript::Data::cos)
196      .def("_tan",&escript::Data::tan)      .def("_tan",&escript::Data::tan)
# Line 234  BOOST_PYTHON_MODULE(escriptcpp) Line 268  BOOST_PYTHON_MODULE(escriptcpp)
268    // Factory methods for function space    // Factory methods for function space
269    //    //
270    def("ContinuousFunction",escript::continuousFunction);    def("ContinuousFunction",escript::continuousFunction);
271      def("ReducedContinuousFunction",escript::reducedContinuousFunction);
272    def("Function",escript::function);    def("Function",escript::function);
273      def("ReducedFunction",escript::reducedFunction);
274    def("FunctionOnBoundary",escript::functionOnBoundary);    def("FunctionOnBoundary",escript::functionOnBoundary);
275      def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary);
276    def("FunctionOnContactZero",escript::functionOnContactZero);    def("FunctionOnContactZero",escript::functionOnContactZero);
277      def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero);
278    def("FunctionOnContactOne",escript::functionOnContactOne);    def("FunctionOnContactOne",escript::functionOnContactOne);
279      def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne);
280    def("Solution",escript::solution);    def("Solution",escript::solution);
281    def("ReducedSolution",escript::reducedSolution);    def("ReducedSolution",escript::reducedSolution);
282    def("DiracDeltaFunction",escript::diracDeltaFunction);    def("DiracDeltaFunction",escript::diracDeltaFunction);
# Line 245  BOOST_PYTHON_MODULE(escriptcpp) Line 284  BOOST_PYTHON_MODULE(escriptcpp)
284    //    //
285    // Factory methods for Data    // Factory methods for Data
286    //    //
287      def("load",escript::load);
288      def("loadIsConfigured",escript::loadConfigured);
289    def("Scalar",escript::Scalar,    def("Scalar",escript::Scalar,
290        (arg("value")=0.0,        (arg("value")=0.0,
291         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 267  BOOST_PYTHON_MODULE(escriptcpp) Line 308  BOOST_PYTHON_MODULE(escriptcpp)
308         arg("expanded")=false));         arg("expanded")=false));
309    
310    //    //
311      // Binary operators
312      //
313      def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
314          (arg("arg0")=escript::Data(),
315           arg("arg1")=escript::Data(),
316           arg("axis_offset")=0,
317           arg("transpose")=0));
318    
319      //
320    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
321    //    //
322    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator",init<>())
# Line 277  BOOST_PYTHON_MODULE(escriptcpp) Line 327  BOOST_PYTHON_MODULE(escriptcpp)
327       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
328       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
329       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
330      //
331      // Interface for AbstractTransportProblem
332      //
333      class_<escript::AbstractTransportProblem>("TransportProblem",init<>())
334         .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
335         .def("solve",&escript::AbstractTransportProblem::solve)
336         .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
337         .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)
338         .def("reset",&escript::AbstractTransportProblem::resetTransport)
339         .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize);
340    
341    //    //
342    // Register esysExceptionTranslator    // Register esysExceptionTranslator

Legend:
Removed from v.804  
changed lines
  Added in v.1426

  ViewVC Help
Powered by ViewVC 1.1.26