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

  ViewVC Help
Powered by ViewVC 1.1.26