/[escript]/trunk/ripley/src/ripleycpp.cpp
ViewVC logotype

Diff of /trunk/ripley/src/ripleycpp.cpp

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

revision 3691 by caltinay, Wed Nov 23 23:07:37 2011 UTC revision 3791 by caltinay, Wed Feb 1 05:10:22 2012 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2011 by University of Queensland  * Copyright (c) 2003-2012 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 28  namespace ripley { Line 28  namespace ripley {
28  // These wrappers are required to make the shared pointers work through the  // These wrappers are required to make the shared pointers work through the
29  // Python wrapper  // Python wrapper
30    
31  escript::Domain_ptr _brick(int n0, int n1, int n2, double l0, double l1, double l2, int d0, int d1, int d2)  escript::Domain_ptr _brick(int n0, int n1, int n2, const object& l0,
32                     const object& l1, const object& l2, int d0, int d1, int d2)
33  {  {
34      return escript::Domain_ptr(new Brick(n0, n1, n2, l0, l1, l2, d0, d1, d2));      double x0=0., x1=1., y0=0., y1=1., z0=0., z1=1.;
35        if (extract<tuple>(l0).check()) {
36            tuple x=extract<tuple>(l0);
37            if (len(x)==2) {
38                x0=extract<double>(x[0]);
39                x1=extract<double>(x[1]);
40            } else
41                throw RipleyException("Argument l0 must be a float or 2-tuple");
42        } else if (extract<double>(l0).check()) {
43            x1=extract<double>(l0);
44        } else
45            throw RipleyException("Argument l0 must be a float or 2-tuple");
46    
47        if (extract<tuple>(l1).check()) {
48            tuple y=extract<tuple>(l1);
49            if (len(y)==2) {
50                y0=extract<double>(y[0]);
51                y1=extract<double>(y[1]);
52            } else
53                throw RipleyException("Argument l1 must be a float or 2-tuple");
54        } else if (extract<double>(l1).check()) {
55            y1=extract<double>(l1);
56        } else
57            throw RipleyException("Argument l1 must be a float or 2-tuple");
58    
59        if (extract<tuple>(l2).check()) {
60            tuple z=extract<tuple>(l2);
61            if (len(z)==2) {
62                z0=extract<double>(z[0]);
63                z1=extract<double>(z[1]);
64            } else
65                throw RipleyException("Argument l2 must be a float or 2-tuple");
66        } else if (extract<double>(l2).check()) {
67            z1=extract<double>(l2);
68        } else
69            throw RipleyException("Argument l2 must be a float or 2-tuple");
70    
71        return escript::Domain_ptr(new Brick(n0,n1,n2, x0,y0,z0, x1,y1,z1, d0,d1,d2));
72  }  }
73    
74  escript::Domain_ptr _rectangle(int n0, int n1, double l0, double l1, int d0, int d1)  const int _q[]={0x61686969,0x746c4144,0x79616e43};
75    escript::Domain_ptr _rectangle(int n0, int n1, const object& l0,
76                                   const object& l1, int d0, int d1)
77  {  {
78      return escript::Domain_ptr(new Rectangle(n0, n1, l0, l1, d0, d1));      double x0=0., x1=1., y0=0., y1=1.;
79        if (extract<tuple>(l0).check()) {
80            tuple x=extract<tuple>(l0);
81            if (len(x)==2) {
82                x0=extract<double>(x[0]);
83                x1=extract<double>(x[1]);
84            } else
85                throw RipleyException("Argument l0 must be a float or 2-tuple");
86        } else if (extract<double>(l0).check()) {
87            x1=extract<double>(l0);
88        } else
89            throw RipleyException("Argument l0 must be a float or 2-tuple");
90    
91        if (extract<tuple>(l1).check()) {
92            tuple y=extract<tuple>(l1);
93            if (len(y)==2) {
94                y0=extract<double>(y[0]);
95                y1=extract<double>(y[1]);
96            } else
97                throw RipleyException("Argument l1 must be a float or 2-tuple");
98        } else if (extract<double>(l1).check()) {
99            y1=extract<double>(l1);
100        } else
101            throw RipleyException("Argument l1 must be a float or 2-tuple");
102    
103        return escript::Domain_ptr(new Rectangle(n0,n1, x0,y0, x1,y1, d0,d1));
104  }  }
105    std::string _who(){int a[]={_q[0]^42,_q[1]^42,_q[2]^42,0};return (char*)&a[0];}
106    
107  }  }
108    
109  /**  /**
110      \page ripley Ripley      \page ripley Ripley
111      Ripley is the python module name that contains the interfaces      ripleycpp is the python module name that contains the interfaces
112      to the C++ wrapper to ripley.      to the C++ wrapper to ripley.
113  */  */
114    
# Line 61  BOOST_PYTHON_MODULE(ripleycpp) Line 127  BOOST_PYTHON_MODULE(ripleycpp)
127  ":param n0: number of elements in direction 0\n:type n0: ``int``\n"  ":param n0: number of elements in direction 0\n:type n0: ``int``\n"
128  ":param n1: number of elements in direction 1\n:type n1: ``int``\n"  ":param n1: number of elements in direction 1\n:type n1: ``int``\n"
129  ":param n2: number of elements in direction 2\n:type n2: ``int``\n"  ":param n2: number of elements in direction 2\n:type n2: ``int``\n"
130  ":param l0: length of side 0\n:type l0: ``float``\n"  ":param l0: length of side 0 or coordinate range of side 0\n:type l0: ``float`` or ``tuple``\n"
131  ":param l1: length of side 1\n:type l1: ``float``\n"  ":param l1: length of side 1 or coordinate range of side 1\n:type l1: ``float`` or ``tuple``\n"
132  ":param l2: length of side 2\n:type l2: ``float``\n"  ":param l2: length of side 2 or coordinate range of side 2\n:type l2: ``float`` or ``tuple``\n"
133  ":param d0: number of subdivisions in direction 0\n:type d0: ``int``\n"  ":param d0: number of subdivisions in direction 0\n:type d0: ``int``\n"
134  ":param d1: number of subdivisions in direction 1\n:type d1: ``int``\n"  ":param d1: number of subdivisions in direction 1\n:type d1: ``int``\n"
135  ":param d2: number of subdivisions in direction 2\n:type d2: ``int``");  ":param d2: number of subdivisions in direction 2\n:type d2: ``int``");
# Line 72  BOOST_PYTHON_MODULE(ripleycpp) Line 138  BOOST_PYTHON_MODULE(ripleycpp)
138  "Creates a rectangular mesh with n0 x n1 elements over the rectangle [0,l0] x [0,l1].\n\n"  "Creates a rectangular mesh with n0 x n1 elements over the rectangle [0,l0] x [0,l1].\n\n"
139  ":param n0: number of elements in direction 0\n:type n0: ``int``\n"  ":param n0: number of elements in direction 0\n:type n0: ``int``\n"
140  ":param n1: number of elements in direction 1\n:type n1: ``int``\n"  ":param n1: number of elements in direction 1\n:type n1: ``int``\n"
141  ":param l0: length of side 0\n:type l0: ``float``\n"  ":param l0: length of side 0 or coordinate range of side 0\n:type l0: ``float`` or ``tuple``\n"
142  ":param l1: length of side 1\n:type l1: ``float``\n"  ":param l1: length of side 1 or coordinate range of side 1\n:type l1: ``float`` or ``tuple``\n"
143  ":param d0: number of subdivisions in direction 0\n:type d0: ``int``\n"  ":param d0: number of subdivisions in direction 0\n:type d0: ``int``\n"
144  ":param d1: number of subdivisions in direction 1\n:type d1: ``int``");  ":param d1: number of subdivisions in direction 1\n:type d1: ``int``");
145        def("_theculprit_", ripley::_who),
146      def("LoadMesh", ripley::RipleyDomain::loadMesh, (arg("filename")),      def("LoadMesh", ripley::RipleyDomain::loadMesh, (arg("filename")),
147             "Loads a ripley domain from a dump file" ":rtype: `Domain`");             "Loads a ripley domain from a dump file" ":rtype: `Domain`");
148    
# Line 113  args("mat", "rhs", "A", "B", "C", "D", " Line 179  args("mat", "rhs", "A", "B", "C", "D", "
179  ":param Y:\n:type Y: `Data`\n"  ":param Y:\n:type Y: `Data`\n"
180  ":param d:\n:type d: `Data`\n"  ":param d:\n:type d: `Data`\n"
181  ":param d_contact:\n:type d_contact: `Data`\n"  ":param d_contact:\n:type d_contact: `Data`\n"
182  ":param y_contact:\n:type y_contact: `Data`\n"  ":param y_contact:\n:type y_contact: `Data`"
 )  
         .def("addPDEToLumpedSystem",&ripley::RipleyDomain::addPDEToLumpedSystem,  
 args("mat", "D", "d"),  
 "adds a PDE onto the lumped stiffness matrix\n\n"  
 ":param mat:\n:type mat: `Data`\n"  
 ":param D:\n:type D: `Data`\n"  
 ":param d:\n:type d: `Data`\n"  
 ":param useHRZ:\n:type useHRZ: bool\n"  
183  )  )
184          .def("addPDEToRHS",&ripley::RipleyDomain::addPDEToRHS,          .def("addPDEToRHS",&ripley::RipleyDomain::addPDEToRHS,
185  args("rhs", "X", "Y", "y", "y_contact"),  args("rhs", "X", "Y", "y", "y_contact"),
# Line 146  args( "tp", "source", "M", "A", "B", "C" Line 204  args( "tp", "source", "M", "A", "B", "C"
204  ":param d:\n:type d: `Data`\n"  ":param d:\n:type d: `Data`\n"
205  ":param y:\n:type y: `Data`\n"  ":param y:\n:type y: `Data`\n"
206  ":param d_contact:\n:type d_contact: `Data`\n"  ":param d_contact:\n:type d_contact: `Data`\n"
207  ":param y_contact:\n:type y_contact: `Data`\n"  ":param y_contact:\n:type y_contact: `Data`"
208  )  )
209          .def("newOperator",&ripley::RipleyDomain::newSystemMatrix,          .def("newOperator",&ripley::RipleyDomain::newSystemMatrix,
210  args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),  args("row_blocksize", "row_functionspace", "column_blocksize", "column_functionspace", "type"),
# Line 155  args("row_blocksize", "row_functionspace Line 213  args("row_blocksize", "row_functionspace
213  ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"  ":param row_functionspace:\n:type row_functionspace: `FunctionSpace`\n"
214  ":param column_blocksize:\n:type column_blocksize: ``int``\n"  ":param column_blocksize:\n:type column_blocksize: ``int``\n"
215  ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"  ":param column_functionspace:\n:type column_functionspace: `FunctionSpace`\n"
216  ":param type:\n:type type: ``int``\n"  ":param type:\n:type type: ``int``"
217  )  )
218          .def("newTransportProblem",&ripley::RipleyDomain::newTransportProblem,          .def("newTransportProblem",&ripley::RipleyDomain::newTransportProblem,
219  args("theta", "blocksize", "functionspace", "type"),  args("theta", "blocksize", "functionspace", "type"),
# Line 163  args("theta", "blocksize", "functionspac Line 221  args("theta", "blocksize", "functionspac
221  ":param theta:\n:type theta: ``float``\n"  ":param theta:\n:type theta: ``float``\n"
222  ":param blocksize:\n:type blocksize: ``int``\n"  ":param blocksize:\n:type blocksize: ``int``\n"
223  ":param functionspace:\n:type functionspace: `FunctionSpace`\n"  ":param functionspace:\n:type functionspace: `FunctionSpace`\n"
224  ":param type:\n:type type: ``int``\n"  ":param type:\n:type type: ``int``"
225  )  )
226          .def("getSystemMatrixTypeId",&ripley::RipleyDomain::getSystemMatrixTypeId,          .def("getSystemMatrixTypeId",&ripley::RipleyDomain::getSystemMatrixTypeId,
227  args("solver", "preconditioner", "package", "symmetry"),  args("solver", "preconditioner", "package", "symmetry"),
228  ":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"  ":return: the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package, preconditioner, and symmetric matrix is used.\n"
229  ":rtype: ``int``\n"  ":rtype: ``int``\n"
230  ":param solver:\n:type solver: ``int``\n"  ":param solver:\n:type solver: ``int``\n"
231  ":param preconditioner:\n:type preconditioner: ``int``\n"  ":param preconditioner:\n:type preconditioner: ``int``\n"
232  ":param package:\n:type package: ``int``\n"  ":param package:\n:type package: ``int``\n"
233  ":param symmetry:\n:type symmetry: ``int``\n"  ":param symmetry:\n:type symmetry: ``int``"
234  )  )
235          .def("getTransportTypeId",&ripley::RipleyDomain::getTransportTypeId,          .def("getTransportTypeId",&ripley::RipleyDomain::getTransportTypeId,
236  args("solver", "preconditioner", "package", "symmetry"),  args("solver", "preconditioner", "package", "symmetry"),
237  ":return: the identifier of the transport problem type to be used when a particular solver, perconditioner, package and symmetric matrix is used.\n"  ":return: the identifier of the transport problem type to be used when a particular solver, preconditioner, package and symmetric matrix is used.\n"
238  ":rtype: ``int``\n"  ":rtype: ``int``\n"
239  ":param solver:\n:type solver: ``int``\n"  ":param solver:\n:type solver: ``int``\n"
240  ":param preconditioner:\n:type preconditioner: ``int``\n"  ":param preconditioner:\n:type preconditioner: ``int``\n"
241  ":param package:\n:type package: ``int``\n"  ":param package:\n:type package: ``int``\n"
242  ":param symmetry:\n:type symmetry: ``int``\n"  ":param symmetry:\n:type symmetry: ``int``"
243  )  )
 //      .def("setX",&ripley::RipleyDomain::setNewX,  
 //args("arg"), "assigns new location to the domain\n\n:param arg:\n:type arg: `Data`")  
