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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3671 - (hide annotations)
Wed Nov 16 04:01:53 2011 UTC (9 years, 10 months ago) by jfenwick
File size: 11020 byte(s)
Rename complete
1 jfenwick 3658
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 jfenwick 3671 #include "BuckleyDomain.h"
20 jfenwick 3658
21 jfenwick 3671 #include "BuckleyException.h"
22 jfenwick 3658 #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 jfenwick 3668 \page buckley
36 jfenwick 3658
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 jfenwick 3668 BOOST_PYTHON_MODULE(buckleycpp)
54 jfenwick 3658 {
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 jfenwick 3671 register_exception_translator<buckley::BuckleyException>(&(esysUtils::esysExceptionTranslator));
66 jfenwick 3658
67 jfenwick 3668 // def("LoadMesh",buckley::loadMesh,
68 jfenwick 3658 // (arg("fileName")="file.nc"),":rtype: `Domain`"
69     // );
70     //
71 jfenwick 3668 // def("ReadMesh",buckley::readMesh,
72 jfenwick 3658 // (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 jfenwick 3668 // def ("Brick",buckley::brick,
83 jfenwick 3658 // (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 jfenwick 3671 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 jfenwick 3658 "Write the current mesh to a file with the given name.")
111 jfenwick 3671 .def("print_mesh_info",&buckley::BuckleyDomain::Print_Mesh_Info,(arg("full")=false),
112 jfenwick 3658 ":param full:\n:type full: ``bool``")
113 jfenwick 3671 .def("dump",&buckley::BuckleyDomain::dump,args("fileName")
114 jfenwick 3658 ,"dumps the mesh to a file with the given name.")
115 jfenwick 3671 .def("getDescription",&buckley::BuckleyDomain::getDescription,
116 jfenwick 3658 ":return: a description for this domain\n:rtype: ``string``")
117 jfenwick 3671 .def("getDim",&buckley::BuckleyDomain::getDim,":rtype: ``int``")
118     .def("getDataShape",&buckley::BuckleyDomain::getDataShape, args("functionSpaceCode"),
119 jfenwick 3658 ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
120 jfenwick 3671 .def("getNumDataPointsGlobal",&buckley::BuckleyDomain::getNumDataPointsGlobal,
121 jfenwick 3658 ":return: the number of data points summed across all MPI processes\n"
122     ":rtype: ``int``")
123 jfenwick 3671 .def("addPDEToSystem",&buckley::BuckleyDomain::addPDEToSystem,
124 jfenwick 3658 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 jfenwick 3671 .def("addPDEToRHS",&buckley::BuckleyDomain::addPDEToRHS,
139 jfenwick 3658 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 jfenwick 3671 .def("addPDEToTransportProblem",&buckley::BuckleyDomain::addPDEToTransportProblem,
148 jfenwick 3658 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 jfenwick 3671 .def("newOperator",&buckley::BuckleyDomain::newSystemMatrix,
164 jfenwick 3658 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 jfenwick 3671 .def("newTransportProblem",&buckley::BuckleyDomain::newTransportProblem,
173 jfenwick 3658 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 jfenwick 3671 .def("getSystemMatrixTypeId",&buckley::BuckleyDomain::getSystemMatrixTypeId,
181 jfenwick 3658 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 jfenwick 3671 .def("getTransportTypeId",&buckley::BuckleyDomain::getTransportTypeId,
190 jfenwick 3658 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 jfenwick 3671 .def("setX",&buckley::BuckleyDomain::setNewX,
199 jfenwick 3658 args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
200 jfenwick 3671 .def("getX",&buckley::BuckleyDomain::getX, ":return: locations in the FEM nodes\n\n"
201 jfenwick 3658 ":rtype: `Data`")
202 jfenwick 3671 .def("getNormal",&buckley::BuckleyDomain::getNormal,
203 jfenwick 3658 ":return: boundary normals at the quadrature point on the face elements\n"
204     ":rtype: `Data`")
205 jfenwick 3671 .def("getSize",&buckley::BuckleyDomain::getSize,":return: the element size\n"
206 jfenwick 3658 ":rtype: `Data`")
207 jfenwick 3671 .def("saveDX",&buckley::BuckleyDomain::saveDX,args("filename" ,"arg"),
208 jfenwick 3658 "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 jfenwick 3671 .def("saveVTK",&buckley::BuckleyDomain::saveVTK,
212 jfenwick 3658 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 jfenwick 3671 .def("setTagMap",&buckley::BuckleyDomain::setTagMap,args("name","tag"),
220 jfenwick 3658 "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 jfenwick 3671 .def("getTag",&buckley::BuckleyDomain::getTag,args("name"),":return: tag id for "
223 jfenwick 3658 "``name``\n:rtype: ``string``")
224 jfenwick 3671 .def("isValidTagName",&buckley::BuckleyDomain::isValidTagName,args("name"),
225 jfenwick 3658 ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
226 jfenwick 3671 .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 jfenwick 3658
232     }

  ViewVC Help
Powered by ViewVC 1.1.26