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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 478 - (hide annotations)
Tue Jan 31 02:21:49 2006 UTC (13 years, 7 months ago) by jgs
File size: 2509 byte(s)
rationalise #includes

1 jgs 82 // $Id$
2     /*
3     ******************************************************************************
4     * *
5     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
6     * *
7     * This software is the property of ACcESS. No part of this code *
8     * may be copied in any form or by any means without the expressed written *
9     * consent of ACcESS. Copying, use or modification of this software *
10     * by any unauthorised person is illegal unless that person has a software *
11     * license agreement with ACcESS. *
12     * *
13     ******************************************************************************
14     */
15    
16 jgs 474 #include "DataFactory.h"
17 jgs 82
18     #include <boost/python/extract.hpp>
19    
20     using namespace boost::python;
21    
22     namespace escript {
23    
24     Data
25     Scalar(double value,
26     const FunctionSpace& what,
27     bool expanded)
28     {
29     //
30     // an empty shape is a scalar
31     DataArrayView::ShapeType shape;
32     return Data(value,shape,what,expanded);
33     }
34    
35     Data
36     Vector(double value,
37     const FunctionSpace& what,
38     bool expanded)
39     {
40     DataArrayView::ShapeType shape(1,what.getDomain().getDim());
41     return Data(value,shape,what,expanded);
42     }
43    
44     Data
45     Tensor(double value,
46     const FunctionSpace& what,
47     bool expanded)
48     {
49     DataArrayView::ShapeType shape(2,what.getDomain().getDim());
50     return Data(value,shape,what,expanded);
51     }
52    
53     Data
54     Tensor3(double value,
55     const FunctionSpace& what,
56     bool expanded)
57     {
58     DataArrayView::ShapeType shape(3,what.getDomain().getDim());
59     return Data(value,shape,what,expanded);
60     }
61    
62     Data
63     Tensor4(double value,
64     const FunctionSpace& what,
65     bool expanded)
66     {
67     DataArrayView::ShapeType shape(4,what.getDomain().getDim());
68     return Data(value,shape,what,expanded);
69     }
70    
71     Data
72     convertToData(const boost::python::object& value,
73     const FunctionSpace& what)
74     {
75     // first we try to extract a Data object from value
76     extract<Data> value_data(value);
77     if (value_data.check()) {
78     Data extracted_data=value_data();
79     if (extracted_data.isEmpty()) {
80     return extracted_data;
81     } else {
82     return Data(extracted_data,what);
83     }
84     } else {
85     return Data(value,what);
86     }
87     }
88    
89     } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26