/[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 1877 by ksteube, Tue Oct 14 02:58:39 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"
16  ******************************************************************************/  #include "FunctionSpace.h"
17    #include "FunctionSpaceFactory.h"
18  #include "escript/Data/Data.h"  #include "DataFactory.h"
19  #include "escript/Data/DataVariable.h"  #include "AbstractContinuousDomain.h"
20  #include "escript/Data/FunctionSpace.h"  #include "AbstractDomain.h"
21  #include "escript/Data/FunctionSpaceFactory.h"  #include "Utils.h"
22  #include "escript/Data/DataFactory.h"  #include "AbstractSystemMatrix.h"
23  #include "escript/Data/AbstractContinuousDomain.h"  #include "AbstractTransportProblem.h"
24  #include "escript/Data/AbstractDomain.h"  #include "DataVector.h"
25  #include "escript/Data/Utils.h"  #include "paso/Paso_MPI.h"
26    
27    
28    
29    extern "C" {
30    #include "escript/blocktimer.h"
31    }
32    
33  #include "esysUtils/esysExceptionTranslator.h"  #include "esysUtils/esysExceptionTranslator.h"
34    
35  #include <boost/python.hpp>  #include <boost/python.hpp>
# Line 31  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 72  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         .def("MPIBarrier",&escript::AbstractDomain::MPIBarrier)
112         .def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor)
113    
114       .def(self == self)       .def(self == self)
115       .def(self != self);       .def(self != self);
116    
# Line 89  BOOST_PYTHON_MODULE(escriptcpp) Line 118  BOOST_PYTHON_MODULE(escriptcpp)
118    // Interface for AbstractContinuousDomain    // Interface for AbstractContinuousDomain
119    //    //
120    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)    class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init)
121         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId);         .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId)
122           .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId);
123    
124    //    //
125    // Interface for FunctionSpace    // Interface for FunctionSpace
126    //    //
127    class_<escript::FunctionSpace>("FunctionSpace",init<>())    class_<escript::FunctionSpace> fs_definer("FunctionSpace",init<>());
128       .def("getDim",&escript::FunctionSpace::getDim)    fs_definer.def("getDim",&escript::FunctionSpace::getDim);
129       .def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>())  //   fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
130       .def("getX",&escript::FunctionSpace::getX)  //                  return_internal_reference<>());
131       .def("getNormal",&escript::FunctionSpace::getNormal)    fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython);
132       .def("getSize",&escript::FunctionSpace::getSize)    fs_definer.def("getX",&escript::FunctionSpace::getX);
133       .def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo)    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal);
134       .def("__str__",&escript::FunctionSpace::toString)    fs_definer.def("getSize",&escript::FunctionSpace::getSize);
135       .def(self == self)    fs_definer.def("setTags",&escript::FunctionSpace::setTags);
136       .def(self != self);    fs_definer.def("getTagFromDataPointNo",
137                     &escript::FunctionSpace::getTagFromDataPointNo);
138    //    fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo);
139    // Interface for DataVariable    fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags);
140    //    fs_definer.def("__str__", &escript::FunctionSpace::toString);
141    class_<escript::DataVariable>("DataVariable",init<>())    fs_definer.def(self == self);
142      .def(init<escript::Data*>())    fs_definer.def(self != self);
     .def("evaluate",&escript::DataVariable::evaluate)  
     .def("sum",&escript::DataVariable::sum)  
     .def("diff",&escript::DataVariable::diff);  
   
