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

Contents of /trunk/escript/src/DataVector.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 751 - (show annotations)
Mon Jun 26 01:46:34 2006 UTC (12 years, 9 months ago) by bcumming
File MIME type: text/plain
File size: 6003 byte(s)
Changes relating to the MPI version of escript
The standard OpenMP version of escript is unchanged

- updated data types (Finley_Mesh, Finley_NodeFile, etc) to store meshes
  over multiple MPI processes.
- added CommBuffer code in Paso for communication of Data associated
  with distributed meshes
- updates in Finley and Escript to support distributed data and operations
  on distributed data (such as interpolation).
- construction of RHS in MPI, so that simple explicit schemes (such as
  /docs/examples/wave.py without IO and the Locator) can run in MPI.
- updated mesh generation for first order line, rectangle and brick
  meshes and second order line meshes in MPI.        
- small changes to trunk/SConstruct and trunk/scons/ess_options.py to
  build the MPI version, these changes are turned off by default.

1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 #if !defined escript_DataVector_20050324_H
14 #define escript_DataVector_20050324_H
15
16 #include "esysUtils/EsysAssert.h"
17
18 #include <mpi.h>
19 #include <vector>
20 #include <iostream>
21 #include <fstream>
22
23 namespace escript {
24
25 /**
26 \brief
27 DataVector implements an arbitrarily long vector of data values.
28 DataVector is the underlying data container for Data objects.
29
30 Description:
31 DataVector provides an implementation of a vector of data values for use
32 by DataBlocks2D and DataArrayView. Hiding the vector in this container
33 allows different implementations to be swapped in without disrupting the
34 client classes.
35 */
36
37 class DataVector {
38
39 public:
40
41 //
42 // The type of the elements stored in the vector.
43 typedef double ElementType;
44
45 //
46 // The underlying type used to implement the vector.
47 typedef ElementType * ValueType;
48
49 //
50 // Various types exported to clients of this class.
51 typedef ElementType value_type;
52 typedef long size_type;
53 typedef ElementType & reference;
54 typedef const ElementType & const_reference;
55
56 /**
57 \brief
58 Default constructor for DataVector.
59
60 Description:
61 Constructs an empty DataVector object.
62 */
63 DataVector();
64
65 /**
66 \brief
67 Copy constructor for DataVector.
68
69 Description:
70 Constructs a DataVector object which is a copy of the
71 given DataVector object.
72 */
73 DataVector(const DataVector& other);
74
75 /**
76 \brief
77 Constructor for DataVector.
78
79 Description:
80 Constructs a DataVector object of length "size" with all elements
81 initilised to "val".
82
83 \param size - Input - Number of elements in the vector.
84 \param val - Input - Initial value for all elements in the vector. Default is 0.0.
85 \param blockSize - Input - size of blocks within the vector, overall vector
86 size must be a precise multiple of the block size. Default is 1.
87
88 In escript::Data, blocksize corresponds to the number of elements required to hold all
89 the data-points for a sample, ie: the product of the dimensions of a data-point and the
90 number of data-points per sample. Size is the total number of elements required to hold
91 all elements for all data-points in the given object, ie: number of samples * blocksize.
92 */
93 DataVector(const size_type size,
94 const value_type val=0.0,
95 const size_type blockSize=1);
96
97 /**
98 \brief
99 Default destructor for DataVector.
100
101 Description:
102 Destroys the current DataVector object.
103 */
104 ~DataVector();
105
106 /**
107 \brief
108 Resize the DataVector to the given length "newSize".
109 All current data is lost. All elements in the new DataVector are
110 initialised to "newVal".
111
112 \param newSize - Input - New size for the vector.
113 \param newVal - Input - New initial value for all elements in the vector.
114 \param newBlockSize - Input - New block size for the vector.
115 */
116 void
117 resize(const size_type newSize,
118 const value_type newVal=0.0,
119 const size_type newBlockSize=1);
120
121 /**
122 \brief
123 Return the number of elements in this DataVector.
124 */
125 inline
126 size_type
127 size() const;
128
129 /**
130 \brief
131 DataVector assignment operator "=".
132 Assign the given DataVector object to this.
133 */
134 DataVector&
135 operator=(const DataVector& other);
136
137 /**
138 \brief
139 DataVector equality comparison operator "==".
140 Return true if the given DataVector is equal to this.
141 */
142 bool
143 operator==(const DataVector& other) const;
144
145 /**
146 \brief
147 DataVector inequality comparison operator "!=".
148 Return true if the given DataVector is not equal to this.
149 */
150 bool
151 operator!=(const DataVector& other) const;
152
153 /**
154 \brief
155 Return a reference to the element at position i in this DataVector.
156 Will throw an exception if an invalid index "i" is given.
157
158 NB: access to the element one past the end of the vector is permitted
159 in order to provide a facility equivalent to an end() pointer.
160 */
161 inline
162 reference
163 operator[](const size_type i);
164
165 inline
166 const_reference
167 operator[](const size_type i) const;
168
169 /**
170 \brief
171 Archive the data managed by this DataVector to the file referenced
172 by ofstream. A count of the number of values expected to be written
173 is provided as a cross-check.
174
175
176 The return value indicates success (0) or otherwise (1).
177 */
178 int
179 archiveData(std::ofstream& archiveFile,
180 const size_type noValues) const;
181
182 /**
183 \brief
184 Extract the number of values specified by noValues from the file
185 referenced by ifstream to this DataVector.
186
187 The return value indicates success (0) or otherwise (1).
188 */
189 int
190 extractData(std::ifstream& archiveFile,
191 const size_type noValues);
192
193 protected:
194
195 private:
196
197 size_type m_size;
198 size_type m_dim;
199 size_type m_N;
200
201 //
202 // The container for the elements contained in this DataVector.
203 ValueType m_array_data;
204 };
205
206 inline
207 DataVector::size_type
208 DataVector::size() const
209 {
210 return m_size;
211 }
212
213 inline
214 DataVector::reference
215 DataVector::operator[](const DataVector::size_type i)
216 {
217 EsysAssert(i<size(),"DataVector: invalid index specified.");
218 return m_array_data[i];
219 }
220
221 inline
222 DataVector::const_reference
223 DataVector::operator[](const DataVector::size_type i) const
224 {
225 EsysAssert(i<size(),"DataVector: invalid index specified.");
226 return m_array_data[i];
227 }
228
229 } // end of namespace
230
231 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26