OpenLB 1.7
Loading...
Searching...
No Matches
cuboidGeometry2D.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
29#ifndef CUBOID_GEOMETRY_2D_H
30#define CUBOID_GEOMETRY_2D_H
31
32#include <vector>
33#include "geometry/cuboid2D.h"
34#include "io/ostreamManager.h"
35
36
37// All OpenLB code is contained in this namespace.
38namespace olb {
39
40template<typename T> class IndicatorF2D;
41
43
55template<typename T>
57
58private:
59 // TODO quick and dirty solution for 3d split to be removed after 2d clearence
60 bool _oldApproach;
61
63 std::vector<Cuboid2D<T> > _cuboids;
65 Cuboid2D<T> _motherCuboid;
67 std::vector<bool> _periodicityOn;
69 mutable OstreamManager clout;
70
71public:
72
76 CuboidGeometry2D(T originX, T originY, T deltaR, int nX, int nY, int nC=1);
78 CuboidGeometry2D(IndicatorF2D<T>& indicatorF, T voxelSize, int nC=1);
79
81 void reInit(T globPosX, T globPosY,
82 T delta, int nX, int nY, int nC=1);
84 Cuboid2D<T>& get(int i);
86 Cuboid2D<T> const& get(int i) const;
88 void setPeriodicity(bool periodicityX, bool periodicityY);
89
91 bool getC(std::vector<T> physR, int& iC) const;
93 bool getC(const Vector<T,2>& physR, int& iC) const;
95 bool getLatticeR(std::vector<T> physR, std::vector<int>& latticeR) const;
96 bool getLatticeR(int latticeR[], const T physR[]) const;
97 bool getLatticeR(const Vector<T,2>& physR, Vector<int,3>& latticeR) const;
99 bool getFloorLatticeR(std::vector<T> physR, std::vector<int>& latticeR) const;
101 bool getFloorLatticeR(const Vector<T,2>& physR, Vector<int,3>& latticeR) const;
103 std::vector<T> getPhysR(int iCglob, int iX, int iY) const;
105 std::vector<T> getPhysR(std::vector<int> latticeR) const;
106 void getPhysR(T output[2], const int latticeR[3]) const;
107 void getPhysR(T output[2], const int iCglob, const int iX, const int iY) const;
108 void getPhysR(T output[2], const int iCglob, LatticeR<2> latticeR) const;
109 void getPhysR(T output[3], LatticeR<3> latticeR) const;
110
112 int getNc() const;
114 T getMinRatio() const;
115 T getMaxRatio() const;
117 std::vector<T> getMinPhysR() const;
119 std::vector<T> getMaxPhysR() const;
121 T getMinPhysVolume() const;
122 T getMaxPhysVolume() const;
124 size_t getMinLatticeVolume() const;
125 size_t getMaxLatticeVolume() const;
127 T getMinDeltaR() const;
128 T getMaxDeltaR() const;
132
135 int get_iC(T globX, T globY, int offset = 0) const;
141 int get_iC(T globX, T globY, int orientationX, int orientationY) const;
142
144 void add(Cuboid2D<T> cuboid);
146 void remove(int iC);
148 //void remove(olb::ScalarField2D<int>* geometryData);
150 void split(int iC, int p);
152 void shrink(IndicatorF2D<T>& indicatorF);
153
155 void getNeighbourhood(int cuboid, std::vector<int>& neighbours, int offset = 0);
156
158 void print() const;
160 void printExtended();
161};
162
163
165template<typename T>
167 CuboidGeometry2D<T>& cuboidGeometry,
168 std::map<int,std::vector<int>>& neighbourhood,
169 int offset=0 )
170{
171 for (int iC=0; iC<cuboidGeometry.getNc(); ++iC){
172 //Retrieve neighbours of iC
173 std::vector<int> neighbours;
174 cuboidGeometry.getNeighbourhood(iC, neighbours, offset);
175 neighbourhood[iC]=neighbours;
176 }
177}
178
179} // namespace olb
180
181#endif
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
Definition cuboid2D.h:54
A cuboid structure represents the grid of a considered domain.
void reInit(T globPosX, T globPosY, T delta, int nX, int nY, int nC=1)
Re init.
bool getFloorLatticeR(std::vector< T > physR, std::vector< int > &latticeR) const
Returns true and the util::floor lattice position to the given physical position if the physical posi...
void getPhysR(T output[3], LatticeR< 3 > latticeR) const
void remove(int iC)
Removes the cuboid iC.
void print() const
Prints cuboid geometry details.
int getNc() const
Returns the number of cuboids in t < 2he structure.
size_t getMinLatticeVolume() const
Returns the maximum/minimum number of nodes in the structure.
void printExtended()
Prints cuboid geometry details plus details of all cuboids.
CuboidGeometry2D()
Constructs empty Geometry.
void shrink(IndicatorF2D< T > &indicatorF)
Shrink all cuboids so that no empty planes are left.
Cuboid2D< T > getMotherCuboid() const
Returns the smallest cuboid that includes all cuboids of the structure.
void setPeriodicity(bool periodicityX, bool periodicityY)
Set flag to enable/disable periodicity.
size_t getMaxLatticeVolume() const
bool getC(std::vector< T > physR, int &iC) const
Returns true and the cuboid number of the nearest lattice position to the given physical position if ...
Cuboid2D< T > & get(int i)
Read and write access to the cuboids.
T getMinRatio() const
Returns the maximum/minimum of the ratio nX/NY in the structure.
T getMinDeltaR() const
Returns the maximum/minimum delata in the structure.
std::vector< T > getPhysR(int iCglob, int iX, int iY) const
Returns the physical position to the given lattice position respecting periodicity for the overlap no...
std::vector< T > getMinPhysR() const
Returns the minimum coordinate in the structure.
void getNeighbourhood(int cuboid, std::vector< int > &neighbours, int offset=0)
stores the neighbouring cuboids in array neighbours;
bool getLatticeR(std::vector< T > physR, std::vector< int > &latticeR) const
Returns true and the nearest lattice position to the given physical position if the physical position...
T getMinPhysVolume() const
Returns the maximum/minimum volume in the structure.
void add(Cuboid2D< T > cuboid)
Adds a cuboid.
std::vector< T > getMaxPhysR() const
Returns the maximum coordinate in the structure.
void split(int iC, int p)
Removes all cuboids where geometryData = 0.
int get_iC(T globX, T globY, int offset=0) const
for a given point (globX/globY), returns the related cuboidID and _p if the point is not in any of th...
IndicatorF2D is an application from .
class for marking output with some text
Plain old scalar vector.
Definition vector.h:47
The description of a single 2D cuboid – header file.
Top level namespace for all of OpenLB.
void evaluateCuboidGeometryNeighbourhood(CuboidGeometry2D< T > &cuboidGeometry, std::map< int, std::vector< int > > &neighbourhood, int offset=0)
Evaluate complete neighbourhood and store in std::map.