OpenLB 1.7
Loading...
Searching...
No Matches
blockGeometryStatistics3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2011, 2014 Mathias J. Krause, Simon Zimny
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 BLOCK_GEOMETRY_STATISTICS_3D_H
29#define BLOCK_GEOMETRY_STATISTICS_3D_H
30
31#include <vector>
32#include <map>
33#include <string>
34
35#include "io/ostreamManager.h"
36
37// All OpenLB code is contained in this namespace.
38namespace olb {
39
41
49template<typename T, unsigned D>
50class BlockGeometry;
51
52template<typename T>
54private:
56 BlockGeometry<T,3>* _blockGeometry{};
58 bool _statisticsUpdateNeeded{};
60 int _nX{}, _nY{}, _nZ{};
62 T _h{};
63
65 int _nMaterials{};
67 std::map<int, std::size_t> _material2n{};
69 std::map<int, std::vector<int> > _material2min{};
71 std::map<int, std::vector<int> > _material2max{};
72
74 mutable OstreamManager clout;
75
76 const BlockGeometryStatistics3D<T>* const_this{};
77
78public:
81
83 bool& getStatisticsStatus();
85 bool const & getStatisticsStatus() const;
87 std::map<int, std::size_t> getMaterial2n();
88 std::map<int, std::size_t> getMaterial2n() const;
89
91 void update(bool verbose=false);
92
94 int getNmaterials();
95 int getNmaterials() const;
97 std::size_t getNvoxel(int material);
98 std::size_t getNvoxel(int material) const;
100 std::size_t getNvoxel();
101 std::size_t getNvoxel() const;
103 std::vector<int> getMinLatticeR(int material);
104 std::vector<int> getMinLatticeR(int material) const;
106 std::vector<int> getMaxLatticeR(int material);
107 std::vector<int> getMaxLatticeR(int material) const;
109 std::vector<T> getMinPhysR(int material) const;
111 std::vector<T> getMaxPhysR(int material) const;
113 std::vector<T> getLatticeExtend(int material);
114 std::vector<T> getLatticeExtend(int material) const;
116 std::vector<T> getPhysExtend(int material);
117 std::vector<T> getPhysExtend(int material) const;
119 std::vector<T> getPhysRadius(int material);
120 std::vector<T> getPhysRadius(int material) const;
122 std::vector<T> getCenterPhysR(int material);
123 std::vector<T> getCenterPhysR(int material) const;
124 /* Returns the boundary type which is characterized by a discrete normal (c.f. Zimny)
125 * 0 element: flat, corner or edge
126 * 1 element: orientation -1, 0 or 1
127 * 2 element: orientation -1, 0 or 1
128 * 3 element: orientation -1, 0 or 1
129 */
130 std::vector<int> getType(int iX, int iY, int iZ, bool anyNormal = false);
131 std::vector<int> getType(const int* input, bool anyNormal = false) const;
132 std::vector<int> getType(int iX, int iY, int iZ, bool anyNormal = false) const;
133
135 std::vector<int> computeNormal(int iX, int iY, int iZ);
136 std::vector<int> computeNormal(int iX, int iY, int iZ) const;
138 std::vector<T> computeNormal (int material);
139 std::vector<T> computeNormal (int material) const;
142 std::vector<int> computeDiscreteNormal (int material, T maxNorm = 1.1);
143 std::vector<int> computeDiscreteNormal (int material, T maxNorm = 1.1) const;
144
145 // Returns true if at position (iX,iY,iZ) and in a neighbourhood of size (offsetX,offsetY,offsetZ) only voxels of the given material are found
146 bool check(int material, int iX, int iY, int iZ, unsigned offsetX, unsigned offsetY, unsigned offsetZ);
147 bool check(int material, int iX, int iY, int iZ, unsigned offsetX, unsigned offsetY, unsigned offsetZ) const;
148 // Returns true and a position (iX,iY,iZ) if there is a neighbourhood of size (offsetX,offsetY,offsetZ) around (iX,iY,iZ) with only voxels of the given material
149 bool find(int material, unsigned offsetX, unsigned offsetY, unsigned offsetZ, int& iX, int& iY, int& iZ);
150 bool find(int material, unsigned offsetX, unsigned offsetY, unsigned offsetZ, int& iX, int& iY, int& iZ) const;
151
153 void print();
154 void print() const;
155
156private:
157
159 void takeStatistics(int iX, int iY, int iZ);
161 std::vector<int> checkExtraBoundary(std::vector<int> discreteNormal,
162 std::vector<int> discreteNormal2);
163 std::vector<int> checkExtraBoundary(std::vector<int> discreteNormal,
164 std::vector<int> discreteNormal2) const;
165};
166
167} // namespace olb
168
169#endif
std::vector< int > computeNormal(int iX, int iY, int iZ)
Returns normal that points into the fluid for paraxial surfaces.
std::vector< T > getCenterPhysR(int material)
Returns the center position.
std::vector< int > getMaxLatticeR(int material)
Returns the max. lattice position in each direction.
int getNmaterials()
Returns the number of different materials.
BlockGeometryStatistics3D(BlockGeometry< T, 3 > *blockGeometry)
Constructor.
std::vector< T > getMinPhysR(int material) const
Returns the min. phys position in each direction.
std::vector< int > getType(int iX, int iY, int iZ, bool anyNormal=false)
bool find(int material, unsigned offsetX, unsigned offsetY, unsigned offsetZ, int &iX, int &iY, int &iZ)
std::vector< T > getMaxPhysR(int material) const
Returns the max. phys position in each direction.
std::size_t getNvoxel()
Returns the number of voxels with material!=0.
std::vector< T > getLatticeExtend(int material)
Returns the lattice extend as length in each direction.
std::map< int, std::size_t > getMaterial2n()
Returns the map with the numbers of voxels for each material.
std::vector< T > getPhysExtend(int material)
Returns the phys extend as length in each direction.
std::vector< int > getMinLatticeR(int material)
Returns the min. lattice position in each direction.
void update(bool verbose=false)
Updates the statistics if it is really needed.
void print()
Prints some statistic information, i.e. the number of voxels and min. max. physical position for each...
std::vector< int > computeDiscreteNormal(int material, T maxNorm=1.1)
Returns discrete normal with norm maxNorm that points into the fluid for paraxial surfaces without up...
bool & getStatisticsStatus()
Read and write access to a flag, which indicates if an uptate is needed (=true)
bool check(int material, int iX, int iY, int iZ, unsigned offsetX, unsigned offsetY, unsigned offsetZ)
std::vector< T > getPhysRadius(int material)
Returns the phys radius as length in each direction.
Representation of a block geometry.
class for marking output with some text
Top level namespace for all of OpenLB.