244          .def("getX",&ripley::RipleyDomain::getX, ":return: locations in the FEM nodes\n\n"          .def("getX",&ripley::RipleyDomain::getX, ":return: locations in the FEM nodes\n\n"
245  ":rtype: `Data`")  ":rtype: `Data`")
246          .def("getNormal",&ripley::RipleyDomain::getNormal,          .def("getNormal",&ripley::RipleyDomain::getNormal,
# Line 206  args("solver", "preconditioner", "packag Line 262  args("solver", "preconditioner", "packag
262          .def("onMasterProcessor",&ripley::RipleyDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");          .def("onMasterProcessor",&ripley::RipleyDomain::onMasterProcessor,":return: True if this code is executing on the master process\n:rtype: `bool`");
263    
264      class_<ripley::Brick, bases<ripley::RipleyDomain> >("RipleyBrick", "", no_init);      class_<ripley::Brick, bases<ripley::RipleyDomain> >("RipleyBrick", "", no_init);
   
265      class_<ripley::Rectangle, bases<ripley::RipleyDomain> >("RipleyRectangle", "", no_init);      class_<ripley::Rectangle, bases<ripley::RipleyDomain> >("RipleyRectangle", "", no_init);
   
266  }  }
267    

Legend:
Removed from v.3691  
changed lines
  Added in v.3791

  ViewVC Help
Powered by ViewVC 1.1.26