/[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 3658 - (hide annotations)
Fri Nov 11 06:55:48 2011 UTC (9 years, 10 months ago) by jfenwick
Original Path: branches/refine/refine/src/refinecpp.cpp
File size: 10899 byte(s)
the refine domain is hooked into scons but doesn't do anything useful yet.

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     \page refine
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     BOOST_PYTHON_MODULE(refinecpp)
57     {
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     register_exception_translator<refine::RDomainException>(&(esysUtils::esysExceptionTranslator));
69    
70     // def("LoadMesh",refine::loadMesh,
71     // (arg("fileName")="file.nc"),":rtype: `Domain`"
72     // );
73     //
74     // def("ReadMesh",refine::readMesh,
75     // (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     // def ("Brick",refine::brick,
86     // (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     class_<refine::RDomain, bases<escript::AbstractContinuousDomain> >
110     ("RDomain","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<double, double, double>())
111     .def(init<const refine::RDomain&>())
112     .def("write",&refine::RDomain::write,args("filename"),
113     "Write the current mesh to a file with the given name.")
114     .def("print_mesh_info",&refine::RDomain::Print_Mesh_Info,(arg("full")=false),
115     ":param full:\n:type full: ``bool``")
116     .def("dump",&refine::RDomain::dump,args("fileName")
117     ,"dumps the mesh to a file with the given name.")
118     .def("getDescription",&refine::RDomain::getDescription,
119     ":return: a description for this domain\n:rtype: ``string``")
120     .def("getDim",&refine::RDomain::getDim,":rtype: ``int``")
121     .def("getDataShape",&refine::RDomain::getDataShape, args("functionSpaceCode"),
122     ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
123     .def("getNumDataPointsGlobal",&refine::RDomain::getNumDataPointsGlobal,
124     ":return: the number of data points summed across all MPI processes\n"
125     ":rtype: ``int``")
126     .def("addPDEToSystem",&refine::RDomain::addPDEToSystem,
127     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     .def("addPDEToRHS",&refine::RDomain::addPDEToRHS,
142     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     .def("addPDEToTransportProblem",&refine::RDomain::addPDEToTransportProblem,
151     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     .def("newOperator",&refine::RDomain::newSystemMatrix,
167     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     .def("newTransportProblem",&refine::RDomain::newTransportProblem,
176     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     .def("getSystemMatrixTypeId",&refine::RDomain::getSystemMatrixTypeId,
184     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     .def("getTransportTypeId",&refine::RDomain::getTransportTypeId,
193     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     .def("setX",&refine::RDomain::setNewX,
202     args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
203     .def("getX",&refine::RDomain::getX, ":return: locations in the FEM nodes\n\n"
204     ":rtype: `Data`")
205     .def("getNormal",&refine::RDomain::getNormal,
206     ":return: boundary normals at the quadrature point on the face elements\n"
207     ":rtype: `Data`")
208     .def("getSize",&refine::RDomain::getSize,":return: the element size\n"
209     ":rtype: `Data`")
210     .def("saveDX",&refine::RDomain::saveDX,args("filename" ,"arg"),
211     "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     .def("saveVTK",&refine::RDomain::saveVTK,
215     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     .def("setTagMap",&refine::RDomain::setTagMap,args("name","tag"),
223     "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     .def("getTag",&refine::RDomain::getTag,args("name"),":return: tag id for "
226     "``name``\n:rtype: ``string``")
227     .def("isValidTagName",&refine::RDomain::isValidTagName,args("name"),
228     ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
229     .def("showTagNames",&refine::RDomain::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
230     .def("getMPISize",&refine::RDomain::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
231     .def("getMPIRank",&refine::RDomain::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
232     .def("MPIBarrier",&refine::RDomain::MPIBarrier,"Wait until all processes have reached this point")
233     .def("onMasterProcessor",&refine::RDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
234    
235     }

  ViewVC Help
Powered by ViewVC 1.1.26