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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3269 - (hide annotations)
Wed Oct 13 03:21:50 2010 UTC (8 years, 5 months ago) by jfenwick
Original Path: trunk/dudley/src/CPPAdapter/dudleycpp.cpp
File size: 14995 byte(s)
Fixed some intel compiler warnings.
Put linearPDEs back the way it was and present a common interface for dudley and finley (as per Lutz)

1 jgs 102
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 ksteube 1312
14 ksteube 1811
15 jfenwick 3231 #ifdef ESYS_MPI
16     #include "esysUtils/Esys_MPI.h"
17 ksteube 817 #endif
18 jgs 102 extern "C" {
19 jfenwick 3082 #include "../Dudley.h"
20 jgs 102 }
21 jgs 472
22 jgs 203 #include "MeshAdapter.h"
23     #include "MeshAdapterFactory.h"
24     #include "SystemMatrixAdapter.h"
25 gross 1364 #include "TransportProblemAdapter.h"
26 jgs 102
27 jfenwick 3086 #include "DudleyAdapterException.h"
28 gross 727 // #include "esysUtils/EsysException.h"
29 robwdcock 682 #include "esysUtils/esysExceptionTranslator.h"
30 jgs 102
31 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
32 jgs 102
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 jfenwick 2064 #include <boost/version.hpp>
38 jgs 102
39     using namespace boost::python;
40    
41     /**
42 jfenwick 3082 \page dudley Dudley
43 jfenwick 3086 Dudley is the python module name that contains the interfaces
44 jfenwick 3082 to the C++ wrapper to dudley.
45 jgs 102
46 jgs 121 \version 1.0.0
47 jgs 102
48 jgs 121 \section class_desc Class Description:
49 jgs 102 Data
50    
51 jgs 121 \section class_limits Class Limitations:
52 jgs 102 None
53    
54 jgs 121 \section class_conds Class Conditions of Use:
55 jgs 102 None
56    
57 jgs 121 \section throws Throws:
58 jgs 102 None
59    
60     */
61    
62 jfenwick 3082 BOOST_PYTHON_MODULE(dudleycpp)
63 jgs 102 {
64 jfenwick 2064 // This feature was added in boost v1.34
65 phornby 2076 #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
66 jfenwick 2061 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
67     docstring_options docopt(true, true, false);
68 jfenwick 2064 #endif
69 jgs 102
70     //
71     // NOTE: The return_value_policy is necessary for functions that
72     // return pointers.
73 gross 1382 //
74 jfenwick 3086 register_exception_translator<dudley::DudleyAdapterException>(&(esysUtils::esysExceptionTranslator));
75 jgs 102
76 jfenwick 3082 def("LoadMesh",dudley::loadMesh,
77 jfenwick 2625 (arg("fileName")="file.nc"),":rtype: `Domain`"
78 jfenwick 1872 /* ,return_value_policy<manage_new_object>());*/
79     );
80    
81 jfenwick 3082 def("ReadMesh",dudley::readMesh,
82 jfenwick 1872 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
83     /* ,return_value_policy<manage_new_object>());*/
84 jfenwick 2625 ,"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 jgs 102
91 jfenwick 3082 def("ReadGmsh",dudley::readGmsh,
92 gross 2722 (arg("fileName")="file.msh",
93     arg("numDim"),
94     arg("integrationOrder")=-1,
95     arg("reducedIntegrationOrder")=-1,
96     arg("optimize")=true,
97     arg("useMacroElements")=false)
98 jfenwick 1872 // ,return_value_policy<manage_new_object>());
99 jfenwick 2625 ,"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 gross 2722 ":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 gross 934
108 jfenwick 3082 def ("Brick",dudley::brick,
109 jgs 102 (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 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
114 ksteube 1312 arg("useElementsOnFace")=false,
115     arg("useFullElementOrder")=false,
116 jfenwick 1872 arg("optimize")=false)
117 jfenwick 2625 ,"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 gross 2722 ":param order: =1, =-1 or =2 gives the order of shape function. If -1 macro elements of order 1 are used.\n"
120 jfenwick 2625 ":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 gross 2722 ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``"
129 jfenwick 2625 );
130 jgs 102
131 jfenwick 3082 def ("Rectangle",dudley::rectangle,
132 jgs 102 (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 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
136 ksteube 1312 arg("useElementsOnFace")=false,
137     arg("useFullElementOrder")=false,
138 jfenwick 1872 arg("optimize")=false)
139 jfenwick 2625 ,"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 gross 2722 ":param order: =1, =-1 or =2 gives the order of shape function. If -1 macro elements of order 1 are used.\n"
142 jfenwick 2625 ":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 gross 2722 ":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 jgs 102
154 jfenwick 3082 class_<dudley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
155 jfenwick 3086 ("MeshAdapter","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<optional <Dudley_Mesh*> >())
156 jfenwick 3082 .def(init<const dudley::MeshAdapter&>())
157     .def("write",&dudley::MeshAdapter::write,args("filename"),
158 jfenwick 2625 "Write the current mesh to a file with the given name.")
159 jfenwick 3082 .def("print_mesh_info",&dudley::MeshAdapter::Print_Mesh_Info,(arg("full")=false),
160 jfenwick 2625 ":param full:\n:type full: ``bool``")
161 jfenwick 3082 .def("dump",&dudley::MeshAdapter::dump,args("fileName")
162 jfenwick 2625 ,"dumps the mesh to a file with the given name.")
163 jfenwick 3082 .def("getDescription",&dudley::MeshAdapter::getDescription,
164 jfenwick 2625 ":return: a description for this domain\n:rtype: ``string``")
165 jfenwick 3082 .def("getDim",&dudley::MeshAdapter::getDim,":rtype: ``int``")
166     .def("getDataShape",&dudley::MeshAdapter::getDataShape, args("functionSpaceCode"),
167 jfenwick 2625 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
168 jfenwick 3082 .def("getNumDataPointsGlobal",&dudley::MeshAdapter::getNumDataPointsGlobal,
169 jfenwick 2625 ":return: the number of data points summed across all MPI processes\n"
170     ":rtype: ``int``")
171 jfenwick 3082 .def("addPDEToSystem",&dudley::MeshAdapter::addPDEToSystem,
172 jfenwick 3269 args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
173 jfenwick 2625 "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 jfenwick 3269 ":param d_contact:\n:type d_contact: `Data`\n"
183     ":param y_contact:\n:type y_contact: `Data`\n"
184 jfenwick 2625 )
185 jfenwick 3082 .def("addPDEToLumpedSystem",&dudley::MeshAdapter::addPDEToLumpedSystem,
186 jfenwick 2625 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 jfenwick 3082 .def("addPDEToRHS",&dudley::MeshAdapter::addPDEToRHS,
192 jfenwick 2625 args("rhs", "X", "Y", "y", "y_contact"),
193     "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
194     ":param rhs:\n:type rhs: `Data`\n"
195     ":param X:\n:type X: `Data`\n"
196     ":param Y:\n:type Y: `Data`\n"
197     ":param y:\n:type y: `Data`\n"
198 jfenwick 3269 ":param y_contact:\n:type y_contact: `Data`"
199 jfenwick 2625 )
200 jfenwick 3082 .def("addPDEToTransportProblem",&dudley::MeshAdapter::addPDEToTransportProblem,
201 jfenwick 2625 args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
202     ":param tp:\n:type tp: `TransportProblemAdapter`\n"
203     ":param source:\n:type source: `Data`\n"
204     ":param M:\n:type M: `Data`\n"
205     ":param A:\n:type A: `Data`\n"
206     ":param B:\n:type B: `Data`\n"
207     ":param C:\n:type C: `Data`\n"
208     ":param D:\n:type D: `Data`\n"
209     ":param X:\n:type X: `Data`\n"
210     ":param Y:\n:type Y: `Data`\n"
211     ":param d:\n:type d: `Data`\n"
212     ":param y:\n:type y: `Data`\n"
213     ":param d_contact:\n:type d_contact: `Data`\n"
214     ":param y_contact:\n:type y_contact: `Data`\n"
215     )
216 jfenwick 3082 .def("newOperator",&dudley::MeshAdapter::newSystemMatrix,
217 jfenwick 2625 args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
218     "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
219     ":param row_blocksize:\n:type row_blocksize: ``int``\n"
220     ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
221     ":param column_blocksize:\n:type column_blocksize: ``int``\n"
222     ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
223     ":param type:\n:type type: ``int``\n"
224     )
225 jfenwick 3082 .def("newTransportProblem",&dudley::MeshAdapter::newTransportProblem,
226 jfenwick 2625 args("theta", "blocksize", "functionspace", "type"),
227     "creates a TransportProblemAdapter\n\n"
228     ":param theta:\n:type theta: ``float``\n"
229     ":param blocksize:\n:type blocksize: ``int``\n"
230     ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
231     ":param type:\n:type type: ``int``\n"
232     )
233 jfenwick 3082 .def("getSystemMatrixTypeId",&dudley::MeshAdapter::getSystemMatrixTypeId,
234 jfenwick 2625 args("solver", "preconditioner", "package", "symmetry"),
235     ":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"
236     ":rtype: ``int``\n"
237     ":param solver:\n:type solver: ``int``\n"
238     ":param preconditioner:\n:type preconditioner: ``int``\n"
239     ":param package:\n:type package: ``int``\n"
240     ":param symmetry:\n:type symmetry: ``int``\n"
241     )
242 jfenwick 3082 .def("getTransportTypeId",&dudley::MeshAdapter::getTransportTypeId,
243 jfenwick 2625 args("solver", "preconditioner", "package", "symmetry"),
244     ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"
245     ":rtype: ``int``\n"
246     ":param solver:\n:type solver: ``int``\n"
247     ":param preconditioner:\n:type preconditioner: ``int``\n"
248     ":param package:\n:type package: ``int``\n"
249     ":param symmetry:\n:type symmetry: ``int``\n"
250     )
251 jfenwick 3082 .def("setX",&dudley::MeshAdapter::setNewX,
252 jfenwick 2625 args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
253 jfenwick 3082 .def("getX",&dudley::MeshAdapter::getX, ":return: locations in the FEM nodes\n\n"
254 jfenwick 2625 ":rtype: `Data`")
255 jfenwick 3082 .def("getNormal",&dudley::MeshAdapter::getNormal,
256 jfenwick 2625 ":return: boundary normals at the quadrature point on the face elements\n"
257     ":rtype: `Data`")
258 jfenwick 3082 .def("getSize",&dudley::MeshAdapter::getSize,":return: the element size\n"
259 jfenwick 2625 ":rtype: `Data`")
260 jfenwick 3082 .def("saveDX",&dudley::MeshAdapter::saveDX,args("filename" ,"arg"),
261 jfenwick 2625 "Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier"
262     "\n\n:param filename: \n:type filename: ``string``\n"
263     "\n:param arg: \n:type arg: ``dict``\n")
264 jfenwick 3082 .def("saveVTK",&dudley::MeshAdapter::saveVTK,
265 jfenwick 2625 args("filename" ,"arg", "metadata", "metadata_schema"),
266     "Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier"
267     "\n\n:param filename:\n:type filename: ``string``\n"
268     ":param arg:\n:type arg: ``dict``\n"
269     ":param metadata:\n:type metadata: ``string``\n"
270     ":param metadata_schema:\n:type metadata_schema: ``string``\n"
271     )
272 jfenwick 3082 .def("setTagMap",&dudley::MeshAdapter::setTagMap,args("name","tag"),
273 jfenwick 2625 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
274     ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
275 jfenwick 3082 .def("getTag",&dudley::MeshAdapter::getTag,args("name"),":return: tag id for "
276 jfenwick 2625 "``name``\n:rtype: ``string``")
277 jfenwick 3082 .def("isValidTagName",&dudley::MeshAdapter::isValidTagName,args("name"),
278 jfenwick 2625 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
279 jfenwick 3082 .def("showTagNames",&dudley::MeshAdapter::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
280     .def("getMPISize",&dudley::MeshAdapter::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
281     .def("getMPIRank",&dudley::MeshAdapter::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
282     .def("MPIBarrier",&dudley::MeshAdapter::MPIBarrier,"Wait until all processes have reached this point")
283     .def("onMasterProcessor",&dudley::MeshAdapter::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
284 jgs 102
285 jfenwick 3082 class_<dudley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
286 jfenwick 2061 ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)
287 jfenwick 3082 .def("print_matrix_info",&dudley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false),"prints information about a system matrix")
288     .def("nullifyRowsAndCols",&dudley::SystemMatrixAdapter::nullifyRowsAndCols)
289     .def("resetValues",&dudley::SystemMatrixAdapter::resetValues, "resets the matrix entries")
290     .def("saveMM",&dudley::SystemMatrixAdapter::saveMM,args("fileName"),
291 jfenwick 2625 "writes the matrix to a file using the Matrix Market file format")
292 jfenwick 3082 .def("saveHB",&dudley::SystemMatrixAdapter::saveHB, args("filename"),
293 jfenwick 2625 "writes the matrix to a file using the Harwell-Boeing file format");
294 jgs 102
295 jfenwick 3082 class_<dudley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
296 jfenwick 2061 ("TransportProblemAdapter","",no_init)
297 jfenwick 3082 .def("getSafeTimeStepSize",&dudley::TransportProblemAdapter::getSafeTimeStepSize)
298     .def("getUnlimitedTimeStepSize",&dudley::TransportProblemAdapter::getUnlimitedTimeStepSize)
299     .def("resetTransport",&dudley::TransportProblemAdapter::resetTransport,
300 jfenwick 2625 "resets the transport operator typically as they have been updated");
301 jgs 102 }

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