OpenLB 1.7
Loading...
Searching...
No Matches
cuboid2D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2007, 2014 Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
28#ifndef CUBOID_2D_H
29#define CUBOID_2D_H
30
31#include <vector>
32#include <math.h>
33
34#include "io/ostreamManager.h"
35#include "core/vector.h"
36#include "core/olbDebug.h"
37#include "core/blockStructure.h"
38
39// All OpenLB code is contained in this namespace.
40namespace olb {
41
44
53template<typename T>
54class Cuboid2D {
55private:
57 T _globPosX, _globPosY;
59 T _delta;
61 int _nX, _nY;
63 size_t _weight;
64
66 mutable OstreamManager clout;
67
68public:
70 Cuboid2D(T globPosX, T globPosY, T delta, int nX, int nY);
72 Cuboid2D(Vector<T,2> origin, T delta, Vector<int,2> extend);
74 Cuboid2D(Cuboid2D<T> const& rhs, int overlap=0);
76 Cuboid2D& operator=(Cuboid2D const& rhs);
78 void init(T globPosX, T globPosY, T delta, int nX, int nY);
80 T get_globPosX() const;
81 T get_globPosY() const;
83 Vector<T,2> const getOrigin() const;
85 T getDeltaR() const;
87 int getNx() const;
89 int getNy() const;
91 Vector<int,2> const getExtent() const;
92
94 T getPhysVolume() const;
96 size_t getLatticeVolume() const;
98 T getPhysPerimeter() const;
100 int getLatticePerimeter() const;
102 void print() const;
103
104 void getPhysR(T physR[2], const int latticeR[2]) const;
105 void getPhysR(T physR[2], const int& iX, const int& iY) const;
106 void getPhysR(T physR[3], LatticeR<2> latticeR) const;
107
108 void getLatticeR(int latticeR[2], const T physR[2]) const;
109 void getLatticeR(int latticeR[2], const Vector<T,2>& physR) const;
110
111 void getFloorLatticeR(const std::vector<T>& physR, std::vector<int>& latticeR) const
112 {
113 getFloorLatticeR(&latticeR[0], &physR[0]);
114 }
115
116 void getFloorLatticeR(int latticeR[2], const T physR[2]) const
117 {
118 latticeR[0] = (int)util::floor( (physR[0] - _globPosX)/_delta);
119 latticeR[1] = (int)util::floor( (physR[1] - _globPosY)/_delta);
120 }
121
123 size_t getWeight() const;
125 void setWeight(size_t fullCells);
126
129 bool checkPoint(T globX, T globY, int overlap = 0) const;
130 bool checkPoint(Vector<T,2>& globXY, int overlap = 0) const;
134 // TODO: adapt to use only sum operation (cf. #204)
135 [[deprecated]] bool checkPoint(T globX, T globY, int &locX, int &locY, int overlap = 0) const;
138 bool checkInters(T globX0, T globX1, T globY0, T globY1, int overlap = 0) const;
141 bool checkInters(T globX, T globY, int overlap = 0) const;
146 bool checkInters(T globX0, T globX1, T globY0, T globY1,
147 int &locX0, int &locX1, int &locY0, int &locY1,
148 int overlap = 0) const;
150 void divide(int p, int q, std::vector<Cuboid2D<T> > &childrenC) const;
152 void divide(int p, std::vector<Cuboid2D<T> > &childrenC) const;
153
155 void resize(int X, int Y, int nX, int nY);
156
157};
158
159} // namespace olb
160
161#endif
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
Definition cuboid2D.h:54
size_t getLatticeVolume() const
Returns the number of Nodes in the volume.
Definition cuboid2D.hh:136
void print() const
Prints cuboid details.
Definition cuboid2D.hh:154
T getPhysVolume() const
Returns the volume of the cuboid.
Definition cuboid2D.hh:130
int getLatticePerimeter() const
Returns the number of Nodes at the perimeter.
Definition cuboid2D.hh:148
void getFloorLatticeR(const std::vector< T > &physR, std::vector< int > &latticeR) const
Definition cuboid2D.h:111
Cuboid2D(T globPosX, T globPosY, T delta, int nX, int nY)
Construction of a cuboid.
Definition cuboid2D.hh:45
void setWeight(size_t fullCells)
Sets the number of full cells.
Definition cuboid2D.hh:397
void getLatticeR(int latticeR[2], const T physR[2]) const
Definition cuboid2D.hh:189
bool checkInters(T globX0, T globX1, T globY0, T globY1, int overlap=0) const
Checks whether there is an intersection with the cuboid extended with an layer of size overlap*delta.
Definition cuboid2D.hh:241
T get_globPosY() const
Definition cuboid2D.hh:94
size_t getWeight() const
Returns the number of full cells.
Definition cuboid2D.hh:386
void divide(int p, int q, std::vector< Cuboid2D< T > > &childrenC) const
Divides the cuboid in p*q cuboids and adds them to the given vector.
Definition cuboid2D.hh:298
Vector< int, 2 > const getExtent() const
Read only access to the number of voxels in every dimension.
Definition cuboid2D.hh:124
T getDeltaR() const
Read access to the distance of cuboid nodes.
Definition cuboid2D.hh:106
bool checkPoint(T globX, T globY, int overlap=0) const
Checks whether a point (globX/globY) is contained in the cuboid extended with an layer of size overla...
Definition cuboid2D.hh:203
void getPhysR(T physR[3], LatticeR< 2 > latticeR) const
void resize(int X, int Y, int nX, int nY)
resize the cuboid to the passed size
Definition cuboid2D.hh:377
void getFloorLatticeR(int latticeR[2], const T physR[2]) const
Definition cuboid2D.h:116
void getPhysR(T physR[2], const int latticeR[2]) const
Definition cuboid2D.hh:168
Vector< T, 2 > const getOrigin() const
Read only access to left lower corner coordinates.
Definition cuboid2D.hh:100
int getNx() const
Read access to cuboid width.
Definition cuboid2D.hh:112
int getNy() const
Read access to cuboid height.
Definition cuboid2D.hh:118
T get_globPosX() const
Read access to left lower corner coordinates.
Definition cuboid2D.hh:88
T getPhysPerimeter() const
Returns the perimeter of the cuboid.
Definition cuboid2D.hh:142
Cuboid2D & operator=(Cuboid2D const &rhs)
Copy assignment.
Definition cuboid2D.hh:69
void init(T globPosX, T globPosY, T delta, int nX, int nY)
Initializes the cuboid.
Definition cuboid2D.hh:77
class for marking output with some text
Plain old scalar vector.
Definition vector.h:47
ADf< T, DIM > floor(const ADf< T, DIM > &a)
Definition aDiff.h:869
Top level namespace for all of OpenLB.
efficient implementation of a vector class