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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4934 - (hide annotations)
Tue May 13 00:28:11 2014 UTC (5 years, 4 months ago) by jfenwick
File size: 23664 byte(s)
This commit is brought to you by the number 4934 and the tool "meld".
Merge of partially complete split world code from branch.



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

  ViewVC Help
Powered by ViewVC 1.1.26