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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26