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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3670 - (show annotations)
Wed Nov 16 02:21:18 2011 UTC (7 years, 5 months ago) by caltinay
Original Path: branches/ripleygmg_from_3668/ripley/src/ripleycpp.cpp
File size: 11025 byte(s)
First steps...

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2011 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14 #include <ripley/RipleyDomainFactory.h>
15 #include <esysUtils/esysExceptionTranslator.h>
16
17 #include <boost/python.hpp>
18 #include <boost/python/module.hpp>
19 #include <boost/python/def.hpp>
20 #include <boost/python/detail/defaults_gen.hpp>
21 #include <boost/version.hpp>
22
23 using namespace boost::python;
24
25 /**
26 \page ripley Ripley
27 Ripley is the python module name that contains the interfaces
28 to the C++ wrapper to ripley.
29
30 \version 1.0.0
31
32 \section class_desc Class Description:
33 None
34
35 \section class_limits Class Limitations:
36 None
37
38 \section class_conds Class Conditions of Use:
39 None
40
41 \section throws Throws:
42 None
43 */
44
45 BOOST_PYTHON_MODULE(ripleycpp)
46 {
47 // This feature was added in boost v1.34
48 #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
49 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
50 docstring_options docopt(true, true, false);
51 #endif
52
53 register_exception_translator<ripley::RipleyException>(&(esysUtils::esysExceptionTranslator));
54
55 def("LoadMesh",ripley::loadMesh, (arg("fileName")), ":rtype: `Domain`");
56
57 def("ReadMesh",ripley::readMesh, (arg("fileName"), arg("optimize")=true)
58 ,"Reads a mesh from a file. For MPI parallel runs the mesh is fanned out to multiple processes.\n\n"
59 ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
60 ":param optimize: Whether to optimize node labels\n:type optimize: ``bool``");
61
62 def("ReadGmsh",ripley::readGmsh,
63 (arg("fileName"), arg("numDim"), arg("optimize")=true)
64 ,"Reads a gmsh mesh file\n\n"
65 ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
66 ":param optimize: Whether to optimize node labels\n:type optimize: ``bool``\n");
67
68 def ("Brick", ripley::brick,
69 (arg("n0")=1, arg("n1")=1, arg("n2")=1,
70 arg("l0")=1.0, arg("l1")=1.0, arg("l2")=1.0,
71 arg("optimize")=false)
72 ,"Creates a rectangular mesh with n0 x n1 x n2 elements over the brick [0,l0] x [0,l1] x [0,l2]."
73 "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n:param n2:\n:type n2:\n"
74 ":param l0: length of side 0\n:param l1:\n:param l2:\n"
75 ":param optimize: Whether to optimize node labels\n:type optimize: ``bool``");
76
77 def ("Rectangle", ripley::rectangle,
78 (arg("n0")=1, arg("n1")=1, arg("l0")=1.0, arg("l1")=1.0,
79 arg("optimize")=false)
80 ,"Creates a rectangular mesh with n0 x n1 elements over the rectangle [0,l0] x [0,l1]."
81 "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n"
82 ":param l0: length of side 0\n:param l1:\n"
83 ":param optimize: Whether to optimize node labels\n:type optimize: ``bool``");
84
85 class_<ripley::RipleyDomain, bases<escript::AbstractContinuousDomain> >
86 ("RipleyDomain","A concrete class representing a domain. For more details, please consult the c++ documentation.", no_init)
87 .def(init<const ripley::RipleyDomain&>())
88 .def("write",&ripley::RipleyDomain::write,args("filename"),
89 "Write the current mesh to a file with the given name.")
90 .def("print_mesh_info",&ripley::RipleyDomain::Print_Mesh_Info,(arg("full")=false),
91 ":param full:\n:type full: ``bool``")
92 .def("dump",&ripley::RipleyDomain::dump,args("fileName")
93 ,"dumps the mesh to a file with the given name.")
94 .def("getDescription",&ripley::RipleyDomain::getDescription,
95 ":return: a description for this domain\n:rtype: ``string``")
96 .def("getDim",&ripley::RipleyDomain::getDim,":rtype: ``int``")
97 .def("getDataShape",&ripley::RipleyDomain::getDataShape, args("functionSpaceCode"),
98 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
99 .def("getNumDataPointsGlobal",&ripley::RipleyDomain::getNumDataPointsGlobal,
100 ":return: the number of data points summed across all MPI processes\n"
101 ":rtype: ``int``")
102 .def("addPDEToSystem",&ripley::RipleyDomain::addPDEToSystem,
103 args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
104 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
105 ":param mat:\n:type mat: `OperatorAdapter`\n:param rhs:\n:type rhs: `Data`\n"
106 ":param A:\n:type A: `Data`\n"
107 ":param B:\n:type B: `Data`\n"
108 ":param C:\n:type C: `Data`\n"
109 ":param D:\n:type D: `Data`\n"
110 ":param X:\n:type X: `Data`\n"
111 ":param Y:\n:type Y: `Data`\n"
112 ":param d:\n:type d: `Data`\n"
113 ":param d_contact:\n:type d_contact: `Data`\n"
114 ":param y_contact:\n:type y_contact: `Data`\n"
115 )
116 .def("addPDEToLumpedSystem",&ripley::RipleyDomain::addPDEToLumpedSystem,
117 args("mat", "D", "d"),
118 "adds a PDE onto the lumped stiffness matrix\n\n"
119 ":param mat:\n:type mat: `Data`\n"
120 ":param D:\n:type D: `Data`\n"
121 ":param d:\n:type d: `Data`\n"
122 ":param useHRZ:\n:type useHRZ: bool\n"
123 )
124 .def("addPDEToRHS",&ripley::RipleyDomain::addPDEToRHS,
125 args("rhs", "X", "Y", "y", "y_contact"),
126 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
127 ":param rhs:\n:type rhs: `Data`\n"
128 ":param X:\n:type X: `Data`\n"
129 ":param Y:\n:type Y: `Data`\n"
130 ":param y:\n:type y: `Data`\n"
131 ":param y_contact:\n:type y_contact: `Data`"
132 )
133 .def("addPDEToTransportProblem",&ripley::RipleyDomain::addPDEToTransportProblem,
134 args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
135 ":param tp:\n:type tp: `TransportProblemAdapter`\n"
136 ":param source:\n:type source: `Data`\n"
137 ":param M:\n:type M: `Data`\n"
138 ":param A:\n:type A: `Data`\n"
139 ":param B:\n:type B: `Data`\n"
140 ":param C:\n:type C: `Data`\n"
141 ":param D:\n:type D: `Data`\n"
142 ":param X:\n:type X: `Data`\n"
143 ":param Y:\n:type Y: `Data`\n"
144 ":param d:\n:type d: `Data`\n"
145 ":param y:\n:type y: `Data`\n"
146 ":param d_contact:\n:type d_contact: `Data`\n"
147 ":param y_contact:\n:type y_contact: `Data`\n"
148 )
149 .def("newOperator",&ripley::RipleyDomain::newSystemMatrix,
150 args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
151 "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
152 ":param row_blocksize:\n:type row_blocksize: ``int``\n"
153 ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
154 ":param column_blocksize:\n:type column_blocksize: ``int``\n"
155 ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
156 ":param type:\n:type type: ``int``\n"
157 )
158 .def("newTransportProblem",&ripley::RipleyDomain::newTransportProblem,
159 args("theta", "blocksize", "functionspace", "type"),
160 "creates a TransportProblemAdapter\n\n"
161 ":param theta:\n:type theta: ``float``\n"
162 ":param blocksize:\n:type blocksize: ``int``\n"
163 ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
164 ":param type:\n:type type: ``int``\n"
165 )
166 .def("getSystemMatrixTypeId",&ripley::RipleyDomain::getSystemMatrixTypeId,
167 args("solver", "preconditioner", "package", "symmetry"),
168 ":return: the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package, perconditioner, and symmetric matrix is used.\n"
169 ":rtype: ``int``\n"
170 ":param solver:\n:type solver: ``int``\n"
171 ":param preconditioner:\n:type preconditioner: ``int``\n"
172 ":param package:\n:type package: ``int``\n"
173 ":param symmetry:\n:type symmetry: ``int``\n"
174 )
175 .def("getTransportTypeId",&ripley::RipleyDomain::getTransportTypeId,
176 args("solver", "preconditioner", "package", "symmetry"),
177 ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"
178 ":rtype: ``int``\n"
179 ":param solver:\n:type solver: ``int``\n"
180 ":param preconditioner:\n:type preconditioner: ``int``\n"
181 ":param package:\n:type package: ``int``\n"
182 ":param symmetry:\n:type symmetry: ``int``\n"
183 )
184 .def("setX",&ripley::RipleyDomain::setNewX,
185 args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
186 .def("getX",&ripley::RipleyDomain::getX, ":return: locations in the FEM nodes\n\n"
187 ":rtype: `Data`")
188 .def("getNormal",&ripley::RipleyDomain::getNormal,
189 ":return: boundary normals at the quadrature point on the face elements\n"
190 ":rtype: `Data`")
191 .def("getSize",&ripley::RipleyDomain::getSize,":return: the element size\n"
192 ":rtype: `Data`")
193 .def("setTagMap",&ripley::RipleyDomain::setTagMap,args("name","tag"),
194 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
195 ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
196 .def("getTag",&ripley::RipleyDomain::getTag,args("name"),":return: tag id for "
197 "``name``\n:rtype: ``string``")
198 .def("isValidTagName",&ripley::RipleyDomain::isValidTagName,args("name"),
199 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
200 .def("showTagNames",&ripley::RipleyDomain::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
201 .def("getMPISize",&ripley::RipleyDomain::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
202 .def("getMPIRank",&ripley::RipleyDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
203 .def("MPIBarrier",&ripley::RipleyDomain::MPIBarrier,"Wait until all processes have reached this point")
204 .def("onMasterProcessor",&ripley::RipleyDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
205
206 class_<ripley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
207 ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)
208 .def("print_matrix_info",&ripley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false),"prints information about a system matrix")
209 .def("nullifyRowsAndCols",&ripley::SystemMatrixAdapter::nullifyRowsAndCols)
210 .def("resetValues",&ripley::SystemMatrixAdapter::resetValues, "resets the matrix entries")
211 .def("saveMM",&ripley::SystemMatrixAdapter::saveMM,args("fileName"),
212 "writes the matrix to a file using the Matrix Market file format")
213 .def("saveHB",&ripley::SystemMatrixAdapter::saveHB, args("filename"),
214 "writes the matrix to a file using the Harwell-Boeing file format");
215
216 class_<ripley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
217 ("TransportProblemAdapter","",no_init)
218 .def("getSafeTimeStepSize",&ripley::TransportProblemAdapter::getSafeTimeStepSize)
219 .def("getUnlimitedTimeStepSize",&ripley::TransportProblemAdapter::getUnlimitedTimeStepSize)
220 .def("resetTransport",&ripley::TransportProblemAdapter::resetTransport,
221 "resets the transport operator typically as they have been updated");
222 }
223

  ViewVC Help
Powered by ViewVC 1.1.26