/[escript]/branches/refine/buckley/src/buckleycpp.cpp
ViewVC logotype

Contents of /branches/refine/buckley/src/buckleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3671 - (show annotations)
Wed Nov 16 04:01:53 2011 UTC (9 years, 10 months ago) by jfenwick
File size: 11020 byte(s)
Rename complete
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * 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
14
15 #ifdef ESYS_MPI
16 #include "esysUtils/Esys_MPI.h"
17 #endif
18
19 #include "BuckleyDomain.h"
20
21 #include "BuckleyException.h"
22 #include "esysUtils/esysExceptionTranslator.h"
23
24 #include "escript/AbstractContinuousDomain.h"
25
26 #include <boost/python.hpp>
27 #include <boost/python/module.hpp>
28 #include <boost/python/def.hpp>
29 #include <boost/python/detail/defaults_gen.hpp>
30 #include <boost/version.hpp>
31
32 using namespace boost::python;
33
34 /**
35 \page buckley
36
37 \version 1.0.0
38
39 \section class_desc Class Description:
40 None
41
42 \section class_limits Class Limitations:
43 None
44
45 \section class_conds Class Conditions of Use:
46 None
47
48 \section throws Throws:
49 depends what you try to do
50
51 */
52
53 BOOST_PYTHON_MODULE(buckleycpp)
54 {
55 // This feature was added in boost v1.34
56 #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
57 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
58 docstring_options docopt(true, true, false);
59 #endif
60
61 //
62 // NOTE: The return_value_policy is necessary for functions that
63 // return pointers.
64 //
65 register_exception_translator<buckley::BuckleyException>(&(esysUtils::esysExceptionTranslator));
66
67 // def("LoadMesh",buckley::loadMesh,
68 // (arg("fileName")="file.nc"),":rtype: `Domain`"
69 // );
70 //
71 // def("ReadMesh",buckley::readMesh,
72 // (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
73 // ,"Read a mesh from a file. For MPI parallel runs fan out the mesh to multiple processes.\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``");
79
80
81
82 // def ("Brick",buckley::brick,
83 // (arg("n0")=1,arg("n1")=1,arg("n2")=1,
84 // arg("order")=1,
85 // arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
86 // arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
87 // arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
88 // arg("useElementsOnFace")=false,
89 // arg("useFullElementOrder")=false,
90 // arg("optimize")=false)
91 // ,"Creates a tetrahedral mesh by subdividing n0 x n1 x n2 rectangular elements over the brick [0,l0] x [0,l1] x [0,l2]."
92 // "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n:param n2:\n:type n2:\n"
93 // ":param order: =1, =-1 or =2 gives the order of shape function. If -1 macro elements of order 1 are used.\n"
94 // ":param l0: length of side 0\n:param l1:\n:param l2:\n"
95 // ":param integrationOrder: order of the quadrature scheme. If integrationOrder<0 the integration order is selected independently.\n"
96 // ":param reducedIntegrationOrder: order of the quadrature scheme. If reducedIntegrationOrder<0 the integration order is selected independently.\n"
97 // ":param useElementsOnFace: whether or not to use elements on face\n"
98 // ":type useElementsOnFace: ``int``"
99 // ":param periodic0: whether or not boundary conditions are periodic\n"
100 // ":param periodic1:\n:param periodic2:\n"
101 // ":param useFullElementOrder:\n:param optimize:\n"
102 // ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``"
103 // );
104
105
106 class_<buckley::BuckleyDomain, bases<escript::AbstractContinuousDomain> >
107 ("BuckleyDomain","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<double, double, double>())
108 .def(init<const buckley::BuckleyDomain&>())
109 .def("write",&buckley::BuckleyDomain::write,args("filename"),
110 "Write the current mesh to a file with the given name.")
111 .def("print_mesh_info",&buckley::BuckleyDomain::Print_Mesh_Info,(arg("full")=false),
112 ":param full:\n:type full: ``bool``")
113 .def("dump",&buckley::BuckleyDomain::dump,args("fileName")
114 ,"dumps the mesh to a file with the given name.")
115 .def("getDescription",&buckley::BuckleyDomain::getDescription,
116 ":return: a description for this domain\n:rtype: ``string``")
117 .def("getDim",&buckley::BuckleyDomain::getDim,":rtype: ``int``")
118 .def("getDataShape",&buckley::BuckleyDomain::getDataShape, args("functionSpaceCode"),
119 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
120 .def("getNumDataPointsGlobal",&buckley::BuckleyDomain::getNumDataPointsGlobal,
121 ":return: the number of data points summed across all MPI processes\n"
122 ":rtype: ``int``")
123 .def("addPDEToSystem",&buckley::BuckleyDomain::addPDEToSystem,
124 args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
125 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
126 ":param mat:\n:type mat: `OperatorAdapter`\n:param rhs:\n:type rhs: `Data`\n"
127 ":param A:\n:type A: `Data`\n"
128 ":param B:\n:type B: `Data`\n"
129 ":param C:\n:type C: `Data`\n"
130 ":param D:\n:type D: `Data`\n"
131 ":param X:\n:type X: `Data`\n"
132 ":param Y:\n:type Y: `Data`\n"
133 ":param d:\n:type d: `Data`\n"
134 ":param d_contact:\n:type d_contact: `Data`\n"
135 ":param y_contact:\n:type y_contact: `Data`\n"
136 )
137
138 .def("addPDEToRHS",&buckley::BuckleyDomain::addPDEToRHS,
139 args("rhs", "X", "Y", "y", "y_contact"),
140 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
141 ":param rhs:\n:type rhs: `Data`\n"
142 ":param X:\n:type X: `Data`\n"
143 ":param Y:\n:type Y: `Data`\n"
144 ":param y:\n:type y: `Data`\n"
145 ":param y_contact:\n:type y_contact: `Data`"
146 )
147 .def("addPDEToTransportProblem",&buckley::BuckleyDomain::addPDEToTransportProblem,
148 args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
149 ":param tp:\n:type tp: `TransportProblemAdapter`\n"
150 ":param source:\n:type source: `Data`\n"
151 ":param M:\n:type M: `Data`\n"
152 ":param A:\n:type A: `Data`\n"
153 ":param B:\n:type B: `Data`\n"
154 ":param C:\n:type C: `Data`\n"
155 ":param D:\n:type D: `Data`\n"
156 ":param X:\n:type X: `Data`\n"
157 ":param Y:\n:type Y: `Data`\n"
158 ":param d:\n:type d: `Data`\n"
159 ":param y:\n:type y: `Data`\n"
160 ":param d_contact:\n:type d_contact: `Data`\n"
161 ":param y_contact:\n:type y_contact: `Data`\n"
162 )
163 .def("newOperator",&buckley::BuckleyDomain::newSystemMatrix,
164 args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
165 "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
166 ":param row_blocksize:\n:type row_blocksize: ``int``\n"
167 ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
168 ":param column_blocksize:\n:type column_blocksize: ``int``\n"
169 ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
170 ":param type:\n:type type: ``int``\n"
171 )
172 .def("newTransportProblem",&buckley::BuckleyDomain::newTransportProblem,
173 args("theta", "blocksize", "functionspace", "type"),
174 "creates a TransportProblemAdapter\n\n"
175 ":param theta:\n:type theta: ``float``\n"
176 ":param blocksize:\n:type blocksize: ``int``\n"
177 ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
178 ":param type:\n:type type: ``int``\n"
179 )
180 .def("getSystemMatrixTypeId",&buckley::BuckleyDomain::getSystemMatrixTypeId,
181 args("solver", "preconditioner", "package", "symmetry"),
182 ":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"
183 ":rtype: ``int``\n"
184 ":param solver:\n:type solver: ``int``\n"
185 ":param preconditioner:\n:type preconditioner: ``int``\n"
186 ":param package:\n:type package: ``int``\n"
187 ":param symmetry:\n:type symmetry: ``int``\n"
188 )
189 .def("getTransportTypeId",&buckley::BuckleyDomain::getTransportTypeId,
190 args("solver", "preconditioner", "package", "symmetry"),
191 ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"
192 ":rtype: ``int``\n"
193 ":param solver:\n:type solver: ``int``\n"
194 ":param preconditioner:\n:type preconditioner: ``int``\n"
195 ":param package:\n:type package: ``int``\n"
196 ":param symmetry:\n:type symmetry: ``int``\n"
197 )
198 .def("setX",&buckley::BuckleyDomain::setNewX,
199 args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
200 .def("getX",&buckley::BuckleyDomain::getX, ":return: locations in the FEM nodes\n\n"
201 ":rtype: `Data`")
202 .def("getNormal",&buckley::BuckleyDomain::getNormal,
203 ":return: boundary normals at the quadrature point on the face elements\n"
204 ":rtype: `Data`")
205 .def("getSize",&buckley::BuckleyDomain::getSize,":return: the element size\n"
206 ":rtype: `Data`")
207 .def("saveDX",&buckley::BuckleyDomain::saveDX,args("filename" ,"arg"),
208 "Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier"
209 "\n\n:param filename: \n:type filename: ``string``\n"
210 "\n:param arg: \n:type arg: ``dict``\n")
211 .def("saveVTK",&buckley::BuckleyDomain::saveVTK,
212 args("filename" ,"arg", "metadata", "metadata_schema"),
213 "Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier"
214 "\n\n:param filename:\n:type filename: ``string``\n"
215 ":param arg:\n:type arg: ``dict``\n"
216 ":param metadata:\n:type metadata: ``string``\n"
217 ":param metadata_schema:\n:type metadata_schema: ``string``\n"
218 )
219 .def("setTagMap",&buckley::BuckleyDomain::setTagMap,args("name","tag"),
220 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
221 ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
222 .def("getTag",&buckley::BuckleyDomain::getTag,args("name"),":return: tag id for "
223 "``name``\n:rtype: ``string``")
224 .def("isValidTagName",&buckley::BuckleyDomain::isValidTagName,args("name"),
225 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
226 .def("showTagNames",&buckley::BuckleyDomain::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
227 .def("getMPISize",&buckley::BuckleyDomain::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
228 .def("getMPIRank",&buckley::BuckleyDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
229 .def("MPIBarrier",&buckley::BuckleyDomain::MPIBarrier,"Wait until all processes have reached this point")
230 .def("onMasterProcessor",&buckley::BuckleyDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
231
232 }

  ViewVC Help
Powered by ViewVC 1.1.26