/[escript]/trunk/escript/src/DataFactory.cpp
ViewVC logotype

Contents of /trunk/escript/src/DataFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (show annotations)
Wed Mar 22 02:12:00 2006 UTC (13 years, 8 months ago) by elspeth
File size: 2187 byte(s)
More copyright information.

1 // $Id$
2 /*
3 ************************************************************
4 * Copyright 2006 by ACcESS MNRF *
5 * *
6 * http://www.access.edu.au *
7 * Primary Business: Queensland, Australia *
8 * Licensed under the Open Software License version 3.0 *
9 * http://www.opensource.org/licenses/osl-3.0.php *
10 * *
11 ************************************************************
12 */
13
14 #include "DataFactory.h"
15
16 #include <boost/python/extract.hpp>
17
18 using namespace boost::python;
19
20 namespace escript {
21
22 Data
23 Scalar(double value,
24 const FunctionSpace& what,
25 bool expanded)
26 {
27 //
28 // an empty shape is a scalar
29 DataArrayView::ShapeType shape;
30 return Data(value,shape,what,expanded);
31 }
32
33 Data
34 Vector(double value,
35 const FunctionSpace& what,
36 bool expanded)
37 {
38 DataArrayView::ShapeType shape(1,what.getDomain().getDim());
39 return Data(value,shape,what,expanded);
40 }
41
42 Data
43 Tensor(double value,
44 const FunctionSpace& what,
45 bool expanded)
46 {
47 DataArrayView::ShapeType shape(2,what.getDomain().getDim());
48 return Data(value,shape,what,expanded);
49 }
50
51 Data
52 Tensor3(double value,
53 const FunctionSpace& what,
54 bool expanded)
55 {
56 DataArrayView::ShapeType shape(3,what.getDomain().getDim());
57 return Data(value,shape,what,expanded);
58 }
59
60 Data
61 Tensor4(double value,
62 const FunctionSpace& what,
63 bool expanded)
64 {
65 DataArrayView::ShapeType shape(4,what.getDomain().getDim());
66 return Data(value,shape,what,expanded);
67 }
68
69 Data
70 convertToData(const boost::python::object& value,
71 const FunctionSpace& what)
72 {
73 // first we try to extract a Data object from value
74 extract<Data> value_data(value);
75 if (value_data.check()) {
76 Data extracted_data=value_data();
77 if (extracted_data.isEmpty()) {
78 return extracted_data;
79 } else {
80 return Data(extracted_data,what);
81 }
82 } else {
83 return Data(value,what);
84 }
85 }
86
87 } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26