/[escript]/trunk/esys2/escript/src/Data/DataBlocks2D.h
ViewVC logotype

Contents of /trunk/esys2/escript/src/Data/DataBlocks2D.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years, 1 month ago) by jgs
File MIME type: text/plain
File size: 3977 byte(s)
Initial revision

1 /*
2 ******************************************************************************
3 * *
4 * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5 * *
6 * This software is the property of ACcESS. No part of this code *
7 * may be copied in any form or by any means without the expressed written *
8 * consent of ACcESS. Copying, use or modification of this software *
9 * by any unauthorised person is illegal unless that person has a software *
10 * license agreement with ACcESS. *
11 * *
12 ******************************************************************************
13 */
14
15 #if !defined escript_DataBlocks2D_20040405_H
16 #define escript_DataBlocks2D_20040405_H
17
18 #include <vector>
19
20 namespace escript {
21
22 /**
23 \brief
24 DataBlocks2D allocates and manages a 2D array of data blocks.
25
26 Description:
27 DataBlocks2D allocates and manages a 2D array of data blocks.
28
29 */
30
31 class DataBlocks2D {
32
33 public:
34
35 typedef std::vector<double> ValueType;
36
37 /**
38 \brief
39 Default constructor for DataBlocks2D
40
41 Description:
42 Default constructor for DataBlocks2D
43 */
44 DataBlocks2D();
45
46 /**
47 \brief
48 Copy constructor for DataBlocks2D
49
50 Description:
51 Copy constructor for DataBlocks2D
52 */
53 DataBlocks2D(const DataBlocks2D& other);
54
55 /**
56 \brief
57 Constructor for DataBlocks2D
58
59 Description:
60 Constructor for DataBlocks2D
61 \param numRows - Input - Number of rows
62 \param numCols - Input - Number of columns
63 \param blockSize - Input - Number of elements per block
64 */
65 DataBlocks2D(int numRows, int numCols, int blockSize);
66
67 /**
68 \brief
69 Default destructor for DataBlocks2D
70
71 Description:
72 Default destructor for DataBlocks2D
73 */
74 ~DataBlocks2D();
75
76 /**
77 \brief
78 Resize the container. All current data is lost.
79
80 Description:
81 Resize the container. All current data is lost. The data elements are
82 initialised to 0.
83
84 \param numRows - Input - Number of rows
85 \param numCols - Input - Number of columns
86 \param blockSize - Input - Number of elements per block
87 */
88 void resize(int numRows, int numCols, int blockSize);
89
90 /**
91 \brief
92 Return the 1 dimensional index of the first element for the block i,j.
93 Allows each element to be referenced as though entire 3D array was laid
94 out as a 1 dimensional list of elements.
95 */
96 ValueType::size_type index(ValueType::size_type i, ValueType::size_type j) const;
97
98 /**
99 \brief
100 Return the data
101 Data is returned as an array that can be indexed via indexes generated by DataBlocks2D::index
102 */
103 ValueType& getData();
104
105 /**
106 \brief
107 Return the data
108 Data is returned as an array that can be indexed via indexes generated by DataBlocks2D::index
109 */
110 const ValueType& getData() const;
111
112 /**
113 \brief
114 Return the number of rows
115 */
116 ValueType::size_type getNumRows() const;
117
118 /**
119 \brief
120 Return the number of columns
121 */
122 ValueType::size_type getNumCols() const;
123
124 /**
125 \brief
126 Swap
127 */
128 void Swap(DataBlocks2D& other);
129
130 /**
131 \brief
132 operator=
133 */
134 DataBlocks2D& operator=(const DataBlocks2D& other);
135
136 protected:
137
138 private:
139
140 //
141 // data container, currently only concerned with doubles
142 ValueType m_data;
143
144 //
145 // the number of doubles per data block
146 int m_blockSize;
147
148 //
149 //
150 int m_numRows;
151 int m_numCols;
152
153 };
154
155 inline DataBlocks2D::ValueType::size_type DataBlocks2D::getNumRows() const
156 {
157 return m_numRows;
158 }
159
160 inline DataBlocks2D::ValueType::size_type DataBlocks2D::getNumCols() const
161 {
162 return m_numCols;
163 }
164
165 } // end of namespace
166 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26