/[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 3682 - (show annotations)
Mon Nov 21 01:56:45 2011 UTC (9 years, 8 months ago) by jfenwick
File size: 11322 byte(s)
Fixed some cases which allowed domain objects to be created without wrappers

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 namespace buckley
54 {
55
56 escript::Domain_ptr buckley(double x, double y, double z)
57 {
58 BuckleyDomain* temp=new BuckleyDomain(x, y, z);
59 return temp->getPtr();
60 }
61
62
63
64 }
65
66
67 BOOST_PYTHON_MODULE(buckleycpp)
68 {
69 // This feature was added in boost v1.34
70 #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
71 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
72 docstring_options docopt(true, true, false);
73 #endif
74
75 //
76 // NOTE: The return_value_policy is necessary for functions that
77 // return pointers.
78 //
79 register_exception_translator<buckley::BuckleyException>(&(esysUtils::esysExceptionTranslator));
80
81 // def("LoadMesh",buckley::loadMesh,
82 // (arg("fileName")="file.nc"),":rtype: `Domain`"
83 // );
84 //
85 // def("ReadMesh",buckley::readMesh,
86 // (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
87 // ,"Read a mesh from a file. For MPI parallel runs fan out the mesh to multiple processes.\n\n"
88 // ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
89 // ":param integrationOrder: order of the quadrature scheme. If *integrationOrder<0* the integration order is selected independently.\n"
90 // ":type integrationOrder: ``int``\n"
91 // ":param reducedIntegrationOrder: order of the quadrature scheme. If *reducedIntegrationOrder<0* the integration order is selected independently.\n"
92 // ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``");
93
94
95 def("Buckley", buckley::buckley, (arg("n0")=1, arg("n1")=1, arg("n2")=1), "Creates an OctTree mesh for a box with the specified dimensions");
96 // def ("Brick",buckley::brick,
97 // (arg("n0")=1,arg("n1")=1,arg("n2")=1,
98 // arg("order")=1,
99 // arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
100 // arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
101 // arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
102 // arg("useElementsOnFace")=false,
103 // arg("useFullElementOrder")=false,
104 // arg("optimize")=false)
105 // ,"Creates a tetrahedral mesh by subdividing n0 x n1 x n2 rectangular elements over the brick [0,l0] x [0,l1] x [0,l2]."
106 // "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n:param n2:\n:type n2:\n"
107 // ":param order: =1, =-1 or =2 gives the order of shape function. If -1 macro elements of order 1 are used.\n"
108 // ":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 // ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``"
117 // );
118
119
120 class_<buckley::BuckleyDomain, bases<escript::AbstractContinuousDomain> >
121 ("BuckleyDomain","A concrete class representing a domain. For more details, please consult the c++ documentation.",no_init)
122 .def(init<const buckley::BuckleyDomain&>())
123 .def("write",&buckley::BuckleyDomain::write,args("filename"),
124 "Write the current mesh to a file with the given name.")
125 .def("print_mesh_info",&buckley::BuckleyDomain::Print_Mesh_Info,(arg("full")=false),
126 ":param full:\n:type full: ``bool``")
127 .def("dump",&buckley::BuckleyDomain::dump,args("fileName")
128 ,"dumps the mesh to a file with the given name.")
129 .def("getDescription",&buckley::BuckleyDomain::getDescription,
130 ":return: a description for this domain\n:rtype: ``string``")
131 .def("getDim",&buckley::BuckleyDomain::getDim,":rtype: ``int``")
132 .def("getDataShape",&buckley::BuckleyDomain::getDataShape, args("functionSpaceCode"),
133 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
134 .def("getNumDataPointsGlobal",&buckley::BuckleyDomain::getNumDataPointsGlobal,
135 ":return: the number of data points summed across all MPI processes\n"
136 ":rtype: ``int``")
137 .def("addPDEToSystem",&buckley::BuckleyDomain::addPDEToSystem,
138 args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
139 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
140 ":param mat:\n:type mat: `OperatorAdapter`\n:param rhs:\n:type rhs: `Data`\n"
141 ":param A:\n:type A: `Data`\n"
142 ":param B:\n:type B: `Data`\n"
143 ":param C:\n:type C: `Data`\n"
144 ":param D:\n:type D: `Data`\n"
145 ":param X:\n:type X: `Data`\n"
146 ":param Y:\n:type Y: `Data`\n"
147 ":param d:\n:type d: `Data`\n"
148 ":param d_contact:\n:type d_contact: `Data`\n"
149 ":param y_contact:\n:type y_contact: `Data`\n"
150 )
151
152 .def("addPDEToRHS",&buckley::BuckleyDomain::addPDEToRHS,
153 args("rhs", "X", "Y", "y", "y_contact"),
154 "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
155 ":param rhs:\n:type rhs: `Data`\n"
156 ":param X:\n:type X: `Data`\n"
157 ":param Y:\n:type Y: `Data`\n"
158 ":param y:\n:type y: `Data`\n"
159 ":param y_contact:\n:type y_contact: `Data`"
160 )
161 .def("addPDEToTransportProblem",&buckley::BuckleyDomain::addPDEToTransportProblem,
162 args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
163 ":param tp:\n:type tp: `TransportProblemAdapter`\n"
164 ":param source:\n:type source: `Data`\n"
165 ":param M:\n:type M: `Data`\n"
166 ":param A:\n:type A: `Data`\n"
167 ":param B:\n:type B: `Data`\n"
168 ":param C:\n:type C: `Data`\n"
169 ":param D:\n:type D: `Data`\n"
170 ":param X:\n:type X: `Data`\n"
171 ":param Y:\n:type Y: `Data`\n"
172 ":param d:\n:type d: `Data`\n"
173 ":param y:\n:type y: `Data`\n"
174 ":param d_contact:\n:type d_contact: `Data`\n"
175 ":param y_contact:\n:type y_contact: `Data`\n"
176 )
177 .def("newOperator",&buckley::BuckleyDomain::newSystemMatrix,
178 args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
179 "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
180 ":param row_blocksize:\n:type row_blocksize: ``int``\n"
181 ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
182 ":param column_blocksize:\n:type column_blocksize: ``int``\n"
183 ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
184 ":param type:\n:type type: ``int``\n"
185 )
186 .def("newTransportProblem",&buckley::BuckleyDomain::newTransportProblem,
187 args("theta", "blocksize", "functionspace", "type"),
188 "creates a TransportProblemAdapter\n\n"
189 ":param theta:\n:type theta: ``float``\n"
190 ":param blocksize:\n:type blocksize: ``int``\n"
191 ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
192 ":param type:\n:type type: ``int``\n"
193 )
194 .def("getSystemMatrixTypeId",&buckley::BuckleyDomain::getSystemMatrixTypeId,
195 args("solver", "preconditioner", "package", "symmetry"),
196 ":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"
197 ":rtype: ``int``\n"
198 ":param solver:\n:type solver: ``int``\n"
199 ":param preconditioner:\n:type preconditioner: ``int``\n"
200 ":param package:\n:type package: ``int``\n"
201 ":param symmetry:\n:type symmetry: ``int``\n"
202 )
203 .def("getTransportTypeId",&buckley::BuckleyDomain::getTransportTypeId,
204 args("solver", "preconditioner", "package", "symmetry"),
205 ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"
206 ":rtype: ``int``\n"
207 ":param solver:\n:type solver: ``int``\n"
208 ":param preconditioner:\n:type preconditioner: ``int``\n"
209 ":param package:\n:type package: ``int``\n"
210 ":param symmetry:\n:type symmetry: ``int``\n"
211 )
212 .def("setX",&buckley::BuckleyDomain::setNewX,
213 args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
214 .def("getX",&buckley::BuckleyDomain::getX, ":return: locations in the FEM nodes\n\n"
215 ":rtype: `Data`")
216 .def("getNormal",&buckley::BuckleyDomain::getNormal,
217 ":return: boundary normals at the quadrature point on the face elements\n"
218 ":rtype: `Data`")
219 .def("getSize",&buckley::BuckleyDomain::getSize,":return: the element size\n"
220 ":rtype: `Data`")
221 .def("saveDX",&buckley::BuckleyDomain::saveDX,args("filename" ,"arg"),
222 "Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier"
223 "\n\n:param filename: \n:type filename: ``string``\n"
224 "\n:param arg: \n:type arg: ``dict``\n")
225 .def("saveVTK",&buckley::BuckleyDomain::saveVTK,
226 args("filename" ,"arg", "metadata", "metadata_schema"),
227 "Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier"
228 "\n\n:param filename:\n:type filename: ``string``\n"
229 ":param arg:\n:type arg: ``dict``\n"
230 ":param metadata:\n:type metadata: ``string``\n"
231 ":param metadata_schema:\n:type metadata_schema: ``string``\n"
232 )
233 .def("setTagMap",&buckley::BuckleyDomain::setTagMap,args("name","tag"),
234 "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
235 ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
236 .def("getTag",&buckley::BuckleyDomain::getTag,args("name"),":return: tag id for "
237 "``name``\n:rtype: ``string``")
238 .def("isValidTagName",&buckley::BuckleyDomain::isValidTagName,args("name"),
239 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
240 .def("showTagNames",&buckley::BuckleyDomain::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
241 .def("getMPISize",&buckley::BuckleyDomain::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
242 .def("getMPIRank",&buckley::BuckleyDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
243 .def("MPIBarrier",&buckley::BuckleyDomain::MPIBarrier,"Wait until all processes have reached this point")
244 .def("onMasterProcessor",&buckley::BuckleyDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
245
246 }

  ViewVC Help
Powered by ViewVC 1.1.26