/[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 1360 by ksteube, Thu Dec 13 05:05:00 2007 UTC revision 2064 by jfenwick, Thu Nov 20 04:06:34 2008 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #ifdef PASO_MPI  #ifdef PASO_MPI
16  #include <mpi.h>  #include <mpi.h>
17    #include "paso/Paso_MPI.h"
18  #endif  #endif
19  extern "C" {  extern "C" {
20  #include "../Finley.h"  #include "../Finley.h"
# Line 23  extern "C" { Line 23  extern "C" {
23  #include "MeshAdapter.h"  #include "MeshAdapter.h"
24  #include "MeshAdapterFactory.h"  #include "MeshAdapterFactory.h"
25  #include "SystemMatrixAdapter.h"  #include "SystemMatrixAdapter.h"
26    #include "TransportProblemAdapter.h"
27    
28  #include "FinleyAdapterException.h"  #include "FinleyAdapterException.h"
29  // #include "esysUtils/EsysException.h"  // #include "esysUtils/EsysException.h"
# Line 34  extern "C" { Line 35  extern "C" {
35  #include <boost/python/module.hpp>  #include <boost/python/module.hpp>
36  #include <boost/python/def.hpp>  #include <boost/python/def.hpp>
37  #include <boost/python/detail/defaults_gen.hpp>  #include <boost/python/detail/defaults_gen.hpp>
38    #include <boost/version.hpp>
39    
40  using namespace boost::python;  using namespace boost::python;
41    
# Line 77  using namespace boost::python; Line 79  using namespace boost::python;
79    
80  BOOST_PYTHON_MODULE(finleycpp)  BOOST_PYTHON_MODULE(finleycpp)
81  {  {
82    // This feature was added in boost v1.34
83    #if ((BOOST_VERSION/100)%1000 > 33) || (BOOST_VERSION/100000 >1)
84      // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
85      docstring_options docopt(true, true, false);
86    #endif
87    
   // def("ReadMesh",finley::readMesh,readMesh_overloads());  
   // def("Brick",finley::brick,brick_overloads());  
   // def("Rectangle",finley::rectangle,rectangle_overloads());  
   // def("Interval",finley::interval,interval_overloads());  
   // def("GlueFaces",finley::glueFaces,glueFaces_overloads());  
   // def("JoinFaces",finley::joinFaces,joinFaces_overloads());  
88    //    //
89    // NOTE: The return_value_policy is necessary for functions that    // NOTE: The return_value_policy is necessary for functions that
90    // return pointers.    // return pointers.
91      //
92      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")
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    def("ReadMeshMPI",finley::readMeshMPI,      );
       (arg("fileName")="file.fly",arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,  arg("optimize")=true),  
       return_value_policy<manage_new_object>());  
103    
104    def("ReadGmsh",finley::readGmsh,    def("ReadGmsh",finley::readGmsh,
105        (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)
106        return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
107        );
108    
109    def ("Brick",finley::brick,    def ("Brick",finley::brick,
110        (arg("n0")=1,arg("n1")=1,arg("n2")=1,        (arg("n0")=1,arg("n1")=1,arg("n2")=1,
# Line 110  BOOST_PYTHON_MODULE(finleycpp) Line 114  BOOST_PYTHON_MODULE(finleycpp)
114        arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,        arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,
115        arg("useElementsOnFace")=false,        arg("useElementsOnFace")=false,
116        arg("useFullElementOrder")=false,        arg("useFullElementOrder")=false,
117        arg("optimize")=false),        arg("optimize")=false)
118        return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
119        );
120    
121    def ("Rectangle",finley::rectangle,    def ("Rectangle",finley::rectangle,
122        (arg("n0")=1,arg("n1")=1,arg("order")=1,        (arg("n0")=1,arg("n1")=1,arg("order")=1,
# Line 120  BOOST_PYTHON_MODULE(finleycpp) Line 125  BOOST_PYTHON_MODULE(finleycpp)
125        arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,        arg("integrationOrder")=-1,  arg("reducedIntegrationOrder")=-1,
126        arg("useElementsOnFace")=false,        arg("useElementsOnFace")=false,
127        arg("useFullElementOrder")=false,        arg("useFullElementOrder")=false,
128        arg("optimize")=false),        arg("optimize")=false)
129        return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
130        );
131    def("Merge",finley::meshMerge,  
132        return_value_policy<manage_new_object>());    def("Merge",finley::meshMerge
133    //       ,return_value_policy<manage_new_object>());
134      );
135    
136    def("GlueFaces",finley::glueFaces,    def("GlueFaces",finley::glueFaces,
137        (arg("safetyFactor")=0.2,        (arg("safetyFactor")=0.2,
138        arg("tolerance")=1.e-8,        arg("tolerance")=1.e-8,
139        arg("optimize")=true),        arg("optimize")=true)
140        return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
141        );
142    
143    def("JoinFaces",finley::joinFaces,    def("JoinFaces",finley::joinFaces,
144        (arg("safetyFactor")=0.2,        (arg("safetyFactor")=0.2,
145        arg("tolerance")=1.e-8,        arg("tolerance")=1.e-8,
146        arg("optimize")=true),        arg("optimize")=true)
147        return_value_policy<manage_new_object>());  //       ,return_value_policy<manage_new_object>());
148        );
149    
   register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));  
150    
151    class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >    class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
152        ("MeshAdapter",init<optional <Finley_Mesh*> >())        ("MeshAdapter","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<optional <Finley_Mesh*> >())
153        .def(init<const finley::MeshAdapter&>())        .def(init<const finley::MeshAdapter&>())
154        .def("write",&finley::MeshAdapter::write)        .def("write",&finley::MeshAdapter::write)
155        .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))        .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
# Line 149  BOOST_PYTHON_MODULE(finleycpp) Line 157  BOOST_PYTHON_MODULE(finleycpp)
157        .def("getDescription",&finley::MeshAdapter::getDescription)        .def("getDescription",&finley::MeshAdapter::getDescription)
158        .def("getDim",&finley::MeshAdapter::getDim)        .def("getDim",&finley::MeshAdapter::getDim)
159        .def("getDataShape",&finley::MeshAdapter::getDataShape)        .def("getDataShape",&finley::MeshAdapter::getDataShape)
160          .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)
161        .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)        .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
162        .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)        .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
163        .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)        .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
164          .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)
165        .def("newOperator",&finley::MeshAdapter::newSystemMatrix)        .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
166          .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)
167        .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)        .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
168          .def("getTransportTypeId",&finley::MeshAdapter::getTransportTypeId)
169        .def("setX",&finley::MeshAdapter::setNewX)        .def("setX",&finley::MeshAdapter::setNewX)
170        .def("getX",&finley::MeshAdapter::getX)        .def("getX",&finley::MeshAdapter::getX)
171        .def("getNormal",&finley::MeshAdapter::getNormal)        .def("getNormal",&finley::MeshAdapter::getNormal)
# Line 165  BOOST_PYTHON_MODULE(finleycpp) Line 177  BOOST_PYTHON_MODULE(finleycpp)
177        .def("isValidTagName",&finley::MeshAdapter::isValidTagName)        .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
178        .def("showTagNames",&finley::MeshAdapter::showTagNames)        .def("showTagNames",&finley::MeshAdapter::showTagNames)
179        .def("getMPISize",&finley::MeshAdapter::getMPISize)        .def("getMPISize",&finley::MeshAdapter::getMPISize)
180        .def("getMPIRank",&finley::MeshAdapter::getMPIRank);        .def("getMPIRank",&finley::MeshAdapter::getMPIRank)
181          .def("MPIBarrier",&finley::MeshAdapter::MPIBarrier)
182          .def("onMasterProcessor",&finley::MeshAdapter::onMasterProcessor);
183    
184    class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >    class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
185        ("OperatorAdapter",no_init)        ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)
186        .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))        .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
187        .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)        .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
188        .def("resetValues",&finley::SystemMatrixAdapter::resetValues)        .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
189        .def("saveMM",&finley::SystemMatrixAdapter::saveMM)        .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
190        .def("saveHB",&finley::SystemMatrixAdapter::saveHB);        .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
191    
192      class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
193          ("TransportProblemAdapter","",no_init)
194          .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
195          .def("getUnlimitedTimeStepSize",&finley::TransportProblemAdapter::getUnlimitedTimeStepSize)
196          .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);
197  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26