summaryrefslogtreecommitdiff
path: root/src/geometry/blockGeometryView2D.hh
blob: d038f8e142a36109badcdea934dd30f2be82d3b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2014 Mathias J. Krause
 *  E-mail contact: info@openlb.net
 *  The most recent release of OpenLB can be downloaded at
 *  <http://www.openlb.net/>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA  02110-1301, USA.
 */

/** \file
 * Representation of the 2D block geometry view -- generic implementation.
 */

#ifndef BLOCK_GEOMETRY_VIEW_2D_HH
#define BLOCK_GEOMETRY_VIEW_2D_HH


#include <vector>
#include "geometry/blockGeometryView2D.h"


namespace olb {

template<typename T>
BlockGeometryView2D<T>::BlockGeometryView2D
(BlockGeometryStructure2D<T>& originalBlockGeometry, int x0, int x1, int y0,
 int y1)
  : BlockGeometryStructure2D<T>(originalBlockGeometry.getIcGlob()),
    BlockStructure2D(x1-x0+1, y1-y0+1),
    _originalBlockGeometry(&originalBlockGeometry), _x0(x0), _y0(y0),
    _nx(x1-x0+1), _ny(y1-y0+1)
{
  this->_statistics = BlockGeometryStatistics2D<T>(this);
  addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
}

template<typename T>
BlockGeometryView2D<T>::BlockGeometryView2D(BlockGeometryView2D const& rhs)
  : BlockGeometryStructure2D<T>(rhs),
    BlockStructure2D(0,0)
{
  _originalBlockGeometry = rhs._originalBlockGeometry;
  _x0 = rhs._x0;
  _y0 = rhs._y0;
  _nx = rhs._nx;
  _ny = rhs._ny;
  this->_iCglob = rhs._iCglob;
  this->_statistics = BlockGeometryStatistics2D<T>(this);
  addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
}

template<typename T>
BlockGeometryView2D<T>& BlockGeometryView2D<T>::operator=(BlockGeometryView2D const& rhs)
{
  _originalBlockGeometry = rhs._originalBlockGeometry;
  _x0 = rhs._x0;
  _y0 = rhs._y0;
  _nx = rhs._nx;
  _ny = rhs._ny;
  this->_iCglob = rhs._iCglob;
  this->_statistics = BlockGeometryStatistics2D<T>(this);
  addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
  return *this;
}

template<typename T>
BlockGeometryView2D<T>::~BlockGeometryView2D()
{
  removeFromStatisticsList( &(this->_statistics.getStatisticsStatus()) );
}

template<typename T>
BlockStructure2D& BlockGeometryView2D<T>::getBlockStructure()
{
  return *this;
}

template<typename T>
BlockGeometryStatistics2D<T>& BlockGeometryView2D<T>::getStatistics(bool verbose)
{
  return this->_statistics;
}

template<typename T>
BlockGeometryStatistics2D<T> const& BlockGeometryView2D<T>::getStatistics(bool verbose) const
{
  return this->_statistics;
}

template<typename T>
Vector<T,2> BlockGeometryView2D<T>::getOrigin() const
{
  Vector<T,2> origin;
  origin[0] = _originalBlockGeometry->getOrigin()[0] + _x0*getDeltaR();
  origin[1] = _originalBlockGeometry->getOrigin()[1] + _y0*getDeltaR();
  return origin;
}

template<typename T>
const T BlockGeometryView2D<T>::getDeltaR() const
{
  return _originalBlockGeometry->getDeltaR();
}

template<typename T>
int BlockGeometryView2D<T>::getNx() const
{
  return _nx;
}

template<typename T>
int BlockGeometryView2D<T>::getNy() const
{
  return _ny;
}


template<typename T>
int& BlockGeometryView2D<T>::get(int iX, int iY)
{
  return _originalBlockGeometry->get(_x0+iX, _y0+iY);
}

template<typename T>
const int& BlockGeometryView2D<T>::get(int iX, int iY) const
{
  return _originalBlockGeometry->get(_x0+iX, _y0+iY);
}

template<typename T>
int BlockGeometryView2D<T>::getMaterial(int iX, int iY) const
{
  return _originalBlockGeometry->getMaterial(_x0+iX, _y0+iY);
}

template<typename T>
void BlockGeometryView2D<T>::getPhysR(T physR[2], const int& iX, const int& iY) const
{
  _originalBlockGeometry->getPhysR(physR, _x0 + iX, _y0 + iY);
  return;
}

template<typename T>
void BlockGeometryView2D<T>::addToStatisticsList(bool* statisticStatus)
{
  _originalBlockGeometry->addToStatisticsList(statisticStatus);
}

template<typename T>
void BlockGeometryView2D<T>::removeFromStatisticsList(bool* statisticStatus)
{
  _originalBlockGeometry->removeFromStatisticsList(statisticStatus);
}

} // namespace olb

#endif