/[escript]/trunk/dudley/src/CPPAdapter/dudleycpp.cpp
ViewVC logotype

Contents of /trunk/dudley/src/CPPAdapter/dudleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3379 - (show annotations)
Wed Nov 24 04:48:49 2010 UTC (8 years ago) by gross
File size: 15035 byte(s)
some clarification on lumping
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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
15 #ifdef ESYS_MPI
16 #include "esysUtils/Esys_MPI.h"
17 #endif
18 extern "C" {
19 #include "../Dudley.h"
20 }
21
22 #include "MeshAdapter.h"
23 #include "MeshAdapterFactory.h"
24 #include "SystemMatrixAdapter.h"
25 #include "TransportProblemAdapter.h"
26
27 #include "DudleyAdapterException.h"
28 // #include "esysUtils/EsysException.h"
29 #include "esysUtils/esysExceptionTranslator.h"
30
31 #include "escript/AbstractContinuousDomain.h"
32
33 #include <boost/python.hpp>
34 #include <boost/python/module.hpp>
35 #include <boost/python/def.hpp>
36 #include <boost/python/detail/defaults_gen.hpp>
37 #include <boost/version.hpp>
38
39 using namespace boost::python;
40
41 /**
42 \page dudley Dudley
43 Dudley is the python module name that contains the interfaces
44 to the C++ wrapper to dudley.
45
46 \version 1.0.0
47
48 \section class_desc Class Description:
49 Data
50
51 \section class_limits Class Limitations:
52 None
53
54 \section class_conds Class Conditions of Use:
55 None
56
57 \section throws Throws:
58 None
59
60 */
61
62 BOOST_PYTHON_MODULE(dudleycpp)
63 {
64 // This feature was added in boost v1.34
65 #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
66 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
67 docstring_options docopt(true, true, false);
68 #endif
69
70 //
71 // NOTE: The return_value_policy is necessary for functions that
72 // return pointers.
73 //
74 register_exception_translator<dudley::DudleyAdapterException>(&(esysUtils::esysExceptionTranslator));
75
76 def("LoadMesh",dudley::loadMesh,
77 (arg("fileName")="file.nc"),":rtype: `Domain`"
78 /* ,return_value_policy<manage_new_object>());*/
79 );
80
81 def("ReadMesh",dudley::readMesh,
82 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
83 /* ,return_value_policy<manage_new_object>());*/
84 ,"Read a mesh from a file. For MPI parallel runs fan out the mesh to multiple processes.\n\n"
85 ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
86 ":param integrationOrder: order of the quadrature scheme. If *integrationOrder<0* the integration order is selected independently.\n"
87 ":type integrationOrder: ``int``\n"
88 ":param reducedIntegrationOrder: order of the quadrature scheme. If *reducedIntegrationOrder<0* the integration order is selected independently.\n"
89 ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``");
90
91 def("ReadGmsh",dudley::readGmsh,
92 (arg("fileName")="file.msh",
93 arg("numDim"),
94 arg("integrationOrder")=-1,
95 arg("reducedIntegrationOrder")=-1,
96 arg("optimize")=true,
97 arg("useMacroElements")=false)
98 // ,return_value_policy<manage_new_object>());
99 ,"Read a gmsh mesh file\n\n"
100 ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
101 ":param integrationOrder: order of the quadrature scheme. If *integrationOrder<0* the integration order is selected independently.\n"
102 ":type integrationOrder: ``int``\n"
103 ":param reducedIntegrationOrder: order of the quadrature scheme. If *reducedIntegrationOrder<0* the integration order is selected independently.\n"
104 ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``\n"
105 ":param useMacroElements: Enable the usage of macro elements instead of second order elements.\n:type useMacroElements: ``bool``"
106 );
107
108 def ("Brick",dudley::brick,
109 (arg("n0")=1,arg("n1")=1,arg("n2")=1,
110 arg("order")=1,
111 arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
112 arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
113 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
114 arg("useElementsOnFace")=false,
115 arg("useFullElementOrder")=false,
116 arg("optimize")=false)
117 ,"Creates a rectangular mesh with n0 x n1 x n2 elements over the brick [0,l0] x [0,l1] x [0,l2]."
118 "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n:param n2:\n:type n2:\n"
119 ":param order: =1, =-1 or =2 gives the order of shape function. If -1 macro elements of order 1 are used.\n"
120 ":param l0: length of side 0\n:param l1:\n:param l2:\n"
121 ":param integrationOrder: order of the quadrature scheme. If integrationOrder<0 the integration order is selected independently.\n"
122 ":param reducedIntegrationOrder: order of the quadrature scheme. If reducedIntegrationOrder<0 the integration order is selected independently.\n"
123 ":param useElementsOnFace: whether or not to use elements on face\n"
124 ":type useElementsOnFace: ``int``"
125 ":param periodic0: whether or not boundary conditions are periodic\n"
126 ":param periodic1:\n:param periodic2:\n"
127 ":param useFullElementOrder:\n:param optimize:\n"
128 ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``"
129 );
130
131 def ("Rectangle",dudley::rectangle,
132 (arg("n0")=1,arg("n1")=1,arg("order")=1,
133 arg("l0")=1.0,arg("l1")=1.0,
134 arg("periodic0")=false,arg("periodic1")=false,
135 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
136 arg("useElementsOnFace")=false,
137 arg("useFullElementOrder")=false,
138 arg("optimize")=false)
139 ,"Creates a rectangular mesh with n0 x n1 elements over the brick [0,l0] x [0,l1]."
140 "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n"
141 ":param order: =1, =-1 or =2 gives the order of shape function. If -1 macro elements of order 1 are used.\n"
142 ":param l0: length of side 0\n:param l1:\n"
143 ":param integrationOrder: order of the quadrature scheme. If integrationOrder<0 the integration order is selected independently.\n"
144 ":param reducedIntegrationOrder: order of the quadrature scheme. If reducedIntegrationOrder<0 the integration order is selected independently.\n"
145 ":param useElementsOnFace: whether or not to use elements on face\n"
146 ":type useElementsOnFace: ``int``"
147 ":param periodic0: whether or not boundary conditions are periodic\n"
148 ":param periodic1:\n"
149 ":param useFullElementOrder:\n:param optimize:\n"
150 ":param useMacroElements: Enable the usage of first order macro elements.\n:type useMacroElements: ``bool``\n"
151 ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``"
152 );
153
154 class_<dudley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
155 ("MeshAdapter","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<optional <Dudley_Mesh*> >())
156 .def(init<const dudley::MeshAdapter&>())
157 .def("write",&dudley::MeshAdapter::write,args("filename"),
158 "Write the current mesh to a file with the given name.")
159 .def("print_mesh_info",&dudley::MeshAdapter::Print_Mesh_Info,(arg("full")=false),
160 ":param full:\n:type full: ``bool``")
161 .def("dump",&dudley::MeshAdapter::dump,args("fileName")
162 ,"dumps the mesh to a file with the given name.")
163 .def("getDescription",&dudley::MeshAdapter::getDescription,
164 ":return: a description for this domain\n:rtype: ``string``")
165 .def("getDim",&dudley::MeshAdapter::getDim,":rtype: ``int``")
166 .def("getDataShape",&dudley::MeshAdapter::getDataShape, args("functionSpaceCode"),
167 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
168 .def("getNumDataPointsGlobal",&dudley::MeshAdapter::getNumDataPointsGlobal,
169 ":return: the number of data points summed across all MPI processes\n"
170 ":rtype: ``int``")
171 .def("addPDEToSystem",&dudley::MeshAdapter::addPDEToSystem,
172 args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
173 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
174 ":param mat:\n:type mat: `OperatorAdapter`\n:param rhs:\n:type rhs: `Data`\n"
175 ":param A:\n:type A: `Data`\n"
176 ":param B:\n:type B: `Data`\n"
177 ":param C:\n:type C: `Data`\n"
178 ":param D:\n:type D: `Data`\n"
179 ":param X:\n:type X: `Data`\n"
180 ":param Y:\n:type Y: `Data`\n"
181 ":param d:\n:type d: `Data`\n"
182 ":param d_contact:\n:type d_contact: `Data`\n"
183 ":param y_contact:\n:type y_contact: `Data`\n"
184 )
185 .def("addPDEToLumpedSystem",&dudley::MeshAdapter::addPDEToLumpedSystem,
186 args("mat", "D", "d"),
187 "adds a PDE onto the lumped stiffness matrix\n\n"
188 ":param mat:\n:type mat: `Data`\n"
189 ":param D:\n:type D: `Data`\n"
190 ":param d:\n:type d: `Data`\n"
191 ":param useHRZ:\n:type useHRZ: bool\n"
192 )
193 .def("addPDEToRHS",&dudley::MeshAdapter::addPDEToRHS,
194 args("rhs", "X", "Y", "y", "y_contact"),
195 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
196 ":param rhs:\n:type rhs: `Data`\n"
197 ":param X:\n:type X: `Data`\n"
198 ":param Y:\n:type Y: `Data`\n"
199 ":param y:\n:type y: `Data`\n"
200 ":param y_contact:\n:type y_contact: `Data`"
201 )
202 .def("addPDEToTransportProblem",&dudley::MeshAdapter::addPDEToTransportProblem,
203 args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
204 ":param tp:\n:type tp: `TransportProblemAdapter`\n"
205 ":param source:\n:type source: `Data`\n"
206 ":param M:\n:type M: `Data`\n"
207 ":param A:\n:type A: `Data`\n"
208 ":param B:\n:type B: `Data`\n"
209 ":param C:\n:type C: `Data`\n"
210 ":param D:\n:type D: `Data`\n"
211 ":param X:\n:type X: `Data`\n"
212 ":param Y:\n:type Y: `Data`\n"
213 ":param d:\n:type d: `Data`\n"
214 ":param y:\n:type y: `Data`\n"
215 ":param d_contact:\n:type d_contact: `Data`\n"
216 ":param y_contact:\n:type y_contact: `Data`\n"
217 )
218 .def("newOperator",&dudley::MeshAdapter::newSystemMatrix,
219 args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
220 "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
221 ":param row_blocksize:\n:type row_blocksize: ``int``\n"
222 ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
223 ":param column_blocksize:\n:type column_blocksize: ``int``\n"
224 ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
225 ":param type:\n:type type: ``int``\n"
226 )
227 .def("newTransportProblem",&dudley::MeshAdapter::newTransportProblem,
228 args("theta", "blocksize", "functionspace", "type"),
229 "creates a TransportProblemAdapter\n\n"
230 ":param theta:\n:type theta: ``float``\n"
231 ":param blocksize:\n:type blocksize: ``int``\n"
232 ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
233 ":param type:\n:type type: ``int``\n"
234 )
235 .def("getSystemMatrixTypeId",&dudley::MeshAdapter::getSystemMatrixTypeId,
236 args("solver", "preconditioner", "package", "symmetry"),
237 ":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"
238 ":rtype: ``int``\n"
239 ":param solver:\n:type solver: ``int``\n"
240 ":param preconditioner:\n:type preconditioner: ``int``\n"
241 ":param package:\n:type package: ``int``\n"
242 ":param symmetry:\n:type symmetry: ``int``\n"
243 )
244 .def("getTransportTypeId",&dudley::MeshAdapter::getTransportTypeId,
245 args("solver", "preconditioner", "package", "symmetry"),
246 ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"
247 ":rtype: ``int``\n"
248 ":param solver:\n:type solver: ``int``\n"
249 ":param preconditioner:\n:type preconditioner: ``int``\n"
250 ":param package:\n:type package: ``int``\n"
251 ":param symmetry:\n:type symmetry: ``int``\n"
252 )
253 .def("setX",&dudley::MeshAdapter::setNewX,
254 args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
255 .def("getX",&dudley::MeshAdapter::getX, ":return: locations in the FEM nodes\n\n"
256 ":rtype: `Data`")
257 .def("getNormal",&dudley::MeshAdapter::getNormal,
258 ":return: boundary normals at the quadrature point on the face elements\n"
259 ":rtype: `Data`")
260 .def("getSize",&dudley::MeshAdapter::getSize,":return: the element size\n"
261 ":rtype: `Data`")
262 .def("saveDX",&dudley::MeshAdapter::saveDX,args("filename" ,"arg"),
263 "Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier"
264 "\n\n:param filename: \n:type filename: ``string``\n"
265 "\n:param arg: \n:type arg: ``dict``\n")
266 .def("saveVTK",&dudley::MeshAdapter::saveVTK,
267 args("filename" ,"arg", "metadata", "metadata_schema"),
268 "Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier"
269 "\n\n:param filename:\n:type filename: ``string``\n"
270 ":param arg:\n:type arg: ``dict``\n"
271 ":param metadata:\n:type metadata: ``string``\n"
272 ":param metadata_schema:\n:type metadata_schema: ``string``\n"
273 )
274 .def("setTagMap",&dudley::MeshAdapter::setTagMap,args("name","tag"),
275 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
276 ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
277 .def("getTag",&dudley::MeshAdapter::getTag,args("name"),":return: tag id for "
278 "``name``\n:rtype: ``string``")
279 .def("isValidTagName",&dudley::MeshAdapter::isValidTagName,args("name"),
280 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
281 .def("showTagNames",&dudley::MeshAdapter::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
282 .def("getMPISize",&dudley::MeshAdapter::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
283 .def("getMPIRank",&dudley::MeshAdapter::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
284 .def("MPIBarrier",&dudley::MeshAdapter::MPIBarrier,"Wait until all processes have reached this point")
285 .def("onMasterProcessor",&dudley::MeshAdapter::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
286
287 class_<dudley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
288 ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)
289 .def("print_matrix_info",&dudley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false),"prints information about a system matrix")
290 .def("nullifyRowsAndCols",&dudley::SystemMatrixAdapter::nullifyRowsAndCols)
291 .def("resetValues",&dudley::SystemMatrixAdapter::resetValues, "resets the matrix entries")
292 .def("saveMM",&dudley::SystemMatrixAdapter::saveMM,args("fileName"),
293 "writes the matrix to a file using the Matrix Market file format")
294 .def("saveHB",&dudley::SystemMatrixAdapter::saveHB, args("filename"),
295 "writes the matrix to a file using the Harwell-Boeing file format");
296
297 class_<dudley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
298 ("TransportProblemAdapter","",no_init)
299 .def("getSafeTimeStepSize",&dudley::TransportProblemAdapter::getSafeTimeStepSize)
300 .def("getUnlimitedTimeStepSize",&dudley::TransportProblemAdapter::getUnlimitedTimeStepSize)
301 .def("resetTransport",&dudley::TransportProblemAdapter::resetTransport,
302 "resets the transport operator typically as they have been updated");
303 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/lapack2681/finley/src/CPPAdapter/finleycpp.cpp:2682-2741 /branches/restext/finley/src/CPPAdapter/finleycpp.cpp:2610-2624 /branches/stage3.0/finley/src/CPPAdapter/finleycpp.cpp:2569-2590 /release/3.0/finley/src/CPPAdapter/finleycpp.cpp:2591-2601

  ViewVC Help
Powered by ViewVC 1.1.26