143    //    //
144    // Interface for Data    // Interface for Data
145    //    //
146    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>())    class_<escript::Data>("Data","TEST DOCUMENTATION",init<>() )
147      // various constructors for Data objects      // various constructors for Data objects
148      .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")))
149      .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 127  BOOST_PYTHON_MODULE(escriptcpp) Line 153  BOOST_PYTHON_MODULE(escriptcpp)
153      // 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
154      // reference. In this case return_internal_reference.      // reference. In this case return_internal_reference.
155      .def("__str__",&escript::Data::toString)      .def("__str__",&escript::Data::toString)
156      .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())  //     .def("getDomain",&escript::Data::getDomain,return_internal_reference<>())
157      .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>())      .def("getDomain",&escript::Data::getDomainPython)
158        .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>())
159      .def("isEmpty",&escript::Data::isEmpty)      .def("isEmpty",&escript::Data::isEmpty)
160        .def("isProtected",&escript::Data::isProtected)
161        .def("setProtection",&escript::Data::setProtection)
162      .def("getShape",&escript::Data::getShapeTuple)      .def("getShape",&escript::Data::getShapeTuple)
163      .def("getRank",&escript::Data::getDataPointRank)      .def("getRank",&escript::Data::getDataPointRank)
164        .def("dump",&escript::Data::dump)
165      .def("copyWithMask",&escript::Data::copyWithMask)      .def("copyWithMask",&escript::Data::copyWithMask)
166      .def("setTaggedValue",&escript::Data::setTaggedValue)      .def("setTaggedValue",&escript::Data::setTaggedValue)
167      .def("setRefValue",&escript::Data::setRefValue)      .def("setTaggedValue",&escript::Data::setTaggedValueByName)
168      .def("getRefValue",&escript::Data::getRefValue)      .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints)
169        .def("isExpanded",&escript::Data::isExpanded)
170        .def("isTagged",&escript::Data::isTagged)
171      .def("expand",&escript::Data::expand)      .def("expand",&escript::Data::expand)
172      .def("tag",&escript::Data::tag)      .def("tag",&escript::Data::tag)
173      .def("copy",&escript::Data::copy)      .def("copy",&escript::Data::copy)
174      .def("convertToNumArray",&escript::Data::convertToNumArray)      .def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>())
175      .def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject)
176      .def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
177      .def("fillFromNumArray",&escript::Data::fillFromNumArray)      .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint)
178        .def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint)
179        .def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint)
180        .def("setToZero",&escript::Data::setToZero)
181      .def("interpolate",&escript::Data::interpolate)      .def("interpolate",&escript::Data::interpolate)
182      .def("mindp",&escript::Data::mindp)      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
   
183      .def("saveDX",&escript::Data::saveDX)      .def("saveDX",&escript::Data::saveDX)
184      .def("saveVTK",&escript::Data::saveVTK)      .def("saveVTK",&escript::Data::saveVTK)
185      .def("getTagNumber",&escript::Data::getTagNumber)      .def("getTagNumber",&escript::Data::getTagNumber)
     .def("archiveData",&escript::Data::archiveData)  
     .def("extractData",&escript::Data::extractData)  
