1 |
|
2 |
/***************************************************************************** |
3 |
* |
4 |
* Copyright (c) 2003-2014 by University of Queensland |
5 |
* http://www.uq.edu.au |
6 |
* |
7 |
* Primary Business: Queensland, Australia |
8 |
* Licensed under the Open Software License version 3.0 |
9 |
* http://www.opensource.org/licenses/osl-3.0.php |
10 |
* |
11 |
* Development until 2012 by Earth Systems Science Computational Center (ESSCC) |
12 |
* Development 2012-2013 by School of Earth Sciences |
13 |
* Development from 2014 by Centre for Geoscience Computing (GeoComp) |
14 |
* |
15 |
*****************************************************************************/ |
16 |
|
17 |
#include "Data.h" |
18 |
#include "FunctionSpace.h" |
19 |
#include "FunctionSpaceFactory.h" |
20 |
#include "DataFactory.h" |
21 |
#include "AbstractContinuousDomain.h" |
22 |
#include "AbstractDomain.h" |
23 |
#include "Utils.h" |
24 |
#include "AbstractSystemMatrix.h" |
25 |
#include "AbstractTransportProblem.h" |
26 |
#include "DataVector.h" |
27 |
#include "esysUtils/Esys_MPI.h" |
28 |
#include "EscriptParams.h" |
29 |
#include "TestDomain.h" |
30 |
#include "SubWorld.h" |
31 |
#include "SplitWorld.h" |
32 |
#include "Reducer.h" |
33 |
#include "SolverOptions.h" |
34 |
#include "SolverOptionsException.h" |
35 |
|
36 |
#include "esysUtils/blocktimer.h" |
37 |
|
38 |
#include "esysUtils/esysExceptionTranslator.h" |
39 |
|
40 |
#include <boost/version.hpp> |
41 |
#include <boost/python.hpp> |
42 |
#include <boost/python/module.hpp> |
43 |
#include <boost/python/def.hpp> |
44 |
#include <boost/python/object.hpp> |
45 |
#include <boost/python/tuple.hpp> |
46 |
#include <boost/smart_ptr.hpp> |
47 |
#include <boost/version.hpp> |
48 |
#include <boost/python/errors.hpp> |
49 |
|
50 |
using namespace boost::python; |
51 |
|
52 |
/*! \mainpage Esys Documentation |
53 |
* |
54 |
* \version 3.4.2 |
55 |
* |
56 |
* Main modules/namespaces: |
57 |
* |
58 |
* - \ref escript |
59 |
* |
60 |
* - \ref paso |
61 |
* |
62 |
* - \ref finley |
63 |
* |
64 |
* - \ref dudley |
65 |
* |
66 |
* - \ref ripley |
67 |
* |
68 |
* - \ref weipa |
69 |
* |
70 |
* This documentation describes the C++ layer of escript and related libraries. |
71 |
* For documentation of the python API, please see: |
72 |
* <a href="../../sphinx_api/index.html">Here</a> |
73 |
* |
74 |
*/ |
75 |
|
76 |
#include <boost/python/raw_function.hpp> |
77 |
|
78 |
namespace |
79 |
{ |
80 |
|
81 |
bool block_cmp_data(const escript::Data&, boost::python::object o) |
82 |
{ |
83 |
PyErr_SetString(PyExc_TypeError,"Python relational operators are not defined for Data objects."); |
84 |
boost::python::throw_error_already_set(); |
85 |
return false; |
86 |
} |
87 |
|
88 |
|
89 |
bool block_eq_data(const escript::Data&, boost::python::object o) |
90 |
{ |
91 |
PyErr_SetString(PyExc_TypeError,"The Python == and != operators are not defined for Data objects. " |
92 |
"To check for object identity use 'is'. To check for numerical similarity of x and y, use Lsup(x-y)<TOL " |
93 |
"for a suitable tolerance."); |
94 |
boost::python::throw_error_already_set(); |
95 |
return false; |
96 |
} |
97 |
|
98 |
bool block_cmp_functionspace(const escript::FunctionSpace&, boost::python::object o) |
99 |
{ |
100 |
PyErr_SetString(PyExc_TypeError,"Python relational operators are not defined for FunctionSpaces."); |
101 |
boost::python::throw_error_already_set(); |
102 |
return false; |
103 |
} |
104 |
|
105 |
bool block_cmp_domains(const escript::AbstractDomain&, boost::python::object o) |
106 |
{ |
107 |
PyErr_SetString(PyExc_TypeError,"Python relational operators are not defined for Domains."); |
108 |
boost::python::throw_error_already_set(); |
109 |
return false; |
110 |
} |
111 |
|
112 |
|
113 |
} |
114 |
|
115 |
BOOST_PYTHON_MODULE(escriptcpp) |
116 |
{ |
117 |
|
118 |
#if BOOST_VERSION >= 103500 |
119 |
// params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures |
120 |
docstring_options docopt(true,true,false); |
121 |
#endif |
122 |
|
123 |
scope().attr("__doc__") = "To use this module, please import esys.escript"; |
124 |
|
125 |
/* begin SubWorld things */ |
126 |
|
127 |
|
128 |
class_<escript::AbstractReducer, escript::Reducer_ptr, boost::noncopyable>("Reducer", "", no_init); |
129 |
def("makeDataReducer", escript::makeDataReducer, (arg("op")), "Creates an object to combine values.\n\n" |
130 |
":param op: name of the operation to use.\n:type op: `str`"); |
131 |
|
132 |
// Why doesn't this have a doc-string? Because it doesn't compile if you try to add one |
133 |
// These functions take a SplitWorld instance as their first parameter |
134 |
def("buildDomains", raw_function(escript::raw_buildDomains,2)); |
135 |
def("addJob", raw_function(escript::raw_addJob,2)); |
136 |
def("addVariable", raw_function(escript::raw_addVariable,3)); |
137 |
|
138 |
|
139 |
def("makeDataReducer", escript::makeDataReducer, arg("op"), "Create a reducer to work with Data and the specified operation."); |
140 |
|
141 |
|
142 |
class_<escript::SplitWorld, boost::noncopyable>("SplitWorld", "Manages a group of sub worlds", init<unsigned int>(args("num_worlds"))) |
143 |
.def("runJobs", &escript::SplitWorld::runJobs, "Execute pending jobs.") |
144 |
.def("removeVariable", &escript::SplitWorld::removeVariable, arg("name"), "Remove the named variable from the SplitWorld"); |
145 |
|
146 |
// This class has no methods. This is deliberate - at this stage, I would like this to be an opaque type |
147 |
class_ <escript::SubWorld, escript::SubWorld_ptr, boost::noncopyable>("SubWorld", "Information about a group of workers.", no_init); |
148 |
/* end SubWorld things */ |
149 |
|
150 |
def("setNumberOfThreads",escript::setNumberOfThreads,"Use of this method is strongly discouraged."); |
151 |
def("getNumberOfThreads",escript::getNumberOfThreads,"Return the maximum number of threads" |
152 |
" available to OpenMP."); |
153 |
def("releaseUnusedMemory",escript::releaseUnusedMemory); |
154 |
def("blocktimer_initialize",blocktimer_initialize); |
155 |
def("blocktimer_reportSortByName",blocktimer_reportSortByName); |
156 |
def("blocktimer_reportSortByTime",blocktimer_reportSortByTime); |
157 |
def("blocktimer_increment",blocktimer_increment); |
158 |
def("blocktimer_time",blocktimer_time); |
159 |
def("getVersion",escript::getSvnVersion,"This method will only report accurate version numbers for clean checkouts."); |
160 |
def("printParallelThreadCounts",escript::printParallelThreadCnt); |
161 |
def("getMPISizeWorld",escript::getMPISizeWorld,"Return number of MPI processes in the job."); |
162 |
def("getMPIRankWorld",escript::getMPIRankWorld,"Return the rank of this process in the MPI World."); |
163 |
def("MPIBarrierWorld",escript::MPIBarrierWorld,"Wait until all MPI processes have reached this point."); |
164 |
def("getMPIWorldMax",escript::getMPIWorldMax,"\n" |
165 |
"Each MPI process calls this function with a" |
166 |
" value for arg1. The maximum value is computed and returned.\n\n" |
167 |
":rtype: int"); |
168 |
def("getMPIWorldSum",escript::getMPIWorldSum,"\n" |
169 |
"Each MPI process calls this function with a" |
170 |
" value for arg1. The values are added up and the total value is returned.\n\n" |
171 |
":rtype: int"); |
172 |
def("runMPIProgram",escript::runMPIProgram,"Spawns an external MPI program using a separate communicator."); |
173 |
def("getMachinePrecision",escript::getMachinePrecision); |
174 |
def("getMaxFloat",escript::getMaxFloat); |
175 |
def("_saveDataCSV",escript::saveDataCSV, (args("filename","arg","sep","csep"), arg("append")=false), |
176 |
"Saves data objects passed in a python dictionary to a file.\n" |
177 |
"The data objects must be over the same domain and be able to be interpolated to the same FunctionSpace.\n" |
178 |
"If one of the dictionary keys is named ``mask``, then only samples where ``mask`` has a positive\n" |
179 |
"value will be written to the file.\n\n" |
180 |
"A header line giving the names of each column will be output first.\n" |
181 |
"The keys given in the dictionary will be used to name columns.\n" |
182 |
"Then the data will be output, one line per sample (for all data).\n" |
183 |
"That is, items in each column will be printed in the same order.\n" |
184 |
"So you can be sure that values in the same row correspond to the same input value.\n\n" |
185 |
"\n" |
186 |
":param filename:\n" |
187 |
":type filename: ``string``\n" |
188 |
":param arg: dictionary of named `Data` objects. If one is called ``mask`` it must be scalar data.\n" |
189 |
":type arg: ``dict``\n" |
190 |
":param sep: separator for columns (defaults to ',')\n" |
191 |
":type sep: ``string``\n" |
192 |
":param csep: separator for fields within data object (defaults to \"_\")\n" |
193 |
":type csep: ``string``\n" |
194 |
":param append: If True, write to the end of ``filename``\n" |
195 |
":type append: ``string``\n" |
196 |
""); |
197 |
def("canInterpolate", &escript::canInterpolate, args("src", "dest"),":param src: Source FunctionSpace\n" |
198 |
":param dest: Destination FunctionSpace\n" |
199 |
":return: True if src can be interpolated to dest\n" |
200 |
":rtype: `bool`"); |
201 |
|
202 |
// |
203 |
// Interface for AbstractDomain |
204 |
// |
205 |
class_<escript::AbstractDomain, escript::Domain_ptr, boost::noncopyable >("Domain","Base class for all domains.",no_init) |
206 |
.def("getStatus",&escript::AbstractDomain::getStatus,"The status of a domain changes whenever the domain is modified\n\n" |
207 |
":rtype: int") |
208 |
.def("setTagMap",&escript::AbstractDomain::setTagMap,args("name","tag"), |
209 |
"Give a tag number a name.\n\n" |
210 |
":param name: Name for the tag\n" |
211 |
":type name: ``string``\n" |
212 |
":param tag: numeric id\n" |
213 |
":type tag: ``int``\n" |
214 |
":note: Tag names must be unique within a domain") |
215 |
.def("getTag",&escript::AbstractDomain::getTag,args("name"),":return: tag id for " |
216 |
"``name``\n" |
217 |
":rtype: ``string``") |
218 |
.def("isValidTagName",&escript::AbstractDomain::isValidTagName,args("name"), |
219 |
":return: True is ``name`` corresponds to a tag\n" |
220 |
":rtype: ``bool``") |
221 |
.def("showTagNames",&escript::AbstractDomain::showTagNames,":return: A space separated list of tag names\n" |
222 |
":rtype: ``string``") |
223 |
.def("getX",&escript::AbstractDomain::getX,":rtype: `Data`\n" |
224 |
":return: Locations in the" |
225 |
"`Domain`. FunctionSpace is chosen appropriately") |
226 |
.def("getDim",&escript::AbstractDomain::getDim,":rtype: `int`\n" |
227 |
":return: Spatial dimension of the `Domain`") |
228 |
.def("getNormal",&escript::AbstractDomain::getNormal,":rtype: `escript`\n" |
229 |
":return: Boundary normals") |
230 |
.def("getSize",&escript::AbstractDomain::getSize,":return: the local size of samples. The function space is chosen appropriately\n" |
231 |
":rtype: `Data`") |
232 |
.def("dump",&escript::AbstractDomain::dump,args("filename"),"Dumps the domain to a file\n\n" |
233 |
":param filename: \n" |
234 |
":type filename: string") |
235 |
.def("getMPISize",&escript::AbstractDomain::getMPISize,":return: the number of processes used for this `Domain`\n" |
236 |
":rtype: ``int``") |
237 |
.def("getMPIRank",&escript::AbstractDomain::getMPIRank,":return: the rank of this process\n" |
238 |
":rtype: ``int``") |
239 |
.def("MPIBarrier",&escript::AbstractDomain::MPIBarrier,"Wait until all processes have reached this point") |
240 |
.def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor,":return: True if this code is executing on the master process\n" |
241 |
":rtype: `bool`") |
242 |
.def("supportsContactElements", &escript::AbstractDomain::supportsContactElements,"Does this domain support contact elements.") |
243 |
.def(self == self) |
244 |
.def(self != self) |
245 |
.def("__lt__", block_cmp_domains) |
246 |
.def("__le__", block_cmp_domains) |
247 |
.def("__gt__", block_cmp_domains) |
248 |
.def("__ge__", block_cmp_domains); |
249 |
|
250 |
// |
251 |
// Interface for AbstractContinuousDomain |
252 |
// |
253 |
class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain>, boost::noncopyable >("ContinuousDomain","Class representing continuous domains",no_init) |
254 |
.def("getSystemMatrixTypeId", &escript::AbstractContinuousDomain::getSystemMatrixTypeId, |
255 |
args("options"), |
256 |
":return: the identifier of the matrix type to be used for the global stiffness matrix " |
257 |
"when particular solver options are used.\n" |
258 |
":rtype: int") |
259 |
.def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId, |
260 |
args("solver", "preconditioner", "package", "symmetry")) |
261 |
|
262 |
.def("addPDEToSystem",&escript::AbstractContinuousDomain::addPDEToSystem, |
263 |
args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact", "d_dirac", "y_dirac"), |
264 |
"adds a PDE onto the stiffness matrix mat and a rhs\n\n" |
265 |
":param mat:\n" |
266 |
":type mat: `OperatorAdapter`\n" |
267 |
":param rhs:\n" |
268 |
":type rhs: `Data`\n" |
269 |
":param A:\n" |
270 |
":type A: `Data`\n" |
271 |
":param B:\n" |
272 |
":type B: `Data`\n" |
273 |
":param C:\n" |
274 |
":type C: `Data`\n" |
275 |
":param D:\n" |
276 |
":type D: `Data`\n" |
277 |
":param X:\n" |
278 |
":type X: `Data`\n" |
279 |
":param Y:\n" |
280 |
":type Y: `Data`\n" |
281 |
":param d:\n" |
282 |
":type d: `Data`\n" |
283 |
":param d_contact:\n" |
284 |
":type d_contact: `Data`\n" |
285 |
":param y_contact:\n" |
286 |
":type y_contact: `Data`\n" |
287 |
":param d_dirac:\n" |
288 |
":type d_dirac: `Data`\n" |
289 |
":param y_dirac:\n" |
290 |
":type y_dirac: `Data`\n" |
291 |
) |
292 |
.def("addPDEToRHS",&escript::AbstractContinuousDomain::addPDEToRHS, |
293 |
args("rhs", "X", "Y", "y", "y_contact", "y_dirac"), |
294 |
"adds a PDE onto the stiffness matrix mat and a rhs\n\n" |
295 |
":param rhs:\n" |
296 |
":type rhs: `Data`\n" |
297 |
":param X:\n" |
298 |
":type X: `Data`\n" |
299 |
":param Y:\n" |
300 |
":type Y: `Data`\n" |
301 |
":param y:\n" |
302 |
":type y: `Data`\n" |
303 |
":param y_contact:\n" |
304 |
":type y_contact: `Data`\n" |
305 |
":param y_dirac:\n" |
306 |
":type y_dirac: `Data`" |
307 |
) |
308 |
.def("addPDEToTransportProblem",&escript::AbstractContinuousDomain::addPDEToTransportProblem, |
309 |
args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact", "d_dirac", "y_dirac"), |
310 |
":param tp:\n" |
311 |
":type tp: `TransportProblemAdapter`\n" |
312 |
":param source:\n" |
313 |
":type source: `Data`\n" |
314 |
":param M:\n" |
315 |
":type M: `Data`\n" |
316 |
":param A:\n" |
317 |
":type A: `Data`\n" |
318 |
":param B:\n" |
319 |
":type B: `Data`\n" |
320 |
":param C:\n" |
321 |
":type C: `Data`\n" |
322 |
":param D:\n" |
323 |
":type D: `Data`\n" |
324 |
":param X:\n" |
325 |
":type X: `Data`\n" |
326 |
":param Y:\n" |
327 |
":type Y: `Data`\n" |
328 |
":param d:\n" |
329 |
":type d: `Data`\n" |
330 |
":param y:\n" |
331 |
":type y: `Data`\n" |
332 |
":param d_contact:\n" |
333 |
":type d_contact: `Data`\n" |
334 |
":param y_contact:\n" |
335 |
":type y_contact: `Data`\n" |
336 |
":param d_dirac:\n" |
337 |
":type d_dirac: `Data`\n" |
338 |
":param y_dirac:\n" |
339 |
":type y_dirac: `Data`\n" |
340 |
) |
341 |
.def("newOperator",&escript::AbstractContinuousDomain::newSystemMatrix, |
342 |
args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"), |
343 |
"creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n" |
344 |
":param row_blocksize:\n" |
345 |
":type row_blocksize: ``int``\n" |
346 |
":param row_functionspace:\n" |
347 |
":type row_functionspace: `FunctionSpace`\n" |
348 |
":param column_blocksize:\n" |
349 |
":type column_blocksize: ``int``\n" |
350 |
":param column_functionspace:\n" |
351 |
":type column_functionspace: `FunctionSpace`\n" |
352 |
":param type:\n" |
353 |
":type type: ``int``\n" |
354 |
) |
355 |
.def("newTransportProblem",&escript::AbstractContinuousDomain::newTransportProblem, |
356 |
args("theta", "blocksize", "functionspace", "type"), |
357 |
"creates a TransportProblemAdapter\n\n" |
358 |
":param theta:\n" |
359 |
":type theta: ``float``\n" |
360 |
":param blocksize:\n" |
361 |
":type blocksize: ``int``\n" |
362 |
":param functionspace:\n" |
363 |
":type functionspace: `FunctionSpace`\n" |
364 |
":param type:\n" |
365 |
":type type: ``int``\n" |
366 |
) |
367 |
.def("getDataShape",&escript::AbstractContinuousDomain::getDataShape, args("functionSpaceCode"), |
368 |
":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n" |
369 |
":rtype: ``tuple``") |
370 |
.def("print_mesh_info",&escript::AbstractContinuousDomain::Print_Mesh_Info,(arg("full")=false), |
371 |
":param full:\n" |
372 |
":type full: ``bool``") |
373 |
.def("getDescription",&escript::AbstractContinuousDomain::getDescription, |
374 |
":return: a description for this domain\n" |
375 |
":rtype: ``string``") |
376 |
.def("setX",&escript::AbstractContinuousDomain::setNewX, |
377 |
args("arg"), "assigns new location to the domain\n\n" |
378 |
":param arg:\n" |
379 |
":type arg: `Data`") |
380 |
.def("getNumDataPointsGlobal",&escript::AbstractContinuousDomain::getNumDataPointsGlobal, |
381 |
":return: the number of data points summed across all MPI processes\n" |
382 |
":rtype: ``int``"); |
383 |
|
384 |
|
385 |
|
386 |
|
387 |
// |
388 |
// Interface for TestDomain |
389 |
// |
390 |
class_ <escript::TestDomain, bases<escript::AbstractDomain> >("TestDomain", |
391 |
"Test Class for domains with no structure. May be removed from future releases without notice.", no_init); |
392 |
|
393 |
// This is the only python visible way to get a TestDomain |
394 |
def("getTestDomainFunctionSpace",&escript::getTestDomainFunctionSpace, (arg("dpps"), |
395 |
arg("samples"), arg("size")=1), |
396 |
"For testing only. May be removed without notice."); |
397 |
|
398 |
// |
399 |
// Interface for FunctionSpace |
400 |
// |
401 |
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 |
402 |
fs_definer.def("getDim",&escript::FunctionSpace::getDim,":return: the spatial dimension of the underlying domain.\n" |
403 |
":rtype: int"); |
404 |
// fs_definer.def("getDomain",&escript::FunctionSpace::getDomain, |
405 |
// return_internal_reference<>()); |
406 |
fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython,":return: the underlying `Domain` for this FunctionSpace.\n" |
407 |
":rtype: `Domain`"); |
408 |
fs_definer.def("getX",&escript::FunctionSpace::getX,"\n" |
409 |
":return: a function whose values are its input coordinates. ie an identity function.\n" |
410 |
":rtype: `Data`"); |
411 |
fs_definer.def("getNormal",&escript::FunctionSpace::getNormal,":return: the surface normal field.\n\n" |
412 |
":rtype: `Data`"); |
413 |
fs_definer.def("getSize",&escript::FunctionSpace::getSize,":return: sample size\n" |
414 |
":rtype: `Data`"); |
415 |
fs_definer.def("setTags",&escript::FunctionSpace::setTags,args("newtag","mask"), |
416 |
"Set tags according to a mask\n\n" |
417 |
":param newtag: tag number to set\n" |
418 |
":type newtag: string, non-zero ``int``\n" |
419 |
":param mask: Samples which correspond to positive values in the mask will be set to ``newtag``.\n" |
420 |
":type mask: scalar `Data`"); |
421 |
fs_definer.def("setTags",&escript::FunctionSpace::setTagsByString,args("newtag","mask")); |
422 |
fs_definer.def("getTagFromDataPointNo", |
423 |
&escript::FunctionSpace::getTagFromDataPointNo,":return: the tag associated with the given sample number.\n" |
424 |
":rtype: int"); |
425 |
fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo,args("dataPointNo"),":return: the reference number associated with ``dataPointNo``\n" |
426 |
":rtype: int "); |
427 |
fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags,":return: a list of the tags used in this function space\n" |
428 |
":rtype: ``list``"); |
429 |
fs_definer.def("getApproximationOrder", &escript::FunctionSpace::getApproximationOrder,":return: the approximation order referring to the maximum degree of a polynomial which can be represented exactly in interpolation and/or integration.\n" |
430 |
":rtype: ``int``"); |
431 |
fs_definer.def("__str__", &escript::FunctionSpace::toString); |
432 |
fs_definer.def("__lt__",block_cmp_functionspace); |
433 |
fs_definer.def("__le__",block_cmp_functionspace); |
434 |
fs_definer.def("__gt__",block_cmp_functionspace); |
435 |
fs_definer.def("__ge__",block_cmp_functionspace); |
436 |
fs_definer.def(self == self); |
437 |
fs_definer.def(self != self); |
438 |
|
439 |
|
440 |
|
441 |
// |
442 |
// Interface for Data |
443 |
// |
444 |
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<>() ) |
445 |
// various constructors for Data objects |
446 |
.def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand"))) |
447 |
.def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand"))) |
448 |
.def(init<const escript::Data&, const escript::FunctionSpace&>(args("value","what"))) |
449 |
.def(init<const escript::Data&>()) |
450 |
// Note for Lutz, Need to specify the call policy in order to return a |
451 |
// reference. In this case return_internal_reference. |
452 |
.def("__str__",&escript::Data::toString) |
453 |
.def("getDomain",&escript::Data::getDomainPython,":rtype: `Domain`") |
454 |
.def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>(),":rtype: `FunctionSpace`") |
455 |
.def("isEmpty",&escript::Data::isEmpty,"Is this object an instance of ``DataEmpty``\n\n" |
456 |
":rtype: ``bool``\n" |
457 |
":note: This is not the same thing as asking if the object contains datapoints.") |
458 |
.def("isProtected",&escript::Data::isProtected,"Can this instance be modified.\n" |
459 |
":rtype: ``bool``") |
460 |
.def("setProtection",&escript::Data::setProtection,"Disallow modifications to this data object\n\n" |
461 |
":note: This method does not allow you to undo protection.") |
462 |
.def("getShape",&escript::Data::getShapeTuple,"\n" |
463 |
"Returns the shape of the datapoints in this object as a python tuple. Scalar data has the shape ``()``\n\n" |
464 |
":rtype: ``tuple``") |
465 |
.def("getRank",&escript::Data::getDataPointRank,":return: the number of indices required to address a component of a datapoint\n" |
466 |
":rtype: positive ``int``") |
467 |
.def("dump",&escript::Data::dump,args("fileName"),"Save the data as a netCDF file\n\n" |
468 |
":param fileName: \n" |
469 |
":type fileName: ``string``") |
470 |
.def("toListOfTuples",&escript::Data::toListOfTuples, (arg("scalarastuple")=false), |
471 |
"Return the datapoints of this object in a list. Each datapoint is stored as a tuple.\n\n" |
472 |
":param scalarastuple: if True, scalar data will be wrapped as a tuple." |
473 |
" True => [(0), (1), (2)]; False => [0, 1, 2]") |
474 |
.def("copyWithMask",&escript::Data::copyWithMask,args("other","mask"), |
475 |
"Selectively copy values from ``other`` `Data`." |
476 |
"Datapoints which correspond to positive values in ``mask`` will be copied from ``other``\n" |
477 |
"\n" |
478 |
":param other: source of values\n" |
479 |
":type other: `Data`\n" |
480 |
":param mask:\n" |
481 |
":type mask: Scalar `Data`") |
482 |
.def("setTaggedValue",&escript::Data::setTaggedValue,args("tagKey","value"), |
483 |
"Set the value of tagged Data.\n\n" |
484 |
":param tagKey: tag to update\n" |
485 |
":type tagKey: ``int``\n" |
486 |
"") |
487 |
.def("setTaggedValue",&escript::Data::setTaggedValueByName,args("name","value"),":param name: tag to update\n" |
488 |
":type name: ``string``\n" |
489 |
":param value: value to set tagged data to\n" |
490 |
":type value: ``object`` which acts like an array, ``tuple`` or ``list``\n" |
491 |
"") |
492 |
.def("getNumberOfDataPoints",&escript::Data::getNumDataPoints,":rtype: ``int``\n" |
493 |
":return: Number of datapoints in the object") |
494 |
.def("isExpanded",&escript::Data::isExpanded,":rtype: ``bool``\n" |
495 |
":return: True if this ``Data`` is expanded.") |
496 |
.def("isTagged",&escript::Data::isTagged,":rtype: ``bool``\n" |
497 |
":return: True if this ``Data`` is expanded.") |
498 |
.def("isConstant",&escript::Data::isConstant,":rtype: ``bool``\n" |
499 |
":return: True if this ``Data`` is an instance of ``DataConstant``\n" |
500 |
":note: This does not mean the data is immutable.") |
501 |
.def("isLazy",&escript::Data::isLazy,":rtype: ``bool``\n" |
502 |
":return: True if this ``Data`` is lazy.") |
503 |
.def("isReady",&escript::Data::isReady,":rtype: ``bool``\n" |
504 |
":return: True if this ``Data`` is not lazy.") |
505 |
.def("expand",&escript::Data::expand,"Convert the data to expanded representation if it is not expanded already.") |
506 |
.def("hasNaN",&escript::Data::hasNaN,"Returns return true if data contains NaN.") |
507 |
.def("replaceNaN",&escript::Data::replaceNaN,args("value"),"Replaces NaN values with value") |
508 |
.def("tag",&escript::Data::tag,"Convert data to tagged representation if it is not already tagged or expanded") |
509 |
.def("resolve",&escript::Data::resolve,"Convert the data to non-lazy representation.") |
510 |
.def("copy",&escript::Data::copy,args("other"),"Make this object a copy of ``other``\n" |
511 |
"\n" |
512 |
":note: The two objects will act independently from now on. That is, changing ``other`` " |
513 |
"after this call will not change this object and vice versa.") |
514 |
.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.") |
515 |
.def("delay",&escript::Data::delay,"Convert this object into lazy representation") |
516 |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject,args("dataPointNo","value")) |
517 |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray) |
518 |
.def("_setTupleForGlobalDataPoint", &escript::Data::setTupleForGlobalDataPoint) |
519 |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint,"\n" |
520 |
"Modify the value of a single datapoint.\n\n" |
521 |
":param dataPointNo:\n" |
522 |
":type dataPointNo: int\n" |
523 |
":param value: \n" |
524 |
":type value: ``float`` or an object which acts like an array, ``tuple`` or ``list``\n" |
525 |
":warning: Use of this operation is discouraged. It prevents some optimisations from operating.") |
526 |
.def("getTupleForDataPoint",&escript::Data::getValueOfDataPointAsTuple,args("dataPointNo"), |
527 |
":return: Value of the specified datapoint\n" |
528 |
":rtype: ``tuple``\n" |
529 |
":param dataPointNo: datapoint to access\n" |
530 |
":type dataPointNo: ``int``") |
531 |
.def("getTupleForGlobalDataPoint",&escript::Data::getValueOfGlobalDataPointAsTuple,args("procNo","dataPointNo"),"Get a specific datapoint from a specific process\n\n" |
532 |
":rtype: ``tuple``\n" |
533 |
":param procNo: MPI rank of the process\n" |
534 |
":type procNo: positive ``int``" |
535 |
"\n" |
536 |
":param dataPointNo: datapoint to access\n" |
537 |
":type dataPointNo: int") |
538 |
.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.") |
539 |
.def("interpolate",&escript::Data::interpolate,args("functionspace"),"Interpolate this object's values into a new functionspace.") |
540 |
.def("_interpolateTable3d", &escript::Data::interpolateFromTable3DP, |
541 |
(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.") |
542 |
) |
543 |
|
544 |
.def("interpolateTable", &escript::Data::interpolateFromTable2DP, |
545 |
(arg("table"),arg("Amin"),arg("Astep"), arg("B"), arg("Bmin"), arg("Bstep"), arg("undef")=1.e50, arg("check_boundaries")=false), |
546 |
"Creates a new Data object by interpolating using the source data (which are\n" |
547 |
"looked up in ``table``)\n" |
548 |
"``A`` must be the outer dimension on the table\n\n" |
549 |
":param table: two dimensional collection of values\n" |
550 |
":param Amin: The base of locations in table\n" |
551 |
":type Amin: float\n" |
552 |
":param Astep: size of gap between each item in the table\n" |
553 |
":type Astep: float\n" |
554 |
":param undef: upper bound on interpolated values\n" |
555 |
":type undef: float\n" |
556 |
":param B: Scalar representing the second coordinate to be mapped into the table\n" |
557 |
":type B: `Data`\n" |
558 |
":param Bmin: The base of locations in table for 2nd dimension\n" |
559 |
":type Bmin: float\n" |
560 |
":param Bstep: size of gap between each item in the table for 2nd dimension\n" |
561 |
":type Bstep: float\n" |
562 |
":param check_boundaries: if true, then values outside the boundaries will be rejected. If false, then boundary values will be used.\n" |
563 |
":raise RuntimeError(DataException): if the coordinates do not map into the table or if the interpolated value is above ``undef``" |
564 |
"\n" |
565 |
":rtype: `Data`" |
566 |
) |
567 |
.def("interpolateTable", &escript::Data::interpolateFromTable1DP, |
568 |
(arg("table"),arg("Amin"),arg("Astep"), arg("undef")=1.e50, arg("check_boundaries")=false)/*, |
569 |
"Creates a new Data object by interpolating using the source data (which are\n" |
570 |
"looked up in ``table``)\n\n" |
571 |
":param table: one dimensional collection of values\n" |
572 |
":param Amin: The base of locations in table\n" |
573 |
":type Amin: float\n" |
574 |
":param Astep: size of gap between each item in the table\n" |
575 |
":type Astep: float\n" |
576 |
":param undef: upper bound on interpolated values\n" |
577 |
":type undef: float\n" |
578 |
":param check_boundaries: if true, then values outside the boundaries will be rejected. If false, then boundary values will be used.\n" |
579 |
":raise RuntimeError(DataException): if the coordinates do not map into the table or if the interpolated value is above ``undef``" |
580 |
"\n" |
581 |
":rtype: `Data`" |
582 |
*/ |
583 |
) |
584 |
.def("nonuniformInterpolate", &escript::Data::nonuniforminterp, "1D interpolation with non equally spaced points", |
585 |
(arg("in"), arg("out"), arg("check_boundaries")), |
586 |
"Creates a Data object by linear interpolation of the function F(in)->out\n\n" |
587 |
":param in: input values of interpolation function\n" |
588 |
":param out: corresponding output values of interpolation function\n" |
589 |
":param check_boundaries: If True, an exception will the thrown if the data object contains values" |
590 |
"outside the range given by ``in``.\n" |
591 |
) |
592 |
.def("nonuniformSlope", &escript::Data::nonuniformslope, "1D interpolation of slope with non equally spaced points", |
593 |
(arg("in"), arg("out"), arg("check_boundaries")), |
594 |
"Creates a Data object by computing the slope of the function F(in)->out\n\n" |
595 |
":param in: input values of interpolation function\n" |
596 |
":param out: corresponding output values of interpolation function\n" |
597 |
":param check_boundaries: If True, an exception will the thrown if the data object contains values" |
598 |
"outside the range given by ``in``.\n" |
599 |
) |
600 |
.def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint,"Please consider using getInfLocator() from pdetools instead.") |
601 |
.def("maxGlobalDataPoint",&escript::Data::maxGlobalDataPoint, "Please consider using getSupLocator() from pdetools instead.") |
602 |
.def("getTagNumber",&escript::Data::getTagNumber,args("dpno"),"Return tag number for the specified datapoint\n\n" |
603 |
":rtype: int\n" |
604 |
":param dpno: datapoint number\n" |
605 |
":type dpno: int") |
606 |
// Unary functions for Data |
607 |
.def("_interpolate",&escript::Data::interpolate) |
608 |
.def("_grad",&escript::Data::gradOn) |
609 |
.def("_grad",&escript::Data::grad) |
610 |
.def("_transpose",&escript::Data::transpose) |
611 |
.def("_trace",&escript::Data::trace) |
612 |
.def("_maxval",&escript::Data::maxval) |
613 |
.def("_minval",&escript::Data::minval) |
614 |
.def("_wherePositive",&escript::Data::wherePositive) |
615 |
.def("_whereNegative",&escript::Data::whereNegative) |
616 |
.def("_whereNonNegative",&escript::Data::whereNonNegative) |
617 |
.def("_whereNonPositive",&escript::Data::whereNonPositive) |
618 |
.def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0)) |
619 |
.def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0)) |
620 |
.def("_erf",&escript::Data::erf) |
621 |
.def("_sin",&escript::Data::sin) |
622 |
.def("_cos",&escript::Data::cos) |
623 |
.def("_tan",&escript::Data::tan) |
624 |
.def("_asin",&escript::Data::asin) |
625 |
.def("_acos",&escript::Data::acos) |
626 |
.def("_atan",&escript::Data::atan) |
627 |
.def("_sinh",&escript::Data::sinh) |
628 |
.def("_cosh",&escript::Data::cosh) |
629 |
.def("_tanh",&escript::Data::tanh) |
630 |
.def("_asinh",&escript::Data::asinh) |
631 |
.def("_acosh",&escript::Data::acosh) |
632 |
.def("_atanh",&escript::Data::atanh) |
633 |
.def("_exp",&escript::Data::exp) |
634 |
.def("_sqrt",&escript::Data::sqrt) |
635 |
.def("_log10",&escript::Data::log10) |
636 |
.def("_log",&escript::Data::log) |
637 |
.def("_sign",&escript::Data::sign) |
638 |
.def("_symmetric",&escript::Data::symmetric) |
639 |
.def("_nonsymmetric",&escript::Data::nonsymmetric) |
640 |
.def("_trace",&escript::Data::trace) |
641 |
.def("_swap_axes",&escript::Data::swapaxes) |
642 |
.def("_eigenvalues",&escript::Data::eigenvalues) |
643 |
.def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13)) |
644 |
// functions returning a single real number: |
645 |
.def("_Lsup",&escript::Data::Lsup,":return: the Lsup-norm of the object\n" |
646 |
":rtype: float\n" |
647 |
":note: If the ``Data`` contains no values, zero will be returned instead.") |
648 |
.def("_sup",&escript::Data::sup,":return: the maximum value over all data points.\n" |
649 |
":rtype: float\n" |
650 |
":note: If the ``Data`` contains no values a large negative value will be returned instead.") |
651 |
.def("_inf",&escript::Data::inf,":return: minimum value over all components and all data points\n" |
652 |
":rtype: float\n" |
653 |
":note: If the ``Data`` contains no values a large positive value will be returned instead.") |
654 |
.def("_integrateToTuple",&escript::Data::integrateToTuple,":return: Calculate the integral over the function space domain as a python tuple\n" |
655 |
":rtype: tuple") |
656 |
// following implements the python abs operator |
657 |
.def("__abs__",&escript::Data::abs,":return: absolute value\n\n" |
658 |
":rtype: `Data`") |
659 |
// following implements the python "-" negation operator |
660 |
.def("__neg__",&escript::Data::neg, ":return: negation of the values in this object\n" |
661 |
":rtype: `Data`") |
662 |
// following implements the python "+" identity operator |
663 |
.def("__pos__",&escript::Data::pos, "\n" |
664 |
"The unary + operator\n\n" |
665 |
":rtype: `Data`") |
666 |
// following three functions implement the python [] operator |
667 |
.def("__getitem__",&escript::Data::getItem,"Used by the python [] operator\n\n" |
668 |
":rtype: `Data`") |
669 |
.def("__setitem__",&escript::Data::setItemO,"Used by the python [] operator") |
670 |
.def("__setitem__",&escript::Data::setItemD,"Used by the python [] operator") |
671 |
// following three functions implement the python ** operator |
672 |
.def("__pow__",&escript::Data::powO,"Used by the python ** operator\n\n" |
673 |
":rtype: `Data`") |
674 |
.def("__pow__",&escript::Data::powD) |
675 |
.def("__rpow__",&escript::Data::rpowO,"\n" |
676 |
"Used by the python ** operator\n\n" |
677 |
":rtype: `Data`") |
678 |
// following two functions implement the newer python / operator |
679 |
.def("__truediv__",&escript::Data::truedivO) |
680 |
.def("__truediv__",&escript::Data::truedivD) |
681 |
.def("__rtruediv__",&escript::Data::rtruedivO) |
682 |
.def("__gt__",block_cmp_data) |
683 |
.def("__lt__",block_cmp_data) |
684 |
.def("__le__",block_cmp_data) |
685 |
.def("__ge__",block_cmp_data) |
686 |
// NOTE:: The order of these declarations is important. Anything |
687 |
// declared before the generic declaration isn't found so the generic |
688 |
// version will be called. |
689 |
// .def(self + other<object>()) |
690 |
// .def(other<object>() + self) |
691 |
// .def(self + self) |
692 |
.def(self += other<object>()) |
693 |
.def(self += self) |
694 |
|
695 |
// .def(self - other<object>()) |
696 |
// .def(other<object>() - self) |
697 |
// .def(self - self) |
698 |
.def(self -= other<object>()) |
699 |
.def(self -= self) |
700 |
|
701 |
// .def(self * other<object>()) |
702 |
// .def(other<object>() * self) |
703 |
// .def(self * self) |
704 |
.def(self *= other<object>()) |
705 |
.def(self *= self) |
706 |
|
707 |
// .def(self / other<object>()) |
708 |
// .def(other<object>() / self) |
709 |
// .def(self / self) |
710 |
.def(self /= other<object>()) |
711 |
.def(self /= self) |
712 |
// Need scope resolution due to a bug either in the compiler or |
713 |
// the boost code. This calls operator << for Data. |
714 |
.def(self_ns::str(self)) |
715 |
.def("_inverse", &escript::Data::matrixInverse, ":return: inverse of square matrices\n" |
716 |
"") |
717 |
// .def("__add__", &escript::Data::addOperatorD) |
718 |
.def("__add__", &escript::Data::__add__) |
719 |
.def("__radd__", &escript::Data::__add__) // its the same coz + is commutative |
720 |
.def("__sub__", &escript::Data::__sub__) |
721 |
.def("__rsub__", &escript::Data::__rsub__) |
722 |
.def("__mul__", &escript::Data::__mul__) |
723 |
.def("__rmul__", &escript::Data::__mul__) // commutative |
724 |
.def("__div__", &escript::Data::__div__) |
725 |
.def("__rdiv__", &escript::Data::__rdiv__) // commutative |
726 |
.def("__eq__", block_eq_data) // stop people from using == |
727 |
.def("__ne__", block_eq_data) // stop people from using != |
728 |
; |
729 |
|
730 |
// |
731 |
// Factory methods for function space |
732 |
// |
733 |
def("ContinuousFunction",escript::continuousFunction,args("domain"), |
734 |
":return: a continuous FunctionSpace (overlapped node values)\n" |
735 |
":rtype: `FunctionSpace`"); |
736 |
def("ReducedContinuousFunction",escript::reducedContinuousFunction,args("domain"), |
737 |
":return: a continuous with reduced order FunctionSpace (overlapped node values on reduced element order)\n" |
738 |
":rtype: `FunctionSpace`"); |
739 |
def("Function",escript::function,args("domain"),":return: a function `FunctionSpace`\n" |
740 |
":rtype: `FunctionSpace`"); |
741 |
def("ReducedFunction",escript::reducedFunction, args("domain"),":return: a function FunctionSpace with reduced integration order\n" |
742 |
":rtype: `FunctionSpace`"); |
743 |
def("FunctionOnBoundary",escript::functionOnBoundary, args("domain"), ":return: a function on boundary FunctionSpace\n" |
744 |
":rtype: `FunctionSpace`"); |
745 |
def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary, args("domain"), |
746 |
":return: a function on boundary FunctionSpace with reduced integration order\n" |
747 |
":rtype: `FunctionSpace`"); |
748 |
def("FunctionOnContactZero",escript::functionOnContactZero, args("domain"), ":return: Return a FunctionSpace on left side of contact\n" |
749 |
":rtype: `FunctionSpace`"); |
750 |
def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero, args("domain"), |
751 |
":return: a FunctionSpace on left side of contact with reduced integration order\n" |
752 |
":rtype: `FunctionSpace`"); |
753 |
def("FunctionOnContactOne",escript::functionOnContactOne, args("domain"), ":return: Return a FunctionSpace on right side of contact\n" |
754 |
":rtype: `FunctionSpace`"); |
755 |
def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne, args("domain"), |
756 |
":return: Return a FunctionSpace on right side of contact with reduced integration order\n" |
757 |
":rtype: `FunctionSpace`"); |
758 |
def("Solution",escript::solution, args("domain"), ":rtype: `FunctionSpace`"); |
759 |
def("ReducedSolution",escript::reducedSolution, args("domain"), ":rtype: `FunctionSpace`"); |
760 |
def("DiracDeltaFunctions",escript::diracDeltaFunctions, args("domain"), ":rtype: `FunctionSpace`"); |
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
// |
767 |
// Factory methods for Data |
768 |
// |
769 |
def("load",escript::load, args("fileName","domain"), "reads Data on domain from file in netCDF format\n\n" |
770 |
":param fileName:\n" |
771 |
":type fileName: ``string``\n" |
772 |
":param domain:\n" |
773 |
":type domain: `Domain`"); |
774 |
def("loadIsConfigured",escript::loadConfigured,":return: True if the load function is configured."); |
775 |
def("Scalar",escript::Scalar, |
776 |
(arg("value")=0.0, |
777 |
arg("what")=escript::FunctionSpace(), |
778 |
arg("expanded")=false), |
779 |
"Construct a Data object containing scalar data-points.\n\n" |
780 |
":param value: scalar value for all points\n" |
781 |
"\n" |
782 |
":rtype: `Data`\n" |
783 |
":type value: float\n" |
784 |
":param what: FunctionSpace for Data\n" |
785 |
":type what: `FunctionSpace`\n" |
786 |
":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n" |
787 |
":type expanded: ``bool``"); |
788 |
def("Vector",escript::Vector, |
789 |
(arg("value")=0.0, |
790 |
arg("what")=escript::FunctionSpace(), |
791 |
arg("expanded")=false), |
792 |
"Construct a Data object containing rank1 data-points.\n\n" |
793 |
":param value: scalar value for all points\n" |
794 |
"\n" |
795 |
":rtype: `Data`\n" |
796 |
":type value: float\n" |
797 |
":param what: FunctionSpace for Data\n" |
798 |
":type what: `FunctionSpace`\n" |
799 |
":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n" |
800 |
":type expanded: ``bool``"); |
801 |
def("Vector", escript::VectorFromObj, |
802 |
(arg("value"), |
803 |
arg("what")=escript::FunctionSpace(), |
804 |
arg("expanded")=false)); |
805 |
def("Tensor",escript::Tensor, |
806 |
(arg("value")=0.0, |
807 |
arg("what")=escript::FunctionSpace(), |
808 |
arg("expanded")=false), |
809 |
"Construct a Data object containing rank2 data-points.\n\n" |
810 |
":param value: scalar value for all points\n" |
811 |
"\n" |
812 |
":rtype: `Data`\n" |
813 |
":type value: float\n" |
814 |
":param what: FunctionSpace for Data\n" |
815 |
":type what: `FunctionSpace`\n" |
816 |
":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n" |
817 |
":type expanded: ``bool``"); |
818 |
def("Tensor", escript::TensorFromObj, |
819 |
(arg("value"), |
820 |
arg("what")=escript::FunctionSpace(), |
821 |
arg("expanded")=false)); |
822 |
def("Tensor3",escript::Tensor3, |
823 |
(arg("value")=0.0, |
824 |
arg("what")=escript::FunctionSpace(), |
825 |
arg("expanded")=false), |
826 |
"Construct a Data object containing rank3 data-points.\n\n" |
827 |
":param value: scalar value for all points\n" |
828 |
"\n" |
829 |
":rtype: `Data`\n" |
830 |
":type value: float\n" |
831 |
":param what: FunctionSpace for Data\n" |
832 |
":type what: `FunctionSpace`\n" |
833 |
":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n" |
834 |
":type expanded: ``bool``" |
835 |
); |
836 |
def("Tensor3", escript::Tensor3FromObj, |
837 |
(arg("value"), |
838 |
arg("what")=escript::FunctionSpace(), |
839 |
arg("expanded")=false)); |
840 |
def("Tensor4",escript::Tensor4, |
841 |
(arg("value")=0.0, |
842 |
arg("what")=escript::FunctionSpace(), |
843 |
arg("expanded")=false), |
844 |
"Construct a Data object containing rank4 data-points.\n\n" |
845 |
":param value: scalar value for all points\n" |
846 |
"\n" |
847 |
":rtype: `Data`\n" |
848 |
":type value: float\n" |
849 |
":param what: FunctionSpace for Data\n" |
850 |
":type what: `FunctionSpace`\n" |
851 |
":param expanded: If True, a value is stored for each point. If False, more efficient representations may be used\n" |
852 |
":type expanded: ``bool``" |
853 |
); |
854 |
def("Tensor4", escript::Tensor4FromObj, |
855 |
(arg("value"), |
856 |
arg("what")=escript::FunctionSpace(), |
857 |
arg("expanded")=false)); |
858 |
|
859 |
|
860 |
def("RandomData", escript::randomData, (arg("shape"), arg("fs"), arg("seed")=0, arg("filter")=boost::python::tuple()), |
861 |
"Creates a new expanded Data object containing pseudo-random values. With no filter, values are drawn uniformly at random from [0,1].\n\n" |
862 |
":param shape: datapoint shape\n" |
863 |
":type shape: tuple\n" |
864 |
":param fs: function space for data object.\n" |
865 |
":type fs: `FunctionSpace`\n" |
866 |
":param seed: seed for random number generator.\n" |
867 |
":type seed: long\n" |
868 |
""); |
869 |
|
870 |
// |
871 |
// Binary operators |
872 |
// |
873 |
def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct, |
874 |
(arg("arg0"), |
875 |
arg("arg1"), |
876 |
arg("axis_offset")=0, |
877 |
arg("transpose")=0), |
878 |
"Compute a tensor product of two Data objects.\n\n" |
879 |
":rtype: `Data`\n" |
880 |
":param arg0:\n" |
881 |
":param arg1:\n" |
882 |
":param axis_offset:\n" |
883 |
":type axis_offset: ``int``\n" |
884 |
":param transpose: 0: transpose neither, 1: transpose arg0, 2: transpose arg1\n" |
885 |
":type transpose: int"); |
886 |
|
887 |
// |
888 |
// Interface for AbstractSystemMatrix |
889 |
// |
890 |
class_<escript::AbstractSystemMatrix,escript::ASM_ptr, boost::noncopyable>("Operator","",init<>()) // Doco goes in the empty string param |
891 |
.def("isEmpty",&escript::AbstractSystemMatrix::isEmpty,":rtype: ``bool``\n" |
892 |
":return: True if matrix is empty") |
893 |
.def("solve",&escript::AbstractSystemMatrix::solve, args("in","options"), |
894 |
":return: the solution *u* of the linear system *this*u=in*\n\n" |
895 |
":param in:\n" |
896 |
":type in: `Data`") |
897 |
.def("of",&escript::AbstractSystemMatrix::vectorMultiply,args("right"), |
898 |
"matrix*vector multiplication") |
899 |
.def("nullifyRowsAndCols",&escript::AbstractSystemMatrix::nullifyRowsAndCols) |
900 |
.def("saveMM",&escript::AbstractSystemMatrix::saveMM, args("fileName"), |
901 |
"writes the matrix to a file using the Matrix Market file format") |
902 |
.def("saveHB",&escript::AbstractSystemMatrix::saveHB, args("filename"), |
903 |
"writes the matrix to a file using the Harwell-Boeing file format") |
904 |
.def("resetValues",&escript::AbstractSystemMatrix::resetValues, "resets the matrix entries") |
905 |
.def(self*other<escript::Data>()); |
906 |
// |
907 |
// Interface for AbstractTransportProblem |
908 |
// |
909 |
class_<escript::AbstractTransportProblem, escript::ATP_ptr, boost::noncopyable >("TransportProblem","",init<>()) // Doco goes in the empty string param |
910 |
.def("isEmpty",&escript::AbstractTransportProblem::isEmpty,":rtype: ``int``") |
911 |
.def("solve",&escript::AbstractTransportProblem::solve, args("u0","source","dt", "options"), |
912 |
"returns the solution *u* for a time step *dt>0* with initial value u0\n\n" |
913 |
":rtype: `Data`\n" |
914 |
":param source:\n" |
915 |
":type source: `Data`") |
916 |
.def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint, |
917 |
args("source", "q", "r","factor"), |
918 |
"inserts constraint *u_{,t}=r* where *q>0* into the problem using a weighting factor") |
919 |
.def("reset",&escript::AbstractTransportProblem::resetTransport, |
920 |
"resets the transport operator typically as they have been updated.") |
921 |
.def("resetValues",&escript::AbstractTransportProblem::resetTransport) |
922 |
.def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize) |
923 |
.def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize); |
924 |
|
925 |
enum_<escript::SolverOptions>("SolverOptions") |
926 |
.value("DEFAULT", escript::SO_DEFAULT) |
927 |
|
928 |
.value("TARGET_CPU", escript::SO_TARGET_CPU) |
929 |
.value("TARGET_GPU", escript::SO_TARGET_GPU) |
930 |
|
931 |
.value("CUSP", escript::SO_PACKAGE_CUSP) |
932 |
.value("MKL", escript::SO_PACKAGE_MKL) |
933 |
.value("PASO", escript::SO_PACKAGE_PASO) |
934 |
.value("PASTIX", escript::SO_PACKAGE_PASTIX) |
935 |
.value("SUPER_LU", escript::SO_PACKAGE_SUPER_LU) |
936 |
.value("TRILINOS", escript::SO_PACKAGE_TRILINOS) |
937 |
.value("UMFPACK", escript::SO_PACKAGE_UMFPACK) |
938 |
|
939 |
.value("BICGSTAB", escript::SO_METHOD_BICGSTAB) |
940 |
.value("CGS", escript::SO_METHOD_CGS) |
941 |
.value("CHOLEVSKY", escript::SO_METHOD_CHOLEVSKY) |
942 |
.value("CR", escript::SO_METHOD_CR) |
943 |
.value("DIRECT", escript::SO_METHOD_DIRECT) |
944 |
.value("GMRES", escript::SO_METHOD_GMRES) |
945 |
.value("HRZ_LUMPING", escript::SO_METHOD_HRZ_LUMPING) |
946 |
.value("ITERATIVE", escript::SO_METHOD_ITERATIVE) |
947 |
.value("LSQR", escript::SO_METHOD_LSQR) |
948 |
.value("LUMPING", escript::SO_METHOD_ROWSUM_LUMPING) |
949 |
.value("MINRES", escript::SO_METHOD_MINRES) |
950 |
.value("NONLINEAR_GMRES", escript::SO_METHOD_NONLINEAR_GMRES) |
951 |
.value("PCG", escript::SO_METHOD_PCG) |
952 |
.value("PRES20", escript::SO_METHOD_PRES20) |
953 |
.value("ROWSUM_LUMPING", escript::SO_METHOD_ROWSUM_LUMPING) |
954 |
.value("TFQMR", escript::SO_METHOD_TFQMR) |
955 |
|
956 |
.value("AMG", escript::SO_PRECONDITIONER_AMG) |
957 |
.value("AMLI", escript::SO_PRECONDITIONER_AMLI) |
958 |
.value("BOOMERAMG", escript::SO_PRECONDITIONER_BOOMERAMG) |
959 |
.value("GAUSS_SEIDEL", escript::SO_PRECONDITIONER_GAUSS_SEIDEL) |
960 |
.value("ILU0", escript::SO_PRECONDITIONER_ILU0) |
961 |
.value("ILUT", escript::SO_PRECONDITIONER_ILUT) |
962 |
.value("JACOBI", escript::SO_PRECONDITIONER_JACOBI) |
963 |
.value("NO_PRECONDITIONER", escript::SO_PRECONDITIONER_NONE) |
964 |
.value("REC_ILU", escript::SO_PRECONDITIONER_REC_ILU) |
965 |
.value("RILU", escript::SO_PRECONDITIONER_RILU) |
966 |
|
967 |
.value("BACKWARD_EULER", escript::SO_ODESOLVER_BACKWARD_EULER) |
968 |
.value("CRANK_NICOLSON", escript::SO_ODESOLVER_CRANK_NICOLSON) |
969 |
.value("LINEAR_CRANK_NICOLSON", escript::SO_ODESOLVER_LINEAR_CRANK_NICOLSON) |
970 |
|
971 |
.value("CLASSIC_INTERPOLATION", escript::SO_INTERPOLATION_CLASSIC) |
972 |
.value("CLASSIC_INTERPOLATION_WITH_FF_COUPLING", escript::SO_INTERPOLATION_CLASSIC_WITH_FF_COUPLING) |
973 |
.value("DIRECT_INTERPOLATION", escript::SO_INTERPOLATION_DIRECT) |
974 |
|
975 |
.value("AGGREGATION_COARSENING", escript::SO_COARSENING_AGGREGATION) |
976 |
.value("CIJP_COARSENING", escript::SO_COARSENING_CIJP) |
977 |
.value("CIJP_FIXED_RANDOM_COARSENING", escript::SO_COARSENING_CIJP_FIXED_RANDOM) |
978 |
.value("FALGOUT_COARSENING", escript::SO_COARSENING_FALGOUT) |
979 |
.value("HMIS_COARSENING", escript::SO_COARSENING_HMIS) |
980 |
.value("PMIS_COARSENING", escript::SO_COARSENING_PMIS) |
981 |
.value("RUGE_STUEBEN_COARSENING", escript::SO_COARSENING_RUGE_STUEBEN) |
982 |
.value("STANDARD_COARSENING", escript::SO_COARSENING_STANDARD) |
983 |
.value("YAIR_SHAPIRA_COARSENING", escript::SO_COARSENING_YAIR_SHAPIRA) |
984 |
|
985 |
.value("DEFAULT_REORDERING", escript::SO_REORDERING_DEFAULT) |
986 |
.value("MINIMUM_FILL_IN", escript::SO_REORDERING_MINIMUM_FILL_IN) |
987 |
.value("NESTED_DISSECTION", escript::SO_REORDERING_NESTED_DISSECTION) |
988 |
.value("NO_REORDERING", escript::SO_REORDERING_NONE); |
989 |
|
990 |
|
991 |
class_<escript::SolverBuddy, escript::SB_ptr >("SolverBuddy","",init<>()) |
992 |
.def("getSummary", &escript::SolverBuddy::getSummary,"Returns a string reporting the current settings") |
993 |
.def("__str__", &escript::SolverBuddy::getSummary) |
994 |
.def("getName", &escript::SolverBuddy::getName, args("key"),"Returns the name of a given key\n\n" |
995 |
":param key: a valid key") |
996 |
.def("resetDiagnostics", &escript::SolverBuddy::resetDiagnostics, args("all")=false,"Resets the diagnostics\n\n" |
997 |
":param all: if ``all`` is ``True`` all diagnostics including accumulative counters are reset.\n" |
998 |
":type all: ``bool``") |
999 |
.def("_updateDiagnostics", &escript::SolverBuddy::updateDiagnostics, args("key", "value"),"Updates diagnostic information\n\n" |
1000 |
":param name: name of diagnostic information\n" |
1001 |
":type name: ``str`` in the list 'num_iter', 'num_level',\n" |
1002 |
"'num_inner_iter', 'time', 'set_up_time', 'net_time',\n" |
1003 |
"'residual_norm', 'converged'.\n" |
1004 |
":param value: new value of the diagnostic information\n" |
1005 |
":note: this function is used by a solver to report diagnostics\n" |
1006 |
"informations.") |
1007 |
.def("getDiagnostics", &escript::SolverBuddy::getDiagnostics, args("name"),"Returns the diagnostic information ``name``. Possible values are:\n\n" |
1008 |
"- 'num_iter': the number of iteration steps\n" |
1009 |
"- 'cum_num_iter': the cumulative number of iteration steps\n" |
1010 |
"- 'num_level': the number of level in multi level solver\n" |
1011 |
"- 'num_inner_iter': the number of inner iteration steps\n" |
1012 |
"- 'cum_num_inner_iter': the cumulative number of inner iteration steps\n" |
1013 |
"- 'time': execution time\n" |
1014 |
"- 'cum_time': cumulative execution time\n" |
1015 |
"- 'set_up_time': time to set up of the solver, typically this includes factorization and reordering\n" |
1016 |
"- 'cum_set_up_time': cumulative time to set up of the solver\n" |
1017 |
"- 'net_time': net execution time, excluding setup time for the solver and execution time for preconditioner\n" |
1018 |
"- 'cum_net_time': cumulative net execution time\n" |
1019 |
"- 'preconditioner_size': size of preconditioner [Bytes]\n" |
1020 |
"- 'converged': return True if solution has converged.\n" |
1021 |
"- 'time_step_backtracking_used': returns True if time step back tracking has been used.\n" |
1022 |
"- 'coarse_level_sparsity': returns the sparsity of the matrix on the coarsest level\n" |
1023 |
"- 'num_coarse_unknowns': returns the number of unknowns on the coarsest level\n\n\n" |
1024 |
":param name: name of diagnostic information to return\n" |
1025 |
":type name: ``str`` in the list above.\n" |
1026 |
":return: requested value. 0 is returned if the value is yet to be defined.\n" |
1027 |
":note: If the solver has thrown an exception diagnostic values have an undefined status.") |
1028 |
.def("hasConverged", &escript::SolverBuddy::hasConverged,"Returns ``True`` if the last solver call has been finalized successfully.\n\n" |
1029 |
":note: if an exception has been thrown by the solver the status of this\n" |
1030 |
"flag is undefined.") |
1031 |
.def("setCoarsening", &escript::SolverBuddy::setCoarsening, args("coarsening"),"Sets the key of the coarsening method to be applied in AMG or AMLI or BoomerAMG\n\n" |
1032 |
":param method: selects the coarsening method .\n" |
1033 |
":type method: in `DEFAULT`, `YAIR_SHAPIRA_COARSENING`, `RUGE_STUEBEN_COARSENING`, `AGGREGATION_COARSENING`, `CIJP_FIXED_RANDOM_COARSENING`, `CIJP_COARSENING`, `FALGOUT_COARSENING`, `PMIS_COARSENING`, `HMIS_COARSENING`") |
1034 |
.def("getCoarsening", &escript::SolverBuddy::getCoarsening,"Returns the key of the coarsening algorithm to be applied AMG, AMLI or BoomerAMG\n\n" |
1035 |
":rtype: in the list `DEFAULT`, `YAIR_SHAPIRA_COARSENING`, `RUGE_STUEBEN_COARSENING`, `AGGREGATION_COARSENING`, `CIJP_FIXED_RANDOM_COARSENING`, `CIJP_COARSENING`, `FALGOUT_COARSENING`, `PMIS_COARSENING`, `HMIS_COARSENING`") |
1036 |
.def("setMinCoarseMatrixSize", &escript::SolverBuddy::setMinCoarseMatrixSize, args("size"),"Sets the minimum size of the coarsest level matrix in AMG or AMLI\n\n" |
1037 |
":param size: minimum size of the coarsest level matrix .\n" |
1038 |
":type size: positive ``int``") |
1039 |
.def("getMinCoarseMatrixSize", &escript::SolverBuddy::getMinCoarseMatrixSize,"Returns the minimum size of the coarsest level matrix in AMG or AMLI") |
1040 |
.def("setPreconditioner", &escript::SolverBuddy::setPreconditioner, args("preconditioner"),"Sets the preconditioner to be used.\n\n" |
1041 |
":param preconditioner: key of the preconditioner to be used.\n" |
1042 |
":type preconditioner: in `ILU0`, `ILUT`, `JACOBI`, `AMG`, `AMLI`, `REC_ILU`, `GAUSS_SEIDEL`, `RILU`, `BOOMERAMG`, `NO_PRECONDITIONER`\n" |
1043 |
":note: Not all packages support all preconditioner. It can be assumed that a package makes a reasonable choice if it encounters an unknown\n" |
1044 |
"preconditioner.") |
1045 |
.def("getPreconditioner", &escript::SolverBuddy::getPreconditioner,"Returns the key of the preconditioner to be used.\n\n" |
1046 |
":rtype: in the list `ILU0`, `ILUT`, `JACOBI`, `AMLI`, `AMG`, `REC_ILU`, `GAUSS_SEIDEL`, `RILU`, `BOOMERAMG`, `NO_PRECONDITIONER`") |
1047 |
.def("setSmoother", &escript::SolverBuddy::setSmoother, args("smoother"),"Sets the smoother to be used.\n\n" |
1048 |
":param smoother: key of the smoother to be used.\n" |
1049 |
":type smoother: in `JACOBI`, `GAUSS_SEIDEL`\n" |
1050 |
":note: Not all packages support all smoothers. It can be assumed that a package makes a reasonable choice if it encounters an unknown smoother.") |
1051 |
.def("getSmoother", &escript::SolverBuddy::getSmoother,"Returns key of the smoother to be used.\n\n" |
1052 |
":rtype: in the list `JACOBI`, `GAUSS_SEIDEL`") |
1053 |
.def("setSolverMethod", &escript::SolverBuddy::setSolverMethod, args("method"),"Sets the solver method to be used. Use ``method``=``DIRECT`` to indicate that a direct rather than an iterative solver should be used and use ``method``=``ITERATIVE`` to indicate that an iterative rather than a direct solver should be used.\n\n" |
1054 |
":param method: key of the solver method to be used.\n" |
1055 |
":type method: in `DEFAULT`, `DIRECT`, `CHOLEVSKY`, `PCG`, `CR`, `CGS`, `BICGSTAB`, `GMRES`, `PRES20`, `ROWSUM_LUMPING`, `HRZ_LUMPING`, `ITERATIVE`, `NONLINEAR_GMRES`, `TFQMR`, `MINRES`\n" |
1056 |
":note: Not all packages support all solvers. It can be assumed that a package makes a reasonable choice if it encounters an unknown solver method.") |
1057 |
.def("getSolverMethod", &escript::SolverBuddy::getSolverMethod,"Returns key of the solver method to be used.\n\n" |
1058 |
":rtype: in the list `DEFAULT`, `DIRECT`, `CHOLEVSKY`, `PCG`, `CR`, `CGS`, `BICGSTAB`, `GMRES`, `PRES20`, `ROWSUM_LUMPING`, `HRZ_LUMPING`, `MINRES`, `ITERATIVE`, `NONLINEAR_GMRES`, `TFQMR`") |
1059 |
.def("setPackage", &escript::SolverBuddy::setPackage, args("package"),"Sets the solver package to be used as a solver.\n\n" |
1060 |
":param package: key of the solver package to be used.\n" |
1061 |
":type package: in `DEFAULT`, `PASO`, `CUSP`, `SUPER_LU`, `PASTIX`, `MKL`, `UMFPACK`, `TRILINOS`\n" |
1062 |
":note: Not all packages are support on all implementation. An exception may be thrown on some platforms if a particular package is requested.") |
1063 |
.def("getPackage", &escript::SolverBuddy::getPackage,"Returns the solver package key\n\n" |
1064 |
":rtype: in the list `DEFAULT`, `PASO`, `CUSP`, `SUPER_LU`, `PASTIX`, `MKL`, `UMFPACK`, `TRILINOS`") |
1065 |
.def("setSolverTarget", &escript::SolverBuddy::setSolverTarget, args("target"),"Sets the solver target to be used.\n\n" |
1066 |
":param target: key of the solver target to be used.\n" |
1067 |
":type target: in `TARGET_CPU`, `TARGET_GPU`\n") |
1068 |
.def("getSolverTarget", &escript::SolverBuddy::getSolverTarget, "Returns the solver target key\n\n" |
1069 |
":rtype: in the list `TARGET_CPU`, `TARGET_GPU`") |
1070 |
.def("setReordering", &escript::SolverBuddy::setReordering, args("ordering"),"Sets the key of the reordering method to be applied if supported by the solver. Some direct solvers support reordering to optimize compute time and storage use during elimination.\n\n" |
1071 |
":param ordering: selects the reordering strategy.\n" |
1072 |
":type ordering: in 'NO_REORDERING', 'MINIMUM_FILL_IN', 'NESTED_DISSECTION', 'DEFAULT_REORDERING'") |
1073 |
.def("getReordering", &escript::SolverBuddy::getReordering,"Returns the key of the reordering method to be applied if supported by the solver.\n\n" |
1074 |
":rtype: in `NO_REORDERING`, `MINIMUM_FILL_IN`, `NESTED_DISSECTION`, `DEFAULT_REORDERING`") |
1075 |
.def("setRestart", &escript::SolverBuddy::setRestart, args("restart"),"Sets the number of iterations steps after which GMRES performs a restart.\n\n" |
1076 |
":param restart: number of iteration steps after which to perform a restart. If 0 no restart is performed.\n" |
1077 |
":type restart: ``int``") |
1078 |
.def("getRestart", &escript::SolverBuddy::getRestart,"Returns the number of iterations steps after which GMRES performs a restart. If 0 is returned no restart is performed.\n\n" |
1079 |
":rtype: ``int``") |
1080 |
.def("setDiagonalDominanceThreshold", &escript::SolverBuddy::setDiagonalDominanceThreshold, args("threshold"),"Sets the threshold for diagonal dominant rows which are eliminated during AMG coarsening.\n\n" |
1081 |
":param value: threshold\n" |
1082 |
":type value: ``float``") |
1083 |
.def("getDiagonalDominanceThreshold", &escript::SolverBuddy::getDiagonalDominanceThreshold,"Returns the threshold for diagonal dominant rows which are eliminated during AMG coarsening.\n\n" |
1084 |
":rtype: ``float``") |
1085 |
.def("setTruncation", &escript::SolverBuddy::setTruncation, args("truncation"),"Sets the number of residuals in GMRES to be stored for orthogonalization. The more residuals are stored the faster GMRES converged\n\n" |
1086 |
":param truncation: truncation\n" |
1087 |
":type truncation: ``int``") |
1088 |
.def("getTruncation", &escript::SolverBuddy::getTruncation,"Returns the number of residuals in GMRES to be stored for orthogonalization\n\n" |
1089 |
":rtype: ``int``") |
1090 |
.def("setInnerIterMax", &escript::SolverBuddy::setInnerIterMax, args("iter_max"),"Sets the maximum number of iteration steps for the inner iteration.\n\n" |
1091 |
":param iter_max: maximum number of inner iterations\n" |
1092 |
":type iter_max: ``int``") |
1093 |
.def("getInnerIterMax", &escript::SolverBuddy::getInnerIterMax,"Returns maximum number of inner iteration steps\n\n" |
1094 |
":rtype: ``int``") |
1095 |
.def("setIterMax", &escript::SolverBuddy::setIterMax, args("iter_max"),"Sets the maximum number of iteration steps\n\n" |
1096 |
":param iter_max: maximum number of iteration steps\n" |
1097 |
":type iter_max: ``int``") |
1098 |
.def("getIterMax", &escript::SolverBuddy::getIterMax,"Returns maximum number of iteration steps\n\n" |
1099 |
":rtype: ``int``") |
1100 |
.def("setLevelMax", &escript::SolverBuddy::setLevelMax, args("level_max"),"Sets the maximum number of coarsening levels to be used in an algebraic multi-level solver or preconditioner\n\n" |
1101 |
":param level_max: maximum number of levels\n" |
1102 |
":type level_max: ``int``") |
1103 |
.def("getLevelMax", &escript::SolverBuddy::getLevelMax,"Returns the maximum number of coarsening levels to be used in an algebraic multi level solver or preconditioner\n\n" |
1104 |
":rtype: ``int``") |
1105 |
.def("setCycleType", &escript::SolverBuddy::setCycleType, args("cycle_type"),"Sets the cycle type (V-cycle or W-cycle) to be used in an algebraic multi-level solver or preconditioner\n\n" |
1106 |
":param cycle_type: the type of cycle\n" |
1107 |
":type cycle_type: ``int``") |
1108 |
.def("getCycleType", &escript::SolverBuddy::getCycleType,"Returns the cyle type (V- or W-cycle) to be used in an algebraic multi level solver or preconditioner\n\n" |
1109 |
":rtype: ``int``") |
1110 |
.def("setCoarseningThreshold", &escript::SolverBuddy::setCoarseningThreshold, args("theta"),"Sets the threshold for coarsening in the algebraic multi level solver or\n" |
1111 |
"preconditioner\n\n" |
1112 |
":param theta: threshold for coarsening\n" |
1113 |
":type theta: positive ``float``") |
1114 |
.def("getCoarseningThreshold", &escript::SolverBuddy::getCoarseningThreshold,"Returns the threshold for coarsening in the algebraic multi level solver\n" |
1115 |
"or preconditioner\n\n" |
1116 |
":rtype: ``float``") |
1117 |
.def("setNumSweeps", &escript::SolverBuddy::setNumSweeps, args("sweeps"),"Sets the number of sweeps in a Jacobi or Gauss-Seidel/SOR preconditioner.\n\n" |
1118 |
":param sweeps: number of sweeps\n" |
1119 |
":type sweeps: positive ``int``") |
1120 |
.def("getNumSweeps", &escript::SolverBuddy::getNumSweeps,"Returns the number of sweeps in a Jacobi or Gauss-Seidel/SOR preconditioner.\n\n" |
1121 |
":rtype: ``int``") |
1122 |
.def("setNumPreSweeps", &escript::SolverBuddy::setNumPreSweeps, args("sweeps"),"Sets the number of sweeps in the pre-smoothing step of a multi level\n" |
1123 |
"solver or preconditioner\n\n" |
1124 |
":param sweeps: number of sweeps\n" |
1125 |
":type sweeps: positive ``int``") |
1126 |
.def("getNumPreSweeps", &escript::SolverBuddy::getNumPreSweeps,"Returns he number of sweeps in the pre-smoothing step of a multi level solver or preconditioner\n\n" |
1127 |
":rtype: ``int``") |
1128 |
.def("setNumPostSweeps", &escript::SolverBuddy::setNumPostSweeps, args("sweeps"),"Sets the number of sweeps in the post-smoothing step of a multi level\n" |
1129 |
"solver or preconditioner\n\n" |
1130 |
":param sweeps: number of sweeps\n" |
1131 |
":type sweeps: positive ``int``") |
1132 |
.def("getNumPostSweeps", &escript::SolverBuddy::getNumPostSweeps,"Returns he number of sweeps in the post-smoothing step of a multi level solver or preconditioner\n\n" |
1133 |
":rtype: ``int``") |
1134 |
.def("setTolerance", &escript::SolverBuddy::setTolerance, args("rtol"),"Sets the relative tolerance for the solver\n\n" |
1135 |
":param rtol: relative tolerance\n" |
1136 |
":type rtol: non-negative ``float``") |
1137 |
.def("getTolerance", &escript::SolverBuddy::getTolerance,"Returns the relative tolerance for the solver\n\n" |
1138 |
":rtype: ``float``") |
1139 |
.def("setAbsoluteTolerance", &escript::SolverBuddy::setAbsoluteTolerance, args("atol"),"Sets the absolute tolerance for the solver\n\n" |
1140 |
":param atol: absolute tolerance\n" |
1141 |
":type atol: non-negative ``float``") |
1142 |
.def("getAbsoluteTolerance", &escript::SolverBuddy::getAbsoluteTolerance,"Returns the absolute tolerance for the solver\n\n" |
1143 |
":rtype: ``float``") |
1144 |
.def("setInnerTolerance", &escript::SolverBuddy::setInnerTolerance, args("rtol"),"Sets the relative tolerance for an inner iteration scheme, for instance on the coarsest level in a multi-level scheme.\n\n" |
1145 |
":param rtol: inner relative tolerance\n" |
1146 |
":type rtol: positive ``float``") |
1147 |
.def("getInnerTolerance", &escript::SolverBuddy::getInnerTolerance,"Returns the relative tolerance for an inner iteration scheme\n\n" |
1148 |
":rtype: ``float``") |
1149 |
.def("setDropTolerance", &escript::SolverBuddy::setDropTolerance, args("drop_tol"),"Sets the relative drop tolerance in ILUT\n\n" |
1150 |
":param drop_tol: drop tolerance\n" |
1151 |
":type drop_tol: positive ``float``") |
1152 |
.def("getDropTolerance", &escript::SolverBuddy::getDropTolerance,"Returns the relative drop tolerance in ILUT\n\n" |
1153 |
":rtype: ``float``") |
1154 |
.def("setDropStorage", &escript::SolverBuddy::setDropStorage, args("drop"),"Sets the maximum allowed increase in storage for ILUT. ``storage`` =2 would mean that a doubling of the storage needed for the coefficient matrix is\n" |
1155 |
"allowed in the ILUT factorization.\n\n" |
1156 |
":param storage: allowed storage increase\n" |
1157 |
":type storage: ``float``") |
1158 |
.def("getDropStorage", &escript::SolverBuddy::getDropStorage,"Returns the maximum allowed increase in storage for ILUT\n\n" |
1159 |
":rtype: ``float``") |
1160 |
.def("setRelaxationFactor", &escript::SolverBuddy::setRelaxationFactor, args("relaxation"),"Sets the relaxation factor used to add dropped elements in RILU to the main diagonal.\n\n" |
1161 |
":param factor: relaxation factor\n" |
1162 |
":type factor: ``float``\n" |
1163 |
":note: RILU with a relaxation factor 0 is identical to ILU0") |
1164 |
.def("getRelaxationFactor", &escript::SolverBuddy::getRelaxationFactor,"Returns the relaxation factor used to add dropped elements in RILU to the main diagonal.\n\n" |
1165 |
":rtype: ``float``") |
1166 |
.def("isSymmetric", &escript::SolverBuddy::isSymmetric,"Checks if symmetry of the coefficient matrix is indicated.\n\n" |
1167 |
":return: True if a symmetric PDE is indicated, False otherwise\n" |
1168 |
":rtype: ``bool``") |
1169 |
.def("setSymmetryOn", &escript::SolverBuddy::setSymmetryOn,"Sets the symmetry flag to indicate that the coefficient matrix is symmetric.") |
1170 |
.def("setSymmetryOff", &escript::SolverBuddy::setSymmetryOff,"Clears the symmetry flag for the coefficient matrix.") |
1171 |
.def("setSymmetry", &escript::SolverBuddy::setSymmetry, args("symmetry"),"Sets the symmetry flag for the coefficient matrix to ``flag``.\n\n" |
1172 |
":param flag: If True, the symmetry flag is set otherwise reset.\n" |
1173 |
":type flag: ``bool``") |
1174 |
.def("isVerbose", &escript::SolverBuddy::isVerbose,"Returns ``True`` if the solver is expected to be verbose.\n\n" |
1175 |
":return: True if verbosity of switched on.\n" |
1176 |
":rtype: ``bool``") |
1177 |
.def("setVerbosityOn", &escript::SolverBuddy::setVerbosityOn,"Switches the verbosity of the solver on.") |
1178 |
.def("setVerbosityOff", &escript::SolverBuddy::setVerbosityOff,"Switches the verbosity of the solver off.") |
1179 |
.def("setVerbosity", &escript::SolverBuddy::setVerbosity, args("verbosity"),"Sets the verbosity flag for the solver to ``flag``.\n\n" |
1180 |
":param verbose: If ``True``, the verbosity of the solver is switched on.\n" |
1181 |
":type verbose: ``bool``") |
1182 |
.def("adaptInnerTolerance", &escript::SolverBuddy::adaptInnerTolerance,"Returns ``True`` if the tolerance of the inner solver is selected automatically. Otherwise the inner tolerance set by `setInnerTolerance` is used.\n\n" |
1183 |
":return: ``True`` if inner tolerance adaption is chosen.\n" |
1184 |
":rtype: ``bool``") |
1185 |
.def("setInnerToleranceAdaptionOn", &escript::SolverBuddy::setInnerToleranceAdaptionOn,"Switches the automatic selection of inner tolerance on") |
1186 |
.def("setInnerToleranceAdaptionOff", &escript::SolverBuddy::setInnerToleranceAdaptionOff,"Switches the automatic selection of inner tolerance off.") |
1187 |
.def("setInnerToleranceAdaption", &escript::SolverBuddy::setInnerToleranceAdaption, args("adapt"),"Sets the flag to indicate automatic selection of the inner tolerance.\n\n" |
1188 |
":param adapt: If ``True``, the inner tolerance is selected automatically.\n" |
1189 |
":type adapt: ``bool``") |
1190 |
.def("acceptConvergenceFailure", &escript::SolverBuddy::acceptConvergenceFailure,"Returns ``True`` if a failure to meet the stopping criteria within the given number of iteration steps is not raising in exception. This is useful\n" |
1191 |
"if a solver is used in a non-linear context where the non-linear solver can continue even if the returned the solution does not necessarily meet the stopping criteria. One can use the `hasConverged` method to check if the\n" |
1192 |
"last call to the solver was successful.\n\n" |
1193 |
":return: ``True`` if a failure to achieve convergence is accepted.\n" |
1194 |
":rtype: ``bool``") |
1195 |
.def("setAcceptanceConvergenceFailureOn", &escript::SolverBuddy::setAcceptanceConvergenceFailureOn,"Switches the acceptance of a failure of convergence on") |
1196 |
.def("setAcceptanceConvergenceFailureOff", &escript::SolverBuddy::setAcceptanceConvergenceFailureOff,"Switches the acceptance of a failure of convergence off.") |
1197 |
.def("setAcceptanceConvergenceFailure", &escript::SolverBuddy::setAcceptanceConvergenceFailure, args("accept"),"Sets the flag to indicate the acceptance of a failure of convergence.\n\n" |
1198 |
":param accept: If ``True``, any failure to achieve convergence is accepted.\n" |
1199 |
":type accept: ``bool``") |
1200 |
.def("useLocalPreconditioner", &escript::SolverBuddy::useLocalPreconditioner,"Returns ``True`` if the preconditoner is applied locally on each MPI. This reduces communication costs and speeds up the application of the preconditioner but at the costs of more iteration steps. This can be an advantage on clusters with slower interconnects.\n\n" |
1201 |
":return: ``True`` if local preconditioning is applied\n" |
1202 |
":rtype: ``bool``") |
1203 |
.def("setLocalPreconditionerOn", &escript::SolverBuddy::setLocalPreconditionerOn,"Sets the flag to use local preconditioning to on") |
1204 |
.def("setLocalPreconditionerOff", &escript::SolverBuddy::setLocalPreconditionerOff,"Sets the flag to use local preconditioning to off") |
1205 |
.def("setLocalPreconditioner", &escript::SolverBuddy::setLocalPreconditioner, args("local"),"Sets the flag to use local preconditioning\n\n" |
1206 |
":param use: If ``True``, local preconditioning on each MPI rank is applied\n" |
1207 |
":type use: ``bool``") |
1208 |
.def("setMinCoarseMatrixSparsity", &escript::SolverBuddy::setMinCoarseMatrixSparsity, args("sparsity"),"Sets the minimum sparsity on the coarsest level. Typically a direct solver is used when the sparsity becomes bigger than the set limit.\n\n" |
1209 |
":param sparsity: minimal sparsity\n" |
1210 |
":type sparsity: ``float``") |
1211 |
.def("getMinCoarseMatrixSparsity", &escript::SolverBuddy::getMinCoarseMatrixSparsity,"Returns the minimum sparsity on the coarsest level. Typically a direct solver is used when the sparsity becomes bigger than the set limit.\n\n" |
1212 |
":return: minimal sparsity\n" |
1213 |
":rtype: ``float``") |
1214 |
.def("setNumRefinements", &escript::SolverBuddy::setNumRefinements, args("refinements"),"Sets the number of refinement steps to refine the solution when a direct solver is applied.\n\n" |
1215 |
":param refinements: number of refinements\n" |
1216 |
":type refinements: non-negative ``int``") |
1217 |
.def("getNumRefinements", &escript::SolverBuddy::getNumRefinements,"Returns the number of refinement steps to refine the solution when a direct solver is applied.\n\n" |
1218 |
":rtype: non-negative ``int``") |
1219 |
.def("setNumCoarseMatrixRefinements", &escript::SolverBuddy::setNumCoarseMatrixRefinements, args("refinements"),"Sets the number of refinement steps to refine the solution on the coarsest level when a direct solver is applied.\n\n" |
1220 |
":param refinements: number of refinements\n" |
1221 |
":type refinements: non-negative ``int``") |
1222 |
.def("getNumCoarseMatrixRefinements", &escript::SolverBuddy::getNumCoarseMatrixRefinements,"Returns the number of refinement steps to refine the solution on the coarsest level when a direct solver is applied.\n\n" |
1223 |
":rtype: non-negative ``int``") |
1224 |
.def("usePanel", &escript::SolverBuddy::usePanel,"Returns ``True`` if a panel is used to search for unknown in the AMG coarsening, The panel approach is normally faster but can lead to larger coarse level systems.\n\n" |
1225 |
":return: ``True`` if a panel is used to find unknowns in AMG coarsening\n" |
1226 |
":rtype: ``bool``") |
1227 |
.def("setUsePanelOn", &escript::SolverBuddy::setUsePanelOn,"Sets the flag to use a panel to find unknowns in AMG coarsening") |
1228 |
.def("setUsePanelOff", &escript::SolverBuddy::setUsePanelOff,"Sets the flag to use a panel to find unknowns in AMG coarsening to off") |
1229 |
.def("setUsePanel", &escript::SolverBuddy::setUsePanel, args("use"),"Sets the flag to use a panel to find unknowns in AMG coarsening\n\n" |
1230 |
":param use: If ``True``,a panel is used to find unknowns in AMG coarsening\n" |
1231 |
":type use: ``bool``") |
1232 |
.def("setAMGInterpolation", &escript::SolverBuddy::setAMGInterpolation, args("interpolation"),"Set the interpolation method for the AMG preconditioner.\n\n" |
1233 |
":param method: key of the interpolation method to be used.\n" |
1234 |
":type method: in `CLASSIC_INTERPOLATION_WITH_FF_COUPLING`, `CLASSIC_INTERPOLATION`, `DIRECT_INTERPOLATION`") |
1235 |
.def("getAMGInterpolation", &escript::SolverBuddy::getAMGInterpolation,"Returns key of the interpolation method for the SAMG preconditioner\n\n" |
1236 |
":rtype: in the list `CLASSIC_INTERPOLATION_WITH_FF_COUPLING`, `CLASSIC_INTERPOLATION`, `DIRECT_INTERPOLATION`") |
1237 |
.def("setODESolver", &escript::SolverBuddy::setODESolver, args("solver"),"Set the solver method for ODEs.\n\n" |
1238 |
":param method: key of the ODE solver method to be used.\n" |
1239 |
":type method: in `CRANK_NICOLSON`, `BACKWARD_EULER`, `LINEAR_CRANK_NICOLSON`") |
1240 |
.def("getODESolver", &escript::SolverBuddy::getODESolver,"Returns key of the solver method for ODEs.\n\n" |
1241 |
":param method: key of the ODE solver method to be used.\n" |
1242 |
":type method: in `CRANK_NICOLSON`, `BACKWARD_EULER`, `LINEAR_CRANK_NICOLSON`"); |
1243 |
|
1244 |
|
1245 |
// Functions to modify global parameters |
1246 |
def("setEscriptParamInt",escript::setEscriptParamInt, |
1247 |
(arg("name"), arg("value")=0), "Modify the value of an escript tuning parameter\n\n" |
1248 |
":param name:\n" |
1249 |
":type name: ``string``\n" |
1250 |
":param value:\n" |
1251 |
":type value: ``int``"); |
1252 |
def("getEscriptParamInt",escript::getEscriptParamInt, |
1253 |
(arg("name"),arg("sentinel")=0), "Read the value of an escript tuning parameter\n\n" |
1254 |
":param name: parameter to lookup\n" |
1255 |
":type name: ``string``\n" |
1256 |
":param sentinel: Value to be returned if ``name`` is not a known parameter\n" |
1257 |
":type sentinel: ``int``"); |
1258 |
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."); |
1259 |
|
1260 |
|
1261 |
def("resolveGroup", escript::resolveGroup); |
1262 |
|
1263 |
#ifdef IKNOWWHATIMDOING |
1264 |
|
1265 |
def("applyBinaryCFunction", escript::applyBinaryCFunction, (arg("function"), arg("outshape"), |
1266 |
arg("in1"), |
1267 |
arg("in2")) |
1268 |
); |
1269 |
#endif |
1270 |
|
1271 |
def("_condEval", escript::condEval, (arg("mask"), arg("trueval"), arg("falseval"))); |
1272 |
|
1273 |
// |
1274 |
// Register esysExceptionTranslator |
1275 |
// |
1276 |
register_exception_translator<esysUtils::EsysException>(&esysUtils::RuntimeErrorTranslator); |
1277 |
register_exception_translator<escript::SolverOptionsException>(&esysUtils::ValueErrorTranslator); |
1278 |
} |