/[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 4934 - (hide annotations)
Tue May 13 00:28:11 2014 UTC (4 years, 11 months ago) by jfenwick
Original Path: trunk/dudley/src/CPPAdapter/dudleycpp.cpp
File size: 13372 byte(s)
This commit is brought to you by the number 4934 and the tool "meld".
Merge of partially complete split world code from branch.



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

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