/[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 3991 - (hide annotations)
Tue Sep 25 23:52:22 2012 UTC (6 years, 6 months ago) by caltinay
Original Path: trunk/dudley/src/CPPAdapter/dudleycpp.cpp
File size: 13808 byte(s)
Updated doxygen cfg file and made a few first changes to doco.

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

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