/[escript]/branches/diaplayground/dudley/src/CPPAdapter/dudleycpp.cpp
ViewVC logotype

Diff of /branches/diaplayground/dudley/src/CPPAdapter/dudleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2064 by jfenwick, Thu Nov 20 04:06:34 2008 UTC revision 2625 by jfenwick, Fri Aug 21 06:30:25 2009 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2008 by University of Queensland  * Copyright (c) 2003-2009 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
6  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
7  *  *
# Line 80  using namespace boost::python; Line 80  using namespace boost::python;
80  BOOST_PYTHON_MODULE(finleycpp)  BOOST_PYTHON_MODULE(finleycpp)
81  {  {
82  // This feature was added in boost v1.34  // This feature was added in boost v1.34
83  #if ((BOOST_VERSION/100)%1000 > 33) || (BOOST_VERSION/100000 >1)  #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
84    // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures    // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
85    docstring_options docopt(true, true, false);    docstring_options docopt(true, true, false);
86  #endif  #endif
# Line 92  BOOST_PYTHON_MODULE(finleycpp) Line 92  BOOST_PYTHON_MODULE(finleycpp)
92    register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));    register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
93    
94    def("LoadMesh",finley::loadMesh,    def("LoadMesh",finley::loadMesh,
95        (arg("fileName")="file.nc")        (arg("fileName")="file.nc"),":rtype: `Domain`"
96  /*      ,return_value_policy<manage_new_object>());*/  /*      ,return_value_policy<manage_new_object>());*/
97        );        );
98    
99    def("ReadMesh",finley::readMesh,    def("ReadMesh",finley::readMesh,
100        (arg("fileName")="file.fly",arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,  arg("optimize")=true)        (arg("fileName")="file.fly",arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,  arg("optimize")=true)
101  /*      ,return_value_policy<manage_new_object>());*/  /*      ,return_value_policy<manage_new_object>());*/
102      );      ,"Read a mesh from a file. For MPI parallel runs fan out the mesh to multiple processes.\n\n"
103    ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
104    ":param integrationOrder: order of the quadrature scheme. If *integrationOrder<0* the integration order is selected independently.\n"
105    ":type integrationOrder: ``int``\n"
106    ":param reducedIntegrationOrder: order of the quadrature scheme. If *reducedIntegrationOrder<0* the integration order is selected independently.\n"
107    ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``");
108    
109    def("ReadGmsh",finley::readGmsh,    def("ReadGmsh",finley::readGmsh,
110        (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)        (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
111  //       ,return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
112      );  ,"Read a gmsh mesh file\n\n"
113    ":rtype: `Domain`\n:param fileName:\n:type fileName: ``string``\n"
114    ":param integrationOrder: order of the quadrature scheme. If *integrationOrder<0* the integration order is selected independently.\n"
115    ":type integrationOrder: ``int``\n"
116    ":param reducedIntegrationOrder: order of the quadrature scheme. If *reducedIntegrationOrder<0* the integration order is selected independently.\n"
117    ":param optimize: Enable optimisation of node labels\n:type optimize: ``bool``");
118    
119    def ("Brick",finley::brick,    def ("Brick",finley::brick,
120        (arg("n0")=1,arg("n1")=1,arg("n2")=1,        (arg("n0")=1,arg("n1")=1,arg("n2")=1,
# Line 116  BOOST_PYTHON_MODULE(finleycpp) Line 126  BOOST_PYTHON_MODULE(finleycpp)
126        arg("useFullElementOrder")=false,        arg("useFullElementOrder")=false,
127        arg("optimize")=false)        arg("optimize")=false)
128  //       ,return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
129      );  ,"Creates a rectangular mesh with n0 x n1 x n2 elements over the brick [0,l0] x [0,l1] x [0,l2]."
130    "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n:param n2:\n:type n2:\n"
131    ":param order: =1 or =2 gives the order of shape function\n"
132    ":param l0: length of side 0\n:param l1:\n:param l2:\n"
133    ":param integrationOrder: order of the quadrature scheme. If integrationOrder<0 the integration order is selected independently.\n"
134    ":param reducedIntegrationOrder: order of the quadrature scheme. If reducedIntegrationOrder<0 the integration order is selected independently.\n"
135    ":param useElementsOnFace:  whether or not to use elements on face\n"
136    ":type useElementsOnFace: ``int``"
137    ":param periodic0:  whether or not boundary conditions are periodic\n"
138    ":param periodic1:\n:param periodic2:\n"
139    ":param useFullElementOrder:\n:param optimize:\n"
140    );
141    
142    def ("Rectangle",finley::rectangle,    def ("Rectangle",finley::rectangle,
143        (arg("n0")=1,arg("n1")=1,arg("order")=1,        (arg("n0")=1,arg("n1")=1,arg("order")=1,
# Line 127  BOOST_PYTHON_MODULE(finleycpp) Line 148  BOOST_PYTHON_MODULE(finleycpp)
148        arg("useFullElementOrder")=false,        arg("useFullElementOrder")=false,
149        arg("optimize")=false)        arg("optimize")=false)
150  //       ,return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
151      );  ,"Creates a rectangular mesh with n0 x n1 elements over the brick [0,l0] x [0,l1]."
152    "\n\n:param n0:\n:type n0:\n:param n1:\n:type n1:\n"
153    ":param order: =1 or =2 gives the order of shape function\n"
154    ":param l0: length of side 0\n:param l1:\n"
155    ":param integrationOrder: order of the quadrature scheme. If integrationOrder<0 the integration order is selected independently.\n"
156    ":param reducedIntegrationOrder: order of the quadrature scheme. If reducedIntegrationOrder<0 the integration order is selected independently.\n"
157    ":param useElementsOnFace:  whether or not to use elements on face\n"
158    ":type useElementsOnFace: ``int``"
159    ":param periodic0:  whether or not boundary conditions are periodic\n"
160    ":param periodic1:\n"
161    ":param useFullElementOrder:\n:param optimize:\n");
162    
163    def("Merge",finley::meshMerge    def("Merge",finley::meshMerge,args("meshList")
164  //       ,return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
165    ,"Merges a list of meshes into one mesh.\n\n:rtype: `Domain`"
166    );    );
167    
168    def("GlueFaces",finley::glueFaces,    def("GlueFaces",finley::glueFaces,
169        (arg("safetyFactor")=0.2,        (arg("meshList"),arg("safetyFactor")=0.2,
170        arg("tolerance")=1.e-8,        arg("tolerance")=1.e-8,
171        arg("optimize")=true)        arg("optimize")=true)
172  //       ,return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
173    ,"Detects matching faces in the mesh, removes them from the mesh and joins the elements touched by the face elements."
174      );      );
175    
176    def("JoinFaces",finley::joinFaces,    def("JoinFaces",finley::joinFaces,
177        (arg("safetyFactor")=0.2,        (arg("meshList"), arg("safetyFactor")=0.2,
178        arg("tolerance")=1.e-8,        arg("tolerance")=1.e-8,
179        arg("optimize")=true)        arg("optimize")=true)
180  //       ,return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
181    ,"Detects matching faces in the mesh and replaces them by joint elements."
182      );      );
183    
184    
185    class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >    class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
186        ("MeshAdapter","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<optional <Finley_Mesh*> >())        ("MeshAdapter","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<optional <Finley_Mesh*> >())
187        .def(init<const finley::MeshAdapter&>())        .def(init<const finley::MeshAdapter&>())
188        .def("write",&finley::MeshAdapter::write)        .def("write",&finley::MeshAdapter::write,args("filename"),
189        .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))  "Write the current mesh to a file with the given name.")
190        .def("dump",&finley::MeshAdapter::dump)        .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false),
191        .def("getDescription",&finley::MeshAdapter::getDescription)  ":param full:\n:type full: ``bool``")
192        .def("getDim",&finley::MeshAdapter::getDim)        .def("dump",&finley::MeshAdapter::dump,args("fileName")
193        .def("getDataShape",&finley::MeshAdapter::getDataShape)  ,"dumps the mesh to a file with the given name.")
194        .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)        .def("getDescription",&finley::MeshAdapter::getDescription,
195        .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)  ":return: a description for this domain\n:rtype: ``string``")
196        .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)        .def("getDim",&finley::MeshAdapter::getDim,":rtype: ``int``")
197        .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)        .def("getDataShape",&finley::MeshAdapter::getDataShape, args("functionSpaceCode"),
198        .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)  ":return: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples\n:rtype: ``tuple``")
199        .def("newOperator",&finley::MeshAdapter::newSystemMatrix)        .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal,
200        .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)  ":return: the number of data points summed across all MPI processes\n"
201        .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)  ":rtype: ``int``")
202        .def("getTransportTypeId",&finley::MeshAdapter::getTransportTypeId)        .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem,
203        .def("setX",&finley::MeshAdapter::setNewX)  args("mat", "rhs","A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
204        .def("getX",&finley::MeshAdapter::getX)  "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
205        .def("getNormal",&finley::MeshAdapter::getNormal)  ":param mat:\n:type mat: `OperatorAdapter`\n:param rhs:\n:type rhs: `Data`\n"
206        .def("getSize",&finley::MeshAdapter::getSize)  ":param A:\n:type A: `Data`\n"
207        .def("saveDX",&finley::MeshAdapter::saveDX)  ":param B:\n:type B: `Data`\n"
208        .def("saveVTK",&finley::MeshAdapter::saveVTK)  ":param C:\n:type C: `Data`\n"
209        .def("setTagMap",&finley::MeshAdapter::setTagMap)  ":param D:\n:type D: `Data`\n"
210        .def("getTag",&finley::MeshAdapter::getTag)  ":param X:\n:type X: `Data`\n"
211        .def("isValidTagName",&finley::MeshAdapter::isValidTagName)  ":param Y:\n:type Y: `Data`\n"
212        .def("showTagNames",&finley::MeshAdapter::showTagNames)  ":param d:\n:type d: `Data`\n"
213        .def("getMPISize",&finley::MeshAdapter::getMPISize)  ":param d_contact:\n:type d_contact: `Data`\n"
214        .def("getMPIRank",&finley::MeshAdapter::getMPIRank)  ":param y_contact:\n:type y_contact: `Data`\n"
215        .def("MPIBarrier",&finley::MeshAdapter::MPIBarrier)  )
216        .def("onMasterProcessor",&finley::MeshAdapter::onMasterProcessor);        .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem,
217    args("mat", "D", "d"),
218    "adds a PDE onto the lumped stiffness matrix\n\n"
219    ":param mat:\n:type mat: `Data`\n"
220    ":param D:\n:type D: `Data`\n"
221    ":param d:\n:type d: `Data`\n")
222          .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS,
223    args("rhs", "X", "Y", "y", "y_contact"),
224    "adds a PDE onto the stiffness matrix mat and a rhs\n\n"
225    ":param rhs:\n:type rhs: `Data`\n"
226    ":param X:\n:type X: `Data`\n"
227    ":param Y:\n:type Y: `Data`\n"
228    ":param y:\n:type y: `Data`\n"
229    ":param y_contact:\n:type y_contact: `Data`"
230    )
231          .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem,
232    args( "tp", "source", "M", "A", "B", "C", "D", "X", "Y", "d", "y", "d_contact", "y_contact"),
233    ":param tp:\n:type tp: `TransportProblemAdapter`\n"
234    ":param source:\n:type source: `Data`\n"
235    ":param M:\n:type M: `Data`\n"
236    ":param A:\n:type A: `Data`\n"
237    ":param B:\n:type B: `Data`\n"
238    ":param C:\n:type C: `Data`\n"
239    ":param D:\n:type D: `Data`\n"
240    ":param X:\n:type X: `Data`\n"
241    ":param Y:\n:type Y: `Data`\n"
242    ":param d:\n:type d: `Data`\n"
243    ":param y:\n:type y: `Data`\n"
244    ":param d_contact:\n:type d_contact: `Data`\n"
245    ":param y_contact:\n:type y_contact: `Data`\n"
246    )
247          .def("newOperator",&finley::MeshAdapter::newSystemMatrix,
248    args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
249    "creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros\n\n"
250    ":param row_blocksize:\n:type row_blocksize: ``int``\n"
251    ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
252    ":param column_blocksize:\n:type column_blocksize: ``int``\n"
253    ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
254    ":param type:\n:type type: ``int``\n"
255    )
256          .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem,
257    args("theta", "blocksize", "functionspace", "type"),
258    "creates a TransportProblemAdapter\n\n"
259    ":param theta:\n:type theta: ``float``\n"
260    ":param blocksize:\n:type blocksize: ``int``\n"
261    ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
262    ":param type:\n:type type: ``int``\n"
263    )
264          .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId,
265    args("solver", "preconditioner", "package", "symmetry"),
266    ":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"
267    ":rtype: ``int``\n"
268    ":param solver:\n:type solver: ``int``\n"
269    ":param preconditioner:\n:type preconditioner: ``int``\n"
270    ":param package:\n:type package: ``int``\n"
271    ":param symmetry:\n:type symmetry: ``int``\n"
272    )
273          .def("getTransportTypeId",&finley::MeshAdapter::getTransportTypeId,
274    args("solver", "preconditioner", "package", "symmetry"),
275    ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"
276    ":rtype: ``int``\n"
277    ":param solver:\n:type solver: ``int``\n"
278    ":param preconditioner:\n:type preconditioner: ``int``\n"
279    ":param package:\n:type package: ``int``\n"
280    ":param symmetry:\n:type symmetry: ``int``\n"
281    )
282          .def("setX",&finley::MeshAdapter::setNewX,
283    args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")
284          .def("getX",&finley::MeshAdapter::getX, ":return: locations in the FEM nodes\n\n"
285    ":rtype: `Data`")
286          .def("getNormal",&finley::MeshAdapter::getNormal,
287    ":return: boundary normals at the quadrature point on the face elements\n"
288    ":rtype: `Data`")
289          .def("getSize",&finley::MeshAdapter::getSize,":return: the element size\n"
290    ":rtype: `Data`")
291          .def("saveDX",&finley::MeshAdapter::saveDX,args("filename" ,"arg"),
292    "Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier"
293    "\n\n:param filename: \n:type filename: ``string``\n"
294    "\n:param arg: \n:type arg: ``dict``\n")
295          .def("saveVTK",&finley::MeshAdapter::saveVTK,
296    args("filename" ,"arg",  "metadata", "metadata_schema"),
297    "Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier"
298    "\n\n:param filename:\n:type filename: ``string``\n"
299    ":param arg:\n:type arg: ``dict``\n"
300    ":param metadata:\n:type metadata: ``string``\n"
301    ":param metadata_schema:\n:type metadata_schema: ``string``\n"
302    )
303          .def("setTagMap",&finley::MeshAdapter::setTagMap,args("name","tag"),
304    "Give a tag number a name.\n\n:param name: Name for the tag\n:type name: ``string``\n"
305    ":param tag: numeric id\n:type tag: ``int``\n:note: Tag names must be unique within a domain")
306          .def("getTag",&finley::MeshAdapter::getTag,args("name"),":return: tag id for "
307    "``name``\n:rtype: ``string``")
308          .def("isValidTagName",&finley::MeshAdapter::isValidTagName,args("name"),
309    ":return: True is ``name`` corresponds to a tag\n:rtype: ``bool``")
310          .def("showTagNames",&finley::MeshAdapter::showTagNames,":return: A space separated list of tag names\n:rtype: ``string``")
311          .def("getMPISize",&finley::MeshAdapter::getMPISize,":return: the number of processes used for this `Domain`\n:rtype: ``int``")
312          .def("getMPIRank",&finley::MeshAdapter::getMPIRank,":return: the rank of this process\n:rtype: ``int``")
313          .def("MPIBarrier",&finley::MeshAdapter::MPIBarrier,"Wait until all processes have reached this point")
314          .def("onMasterProcessor",&finley::MeshAdapter::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
315    
316    class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >    class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
317        ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)        ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)
318        .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))        .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false),"prints information about a system matrix")
319        .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)        .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
320        .def("resetValues",&finley::SystemMatrixAdapter::resetValues)        .def("resetValues",&finley::SystemMatrixAdapter::resetValues, "resets the matrix entries")
321        .def("saveMM",&finley::SystemMatrixAdapter::saveMM)        .def("saveMM",&finley::SystemMatrixAdapter::saveMM,args("fileName"),
322        .def("saveHB",&finley::SystemMatrixAdapter::saveHB);  "writes the matrix to a file using the Matrix Market file format")
323          .def("saveHB",&finley::SystemMatrixAdapter::saveHB, args("filename"),
324    "writes the matrix to a file using the Harwell-Boeing file format");
325    
326    class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >    class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
327        ("TransportProblemAdapter","",no_init)        ("TransportProblemAdapter","",no_init)
328        .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)        .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
329        .def("getUnlimitedTimeStepSize",&finley::TransportProblemAdapter::getUnlimitedTimeStepSize)        .def("getUnlimitedTimeStepSize",&finley::TransportProblemAdapter::getUnlimitedTimeStepSize)
330        .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);        .def("resetTransport",&finley::TransportProblemAdapter::resetTransport,
331    "resets the transport operator typically as they have been updated");
332  }  }

Legend:
Removed from v.2064  
changed lines
  Added in v.2625

  ViewVC Help
Powered by ViewVC 1.1.26