/[escript]/branches/subworld2/escriptcore/src/escriptcpp.cpp
ViewVC logotype

Contents of /branches/subworld2/escriptcore/src/escriptcpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26