/[escript]/trunk/ripley/src/ripleycpp.cpp
ViewVC logotype

Annotation of /trunk/ripley/src/ripleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5464 - (hide annotations)
Sat Feb 14 00:25:03 2015 UTC (4 years, 2 months ago) by jfenwick
File size: 22438 byte(s)
Fix for python compile warnings
1 caltinay 3670
2 jfenwick 3981 /*****************************************************************************
3 caltinay 3670 *
4 jfenwick 5448 * Copyright (c) 2003-2015 by University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 caltinay 3670 *
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 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 caltinay 3670
17 jfenwick 5464 #define ESNEEDPYTHON
18     #include "esysUtils/first.h"
19    
20 sshaw 4943 #include <ripley/AbstractAssembler.h>
21 caltinay 3691 #include <ripley/Brick.h>
22     #include <ripley/Rectangle.h>
23 caltinay 3670 #include <esysUtils/esysExceptionTranslator.h>
24    
25 sshaw 4906 #include <boost/python.hpp>
26 caltinay 3670 #include <boost/python/module.hpp>
27     #include <boost/python/def.hpp>
28     #include <boost/python/detail/defaults_gen.hpp>
29     #include <boost/version.hpp>
30    
31 jfenwick 4934 #include "escript/SubWorld.h"
32    
33 caltinay 3670 using namespace boost::python;
34    
35 caltinay 3691 namespace ripley {
36 caltinay 3670
37 caltinay 4616 template<typename T>
38     std::vector<T> extractPyArray(const object& obj, const std::string& name,
39     int expectedLength=0)
40     {
41     std::vector<T> result;
42     if (extract<tuple>(obj).check() || extract<list>(obj).check()) {
43     if (expectedLength==0 || len(obj)==expectedLength) {
44     for (int i=0; i<len(obj); i++) {
45     result.push_back(extract<T>(obj[i]));
46     }
47     } else {
48     std::stringstream ssError;
49     ssError << "argument '" << name << "' has wrong length";
50     std::string error(ssError.str());
51     throw RipleyException(error.c_str());
52     }
53     } else {
54     std::stringstream ssError;
55     ssError << "argument '" << name << "' must be a tuple or list";
56     std::string error(ssError.str());
57     throw RipleyException(error.c_str());
58     }
59    
60     return result;
61     }
62    
63 caltinay 3971 escript::Data readBinaryGrid(std::string filename, escript::FunctionSpace fs,
64 caltinay 4616 const object& pyShape, double fill, int byteOrder, int dataType,
65 caltinay 4277 const object& pyFirst, const object& pyNum, const object& pyMultiplier,
66 caltinay 4616 const object& pyReverse)
67 caltinay 3971 {
68     int dim=fs.getDim();
69 caltinay 4618 ReaderParameters params;
70 caltinay 3971
71 caltinay 5187 params.first = extractPyArray<dim_t>(pyFirst, "first", dim);
72     params.numValues = extractPyArray<dim_t>(pyNum, "numValues", dim);
73 caltinay 4616 params.multiplier = extractPyArray<int>(pyMultiplier, "multiplier", dim);
74     params.reverse = extractPyArray<int>(pyReverse, "reverse", dim);
75     params.byteOrder = byteOrder;
76     params.dataType = dataType;
77     std::vector<int> shape(extractPyArray<int>(pyShape, "shape"));
78 caltinay 3971
79     const RipleyDomain* dom=dynamic_cast<const RipleyDomain*>(fs.getDomain().get());
80     if (!dom)
81     throw RipleyException("Function space must be on a ripley domain");
82    
83     escript::Data res(fill, shape, fs, true);
84 caltinay 4615 dom->readBinaryGrid(res, filename, params);
85 caltinay 3971 return res;
86     }
87    
88 sshaw 4738 #ifdef USE_BOOSTIO
89     escript::Data readBinaryGridFromZipped(std::string filename, escript::FunctionSpace fs,
90     const object& pyShape, double fill, int byteOrder, int dataType,
91     const object& pyFirst, const object& pyNum, const object& pyMultiplier,
92     const object& pyReverse)
93     {
94     int dim=fs.getDim();
95     ReaderParameters params;
96    
97 caltinay 5187 params.first = extractPyArray<dim_t>(pyFirst, "first", dim);
98     params.numValues = extractPyArray<dim_t>(pyNum, "numValues", dim);
99 sshaw 4738 params.multiplier = extractPyArray<int>(pyMultiplier, "multiplier", dim);
100     params.reverse = extractPyArray<int>(pyReverse, "reverse", dim);
101     params.byteOrder = byteOrder;
102     params.dataType = dataType;
103     std::vector<int> shape(extractPyArray<int>(pyShape, "shape"));
104    
105     const RipleyDomain* dom=dynamic_cast<const RipleyDomain*>(fs.getDomain().get());
106     if (!dom)
107     throw RipleyException("Function space must be on a ripley domain");
108    
109     escript::Data res(fill, shape, fs, true);
110     dom->readBinaryGridFromZipped(res, filename, params);
111     return res;
112     }
113     #endif
114    
115 caltinay 4013 escript::Data readNcGrid(std::string filename, std::string varname,
116 caltinay 4616 escript::FunctionSpace fs, const object& pyShape, double fill,
117     const object& pyFirst, const object& pyNum, const object& pyMultiplier,
118     const object& pyReverse)
119 caltinay 4013 {
120     int dim=fs.getDim();
121 caltinay 4618 ReaderParameters params;
122 caltinay 4013
123 caltinay 5187 params.first = extractPyArray<dim_t>(pyFirst, "first", dim);
124     params.numValues = extractPyArray<dim_t>(pyNum, "numValues", dim);
125 caltinay 4616 params.multiplier = extractPyArray<int>(pyMultiplier, "multiplier", dim);
126     params.reverse = extractPyArray<int>(pyReverse, "reverse", dim);
127     std::vector<int> shape(extractPyArray<int>(pyShape, "shape"));
128 caltinay 4013
129     const RipleyDomain* dom=dynamic_cast<const RipleyDomain*>(fs.getDomain().get());
130     if (!dom)
131     throw RipleyException("Function space must be on a ripley domain");
132    
133     escript::Data res(fill, shape, fs, true);
134 caltinay 4615 dom->readNcGrid(res, filename, varname, params);
135 caltinay 4013 return res;
136     }
137    
138 caltinay 3691 // These wrappers are required to make the shared pointers work through the
139     // Python wrapper
140 caltinay 3670
141 jfenwick 3892 // The double for n? is just to keep python happy when people need to deal with
142 caltinay 3971 // truediv
143 jfenwick 3892 escript::Domain_ptr _brick(double _n0, double _n1, double _n2, const object& l0,
144 sshaw 4622 const object& l1, const object& l2, int d0, int d1, int d2,
145 jfenwick 4934 const object& objpoints, const object& objtags, escript::SubWorld_ptr world)
146 caltinay 3691 {
147 caltinay 5187 dim_t n0=static_cast<dim_t>(_n0), n1=static_cast<dim_t>(_n1), n2=static_cast<dim_t>(_n2);
148 caltinay 3781 double x0=0., x1=1., y0=0., y1=1., z0=0., z1=1.;
149     if (extract<tuple>(l0).check()) {
150     tuple x=extract<tuple>(l0);
151     if (len(x)==2) {
152     x0=extract<double>(x[0]);
153     x1=extract<double>(x[1]);
154     } else
155     throw RipleyException("Argument l0 must be a float or 2-tuple");
156     } else if (extract<double>(l0).check()) {
157     x1=extract<double>(l0);
158     } else
159     throw RipleyException("Argument l0 must be a float or 2-tuple");
160    
161     if (extract<tuple>(l1).check()) {
162     tuple y=extract<tuple>(l1);
163     if (len(y)==2) {
164     y0=extract<double>(y[0]);
165     y1=extract<double>(y[1]);
166     } else
167     throw RipleyException("Argument l1 must be a float or 2-tuple");
168     } else if (extract<double>(l1).check()) {
169     y1=extract<double>(l1);
170     } else
171     throw RipleyException("Argument l1 must be a float or 2-tuple");
172    
173     if (extract<tuple>(l2).check()) {
174     tuple z=extract<tuple>(l2);
175     if (len(z)==2) {
176     z0=extract<double>(z[0]);
177     z1=extract<double>(z[1]);
178     } else
179     throw RipleyException("Argument l2 must be a float or 2-tuple");
180     } else if (extract<double>(l2).check()) {
181     z1=extract<double>(l2);
182     } else
183     throw RipleyException("Argument l2 must be a float or 2-tuple");
184 sshaw 4622 boost::python::list pypoints=extract<boost::python::list>(objpoints);
185     boost::python::list pytags=extract<boost::python::list>(objtags);
186     int numpts=extract<int>(pypoints.attr("__len__")());
187     int numtags=extract<int>(pytags.attr("__len__")());
188     std::vector<double> points;
189     std::vector<int> tags;
190     tags.resize(numtags, -1);
191     for (int i=0;i<numpts;++i) {
192 sshaw 4828 tuple temp = extract<tuple>(pypoints[i]);
193 sshaw 4622 int l=extract<int>(temp.attr("__len__")());
194 sshaw 4828 if (l != 3)
195     throw RipleyException("Number of coordinates for each dirac point must match dimensions.");
196 sshaw 4622 for (int k=0;k<l;++k) {
197     points.push_back(extract<double>(temp[k]));
198     }
199     }
200     std::map<std::string, int> tagstonames;
201     int curmax=40;
202     // but which order to assign tags to names?????
203     for (int i=0;i<numtags;++i) {
204     extract<int> ex_int(pytags[i]);
205     extract<std::string> ex_str(pytags[i]);
206     if (ex_int.check()) {
207     tags[i]=ex_int();
208     if (tags[i]>= curmax) {
209     curmax=tags[i]+1;
210     }
211     } else if (ex_str.check()) {
212     std::string s=ex_str();
213     std::map<std::string, int>::iterator it=tagstonames.find(s);
214     if (it!=tagstonames.end()) {
215     // we have the tag already so look it up
216     tags[i]=it->second;
217     } else {
218     tagstonames[s]=curmax;
219     tags[i]=curmax;
220     curmax++;
221     }
222     } else {
223     throw RipleyException("Error - Unable to extract tag value.");
224     }
225     }
226 sshaw 4872 if (numtags != numpts)
227     throw RipleyException("Number of tags does not match number of points.");
228 sshaw 4622 return escript::Domain_ptr(new Brick(n0,n1,n2, x0,y0,z0, x1,y1,z1, d0,d1,d2,
229 jfenwick 4934 points, tags, tagstonames, world));
230 caltinay 3691 }
231 caltinay 3670
232 jfenwick 4779 //const int _q[]={0x61686969,0x746c4144,0x79616e43};
233     const int _q[]={0x62207363, 0x6574735F, 0x2020214e};
234 jfenwick 3892 escript::Domain_ptr _rectangle(double _n0, double _n1, const object& l0,
235 sshaw 4622 const object& l1, int d0, int d1,
236 jfenwick 4934 const object& objpoints, const object& objtags,
237     escript::SubWorld_ptr world
238     )
239 caltinay 3691 {
240 caltinay 5187 dim_t n0=static_cast<dim_t>(_n0), n1=static_cast<dim_t>(_n1);
241 caltinay 3781 double x0=0., x1=1., y0=0., y1=1.;
242     if (extract<tuple>(l0).check()) {
243     tuple x=extract<tuple>(l0);
244     if (len(x)==2) {
245     x0=extract<double>(x[0]);
246     x1=extract<double>(x[1]);
247     } else
248     throw RipleyException("Argument l0 must be a float or 2-tuple");
249     } else if (extract<double>(l0).check()) {
250     x1=extract<double>(l0);
251     } else
252     throw RipleyException("Argument l0 must be a float or 2-tuple");
253    
254     if (extract<tuple>(l1).check()) {
255     tuple y=extract<tuple>(l1);
256     if (len(y)==2) {
257     y0=extract<double>(y[0]);
258     y1=extract<double>(y[1]);
259     } else
260     throw RipleyException("Argument l1 must be a float or 2-tuple");
261     } else if (extract<double>(l1).check()) {
262     y1=extract<double>(l1);
263     } else
264     throw RipleyException("Argument l1 must be a float or 2-tuple");
265 sshaw 4622 boost::python::list pypoints=extract<boost::python::list>(objpoints);
266     boost::python::list pytags=extract<boost::python::list>(objtags);
267     int numpts=extract<int>(pypoints.attr("__len__")());
268     int numtags=extract<int>(pytags.attr("__len__")());
269     std::vector<double> points;
270     std::vector<int> tags;
271     tags.resize(numtags, -1);
272     for (int i=0;i<numpts;++i) {
273 sshaw 4828 tuple temp = extract<tuple>(pypoints[i]);
274 sshaw 4622 int l=extract<int>(temp.attr("__len__")());
275 sshaw 4828 if (l != 2)
276     throw RipleyException("Number of coordinates for each dirac point must match dimensions.");
277 sshaw 4622 for (int k=0;k<l;++k) {
278     points.push_back(extract<double>(temp[k]));
279     }
280     }
281     std::map<std::string, int> tagstonames;
282     int curmax=40;
283     // but which order to assign tags to names?????
284     for (int i=0;i<numtags;++i) {
285     extract<int> ex_int(pytags[i]);
286     extract<std::string> ex_str(pytags[i]);
287     if (ex_int.check()) {
288     tags[i]=ex_int();
289 caltinay 5187 if (tags[i] >= curmax) {
290 sshaw 4622 curmax=tags[i]+1;
291     }
292     } else if (ex_str.check()) {
293     std::string s=ex_str();
294     std::map<std::string, int>::iterator it=tagstonames.find(s);
295     if (it!=tagstonames.end()) {
296     // we have the tag already so look it up
297     tags[i]=it->second;
298     } else {
299     tagstonames[s]=curmax;
300     tags[i]=curmax;
301     curmax++;
302     }
303     } else {
304     throw RipleyException("Error - Unable to extract tag value.");
305     }
306     }
307 sshaw 4872 if (numtags != numpts)
308     throw RipleyException("Number of tags does not match number of points.");
309 sshaw 4622 return escript::Domain_ptr(new Rectangle(n0,n1, x0,y0, x1,y1, d0,d1,
310 jfenwick 4934 points, tags, tagstonames, world));
311 caltinay 3691 }
312 caltinay 3791 std::string _who(){int a[]={_q[0]^42,_q[1]^42,_q[2]^42,0};return (char*)&a[0];}
313 caltinay 3670
314 caltinay 4357 } // end of namespace ripley
315 caltinay 3670
316    
317     BOOST_PYTHON_MODULE(ripleycpp)
318     {
319     // This feature was added in boost v1.34
320     #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
321 caltinay 3691 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
322     docstring_options docopt(true, true, false);
323 caltinay 3670 #endif
324    
325 sshaw 4821 register_exception_translator<ripley::RipleyException>(&(esysUtils::RuntimeErrorTranslator));
326 caltinay 3670
327 caltinay 4174 scope().attr("__doc__") = "To use this module, please import esys.ripley";
328 caltinay 4357 scope().attr("BYTEORDER_NATIVE") = (int)ripley::BYTEORDER_NATIVE;
329     scope().attr("BYTEORDER_LITTLE_ENDIAN") = (int)ripley::BYTEORDER_LITTLE_ENDIAN;
330     scope().attr("BYTEORDER_BIG_ENDIAN") = (int)ripley::BYTEORDER_BIG_ENDIAN;
331     scope().attr("DATATYPE_INT32") = (int)ripley::DATATYPE_INT32;
332     scope().attr("DATATYPE_FLOAT32") = (int)ripley::DATATYPE_FLOAT32;
333     scope().attr("DATATYPE_FLOAT64") = (int)ripley::DATATYPE_FLOAT64;
334 caltinay 4174
335 jfenwick 4934 def("Brick", ripley::_brick, (arg("n0"),arg("n1"),arg("n2"),arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
336     arg("d0")=-1,arg("d1")=-1,arg("d2")=-1,arg("diracPoints")=list(),arg("diracTags")=list(), arg("escriptworld")=escript::SubWorld_ptr()),
337 caltinay 3691 "Creates a hexagonal mesh with n0 x n1 x n2 elements over the brick [0,l0] x [0,l1] x [0,l2].\n\n"
338     ":param n0: number of elements in direction 0\n:type n0: ``int``\n"
339     ":param n1: number of elements in direction 1\n:type n1: ``int``\n"
340     ":param n2: number of elements in direction 2\n:type n2: ``int``\n"
341 caltinay 3781 ":param l0: length of side 0 or coordinate range of side 0\n:type l0: ``float`` or ``tuple``\n"
342     ":param l1: length of side 1 or coordinate range of side 1\n:type l1: ``float`` or ``tuple``\n"
343     ":param l2: length of side 2 or coordinate range of side 2\n:type l2: ``float`` or ``tuple``\n"
344 caltinay 3691 ":param d0: number of subdivisions in direction 0\n:type d0: ``int``\n"
345     ":param d1: number of subdivisions in direction 1\n:type d1: ``int``\n"
346     ":param d2: number of subdivisions in direction 2\n:type d2: ``int``");
347 caltinay 3670
348 jfenwick 4934 def("Rectangle", ripley::_rectangle, (arg("n0"),arg("n1"),arg("l0")=1.0,arg("l1")=1.0,arg("d0")=-1,arg("d1")=-1,arg("diracPoints")=list(),arg("diracTags")=list(), arg("escriptworld")=escript::SubWorld_ptr()),
349 caltinay 3691 "Creates a rectangular mesh with n0 x n1 elements over the rectangle [0,l0] x [0,l1].\n\n"
350     ":param n0: number of elements in direction 0\n:type n0: ``int``\n"
351     ":param n1: number of elements in direction 1\n:type n1: ``int``\n"
352 caltinay 3781 ":param l0: length of side 0 or coordinate range of side 0\n:type l0: ``float`` or ``tuple``\n"
353     ":param l1: length of side 1 or coordinate range of side 1\n:type l1: ``float`` or ``tuple``\n"
354 caltinay 3691 ":param d0: number of subdivisions in direction 0\n:type d0: ``int``\n"
355     ":param d1: number of subdivisions in direction 1\n:type d1: ``int``");
356 caltinay 3971 def("_theculprit_", ripley::_who);
357 caltinay 3670
358 caltinay 5077 def("readBinaryGrid", &ripley::readBinaryGrid, (arg("filename"),
359 caltinay 4616 arg("functionspace"), arg("shape"), arg("fill")=0.,
360     arg("byteOrder"), arg("dataType"), arg("first"),
361     arg("numValues"), arg("multiplier"), arg("reverse")),
362     "Reads a binary Grid");
363 sshaw 4738 #ifdef USE_BOOSTIO
364     def("_readBinaryGridFromZipped", &ripley::readBinaryGridFromZipped, (arg("filename"),
365     arg("functionspace"), arg("shape"), arg("fill")=0.,
366     arg("byteOrder"), arg("dataType"), arg("first"),
367     arg("numValues"), arg("multiplier"), arg("reverse")),
368     "Reads a binary Grid");
369     #endif
370 caltinay 4616 def("_readNcGrid", &ripley::readNcGrid, (arg("filename"), arg("varname"),
371     arg("functionspace"), arg("shape"), arg("fill"), arg("first"),
372     arg("numValues"), arg("multiplier"), arg("reverse")),
373     "Reads a grid from a netCDF file");
374 caltinay 4013
375 jfenwick 4242 class_<ripley::RipleyDomain, bases<escript::AbstractContinuousDomain>, boost::noncopyable >
376 caltinay 3691 ("RipleyDomain", "", no_init)
377     .def("print_mesh_info", &ripley::RipleyDomain::Print_Mesh_Info, (arg("full")=false),
378     "Prints out a summary about the mesh.\n"
379     ":param full: whether to output additional data\n:type full: ``bool``")
380 caltinay 4357 .def("writeBinaryGrid", &ripley::RipleyDomain::writeBinaryGrid)
381    
382 caltinay 3691 .def("dump", &ripley::RipleyDomain::dump, args("filename"),
383     "Dumps the mesh to a file with the given name.")
384 caltinay 4340 .def("getGridParameters", &ripley::RipleyDomain::getGridParameters,
385     "Returns the tuple (origin, spacing, elements) where the entries are tuples:\n"
386     "``origin``=the coordinates of the domain's global origin,\n"
387     "``spacing``=the element size (=node spacing) of the domain,\n"
388     "``elements``=the global number of elements in all dimensions\n\n"
389     ":rtype: ``tuple``")
390 caltinay 3691 .def("getDescription", &ripley::RipleyDomain::getDescription,
391 caltinay 3670 ":return: a description for this domain\n:rtype: ``string``")
392 caltinay 3691 .def("getDim", &ripley::RipleyDomain::getDim, ":rtype: ``int``")
393     .def("getDataShape", &ripley::RipleyDomain::getDataShape, args("functionSpaceCode"),
394 caltinay 3670 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
395 caltinay 3691 .def("getNumDataPointsGlobal", &ripley::RipleyDomain::getNumDataPointsGlobal,
396 caltinay 3670 ":return: the number of data points summed across all MPI processes\n"
397     ":rtype: ``int``")
398 sshaw 4622 .def("addToSystem",&ripley::RipleyDomain::addToSystemFromPython,
399     args("mat", "rhs", "data"),
400     "adds a PDE to the system, results depend on domain\n\n"
401     ":param mat:\n:type mat: `OperatorAdapter`\n"
402     ":param rhs:\n:type rhs: `Data`\n"
403     ":param data:\ntype data: `list`")
404     .def("addToRHS",&ripley::RipleyDomain::addToRHSFromPython,
405     args("rhs", "data"),
406     "adds a PDE onto the stiffness matrix mat and a rhs, "
407     "results depends on domain\n\n"
408     ":param rhs:\n:type rhs: `Data`\n"
409     ":param data:\ntype data: `list`")
410 sshaw 4942 .def("createAssembler", &ripley::RipleyDomain::createAssemblerFromPython,
411 sshaw 4622 args("typename", "options"),
412 sshaw 4942 "request from the domain an assembler of the specified type, if "
413     "supported, using the supplied options (if provided)"
414 sshaw 4622 ":param typename:\n:type typename: `string`\n"
415     ":param options:\n:type options: `list`\n")
416 sshaw 4942 .def("addPDEToTransportProblem",&ripley::RipleyDomain::addPDEToTransportProblemFromPython,
417     args("tp", "source", "data"),
418     ":param tp:\n:type tp: `TransportProblemAdapter`\n"
419     ":param source:\n:type source: `Data`\n"
420     ":param data:\ntype data: `list`")
421 caltinay 3691 .def("newOperator",&ripley::RipleyDomain::newSystemMatrix,
422 caltinay 3670 args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
423     "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
424     ":param row_blocksize:\n:type row_blocksize: ``int``\n"
425     ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
426     ":param column_blocksize:\n:type column_blocksize: ``int``\n"
427     ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
428 caltinay 3791 ":param type:\n:type type: ``int``"
429 caltinay 3670 )
430 caltinay 3691 .def("newTransportProblem",&ripley::RipleyDomain::newTransportProblem,
431 caltinay 3670 args("theta", "blocksize", "functionspace", "type"),
432     "creates a TransportProblemAdapter\n\n"
433     ":param theta:\n:type theta: ``float``\n"
434     ":param blocksize:\n:type blocksize: ``int``\n"
435     ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
436 caltinay 3791 ":param type:\n:type type: ``int``"
437 caltinay 3670 )
438 caltinay 3691 .def("getSystemMatrixTypeId",&ripley::RipleyDomain::getSystemMatrixTypeId,
439 caltinay 5148 args("options"),
440     ":return: the identifier of the matrix type to be used for the global stiffness matrix when particular solver options are used.\n"
441 caltinay 3670 ":rtype: ``int``\n"
442 caltinay 5148 ":param options:\n:type options: `SolverBuddy`\n"
443 caltinay 3670 )
444 caltinay 3691 .def("getTransportTypeId",&ripley::RipleyDomain::getTransportTypeId,
445 caltinay 3670 args("solver", "preconditioner", "package", "symmetry"),
446 caltinay 3697 ":return: the identifier of the transport problem type to be used when a particular solver, preconditioner, package and symmetric matrix is used.\n"
447 caltinay 3670 ":rtype: ``int``\n"
448     ":param solver:\n:type solver: ``int``\n"
449     ":param preconditioner:\n:type preconditioner: ``int``\n"
450     ":param package:\n:type package: ``int``\n"
451 caltinay 3791 ":param symmetry:\n:type symmetry: ``int``"
452 caltinay 3670 )
453 caltinay 3691 .def("getX",&ripley::RipleyDomain::getX, ":return: locations in the FEM nodes\n\n"
454 caltinay 3670 ":rtype: `Data`")
455 caltinay 3691 .def("getNormal",&ripley::RipleyDomain::getNormal,
456 caltinay 3670 ":return: boundary normals at the quadrature point on the face elements\n"
457     ":rtype: `Data`")
458 caltinay 3691 .def("getSize",&ripley::RipleyDomain::getSize,":return: the element size\n"
459 caltinay 3670 ":rtype: `Data`")
460 caltinay 3691 .def("setTagMap",&ripley::RipleyDomain::setTagMap,args("name","tag"),
461 caltinay 3670 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
462     ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
463 caltinay 3691 .def("getTag",&ripley::RipleyDomain::getTag,args("name"),":return: tag id for "
464 caltinay 3670 "``name``\n:rtype: ``string``")
465 caltinay 3691 .def("isValidTagName",&ripley::RipleyDomain::isValidTagName,args("name"),
466     ":return: True if ``name`` corresponds to a tag, otherwise False\n:rtype: ``bool``")
467     .def("showTagNames",&ripley::RipleyDomain::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
468     .def("getMPISize",&ripley::RipleyDomain::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
469     .def("getMPIRank",&ripley::RipleyDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
470     .def("MPIBarrier",&ripley::RipleyDomain::MPIBarrier,"Wait until all processes have reached this point")
471     .def("onMasterProcessor",&ripley::RipleyDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
472 jfenwick 4825 /* These two class exports are necessary to ensure that the extra methods added by ripley make it to python.
473     * This change became necessary when the Brick and Rectangle constructors turned into factories instead of classes */
474 jfenwick 4687 class_<ripley::Brick, bases<ripley::RipleyDomain> >("RipleyBrick", "", no_init);
475     class_<ripley::Rectangle, bases<ripley::RipleyDomain> >("RipleyRectangle", "", no_init);
476 sshaw 4943 class_<ripley::AbstractAssembler, ripley::Assembler_ptr, boost::noncopyable >
477     ("AbstractAssembler", "", no_init);
478 caltinay 3670 }
479    

  ViewVC Help
Powered by ViewVC 1.1.26