/[escript]/branches/trilinos_from_5897/escriptcore/src/DataConstant.h
ViewVC logotype

Annotation of /branches/trilinos_from_5897/escriptcore/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 480 - (hide annotations)
Wed Feb 1 05:15:12 2006 UTC (13 years, 5 months ago) by jgs
Original Path: trunk/escript/src/DataConstant.h
File MIME type: text/plain
File size: 5817 byte(s)
rationalise #includes and forward declarations

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26