/[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 2626 by jfenwick, Mon Aug 24 00:48:31 2009 UTC revision 3506 by jfenwick, Wed May 11 01:59:45 2011 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2009 by University of Queensland  * Copyright (c) 2003-2010 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
6  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
7  *  *
# Line 22  Line 22 
22  #include "AbstractSystemMatrix.h"  #include "AbstractSystemMatrix.h"
23  #include "AbstractTransportProblem.h"  #include "AbstractTransportProblem.h"
24  #include "DataVector.h"  #include "DataVector.h"
25  #include "paso/Paso_MPI.h"  #include "esysUtils/Esys_MPI.h"
26  #include "EscriptParams.h"  #include "EscriptParams.h"
27  #include "TestDomain.h"  #include "TestDomain.h"
28    
# Line 39  extern "C" { Line 39  extern "C" {
39  #include <boost/python/def.hpp>  #include <boost/python/def.hpp>
40  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
41  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
 #include <boost/python/numeric.hpp>  
42  #include <boost/smart_ptr.hpp>  #include <boost/smart_ptr.hpp>
43  #include <boost/version.hpp>  #include <boost/version.hpp>
44    
# Line 53  using namespace boost::python; Line 52  using namespace boost::python;
52   *   *
53   * - \ref esys_exception "Esys Exception"   * - \ref esys_exception "Esys Exception"
54   *   *
55   * - \ref finley   * - \ref dudley
56   *   *
57   * - <a href="../../epydoc/index.html">Python module documentation (epydoc generated)</a>   * - <a href="../../epydoc/index.html">Python module documentation (epydoc generated)</a>
58   *   *
# Line 107  BOOST_PYTHON_MODULE(escriptcpp) Line 106  BOOST_PYTHON_MODULE(escriptcpp)
106  " value for arg1. The values are added up and the total value is returned.\n\n:rtype: int");  " value for arg1. The values are added up and the total value is returned.\n\n:rtype: int");
107    def("getMachinePrecision",escript::getMachinePrecision);    def("getMachinePrecision",escript::getMachinePrecision);
108    def("getMaxFloat",escript::getMaxFloat);    def("getMaxFloat",escript::getMaxFloat);
109      def("_saveDataCSV",escript::saveDataCSV, (args("filename","arg","sep","csep"), arg("append")=false),
110    "Saves data objects passed in a python dictionary to a file.\n"
111    "The data objects must be over the same domain and be able to be interpolated to the same FunctionSpace.\n"
112    "If one of the dictionary keys is named ``mask``, then only samples where ``mask`` has a positive\n"
113    "value will be written to the file.\n\n"
114    "A header line giving the names of each column will be output first.\n"
115    "The keys given in the dictionary will be used to name columns.\n"
116    "Then the data will be output, one line per sample (for all data).\n"
117    "That is, items in each column will be printed in the same order.\n"
118    "So you can be sure that values in the same row correspond to the same input value.\n\n"
119    "\n:param filename:\n:type filename: ``string``\n"
120    ":param arg: dictionary of named `Data` objects. If one is called ``mask`` it must be scalar data.\n"
121    ":type arg: ``dict``\n"
122    ":param sep: separator for columns (defaults to ',')\n"
123    ":type sep: ``string``\n"
124    ":param csep: separator for fields within data object (defaults to \"_\")\n:type csep: ``string``\n"
125    ":param append: If True, write to the end of ``filename``\n:type append: ``string``\n");
126    
127    
128    //    //
129    // Interface for AbstractDomain    // Interface for AbstractDomain
130    //    //
# Line 138  BOOST_PYTHON_MODULE(escriptcpp) Line 156  BOOST_PYTHON_MODULE(escriptcpp)
156       .def("getMPIRank",&escript::AbstractDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")       .def("getMPIRank",&escript::AbstractDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
157       .def("MPIBarrier",&escript::AbstractDomain::MPIBarrier,"Wait until all processes have reached this point")       .def("MPIBarrier",&escript::AbstractDomain::MPIBarrier,"Wait until all processes have reached this point")
158       .def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`")       .def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`")
159         .def("supportsContactElements", &escript::AbstractDomain::supportsContactElements,"Does this domain support contact elements.")
160       .def(self == self)       .def(self == self)
161       .def(self != self);       .def(self != self);
162    
# Line 152  args("solver", "preconditioner", "packag Line 170  args("solver", "preconditioner", "packag
170  "when a particular solver package and symmetric matrix is used.\n"  "when a particular solver package and symmetric matrix is used.\n"
171  ":rtype: int")  ":rtype: int")
172         .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId,         .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId,
173  args("solver", "preconditioner", "package", "symmetry"));  args("solver", "preconditioner", "package", "symmetry"))
174    
175          .def("addPDEToSystem",&escript::AbstractContinuousDomain::addPDEToSystem,
176    args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
177    "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
178    ":param mat:\n:type mat: `OperatorAdapter`\n:param rhs:\n:type rhs: `Data`\n"
179    ":param A:\n:type A: `Data`\n"
180    ":param B:\n:type B: `Data`\n"
181    ":param C:\n:type C: `Data`\n"
182    ":param D:\n:type D: `Data`\n"
183    ":param X:\n:type X: `Data`\n"
184    ":param Y:\n:type Y: `Data`\n"
185    ":param d:\n:type d: `Data`\n"
186    ":param d_contact:\n:type d_contact: `Data`\n"
187    ":param y_contact:\n:type y_contact: `Data`\n"
188    )
189          .def("addPDEToRHS",&escript::AbstractContinuousDomain::addPDEToRHS,
190    args("rhs", "X", "Y", "y", "y_contact"),
191    "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
192    ":param rhs:\n:type rhs: `Data`\n"
193    ":param X:\n:type X: `Data`\n"
194    ":param Y:\n:type Y: `Data`\n"
195    ":param y:\n:type y: `Data`\n"
196    ":param y_contact:\n:type y_contact: `Data`"
197    )
198          .def("addPDEToTransportProblem",&escript::AbstractContinuousDomain::addPDEToTransportProblem,
199    args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
200    ":param tp:\n:type tp: `TransportProblemAdapter`\n"
201    ":param source:\n:type source: `Data`\n"
202    ":param M:\n:type M: `Data`\n"
203    ":param A:\n:type A: `Data`\n"
204    ":param B:\n:type B: `Data`\n"
205    ":param C:\n:type C: `Data`\n"
206    ":param D:\n:type D: `Data`\n"
207    ":param X:\n:type X: `Data`\n"
208    ":param Y:\n:type Y: `Data`\n"
209    ":param d:\n:type d: `Data`\n"
210    ":param y:\n:type y: `Data`\n"
211    ":param d_contact:\n:type d_contact: `Data`\n"
212    ":param y_contact:\n:type y_contact: `Data`\n"
213    )
214          .def("newOperator",&escript::AbstractContinuousDomain::newSystemMatrix,
215    args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
216    "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
217    ":param row_blocksize:\n:type row_blocksize: ``int``\n"
218    ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
219    ":param column_blocksize:\n:type column_blocksize: ``int``\n"
220    ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
221    ":param type:\n:type type: ``int``\n"
222    )
223          .def("newTransportProblem",&escript::AbstractContinuousDomain::newTransportProblem,
224    args("theta", "blocksize", "functionspace", "type"),
225    "creates a TransportProblemAdapter\n\n"
226    ":param theta:\n:type theta: ``float``\n"
227    ":param blocksize:\n:type blocksize: ``int``\n"
228    ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
229    ":param type:\n:type type: ``int``\n"
230    )
231          .def("getDataShape",&escript::AbstractContinuousDomain::getDataShape, args("functionSpaceCode"),
232    ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
233          .def("print_mesh_info",&escript::AbstractContinuousDomain::Print_Mesh_Info,(arg("full")=false),
234    ":param full:\n:type full: ``bool``")
235          .def("getDescription",&escript::AbstractContinuousDomain::getDescription,
236    ":return: a description for this domain\n:rtype: ``string``")
237          .def("setX",&escript::AbstractContinuousDomain::setNewX,
238    args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
239          .def("getNumDataPointsGlobal",&escript::AbstractContinuousDomain::getNumDataPointsGlobal,
240    ":return: the number of data points summed across all MPI processes\n"
241    ":rtype: ``int``");
242    
243    
244    
245    
246    //    //
# Line 177  args("solver", "preconditioner", "packag Line 265  args("solver", "preconditioner", "packag
265    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal,":return: the surface normal field.\n\n:rtype: `Data`");    fs_definer.def("getNormal",&escript::FunctionSpace::getNormal,":return: the surface normal field.\n\n:rtype: `Data`");
266    fs_definer.def("getSize",&escript::FunctionSpace::getSize,":return: sample size\n:rtype: `Data`");    fs_definer.def("getSize",&escript::FunctionSpace::getSize,":return: sample size\n:rtype: `Data`");
267    fs_definer.def("setTags",&escript::FunctionSpace::setTags,args("newtag","mask"),    fs_definer.def("setTags",&escript::FunctionSpace::setTags,args("newtag","mask"),
268  "Set tags according to a mask\n\n:param newtag: tag number to set\n:type newtag: non-zero ``int``\n:param mask: Samples which correspond to positive values in the mask will be set to ``newtag``.\n:type mask: scalar `Data`");  "Set tags according to a mask\n\n:param newtag: tag number to set\n:type newtag: string, non-zero ``int``\n:param mask: Samples which correspond to positive values in the mask will be set to ``newtag``.\n:type mask: scalar `Data`");
269      fs_definer.def("setTags",&escript::FunctionSpace::setTagsByString,args("newtag","mask"));
270    fs_definer.def("getTagFromDataPointNo",    fs_definer.def("getTagFromDataPointNo",
271                   &escript::FunctionSpace::getTagFromDataPointNo,":return: the tag associated with the given sample number.\n:rtype: int");                   &escript::FunctionSpace::getTagFromDataPointNo,":return: the tag associated with the given sample number.\n:rtype: int");
272    fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo,args("dataPointNo"),":return: the reference number associated with ``dataPointNo``\n:rtype: int ");    fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo,args("dataPointNo"),":return: the reference number associated with ``dataPointNo``\n:rtype: int ");
273    fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags,":return: a list of the tags used in this function space\n:rtype: ``list``");    fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags,":return: a list of the tags used in this function space\n:rtype: ``list``");
274      fs_definer.def("getApproximationOrder", &escript::FunctionSpace::getApproximationOrder,":return: the approximation order refering to the maximum degree of a polynomial which can be represenred exactly in interplation and/or integration.\n:rtype: ``int``");
275    fs_definer.def("__str__", &escript::FunctionSpace::toString);    fs_definer.def("__str__", &escript::FunctionSpace::toString);
276    fs_definer.def(self == self);    fs_definer.def(self == self);
277    fs_definer.def(self != self);    fs_definer.def(self != self);
278    //    //
279    // Interface for Data    // Interface for Data
280    //    //
281    class_<escript::Data>("Data","Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() )    class_<escript::Data>("Data"/*,shared_ptr<Data>*/, "Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() )
282      // various constructors for Data objects      // various constructors for Data objects
283      .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")))
284      .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))      .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))
# Line 243  args("solver", "preconditioner", "packag Line 333  args("solver", "preconditioner", "packag
333  "\n:param dataPointNo: datapoint to access\n:type dataPointNo: int")  "\n:param dataPointNo: datapoint to access\n:type dataPointNo: int")
334      .def("setToZero",&escript::Data::setToZero,"After this call the object will store values of the same shape as before but all components will be zero.")      .def("setToZero",&escript::Data::setToZero,"After this call the object will store values of the same shape as before but all components will be zero.")
335      .def("interpolate",&escript::Data::interpolate,args("functionspace"),"Interpolate this object's values into a new functionspace.")      .def("interpolate",&escript::Data::interpolate,args("functionspace"),"Interpolate this object's values into a new functionspace.")
336      .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)      .def("_interpolateTable3d", &escript::Data::interpolateFromTable3DP,
337      .def("maxGlobalDataPoint",&escript::Data::maxGlobalDataPoint)  (arg("table"),arg("Amin"),arg("Astep"), arg("B"), arg("Bmin"), arg("Bstep"), arg("C"), arg("Cmin"), arg("Cstep"), arg("undef")=1.e50, arg("check_boundaries")=false, "For internal use only. Please use the interpolateTable function.")
338    )
339    
340        .def("interpolateTable", &escript::Data::interpolateFromTable2DP,
341    (arg("table"),arg("Amin"),arg("Astep"), arg("B"), arg("Bmin"), arg("Bstep"), arg("undef")=1.e50, arg("check_boundaries")=false),
342    "Creates a new Data object by interpolating using the source data (which are\n"
343    "looked up in ``table``)\n``A`` must be the outer dimension on the table\n\n"
344    ":param table: two dimensional collection of values\n"
345    ":param Amin: The base of locations in table\n:type Amin: float\n"
346    ":param Astep: size of gap between each item in the table\n:type Astep: float\n"
347    ":param undef: upper bound on interpolated values\n:type undef: float\n"
348    ":param B: Scalar representing the second coordinate to be mapped into the table\n"
349    ":type B: `Data`\n"
350    ":param Bmin: The base of locations in table for 2nd dimension\n:type Bmin: float\n"
351    ":param Bstep: size of gap between each item in the table for 2nd dimension\n:type Bstep: float\n"
352    ":param check_boundaries: if true, then values outside the boundaries will be rejected. If false, then boundary values will be used.\n"
353    ":raise RuntimeError(DataException): if the cordinates do not map into the table or if the interpolated value is above ``undef``"
354    "\n:rtype: `Data`"
355    )
356        .def("interpolateTable", &escript::Data::interpolateFromTable1DP,
357    (arg("table"),arg("Amin"),arg("Astep"), arg("undef")=1.e50, arg("check_boundaries")=false)/*,
358    "Creates a new Data object by interpolating using the source data (which are\n"
359    "looked up in ``table``)\n\n"
360    ":param table: one dimensional collection of values\n"
361    ":param Amin: The base of locations in table\n:type Amin: float\n"
362    ":param Astep: size of gap between each item in the table\n:type Astep: float\n"
363    ":param undef: upper bound on interpolated values\n:type undef: float\n"
364    ":param check_boundaries: if true, then values outside the boundaries will be rejected. If false, then boundary values will be used.\n"
365    ":raise RuntimeError(DataException): if the cordinates do not map into the table or if the interpolated value is above ``undef``"
366    "\n:rtype: `Data`"
367    */
368    )
369    
370    
371        .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint,"Please consider using getInfLocator() from pdetools instead.")
372        .def("maxGlobalDataPoint",&escript::Data::maxGlobalDataPoint, "Please consider using getSupLocator() from pdetools instead.")
373      .def("saveDX",&escript::Data::saveDX,args("fileName"),"Save the object in DX format.\n\n"      .def("saveDX",&escript::Data::saveDX,args("fileName"),"Save the object in DX format.\n\n"
374  ":param fileName: filename\n:type fileName: string")  ":param fileName: filename\n:type fileName: string")
375      .def("saveVTK",&escript::Data::saveVTK, args("fileName"),"Save the object in VTK format.\n\n"      .def("saveVTK",&escript::Data::saveVTK, args("fileName"),"Save the object in VTK format.\n\n"
# Line 293  args("solver", "preconditioner", "packag Line 418  args("solver", "preconditioner", "packag
418      .def("_sup",&escript::Data::sup,":return: the maximum value over all data points.\n:rtype: float\n:note: If the ``Data`` contains no values a large negative value will be returned instead.")      .def("_sup",&escript::Data::sup,":return: the maximum value over all data points.\n:rtype: float\n:note: If the ``Data`` contains no values a large negative value will be returned instead.")
419      .def("_inf",&escript::Data::inf,":return: minimum value over all components and all data points\n:rtype: float\n:note: If the ``Data`` contains no values a large positive value will be returned instead.")      .def("_inf",&escript::Data::inf,":return: minimum value over all components and all data points\n:rtype: float\n:note: If the ``Data`` contains no values a large positive value will be returned instead.")
420      .def("_integrateToTuple",&escript::Data::integrateToTuple,":return: Calculate the integral over the function space domain as a python tuple\n:rtype: tuple")      .def("_integrateToTuple",&escript::Data::integrateToTuple,":return: Calculate the integral over the function space domain as a python tuple\n:rtype: tuple")
   
421      // following implements the python abs operator      // following implements the python abs operator
422      .def("__abs__",&escript::Data::abs,":return: absolute value\n\n:rtype: `Data`")      .def("__abs__",&escript::Data::abs,":return: absolute value\n\n:rtype: `Data`")
423      // following implements the python "-" negation operator      // following implements the python "-" negation operator
424      .def("__neg__",&escript::Data::neg, ":return: negation of the values in this object\n:rtype: `Data`")      .def("__neg__",&escript::Data::neg, ":return: negation of the values in this object\n:rtype: `Data`")
425      // following implements the python "+" identity operator      // following implements the python "+" identity operator
426      .def("__pos__",&escript::Data::pos, "\nThe unary + operator\n\n:rtype: Data`")      .def("__pos__",&escript::Data::pos, "\nThe unary + operator\n\n:rtype: `Data`")
427      // following two functions implement the python [] operator      // following three functions implement the python [] operator
428      .def("__getitem__",&escript::Data::getItem,"Used by the python [] operator\n\n:rtype: `Data`")      .def("__getitem__",&escript::Data::getItem,"Used by the python [] operator\n\n:rtype: `Data`")
429      .def("__setitem__",&escript::Data::setItemO,"Used by the python [] operator")      .def("__setitem__",&escript::Data::setItemO,"Used by the python [] operator")
430      .def("__setitem__",&escript::Data::setItemD,"Used by the python [] operator")      .def("__setitem__",&escript::Data::setItemD,"Used by the python [] operator")
431      // following two functions implement the python ** operator      // following three functions implement the python ** operator
432      .def("__pow__",&escript::Data::powO,"Used by the python ** operator\n\n:rtype: `Data`")      .def("__pow__",&escript::Data::powO,"Used by the python ** operator\n\n:rtype: `Data`")
433      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
434      .def("__rpow__",&escript::Data::rpowO,"\nUsed by the python ** operator\n\n:rtype: `Data`")      .def("__rpow__",&escript::Data::rpowO,"\nUsed by the python ** operator\n\n:rtype: `Data`")
435        // following two functions implement the newer python / operator
436        .def("__truediv__",&escript::Data::truedivD)
437        .def("__truediv__",&escript::Data::truedivO)
438      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
439      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
440      // version will be called.      // version will be called.
441      .def(self + other<object>())  //    .def(self + other<object>())
442      .def(other<object>() + self)  //    .def(other<object>() + self)
443      .def(self + self)  //    .def(self + self)
444      .def(self += other<object>())      .def(self += other<object>())
445      .def(self += self)      .def(self += self)
446    
447      .def(self - other<object>())  //     .def(self - other<object>())
448      .def(other<object>() - self)  //     .def(other<object>() - self)
449      .def(self - self)  //     .def(self - self)
450      .def(self -= other<object>())      .def(self -= other<object>())
451      .def(self -= self)      .def(self -= self)
452    
453      .def(self * other<object>())  //     .def(self * other<object>())
454      .def(other<object>() * self)  //     .def(other<object>() * self)
455      .def(self * self)  //     .def(self * self)
456      .def(self *= other<object>())      .def(self *= other<object>())
457      .def(self *= self)      .def(self *= self)
458    
459      .def(self / other<object>())  //     .def(self / other<object>())
460      .def(other<object>() / self)  //     .def(other<object>() / self)
461      .def(self / self)  //     .def(self / self)
462      .def(self /= other<object>())      .def(self /= other<object>())
463      .def(self /= self)      .def(self /= self)
464      // Need scope resolution due to a bug either in the compiler or      // Need scope resolution due to a bug either in the compiler or
465      // the boost code. This calls operator << for Data.      // the boost code. This calls operator << for Data.
466      .def(self_ns::str(self));      .def(self_ns::str(self))
467        .def("_inverse", &escript::Data::matrixInverse, ":return: inverse of square matricies\n")
468    //    .def("__add__", &escript::Data::addOperatorD)
469        .def("__add__", &escript::Data::__add__)
470        .def("__radd__", &escript::Data::__add__)  // its the same coz + is commutative
471        .def("__sub__", &escript::Data::__sub__)
472        .def("__rsub__", &escript::Data::__rsub__)
473        .def("__mul__", &escript::Data::__mul__)  
474        .def("__rmul__", &escript::Data::__mul__)   // commutative
475        .def("__div__", &escript::Data::__div__)  
476        .def("__rdiv__", &escript::Data::__rdiv__)   // commutative
477        
478        ;
479    
480    //    //
481    // Factory methods for function space    // Factory methods for function space
# Line 365  args("solver", "preconditioner", "packag Line 504  args("solver", "preconditioner", "packag
504    def("ReducedSolution",escript::reducedSolution, args("domain"), ":rtype: `FunctionSpace`");    def("ReducedSolution",escript::reducedSolution, args("domain"), ":rtype: `FunctionSpace`");
505    def("DiracDeltaFunction",escript::diracDeltaFunction, args("domain"), ":rtype: `FunctionSpace`");    def("DiracDeltaFunction",escript::diracDeltaFunction, args("domain"), ":rtype: `FunctionSpace`");
506    
507    
508    
509    
510    
511    //    //
512    // Factory methods for Data    // Factory methods for Data
513    //    //
# Line 386  args("solver", "preconditioner", "packag Line 529  args("solver", "preconditioner", "packag
529  "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"  "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
530  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
531  ":type expanded: ``bool``");  ":type expanded: ``bool``");
532     def("Vector", escript::VectorFromObj,
533          (arg("value"),
534        arg("what")=escript::FunctionSpace(),
535        arg("expanded")=false));
536    def("Tensor",escript::Tensor,    def("Tensor",escript::Tensor,
537        (arg("value")=0.0,        (arg("value")=0.0,
538         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 394  args("solver", "preconditioner", "packag Line 541  args("solver", "preconditioner", "packag
541  "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"  "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
542  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
543  ":type expanded: ``bool``");  ":type expanded: ``bool``");
544     def("Tensor", escript::TensorFromObj,
545          (arg("value"),
546        arg("what")=escript::FunctionSpace(),
547        arg("expanded")=false));
548    def("Tensor3",escript::Tensor3,    def("Tensor3",escript::Tensor3,
549        (arg("value")=0.0,        (arg("value")=0.0,
550         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 403  args("solver", "preconditioner", "packag Line 554  args("solver", "preconditioner", "packag
554  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
555  ":type expanded: ``bool``"  ":type expanded: ``bool``"
556  );  );
557     def("Tensor3", escript::Tensor3FromObj,
558          (arg("value"),
559        arg("what")=escript::FunctionSpace(),
560        arg("expanded")=false));
561    def("Tensor4",escript::Tensor4,    def("Tensor4",escript::Tensor4,
562        (arg("value")=0.0,        (arg("value")=0.0,
563         arg("what")=escript::FunctionSpace(),         arg("what")=escript::FunctionSpace(),
# Line 412  args("solver", "preconditioner", "packag Line 567  args("solver", "preconditioner", "packag
567  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"  ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
568  ":type expanded: ``bool``"  ":type expanded: ``bool``"
569  );  );
570     def("Tensor4", escript::Tensor4FromObj,
571          (arg("value"),
572        arg("what")=escript::FunctionSpace(),
573        arg("expanded")=false));
574    
575    
576     def("RandomData", escript::randomData, (arg("shape"), arg("fs"), arg("seed")=0),
577    "Creates a new expanded Data object containing (not very) random values.\n\n"
578    ":param shape: datapoint shape\n:type shape: tuple\n"
579    ":param fs: function space for data object.\n:type fs: `FunctionSpace`\n"
580    ":param seed: seed for random number generator.\n:type seed: long\n");
581    
582    //    //
583    // Binary operators    // Binary operators
# Line 429  args("solver", "preconditioner", "packag Line 595  args("solver", "preconditioner", "packag
595    //    //
596    // Interface for AbstractSystemMatrix    // Interface for AbstractSystemMatrix
597    //    //
598    class_<escript::AbstractSystemMatrix>("Operator","",init<>())    // Doco goes in the empty string param    class_<escript::AbstractSystemMatrix,escript::ASM_ptr>("Operator","",init<>())    // Doco goes in the empty string param
599       .def("isEmpty",&escript::AbstractSystemMatrix::isEmpty,":rtype: ``bool``\n"       .def("isEmpty",&escript::AbstractSystemMatrix::isEmpty,":rtype: ``bool``\n"
600  ":return: True if matrix is empty")  ":return: True if matrix is empty")
601       .def("solve",&escript::AbstractSystemMatrix::solve, args("in","options"),       .def("solve",&escript::AbstractSystemMatrix::solve, args("in","options"),
# Line 445  args("solver", "preconditioner", "packag Line 611  args("solver", "preconditioner", "packag
611    //    //
612    // Interface for AbstractTransportProblem    // Interface for AbstractTransportProblem
613    //    //
614    class_<escript::AbstractTransportProblem>("TransportProblem","",init<>())    // Doco goes in the empty string param    class_<escript::AbstractTransportProblem, escript::ATP_ptr>("TransportProblem","",init<>())    // Doco goes in the empty string param
615       .def("isEmpty",&escript::AbstractTransportProblem::isEmpty,":rtype: ``int``")       .def("isEmpty",&escript::AbstractTransportProblem::isEmpty,":rtype: ``int``")
616       .def("solve",&escript::AbstractTransportProblem::solve, args("source","dt", "options"),       .def("solve",&escript::AbstractTransportProblem::solve, args("u0","source","dt", "options"),
617  "returns the solution *u* for a time step *dt>0*\n\n:rtype: `Data`\n"  "returns the solution *u* for a time step *dt>0* with initial value u0\n\n:rtype: `Data`\n"
618  ":param source:\n:type source: `Data`")  ":param source:\n:type source: `Data`")
      .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue, args("u"),  
 "sets the value for *u* at time *t=0*.")  
619       .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint,       .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint,
620  args("source", "q", "r","factor"),  args("source", "q", "r","factor"),
621  "inserts constraint *u_{,t}=r* where *q>0*  into the problem using a weighting factor")  "inserts constraint *u_{,t}=r* where *q>0*  into the problem using a weighting factor")
# Line 471  args("source", "q", "r","factor"), Line 635  args("source", "q", "r","factor"),
635  ":type sentinel: ``int``");  ":type sentinel: ``int``");
636    def("listEscriptParams",escript::listEscriptParams,":return: A list of pairs (p,d) where p is the name of a parameter for escript and d is a description.");    def("listEscriptParams",escript::listEscriptParams,":return: A list of pairs (p,d) where p is the name of a parameter for escript and d is a description.");
637    
638    
639      def("resolveGroup", escript::resolveGroup);
640    
641    #ifdef IKNOWWHATIMDOING
642    
643      def("applyBinaryCFunction", escript::applyBinaryCFunction, (arg("function"), arg("outshape"),
644    arg("in1"),
645    arg("in2"))
646    );
647    #endif
648    
649      def("_condEval", escript::condEval, (arg("mask"), arg("trueval"), arg("falseval")));
650    
651    //    //
652    // Register esysExceptionTranslator    // Register esysExceptionTranslator
653    //    //

Legend:
Removed from v.2626  
changed lines
  Added in v.3506

  ViewVC Help
Powered by ViewVC 1.1.26