/[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

trunk/escript/src/Data/escriptcpp.cpp revision 391 by gross, Tue Dec 20 05:36:50 2005 UTC trunk/escript/src/escriptcpp.cpp revision 1800 by ksteube, Thu Sep 18 05:28:20 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"
17    #include "FunctionSpace.h"
18  #include "escript/Data/Data.h"  #include "FunctionSpaceFactory.h"
19  #include "escript/Data/DataVariable.h"  #include "DataFactory.h"
20  #include "escript/Data/FunctionSpace.h"  #include "AbstractContinuousDomain.h"
21  #include "escript/Data/FunctionSpaceFactory.h"  #include "AbstractDomain.h"
22  #include "escript/Data/DataFactory.h"  #include "Utils.h"
23  #include "escript/Data/AbstractContinuousDomain.h"  #include "AbstractSystemMatrix.h"
24  #include "escript/Data/AbstractDomain.h"  #include "AbstractTransportProblem.h"
25  #include "escript/Data/Utils.h"  #include "DataVector.h"
26    #include "paso/Paso_MPI.h"
27    
28    extern "C" {
29    #include "escript/blocktimer.h"
30    }
31    
32  #include "esysUtils/esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
33    
34  #include <boost/python.hpp>  #include <boost/python.hpp>
# Line 72  BOOST_PYTHON_MODULE(escriptcpp) Line 78  BOOST_PYTHON_MODULE(escriptcpp)
78  {  {
79    def("setNumberOfThreads",escript::setNumberOfThreads);    def("setNumberOfThreads",escript::setNumberOfThreads);
80    def("getNumberOfThreads",escript::getNumberOfThreads);    def("getNumberOfThreads",escript::getNumberOfThreads);
81      def("releaseUnusedMemory",escript::releaseUnusedMemory);
82      def("blocktimer_initialize",blocktimer_initialize);
83      def("blocktimer_reportSortByName",blocktimer_reportSortByName);
84      def("blocktimer_reportSortByTime",blocktimer_reportSortByTime);
85      def("blocktimer_increment",blocktimer_increment);
86      def("blocktimer_time",blocktimer_time);
87      def("getVersion",escript::getSvnVersion);
88      def("printParallelThreadCounts",escript::printParallelThreadCnt);
89    
90    
91    //    //
92    // Interface for AbstractDomain    // Interface for AbstractDomain
93    //    //
94    class_<escript::AbstractDomain>("Domain",no_init)    class_<escript::AbstractDomain>("Domain",no_init)
95         .def("setTagMap",&escript::AbstractDomain::setTagMap)
96         .def("getTag",&escript::AbstractDomain::getTag)
97         .def("isValidTagName",&escript::AbstractDomain::isValidTagName)
98         .def("showTagNames",&escript::AbstractDomain::showTagNames)
99       .def("getX",&escript::AbstractDomain::getX)       .def("getX",&escript::AbstractDomain::getX)
100       .def("getNormal",&escript::AbstractDomain::getNormal)       .def("getNormal",&escript::AbstractDomain::getNormal)
101       .def("getSize",&escript::AbstractDomain::getSize)       .def("getSize",&escript::AbstractDomain::getSize)
102       .def("saveVTK",&escript::AbstractDomain::saveVTK)       .def("saveVTK",&escript::AbstractDomain::saveVTK)
103       .def("saveDX",&escript::AbstractDomain::saveDX)       .def("saveDX",&escript::AbstractDomain::saveDX)
104         .def("getMPISize",&escript::AbstractDomain::getMPISize)
105         .def("getMPIRank",&escript::AbstractDomain::getMPIRank)
106         .def("getMPIComm",&escript::AbstractDomain::getMPIComm)
107    
108       .def(self == self)       .def(self == self)
109       .def(self != self);       .def(self != self);
110    
# Line 94  BOOST_PYTHON_MODULE(escriptcpp) Line 117  BOOST_PYTHON_MODULE(escriptcpp)
117    //    //
118    // Interface for FunctionSpace    // Interface for FunctionSpace
119    //    //
120    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace> fs_definer("FunctionSpace",init<>());
121       .def("getDim",&escript::FunctionSpace::getDim)    fs_definer.def("getDim",&escript::FunctionSpace::getDim);
122       .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())    fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
123       .def("getX",&escript::FunctionSpace::getX)                   return_internal_reference<>());
124       .def("getNormal",&escript::FunctionSpace::getNormal)    fs_definer.def("getX",&escript::FunctionSpace::getX);
125       .def("getSize",&escript::FunctionSpace::getSize)    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
126       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
127       .def("__str__",&escript::FunctionSpace::toString)    fs_definer.def("setTags",&escript::FunctionSpace::setTags);
128       .def(self == self)    fs_definer.def("getTagFromDataPointNo",
129       .def(self != self);                   &escript::FunctionSpace::getTagFromDataPointNo);
130      fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo);
131    //    fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags);
132    // Interface for DataVariable    fs_definer.def("__str__", &escript::FunctionSpace::toString);
133    //    fs_definer.def(self == self);
134    class_<escript::DataVariable>("DataVariable",init<>())    fs_definer.def(self != self);
     .def(init<escript::Data*>())  
     .def("evaluate",&escript::DataVariable::evaluate)  
     .def("sum",&escript::DataVariable::sum)  
     .def("diff",&escript::DataVariable::diff);  
   
