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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 10 months ago) by caltinay
File size: 13403 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/dudley/src/CPPAdapter/dudleycpp.cpp:5567-5588 /branches/diaplayground/dudley/src/CPPAdapter/dudleycpp.cpp:4940-5147 /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 /release/4.0/dudley/src/CPPAdapter/dudleycpp.cpp:5380-5406 /trunk/dudley/src/CPPAdapter/dudleycpp.cpp:5898-6007 /trunk/ripley/test/python/dudley/src/CPPAdapter/dudleycpp.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26