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

Contents of /trunk/escript/src/DataBlocks2D.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (show annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 4 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/DataBlocks2D.cpp
File size: 2780 byte(s)
Merge of development branch back to main trunk on 2005-07-08

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 #include "escript/Data/DataException.h"
16 #include "escript/Data/DataBlocks2D.h"
17 #include "esysUtils/EsysAssert.h"
18
19 #include <sstream>
20 #include <iostream>
21
22 using namespace std;
23
24 namespace escript {
25
26 DataBlocks2D::DataBlocks2D():
27 m_numRows(0),
28 m_numCols(0),
29 m_blockSize(0)
30 {
31 }
32
33 DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
34 m_numRows(other.m_numRows),
35 m_numCols(other.m_numCols),
36 m_blockSize(other.m_blockSize)
37 {
38 m_data=other.m_data;
39 }
40
41 DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
42 m_numRows(numRows),
43 m_numCols(numCols),
44 m_blockSize(blockSize)
45 {
46 resize(m_numRows,numCols,blockSize);
47 }
48
49 DataBlocks2D::~DataBlocks2D()
50 {
51 }
52
53 void
54 DataBlocks2D::resize(int numRows, int numCols, int blockSize)
55 {
56 if (numRows < 0 || numCols < 0 || blockSize < 0) {
57 stringstream mess;
58 mess << "Error - Invalid resize parameter. numRows: " << numRows
59 << " numCols: " << numCols << " blockSize: " << blockSize;
60 throw DataException(mess.str());
61 }
62 ValueType::size_type size=numRows*numCols*blockSize;
63 m_data.resize(size);
64 m_numRows=numRows;
65 m_numCols=numCols;
66 m_blockSize=blockSize;
67 }
68
69 void
70 DataBlocks2D::Swap(DataBlocks2D& other)
71 {
72 swap(m_data,other.m_data);
73 swap(m_blockSize,other.m_blockSize);
74 swap(m_numRows,other.m_numRows);
75 swap(m_numCols,other.m_numCols);
76 }
77
78 DataBlocks2D&
79 DataBlocks2D::operator=(const DataBlocks2D& other)
80 {
81 DataBlocks2D temp(other);
82 Swap(temp);
83 return *this;
84 }
85
86 int
87 DataBlocks2D::archiveData(ofstream& archiveFile,
88 const ValueType::size_type noValues) const
89 {
90 return(m_data.archiveData(archiveFile, noValues));
91 }
92
93 int
94 DataBlocks2D::extractData(ifstream& archiveFile,
95 const ValueType::size_type noValues)
96 {
97 return(m_data.extractData(archiveFile, noValues));
98 }
99
100 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26