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

Contents of /branches/diaplayground/dudley/src/CPPAdapter/dudleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

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/pasowrap/dudley/src/CPPAdapter/dudleycpp.cpp:3661-3674 /branches/py3_attempt2/dudley/src/CPPAdapter/dudleycpp.cpp:3871-3891 /branches/restext/finley/src/CPPAdapter/finleycpp.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/CPPAdapter/dudleycpp.cpp:3669-3791 /branches/stage3.0/finley/src/CPPAdapter/finleycpp.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/CPPAdapter/dudleycpp.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/CPPAdapter/dudleycpp.cpp:3517-3974 /release/3.0/finley/src/CPPAdapter/finleycpp.cpp:2591-2601 /trunk/ripley/test/python/dudley/src/CPPAdapter/dudleycpp.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26