/[escript]/trunk/escript/src/DataConstant.h
ViewVC logotype

Annotation of /trunk/escript/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 474 - (hide annotations)
Mon Jan 30 04:23:44 2006 UTC (13 years, 9 months ago) by jgs
File MIME type: text/plain
File size: 5915 byte(s)
restructure escript source tree
move src/Data/* -> src
remove inc
modify #includes and cpppath settings accordingly

1 jgs 102 //$Id$
2 jgs 82 /*
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 102 #if !defined escript_DataConstant_20040323_H
17 jgs 82 #define escript_DataConstant_20040323_H
18    
19 jgs 474 #include "DataAbstract.h"
20     #include "DataArray.h"
21     #include "DataArrayView.h"
22 jgs 82
23     #include <boost/python/numeric.hpp>
24    
25     namespace escript {
26 jgs 102
27 jgs 82 /**
28     \brief
29 jgs 102 DataConstant stores a single data point which represents the entire
30 jgs 82 function space.
31    
32     Description:
33 jgs 102 DataConstant stores a single data point which represents the entire
34 jgs 82 function space.
35     */
36 jgs 102 class DataConstant : public DataAbstract {
37 jgs 82
38     public:
39    
40     /**
41     \brief
42 jgs 102 Constructor for DataConstant objects.
43 jgs 82
44     Description:
45 jgs 102 Constructor for DataConstant objects.
46 jgs 82
47 jgs 102 \param value - Input - Data value for a single point.
48     \param what - Input - A description of what this data object represents.
49     */
50     DataConstant(const boost::python::numeric::array& value,
51     const FunctionSpace& what);
52 jgs 100
53 jgs 82 /**
54     \brief
55     Copy constructor. Performs a deep copy.
56     */
57     DataConstant(const DataConstant& other);
58 jgs 102
59 jgs 82 /**
60     \brief
61 jgs 102 Alternative constructor for DataConstant objects.
62 jgs 82
63     Description:
64 jgs 102 Alternative Constructor for DataConstant objects.
65     \param value - Input - Data value for a single point.
66     \param what - Input - A description of what this data object represents.
67 jgs 82 */
68 jgs 102 DataConstant(const DataArrayView& value,
69     const FunctionSpace& what);
70    
71 jgs 82 /**
72     \brief
73 jgs 102 Alternative constructor for DataConstant objects.
74 jgs 82
75     Description:
76 jgs 102 Alternative Constructor for DataConstant objects.
77     \param other - Input - Data object to copy from.
78     \param region - Input - region to copy.
79 jgs 82 */
80 jgs 102 DataConstant(const DataConstant& other,
81     const DataArrayView::RegionType& region);
82    
83 jgs 82 /**
84     \brief
85 jgs 119 Alternative constructor for DataConstant objects.
86    
87     Description:
88     Alternative Constructor for DataConstant objects.
89     \param what - Input - A description of what this data object represents.
90     \param shape - Input - the shape of each data-point.
91     \param data - the data values for each data-point.
92     */
93     DataConstant(const FunctionSpace& what,
94     const DataArrayView::ShapeType &shape,
95     const DataArrayView::ValueType &data);
96    
97     /**
98     \brief
99 jgs 82 Write the data as a string.
100     */
101 jgs 102 std::string
102     toString() const;
103    
104 jgs 82 /**
105     \brief
106 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
107 jgs 82 but returns the offset in bytes for the given point into the container
108     holding the point data. Only really necessary to avoid many DataArrayView
109     objects.
110 jgs 102 \param sampleNo - Input - sample number.
111     \param dataPointNo - Input - data point number for the sample.
112 jgs 82 */
113 jgs 102 virtual
114     DataArrayView::ValueType::size_type
115     getPointOffset(int sampleNo,
116     int dataPointNo) const;
117    
118 jgs 82 /**
119     \brief
120     Return a view into the data for the data point specified.
121 jgs 102 \param sampleNo - Input - sample number.
122     \param dataPointNo - Input - data point number for the sample.
123 jgs 82 */
124 jgs 102 virtual
125     DataArrayView
126     getDataPoint(int sampleNo,
127     int dataPointNo);
128    
129 jgs 82 /**
130     \brief
131 jgs 102 Return the number of doubles stored for the Data object.
132 jgs 82 */
133 jgs 102 virtual
134 jgs 117 DataArrayView::ValueType::size_type
135 jgs 102 getLength() const;
136    
137 jgs 82 /**
138     \brief
139 jgs 102 Factory method that returns a newly created DataConstant object
140     sliced from the specified region of this object.
141 jgs 82 The caller is reponsible for managing the object created.
142 jgs 102 \param region - Input - region to slice from this object.
143 jgs 82 */
144 jgs 102 virtual
145     DataAbstract*
146     getSlice(const DataArrayView::RegionType& region) const;
147    
148     /**
149 jgs 82 \brief
150     Copy the specified region from the given value.
151 jgs 102 \param value - Input - Data object to copy from.
152     \param region - Input - Region to copy.
153 jgs 82 */
154 jgs 102 virtual
155     void
156     setSlice(const DataAbstract* value,
157     const DataArrayView::RegionType& region);
158    
159 jgs 82 /**
160     \brief
161     Reshape the data point if the data point is currently rank 0.
162     The original data point value is used for all values of the new
163     data point.
164     */
165 jgs 102 void
166     reshapeDataPoint(const DataArrayView::ShapeType& shape);
167    
168 jgs 123 /**
169     \brief
170     Archive the underlying data values to the file referenced
171     by ofstream. A count of the number of values expected to be written
172     is provided as a cross-check.
173    
174     The return value indicates success (0) or otherwise (1).
175     */
176     int
177     archiveData(std::ofstream& archiveFile,
178     const DataArrayView::ValueType::size_type noValues) const;
179    
180     /**
181     \brief
182     Extract the number of values specified by noValues from the file
183     referenced by ifstream to the underlying data structure.
184    
185     The return value indicates success (0) or otherwise (1).
186     */
187     int
188     extractData(std::ifstream& archiveFile,
189     const DataArrayView::ValueType::size_type noValues);
190    
191 jgs 82 protected:
192    
193     private:
194     //
195 jgs 102 // the actual data
196 jgs 82 DataArrayView::ValueType m_data;
197 jgs 102
198 jgs 82 };
199    
200     } // end of namespace
201     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26