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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (hide annotations)
Mon Sep 15 01:25:23 2014 UTC (5 years ago) by caltinay
File size: 22360 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

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

  ViewVC Help
Powered by ViewVC 1.1.26