/[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 3780 by caltinay, Mon Jan 23 06:26:40 2012 UTC revision 3781 by caltinay, Mon Jan 23 22:18:49 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)  escript::Domain_ptr _rectangle(int n0, int n1, const object& l0,
75                                   const object& l1, int d0, int d1)
76  {  {
77      return escript::Domain_ptr(new Rectangle(n0, n1, l0, l1, d0, d1));      double x0=0., x1=1., y0=0., y1=1.;
78        if (extract<tuple>(l0).check()) {
79            tuple x=extract<tuple>(l0);
80            if (len(x)==2) {
81                x0=extract<double>(x[0]);
82                x1=extract<double>(x[1]);
83            } else
84                throw RipleyException("Argument l0 must be a float or 2-tuple");
85        } else if (extract<double>(l0).check()) {
86            x1=extract<double>(l0);
87        } else
88            throw RipleyException("Argument l0 must be a float or 2-tuple");
89    
90        if (extract<tuple>(l1).check()) {
91            tuple y=extract<tuple>(l1);
92            if (len(y)==2) {
93                y0=extract<double>(y[0]);
94                y1=extract<double>(y[1]);
95            } else
96                throw RipleyException("Argument l1 must be a float or 2-tuple");
97        } else if (extract<double>(l1).check()) {
98            y1=extract<double>(l1);
99        } else
100            throw RipleyException("Argument l1 must be a float or 2-tuple");
101    
102        return escript::Domain_ptr(new Rectangle(n0, n1, x0, y0, x1, y1, d0, d1));
103  }  }
104    
105  }  }
# Line 61  BOOST_PYTHON_MODULE(ripleycpp) Line 125  BOOST_PYTHON_MODULE(ripleycpp)
125  ":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"
126  ":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"
127  ":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"
128  ":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"
129  ":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"
130  ":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"
131  ":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"
132  ":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"
133  ":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 136  BOOST_PYTHON_MODULE(ripleycpp)
136  "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"
137  ":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"
138  ":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"
139  ":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"
140  ":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"
141  ":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"
142  ":param d1: number of subdivisions in direction 1\n:type d1: ``int``");  ":param d1: number of subdivisions in direction 1\n:type d1: ``int``");
143    

Legend:
Removed from v.3780  
changed lines
  Added in v.3781

  ViewVC Help
Powered by ViewVC 1.1.26