/[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 3719 - (show annotations)
Wed Dec 7 01:34:03 2011 UTC (9 years, 9 months ago) by jfenwick
File size: 11854 byte(s)
Quadrature points are not matched to the places Lutz' code puts them.
Removed a bunch of redundant includes of the MPI header.
Added new Esys_MPI.hpp header  which has the extern "C" in it.

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

  ViewVC Help
Powered by ViewVC 1.1.26