/[escript]/branches/subworld2/escriptcore/src/DataBlocks2D.cpp
ViewVC logotype

Contents of /branches/subworld2/escriptcore/src/DataBlocks2D.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5504 - (show annotations)
Wed Mar 4 22:58:13 2015 UTC (4 years, 1 month ago) by jfenwick
File size: 2363 byte(s)
Again with a more up to date copy


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2015 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 #include "DataBlocks2D.h"
19
20 #include "DataException.h"
21 #include "esysUtils/EsysAssert.h"
22
23 using namespace std;
24
25 namespace escript {
26
27 DataBlocks2D::DataBlocks2D():
28 m_numRows(0),
29 m_numCols(0),
30 m_blockSize(0)
31 {
32 }
33
34 DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
35 m_numRows(other.m_numRows),
36 m_numCols(other.m_numCols),
37 m_blockSize(other.m_blockSize)
38 {
39 m_data=other.m_data;
40 }
41
42 DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
43 m_numRows(numRows),
44 m_numCols(numCols),
45 m_blockSize(blockSize)
46 {
47 resize(m_numRows,numCols,blockSize);
48 }
49
50 DataBlocks2D::~DataBlocks2D()
51 {
52 m_numRows=-1;
53 m_numCols=-1;
54 m_blockSize=-1;
55 }
56
57 void
58 DataBlocks2D::resize(int numRows, int numCols, int blockSize)
59 {
60 if (numRows < 1 || numCols < 1 || blockSize < 1) {
61 stringstream temp;
62 temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
63 << " numCols: " << numCols << " blockSize: " << blockSize;
64 throw DataException(temp.str());
65 }
66 ValueType::size_type size=numRows*numCols*blockSize;
67 m_data.resize(size, 0.0, numCols*blockSize);
68 m_numRows=numRows;
69 m_numCols=numCols;
70 m_blockSize=blockSize;
71 }
72
73 void
74 DataBlocks2D::Swap(DataBlocks2D& other)
75 {
76 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
77 swap(m_data,other.m_data);
78 swap(m_blockSize,other.m_blockSize);
79 swap(m_numRows,other.m_numRows);
80 swap(m_numCols,other.m_numCols);
81 }
82
83 DataBlocks2D&
84 DataBlocks2D::operator=(const DataBlocks2D& other)
85 {
86 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
87 DataBlocks2D temp(other);
88 Swap(temp);
89 return *this;
90 }
91
92 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26