186      // Unary functions for Data      // Unary functions for Data
187      .def("_interpolate",&escript::Data::interpolate)      .def("_interpolate",&escript::Data::interpolate)
188      .def("_grad",&escript::Data::gradOn)      .def("_grad",&escript::Data::gradOn)
# Line 163  BOOST_PYTHON_MODULE(escriptcpp) Line 195  BOOST_PYTHON_MODULE(escriptcpp)
195      .def("_whereNegative",&escript::Data::whereNegative)      .def("_whereNegative",&escript::Data::whereNegative)
196      .def("_whereNonNegative",&escript::Data::whereNonNegative)      .def("_whereNonNegative",&escript::Data::whereNonNegative)
197      .def("_whereNonPositive",&escript::Data::whereNonPositive)      .def("_whereNonPositive",&escript::Data::whereNonPositive)
198      .def("_whereZero",&escript::Data::whereZero)      .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
199      .def("_whereNonZero",&escript::Data::whereNonZero)      .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
200        .def("_erf",&escript::Data::erf)
201      .def("_sin",&escript::Data::sin)      .def("_sin",&escript::Data::sin)
202      .def("_cos",&escript::Data::cos)      .def("_cos",&escript::Data::cos)
203      .def("_tan",&escript::Data::tan)      .def("_tan",&escript::Data::tan)
# Line 182  BOOST_PYTHON_MODULE(escriptcpp) Line 215  BOOST_PYTHON_MODULE(escriptcpp)
215      .def("_log10",&escript::Data::log10)      .def("_log10",&escript::Data::log10)
216      .def("_log",&escript::Data::log)      .def("_log",&escript::Data::log)
217      .def("_sign",&escript::Data::sign)      .def("_sign",&escript::Data::sign)
218        .def("_symmetric",&escript::Data::symmetric)
219        .def("_nonsymmetric",&escript::Data::nonsymmetric)
220        .def("_trace",&escript::Data::trace)
221        .def("_swap_axes",&escript::Data::swapaxes)
222        .def("_eigenvalues",&escript::Data::eigenvalues)
223        .def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13))
224      // functions returning a single real number:      // functions returning a single real number:
225      .def("_Lsup",&escript::Data::Lsup)      .def("_Lsup",&escript::Data::Lsup)
226      .def("_sup",&escript::Data::sup)      .def("_sup",&escript::Data::sup)
# Line 201  BOOST_PYTHON_MODULE(escriptcpp) Line 240  BOOST_PYTHON_MODULE(escriptcpp)
240      // following two functions implement the python ** operator      // following two functions implement the python ** operator
241      .def("__pow__",&escript::Data::powO)      .def("__pow__",&escript::Data::powO)
242      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
243        .def("__rpow__",&escript::Data::rpowO)
244      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
245      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
246      // version will be called.      // version will be called.
# Line 235  BOOST_PYTHON_MODULE(escriptcpp) Line 275  BOOST_PYTHON_MODULE(escriptcpp)
275    // Factory methods for function space    // Factory methods for function space
276    //    //
277    def("ContinuousFunction",escript::continuousFunction);    def("ContinuousFunction",escript::continuousFunction);
278      def("ReducedContinuousFunction",escript::reducedContinuousFunction);
279    def("Function",escript::function);    def("Function",escript::function);
280      def("ReducedFunction",escript::reducedFunction);
281    def("FunctionOnBoundary",escript::functionOnBoundary);    def("FunctionOnBoundary",escript::functionOnBoundary);
282      def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary);
283    def("FunctionOnContactZero",escript::functionOnContactZero);    def("FunctionOnContactZero",escript::functionOnContactZero);
284      def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero);
285    def("FunctionOnContactOne",escript::functionOnContactOne);    def("FunctionOnContactOne",escript::functionOnContactOne);
286      def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne);
287    def("Solution",escript::solution);    def("Solution",escript::solution);
288    def("ReducedSolution",escript::reducedSolution);    def("ReducedSolution",escript::reducedSolution);
289    def("DiracDeltaFunction",escript::diracDeltaFunction);    def("DiracDeltaFunction",escript::diracDeltaFunction);
# Line 246  BOOST_PYTHON_MODULE(escriptcpp) Line 291  BOOST_PYTHON_MODULE(escriptcpp)
291    //    //
292    // Factory methods for Data    // Factory methods for Data
293    //    //
294      def("load",escript::load);
295      def("loadIsConfigured",escript::loadConfigured);
296    def("Scalar",escript::Scalar,    def("Scalar",escript::Scalar,
297        (arg("value")=0.0,        (arg("value")=0.0,
298         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 268  BOOST_PYTHON_MODULE(escriptcpp) Line 315  BOOST_PYTHON_MODULE(escriptcpp)
315         arg("expanded")=false));         arg("expanded")=false));
316    
317    //    //
318      // Binary operators
319      //
320      def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
321          (arg("arg0")=escript::Data(),
322           arg("arg1")=escript::Data(),
323           arg("axis_offset")=0,
324           arg("transpose")=0));
325    
326      //
327    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
328    //    //
329    class_<escript::AbstractSystemMatrix>("Operator",init<>())    class_<escript::AbstractSystemMatrix>("Operator",init<>())
# Line 278  BOOST_PYTHON_MODULE(escriptcpp) Line 334  BOOST_PYTHON_MODULE(escriptcpp)
334       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)       .def("saveHB",&escript::AbstractSystemMatrix::saveHB)
335       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)       .def("resetValues",&escript::AbstractSystemMatrix::resetValues)
336       .def(self*other<escript::Data>());       .def(self*other<escript::Data>());
337      //
338      // Interface for AbstractTransportProblem
339      //
340      class_<escript::AbstractTransportProblem>("TransportProblem",init<>())
341         .def("isEmpty",&escript::AbstractTransportProblem::isEmpty)
342         .def("solve",&escript::AbstractTransportProblem::solve)
343         .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue)
344         .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint)
345         .def("reset",&escript::AbstractTransportProblem::resetTransport)
346         .def("resetValues",&escript::AbstractTransportProblem::resetTransport)
347         .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize)
348         .def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize);
349    
350    //    //
351    // Register esysExceptionTranslator    // Register esysExceptionTranslator

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

  ViewVC Help
Powered by ViewVC 1.1.26