/[escript]/trunk/escript/src/escriptcpp.cpp
ViewVC logotype

Contents of /trunk/escript/src/escriptcpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2635 - (show annotations)
Thu Aug 27 04:54:41 2009 UTC (10 years, 2 months ago) by jfenwick
File size: 29940 byte(s)
A bunch of changes related to saveDataCSV.
[Not completed or unit tested yet]

Added saveDataCSV to util.py
AbstractDomain (and MeshAdapter) have a commonFunctionSpace method to 
take a group of FunctionSpaces and return something they can all be interpolated to.

Added pointToStream() in DataTypes to help print points.

added actsConstant() to data - required because DataConstant doesn't store samples the same way other Data do.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #include "Data.h"
16 #include "FunctionSpace.h"
17 #include "FunctionSpaceFactory.h"
18 #include "DataFactory.h"
19 #include "AbstractContinuousDomain.h"
20 #include "AbstractDomain.h"
21 #include "Utils.h"
22 #include "AbstractSystemMatrix.h"
23 #include "AbstractTransportProblem.h"
24 #include "DataVector.h"
25 #include "paso/Paso_MPI.h"
26 #include "EscriptParams.h"
27 #include "TestDomain.h"
28
29
30 extern "C" {
31 #include "esysUtils/blocktimer.h"
32 }
33
34 #include "esysUtils/esysExceptionTranslator.h"
35
36 #include <boost/version.hpp>
37 #include <boost/python.hpp>
38 #include <boost/python/module.hpp>
39 #include <boost/python/def.hpp>
40 #include <boost/python/object.hpp>
41 #include <boost/python/tuple.hpp>
42 #include <boost/python/numeric.hpp>
43 #include <boost/smart_ptr.hpp>
44 #include <boost/version.hpp>
45
46 using namespace boost::python;
47
48 /*! \mainpage Esys Documentation
49 *
50 * \version 3.0.0
51 *
52 * - \ref escript
53 *
54 * - \ref esys_exception "Esys Exception"
55 *
56 * - \ref finley
57 *
58 * - <a href="../../epydoc/index.html">Python module documentation (epydoc generated)</a>
59 *
60 */
61
62 /*! \page escript Escript
63 * Escript is the python module that contains the interfaces
64 * to the C++ side of escript.
65 *
66 *
67 *
68 * \section class_desc Class Description:
69 * Data
70 *
71 * \section class_limits Class Limitations:
72 * None
73 *
74 * \section class_conds Class Conditions of Use:
75 * None
76 *
77 * \section class_throws Throws:
78 * None
79 *
80 */
81
82 BOOST_PYTHON_MODULE(escriptcpp)
83 {
84
85 #if BOOST_VERSION >= 103500
86 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
87 docstring_options docopt(true,true,false);
88 #endif
89
90 def("setNumberOfThreads",escript::setNumberOfThreads,"Use of this method is strongly discouraged.");
91 def("getNumberOfThreads",escript::getNumberOfThreads,"Return the maximum number of threads"
92 " available to OpenMP.");
93 def("releaseUnusedMemory",escript::releaseUnusedMemory);
94 def("blocktimer_initialize",blocktimer_initialize);
95 def("blocktimer_reportSortByName",blocktimer_reportSortByName);
96 def("blocktimer_reportSortByTime",blocktimer_reportSortByTime);
97 def("blocktimer_increment",blocktimer_increment);
98 def("blocktimer_time",blocktimer_time);
99 def("getVersion",escript::getSvnVersion,"This method will only report accurate version numbers for clean checkouts.");
100 def("printParallelThreadCounts",escript::printParallelThreadCnt);
101 def("getMPISizeWorld",escript::getMPISizeWorld,"Return number of MPI processes in the job.");
102 def("getMPIRankWorld",escript::getMPIRankWorld,"Return the rank of this process in the MPI World.");
103 def("MPIBarrierWorld",escript::MPIBarrierWorld,"Wait until all MPI processes have reached this point.");
104 def("getMPIWorldMax",escript::getMPIWorldMax,"\nEach MPI process calls this function with a"
105 " value for arg1. The maximum value is computed and returned.\n\n:rtype: int");
106 def("getMPIWorldSum",escript::getMPIWorldSum,"\nEach MPI process calls this function with a"
107 " value for arg1. The values are added up and the total value is returned.\n\n:rtype: int");
108 def("getMachinePrecision",escript::getMachinePrecision);
109 def("getMaxFloat",escript::getMaxFloat);
110
111
112 def("_saveDataCSV",escript::saveDataCSV, (args("filename","arg","sep","csep"), arg("append")=false));
113
114
115 //
116 // Interface for AbstractDomain
117 //
118 class_<escript::AbstractDomain, escript::Domain_ptr>("Domain","Base class for all domains.",no_init)
119 .def("getStatus",&escript::AbstractDomain::getStatus,"The status of a domain changes whenever the domain is modified\n\n:rtype: int")
120 .def("setTagMap",&escript::AbstractDomain::setTagMap,args("name","tag"),
121 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
122 ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
123 .def("getTag",&escript::AbstractDomain::getTag,args("name"),":return: tag id for "
124 "``name``\n:rtype: ``string``")
125 .def("isValidTagName",&escript::AbstractDomain::isValidTagName,args("name"),
126 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
127 .def("showTagNames",&escript::AbstractDomain::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
128 .def("getX",&escript::AbstractDomain::getX,":rtype: `Data`\n:return: Locations in the"
129 "`Domain`. FunctionSpace is chosen appropriately")
130 .def("getDim",&escript::AbstractDomain::getDim,":rtype: `int`\n:return: Spatial dimension of the `Domain`")
131 .def("getNormal",&escript::AbstractDomain::getNormal,":rtype: `escript`\n:return: Boundary normals")
132 .def("getSize",&escript::AbstractDomain::getSize,":return: the local size of samples. The function space is chosen appropriately\n:rtype: `Data`")
133 .def("saveVTK",&escript::AbstractDomain::saveVTK,args("filename","arg", "metadata"
134 , "metadata_schema"),
135 ":param filename: \n:type filename: ``string``\n:param arg: items to be added"
136 "\n:type arg: ``dict``\n:param metadata: string representing some meta data to be added\n:type metadata: ``string``"
137 "\n:param metadata_schema: schema type for metadata\n:type metadata_schema: ``string``")
138 .def("dump",&escript::AbstractDomain::dump,args("filename"),"Dumps the domain to a file"
139 ":param filename:\n:type filename: string")
140 .def("saveDX",&escript::AbstractDomain::saveDX,args("filename","arg"),"Saves a dictonary of Data objects to an OpenDX input file.\n\n:param filename:\n:type filename: ``string``"
141 "\n:param arg:\n:type arg: `dict`")
142 .def("getMPISize",&escript::AbstractDomain::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
143 .def("getMPIRank",&escript::AbstractDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
144 .def("MPIBarrier",&escript::AbstractDomain::MPIBarrier,"Wait until all processes have reached this point")
145 .def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`")
146
147 .def(self == self)
148 .def(self != self);
149
150 //
151 // Interface for AbstractContinuousDomain
152 //
153 class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain","Class representing continuous domains",no_init)
154 .def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId,
155 args("solver", "preconditioner", "package", "symmetry"),
156 ":return: the identifier of the matrix type to be used for the global stiffness matrix "
157 "when a particular solver package and symmetric matrix is used.\n"
158 ":rtype: int")
159 .def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId,
160 args("solver", "preconditioner", "package", "symmetry"));
161
162
163 //
164 // Interface for TestDomain
165 //
166 class_ <escript::TestDomain, bases<escript::AbstractDomain> >("TestDomain", "Test Class for domains with no structure. May be removed from future releases without notice.", init<int,int>());
167
168 // This is the only python visible way to get a TestDomain
169 def("getTestDomainFunctionSpace",&escript::getTestDomainFunctionSpace, args("dpps",
170 "samples"),
171 "For testing only. May be removed without notice.");
172
173 //
174 // Interface for FunctionSpace
175 //
176 class_<escript::FunctionSpace> fs_definer("FunctionSpace","A FunctionSpace describes which points from the `Domain` to use to represent functions.",init<>()); // Doco goes in the empty string param
177 fs_definer.def("getDim",&escript::FunctionSpace::getDim,":return: the spatial dimension of the underlying domain.\n:rtype: int");
178 // fs_definer.def("getDomain",&escript::FunctionSpace::getDomain,
179 // return_internal_reference<>());
180 fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython,":return: the underlying `Domain` for this FunctionSpace.\n:rtype: `Domain`");
181 fs_definer.def("getX",&escript::FunctionSpace::getX,"\n:return: a function whose values are its input coordinates. ie an identity function.\n:rtype: `Data`");
182 fs_definer.def("getNormal",&escript::FunctionSpace::getNormal,":return: the surface normal field.\n\n:rtype: `Data`");
183 fs_definer.def("getSize",&escript::FunctionSpace::getSize,":return: sample size\n:rtype: `Data`");
184 fs_definer.def("setTags",&escript::FunctionSpace::setTags,args("newtag","mask"),
185 "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`");
186 fs_definer.def("getTagFromDataPointNo",
187 &escript::FunctionSpace::getTagFromDataPointNo,":return: the tag associated with the given sample number.\n:rtype: int");
188 fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo,args("dataPointNo"),":return: the reference number associated with ``dataPointNo``\n:rtype: int ");
189 fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags,":return: a list of the tags used in this function space\n:rtype: ``list``");
190 fs_definer.def("__str__", &escript::FunctionSpace::toString);
191 fs_definer.def(self == self);
192 fs_definer.def(self != self);
193 //
194 // Interface for Data
195 //
196 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<>() )
197 // various constructors for Data objects
198 .def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))
199 .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))
200 .def(init<const escript::Data&, const escript::FunctionSpace&>(args("value","what")))
201 .def(init<const escript::Data&>())
202 // Note for Lutz, Need to specify the call policy in order to return a
203 // reference. In this case return_internal_reference.
204 .def("__str__",&escript::Data::toString)
205 .def("getDomain",&escript::Data::getDomainPython,":rtype: `Domain`")
206 .def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>(),":rtype: `FunctionSpace`")
207 .def("isEmpty",&escript::Data::isEmpty,"Is this object an instance of ``DataEmpty``\n\n:rtype: ``bool``\n:note: This is not the same thing as asking if the object contains datapoints.")
208 .def("isProtected",&escript::Data::isProtected,"Can this instance be modified.\n:rtype: ``bool``")
209 .def("setProtection",&escript::Data::setProtection,"Disallow modifications to this data object\n\n:note: This method does not allow you to undo protection.")
210 .def("getShape",&escript::Data::getShapeTuple,"\nReturns the shape of the datapoints in this object as a python tuple. Scalar data has the shape ``()``\n\n:rtype: ``tuple``")
211 .def("getRank",&escript::Data::getDataPointRank,":return: the number of indicies required to address a component of a datapoints\n:rtype: positive ``int``")
212 .def("dump",&escript::Data::dump,args("fileName"),"Save the data as a netCDF file\n\n:param fileName: \n:type fileName: ``string``")
213 .def("toListOfTuples",&escript::Data::toListOfTuples, (arg("scalarastuple")=false),
214 "Return the datapoints of this object in a list. Each datapoint is stored as a tuple.\n\n"
215 ":param scalarastuple: if True, scalar data will be wrapped as a tuple."
216 " True => [(0), (1), (2)]; False => [0, 1, 2]")
217 .def("copyWithMask",&escript::Data::copyWithMask,args("other","mask"),
218 "Selectively copy values from ``other`` `Data`."
219 "Datapoints which correspond to postive values in ``mask`` will be copied from ``other``\n"
220 "\n:param other: source of values\n"
221 ":type other: `Data`\n:param mask:\n:type mask: Scalar `Data`")
222 .def("setTaggedValue",&escript::Data::setTaggedValue,args("tagKey","value"),
223 "Set the value of tagged Data.\n\n:param tagKey: tag to update\n:type tagKey: ``int``\n")
224 .def("setTaggedValue",&escript::Data::setTaggedValueByName,args("name","value"),":param name: tag to update\n:type name: ``string``\n"
225 ":param value: value to set tagged data to\n:type value: ``object`` which acts like an array, ``tuple`` or ``list``\n")
226 .def("getNumberOfDataPoints",&escript::Data::getNumDataPoints,":rtype: ``int``\n:return: Number of datapoints in the object")
227 .def("isExpanded",&escript::Data::isExpanded,":rtype: ``bool``\n:return: True if this ``Data`` is expanded.")
228 .def("isTagged",&escript::Data::isTagged,":rtype: ``bool``\n:return: True if this ``Data`` is expanded.")
229 .def("isConstant",&escript::Data::isConstant,":rtype: ``bool``\n:return: True if this ``Data`` is an instance of ``DataConstant``\n:note: This does not mean the data is immutable.")
230 .def("isLazy",&escript::Data::isLazy,":rtype: ``bool``\n:return: True if this ``Data`` is lazy.")
231 .def("isReady",&escript::Data::isReady,":rtype: ``bool``\n:return: True if this ``Data`` is not lazy.")
232 .def("expand",&escript::Data::expand,"Convert the data to expanded representation if it is not expanded already.")
233 .def("tag",&escript::Data::tag,"Convert data to tagged representation if it is not already tagged or expanded")
234 .def("resolve",&escript::Data::resolve,"Convert the data to non-lazy representation.")
235 .def("copy",&escript::Data::copy,args("other"),"Make this object a copy of ``other``\n"
236 "\n:note: The two objects will act independently from now on. That is, changing ``other`` "
237 "after this call will not change this object and vice versa.")
238 .def("copy",&escript::Data::copySelf,":note: In the no argument form, a new object will be returned which is an independent copy of this object.")
239 .def("delay",&escript::Data::delay,"Convert this object into lazy representation")
240 .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject,args("dataPointNo","value"))
241 .def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray)
242 .def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint,"\nModify the value of a single datapoint.\n\n:param dataPointNo:\n"
243 ":type dataPointNo: int\n:param value: \n:type value: ``float`` or an object which acts like an array, ``tuple`` or ``list``\n:warning: Use of this operation is discouraged. It prevents some optimisations from operating.")
244 .def("getTupleForDataPoint",&escript::Data::getValueOfDataPointAsTuple,args("dataPointNo"),
245 ":return: Value of the specified datapoint\n:rtype: ``tuple``\n:param dataPointNo: datapoint to access\n:type dataPointNo: ``int``")
246 .def("getTupleForGlobalDataPoint",&escript::Data::getValueOfGlobalDataPointAsTuple,args("procNo","dataPointNo"),"Get a specific datapoint from a specific process\n\n"
247 ":rtype: ``tuple``\n:param procNo: MPI rank of the process\n:type procNo: positive ``int``"
248 "\n:param dataPointNo: datapoint to access\n:type dataPointNo: int")
249 .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.")
250 .def("interpolate",&escript::Data::interpolate,args("functionspace"),"Interpolate this object's values into a new functionspace.")
251 .def("interpolateTable", &escript::Data::interpolateFromTable,
252 args("table","Amin","Astep","undef", "B", "Bmin", "Bstep"),
253 "Creates a new Data object by interpolating using the source data (which are\n"
254 "looked up in ``table``)\n\n"
255 ":param table: two dimensional collection of values\n"
256 ":param Amin: The base of locations in table\n:type Amin: float\n"
257 ":param Astep: size of gap between each item in the table\n:type Astep: float\n"
258 ":param undef: upper bound on interpolated values\n:type undef: float\n"
259 ":param B: Scalar representing the second coordinate to be mapped into the table\n"
260 ":type B: `Data`\n"
261 ":param Bmin: The base of locations in table for 2nd dimension\n:type Bmin: float\n"
262 ":param Bstep: size of gap between each item in the table for 2nd dimension\n:type Bstep: float\n"
263 ":raise RuntimeError(DataException): if the cordinates do not map into the table or if the interpolated value is above ``undef``"
264 "\n:rtype: `Data`"
265 )
266
267 .def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint)
268 .def("maxGlobalDataPoint",&escript::Data::maxGlobalDataPoint)
269 .def("saveDX",&escript::Data::saveDX,args("fileName"),"Save the object in DX format.\n\n"
270 ":param fileName: filename\n:type fileName: string")
271 .def("saveVTK",&escript::Data::saveVTK, args("fileName"),"Save the object in VTK format.\n\n"
272 ":param fileName: \n:type fileName: string")
273 .def("getTagNumber",&escript::Data::getTagNumber,args("dpno"),"Return tag number for the specified datapoint\n\n:rtype: int\n:param dpno: datapoint number\n:type dpno: int")
274 // Unary functions for Data
275 .def("_interpolate",&escript::Data::interpolate)
276 .def("_grad",&escript::Data::gradOn)
277 .def("_grad",&escript::Data::grad)
278 .def("_transpose",&escript::Data::transpose)
279 .def("_trace",&escript::Data::trace)
280 .def("_maxval",&escript::Data::maxval)
281 .def("_minval",&escript::Data::minval)
282 .def("_wherePositive",&escript::Data::wherePositive)
283 .def("_whereNegative",&escript::Data::whereNegative)
284 .def("_whereNonNegative",&escript::Data::whereNonNegative)
285 .def("_whereNonPositive",&escript::Data::whereNonPositive)
286 .def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0))
287 .def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0))
288 .def("_erf",&escript::Data::erf)
289 .def("_sin",&escript::Data::sin)
290 .def("_cos",&escript::Data::cos)
291 .def("_tan",&escript::Data::tan)
292 .def("_asin",&escript::Data::asin)
293 .def("_acos",&escript::Data::acos)
294 .def("_atan",&escript::Data::atan)
295 .def("_sinh",&escript::Data::sinh)
296 .def("_cosh",&escript::Data::cosh)
297 .def("_tanh",&escript::Data::tanh)
298 .def("_asinh",&escript::Data::asinh)
299 .def("_acosh",&escript::Data::acosh)
300 .def("_atanh",&escript::Data::atanh)
301 .def("_exp",&escript::Data::exp)
302 .def("_sqrt",&escript::Data::sqrt)
303 .def("_log10",&escript::Data::log10)
304 .def("_log",&escript::Data::log)
305 .def("_sign",&escript::Data::sign)
306 .def("_symmetric",&escript::Data::symmetric)
307 .def("_nonsymmetric",&escript::Data::nonsymmetric)
308 .def("_trace",&escript::Data::trace)
309 .def("_swap_axes",&escript::Data::swapaxes)
310 .def("_eigenvalues",&escript::Data::eigenvalues)
311 .def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13))
312 // functions returning a single real number:
313 .def("_Lsup",&escript::Data::Lsup,":return: the Lsup-norm of the object\n:rtype: float\n:note: If the ``Data`` contains no values, zero will be returned instead.")
314 .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.")
315 .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.")
316 .def("_integrateToTuple",&escript::Data::integrateToTuple,":return: Calculate the integral over the function space domain as a python tuple\n:rtype: tuple")
317 // following implements the python abs operator
318 .def("__abs__",&escript::Data::abs,":return: absolute value\n\n:rtype: `Data`")
319 // following implements the python "-" negation operator
320 .def("__neg__",&escript::Data::neg, ":return: negation of the values in this object\n:rtype: `Data`")
321 // following implements the python "+" identity operator
322 .def("__pos__",&escript::Data::pos, "\nThe unary + operator\n\n:rtype: Data`")
323 // following two functions implement the python [] operator
324 .def("__getitem__",&escript::Data::getItem,"Used by the python [] operator\n\n:rtype: `Data`")
325 .def("__setitem__",&escript::Data::setItemO,"Used by the python [] operator")
326 .def("__setitem__",&escript::Data::setItemD,"Used by the python [] operator")
327 // following two functions implement the python ** operator
328 .def("__pow__",&escript::Data::powO,"Used by the python ** operator\n\n:rtype: `Data`")
329 .def("__pow__",&escript::Data::powD)
330 .def("__rpow__",&escript::Data::rpowO,"\nUsed by the python ** operator\n\n:rtype: `Data`")
331 // NOTE:: The order of these declarations is important. Anything
332 // declared before the generic declaration isn't found so the generic
333 // version will be called.
334 .def(self + other<object>())
335 .def(other<object>() + self)
336 .def(self + self)
337 .def(self += other<object>())
338 .def(self += self)
339
340 .def(self - other<object>())
341 .def(other<object>() - self)
342 .def(self - self)
343 .def(self -= other<object>())
344 .def(self -= self)
345
346 .def(self * other<object>())
347 .def(other<object>() * self)
348 .def(self * self)
349 .def(self *= other<object>())
350 .def(self *= self)
351
352 .def(self / other<object>())
353 .def(other<object>() / self)
354 .def(self / self)
355 .def(self /= other<object>())
356 .def(self /= self)
357 // Need scope resolution due to a bug either in the compiler or
358 // the boost code. This calls operator << for Data.
359 .def(self_ns::str(self));
360
361
362 //
363 // Factory methods for function space
364 //
365 def("ContinuousFunction",escript::continuousFunction,args("domain"),
366 ":return: a continuous FunctionSpace (overlapped node values)\n"
367 ":rtype: `FunctionSpace`");
368 def("ReducedContinuousFunction",escript::reducedContinuousFunction,args("domain"),
369 ":return: a continuous with reduced order FunctionSpace (overlapped node values on reduced element order)\n"
370 ":rtype: `FunctionSpace`");
371 def("Function",escript::function,args("domain"),":return: a function `FunctionSpace`\n"
372 ":rtype: `FunctionSpace`");
373 def("ReducedFunction",escript::reducedFunction, args("domain"),":return: a function FunctionSpace with reduced integration order\n:rtype: `FunctionSpace`");
374 def("FunctionOnBoundary",escript::functionOnBoundary, args("domain"), ":return: a function on boundary FunctionSpace\n:rtype: `FunctionSpace`");
375 def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary, args("domain"),
376 ":return: a function on boundary FunctionSpace with reduced integration order\n"
377 ":rtype: `FunctionSpace`");
378 def("FunctionOnContactZero",escript::functionOnContactZero, args("domain"), ":return: Return a FunctionSpace on left side of contact\n:rtype: `FunctionSpace`");
379 def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero, args("domain"),
380 ":return: a FunctionSpace on left side of contact with reduced integration order\n:rtype: `FunctionSpace`");
381 def("FunctionOnContactOne",escript::functionOnContactOne, args("domain"), ":return: Return a FunctionSpace on right side of contact\n:rtype: `FunctionSpace`");
382 def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne, args("domain"),
383 ":return: Return a FunctionSpace on right side of contact with reduced integration order\n"
384 ":rtype: `FunctionSpace`");
385 def("Solution",escript::solution, args("domain"), ":rtype: `FunctionSpace`");
386 def("ReducedSolution",escript::reducedSolution, args("domain"), ":rtype: `FunctionSpace`");
387 def("DiracDeltaFunction",escript::diracDeltaFunction, args("domain"), ":rtype: `FunctionSpace`");
388
389
390
391
392
393 //
394 // Factory methods for Data
395 //
396 def("load",escript::load, args("fileName","domain"), "reads Data on domain from file in netCDF format\n\n:param fileName:\n:type fileName: ``string``\n:param domain:\n:type domain: `Domain`");
397 def("loadIsConfigured",escript::loadConfigured,":return: True if the load function is configured.");
398 def("Scalar",escript::Scalar,
399 (arg("value")=0.0,
400 arg("what")=escript::FunctionSpace(),
401 arg("expanded")=false),
402 "Construct a Data object containing scalar data-points.\n\n:param value: scalar value for all points\n"
403 "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
404 ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
405 ":type expanded: ``bool``");
406 def("Vector",escript::Vector,
407 (arg("value")=0.0,
408 arg("what")=escript::FunctionSpace(),
409 arg("expanded")=false),
410 "Construct a Data object containing rank1 data-points.\n\n:param value: scalar value for all points\n"
411 "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
412 ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
413 ":type expanded: ``bool``");
414 def("Tensor",escript::Tensor,
415 (arg("value")=0.0,
416 arg("what")=escript::FunctionSpace(),
417 arg("expanded")=false),
418 "Construct a Data object containing rank2 data-points.\n\n:param value: scalar value for all points\n"
419 "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
420 ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
421 ":type expanded: ``bool``");
422 def("Tensor3",escript::Tensor3,
423 (arg("value")=0.0,
424 arg("what")=escript::FunctionSpace(),
425 arg("expanded")=false),
426 "Construct a Data object containing rank3 data-points.\n\n:param value: scalar value for all points\n"
427 "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
428 ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
429 ":type expanded: ``bool``"
430 );
431 def("Tensor4",escript::Tensor4,
432 (arg("value")=0.0,
433 arg("what")=escript::FunctionSpace(),
434 arg("expanded")=false),
435 "Construct a Data object containing rank4 data-points.\n\n:param value: scalar value for all points\n"
436 "\n:rtype: `Data`\n:type value: float\n:param what: FunctionSpace for Data\n:type what: `FunctionSpace`\n"
437 ":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n"
438 ":type expanded: ``bool``"
439 );
440
441 //
442 // Binary operators
443 //
444 def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct,
445 (arg("arg0"),
446 arg("arg1"),
447 arg("axis_offset")=0,
448 arg("transpose")=0),
449 "Compute a tensor product of two Data objects.\n\n:rtype: `Data`\n:param arg0:\n"
450 ":param arg1:\n:param axis_offset:\n:type axis_offset: ``int``\n"
451 ":param transpose: 0: transpose neither, 1: transpose arg0, 2: transpose arg1\n"
452 ":type transpose: int");
453
454 //
455 // Interface for AbstractSystemMatrix
456 //
457 class_<escript::AbstractSystemMatrix>("Operator","",init<>()) // Doco goes in the empty string param
458 .def("isEmpty",&escript::AbstractSystemMatrix::isEmpty,":rtype: ``bool``\n"
459 ":return: True if matrix is empty")
460 .def("solve",&escript::AbstractSystemMatrix::solve, args("in","options"),
461 ":return: the solution *u* of the linear system *this*u=in*\n\n:param in:\n:type in: `Data`")
462 .def("of",&escript::AbstractSystemMatrix::vectorMultiply,args("right"),
463 "matrix*vector multiplication")
464 .def("saveMM",&escript::AbstractSystemMatrix::saveMM, args("fileName"),
465 "writes the matrix to a file using the Matrix Market file format")
466 .def("saveHB",&escript::AbstractSystemMatrix::saveHB, args("filename"),
467 "writes the matrix to a file using the Harwell-Boeing file format")
468 .def("resetValues",&escript::AbstractSystemMatrix::resetValues, "resets the matrix entries")
469 .def(self*other<escript::Data>());
470 //
471 // Interface for AbstractTransportProblem
472 //
473 class_<escript::AbstractTransportProblem>("TransportProblem","",init<>()) // Doco goes in the empty string param
474 .def("isEmpty",&escript::AbstractTransportProblem::isEmpty,":rtype: ``int``")
475 .def("solve",&escript::AbstractTransportProblem::solve, args("source","dt", "options"),
476 "returns the solution *u* for a time step *dt>0*\n\n:rtype: `Data`\n"
477 ":param source:\n:type source: `Data`")
478 .def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue, args("u"),
479 "sets the value for *u* at time *t=0*.")
480 .def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint,
481 args("source", "q", "r","factor"),
482 "inserts constraint *u_{,t}=r* where *q>0* into the problem using a weighting factor")
483 .def("reset",&escript::AbstractTransportProblem::resetTransport,
484 "resets the transport operator typically as they have been updated.")
485 .def("resetValues",&escript::AbstractTransportProblem::resetTransport)
486 .def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize)
487 .def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize);
488
489 // Functions to modify global parameters
490 def("setEscriptParamInt",escript::setEscriptParamInt,
491 (arg("name"), arg("value")=0), "Modify the value of an escript tuning parameter\n\n"
492 ":param name:\n:type name: ``string``\n:param value:\n:type value: ``int``");
493 def("getEscriptParamInt",escript::getEscriptParamInt,
494 (arg("name"),arg("sentinel")=0), "Read the value of an escript tuning paramter\n\n"
495 ":param name: parameter to lookup\n:type name: ``string``\n:param sentinel: Value to be returned if ``name`` is not a known parameter\n"
496 ":type sentinel: ``int``");
497 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.");
498
499 //
500 // Register esysExceptionTranslator
501 //
502 register_exception_translator<esysUtils::EsysException>(&esysUtils::esysExceptionTranslator);
503 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26