135    //    //
136    // Interface for Data    // Interface for Data
137    //    //
# Line 130  BOOST_PYTHON_MODULE(escriptcpp) Line 148  BOOST_PYTHON_MODULE(escriptcpp)
148      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
149      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())
150      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
151        .def("isProtected",&escript::Data::isProtected)
152        .def("setProtection",&escript::Data::setProtection)
153      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
154      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
155        .def("dump",&escript::Data::dump)
156      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
157      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
158      .def("setRefValue",&escript::Data::setRefValue)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
159      .def("getRefValue",&escript::Data::getRefValue)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
160        .def("isExpanded",&escript::Data::isExpanded)
161        .def("isTagged",&escript::Data::isTagged)
162      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
163      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
164      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
165      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())
166      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
167      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
168      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
169        .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)
     .def("archiveData",&escript::Data::archiveData)  
     .def("extractData",&escript::Data::extractData)  
177      // Unary functions for Data      // Unary functions for Data
178      .def("_interpolate",&escript::Data::interpolate)      .def("_interpolate",&escript::Data::interpolate)
179      .def("_grad",&escript::Data::gradOn)      .def("_grad",&escript::Data::gradOn)
# Line 163  BOOST_PYTHON_MODULE(escriptcpp) Line 186  BOOST_PYTHON_MODULE(escriptcpp)
186      .def("_whereNegative",&escript::Data::whereNegative)      .def("_whereNegative",&escript::Data::whereNegative)
187      .def("_whereNonNegative",&escript::Data::whereNonNegative)      .def("_whereNonNegative",&escript::Data::whereNonNegative)
188      .def("_whereNonPositive",&escript::Data::whereNonPositive)      .def("_whereNonPositive",&escript::Data::whereNonPositive)
189      .def("_whereZero",&escript::Data::whereZero)      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
190      .def("_whereNonZero",&escript::Data::whereNonZero)      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
191        .def("_erf",&escript::Data::erf)
192      .def("_sin",&escript::Data::sin)      .def("_sin",&escript::Data::sin)
193      .def("_cos",&escript::Data::cos)      .def("_cos",&escript::Data::cos)
194      .def("_tan",&escript::Data::tan)      .def("_tan",&escript::Data::tan)
# Line 182  BOOST_PYTHON_MODULE(escriptcpp) Line 206  BOOST_PYTHON_MODULE(escriptcpp)
206      .def("_log10",&escript::Data::log10)      .def("_log10",&escript::Data::log10)
207      .def("_log",&escript::Data::log)      .def("_log",&escript::Data::log)
208      .def("_sign",&escript::Data::sign)      .def("_sign",&escript::Data::sign)
209        .def("_symmetric",&escript::Data::symmetric)
210        .def("_nonsymmetric",&escript::Data::nonsymmetric)
211        .def("_trace",&escript::Data::trace)
212        .def("_swap_axes",&escript::Data::swapaxes)
213        .def("_eigenvalues",&escript::Data::eigenvalues)
214        .def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13))
215      // functions returning a single real number:      // functions returning a single real number:
216      .def("_Lsup",&escript::Data::Lsup)      .def("_Lsup",&escript::Data::Lsup)
217      .def("_sup",&escript::Data::sup)      .def("_sup",&escript::Data::sup)
# Line 201  BOOST_PYTHON_MODULE(escriptcpp) Line 231  BOOST_PYTHON_MODULE(escriptcpp)
231      // following two functions implement the python ** operator      // following two functions implement the python ** operator
232      .def("__pow__",&escript::Data::powO)      .def("__pow__",&escript::Data::powO)
233      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
234        .def("__rpow__",&escript::Data::rpowO)
235      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
236      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
237      // version will be called.      // version will be called.
# Line 235  BOOST_PYTHON_MODULE(escriptcpp) Line 266  BOOST_PYTHON_MODULE(escriptcpp)
266    // Factory methods for function space    // Factory methods for function space
267    //    //
268    def("ContinuousFunction",escript::continuousFunction);    def("ContinuousFunction",escript::continuousFunction);
269      def("ReducedContinuousFunction",escript::reducedContinuousFunction);
270    def("Function",escript::function);    def("Function",escript::function);
271      def("ReducedFunction",escript::reducedFunction);
272    def("FunctionOnBoundary",escript::functionOnBoundary);    def("FunctionOnBoundary",escript::functionOnBoundary);
273      def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary);
274    def("FunctionOnContactZero",escript::functionOnContactZero);    def("FunctionOnContactZero",escript::functionOnContactZero);
275      def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero);
276    def("FunctionOnContactOne",escript::functionOnContactOne);    def("FunctionOnContactOne",escript::functionOnContactOne);
277      def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne);
278    def("Solution",escript::solution);    def("Solution",escript::solution);
279    def("ReducedSolution",escript::reducedSolution);    def("ReducedSolution",escript::reducedSolution);
280    def("DiracDeltaFunction",escript::diracDeltaFunction);    def("DiracDeltaFunction",escript::diracDeltaFunction);
# Line 246  BOOST_PYTHON_MODULE(escriptcpp) Line 282  BOOST_PYTHON_MODULE(escriptcpp)
282    //    //
283    // Factory methods for Data    // Factory methods for Data
284    //    //
285      def("load",escript::load);
286      def("loadIsConfigured",escript::loadConfigured);
287    def("Scalar",escript::Scalar,    def("Scalar",escript::Scalar,
288        (arg("value")=0.0,        (arg("value")=0.0,
289         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 268  BOOST_PYTHON_MODULE(escriptcpp) Line 306  BOOST_PYTHON_MODULE(escriptcpp)
306         arg("expanded")=false));         arg("expanded")=false));
307    
308    //    //
309      // Binary operators
310      //
311      def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
312          (arg("arg0")=escript::Data(),
313           arg("arg1")=escript::Data(),
314           arg("axis_offset")=0,
315           arg("transpose")=0));
316    
317      //
318    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
319    //    //
320    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator",init<>())
# Line 278  BOOST_PYTHON_MODULE(escriptcpp) Line 325  BOOST_PYTHON_MODULE(escriptcpp)
325       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
326       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
327       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
328      //
329      // Interface for AbstractTransportProblem
330      //
331      class_<escript::AbstractTransportProblem>("TransportProblem",init<>())
332         .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
333         .def("solve",&escript::AbstractTransportProblem::solve)
334         .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
335         .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)
336         .def("reset",&escript::AbstractTransportProblem::resetTransport)
337         .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize);
338    
339    //    //
340    // Register esysExceptionTranslator    // Register esysExceptionTranslator

Legend:
Removed from v.391  
changed lines
  Added in v.1800

  ViewVC Help
Powered by ViewVC 1.1.26