OpenLB 1.7
Loading...
Searching...
No Matches
blockGeometry.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2014 Mathias J. Krause
4 * 2021 Clara Schragmann, Adrian Kummerlaender
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 */
24
29#ifndef BLOCK_GEOMETRY_H
30#define BLOCK_GEOMETRY_H
31
32#include <vector>
33
34#include "core/blockStructure.h"
35#include "core/fieldArrayD.hh"
37#include "geometry/cuboid2D.h"
40
41// All OpenLB code is contained in this namespace.
42namespace olb {
43
44
46
54template <typename T, unsigned D>
55class BlockGeometry final : public BlockStructureD<D>
56 , public Serializable {
57private:
63 Cuboid<T,D> _cuboid;
65 const int _iCglob;
69 mutable OstreamManager clout;
70
71public:
73
74 BlockGeometry(Cuboid<T,D>& cuboid, int padding, int iCglob=-1);
75
77 return platform;
78 }
79
84
85 bool hasCommunicatable(std::type_index field) const {
86 return field == typeid(descriptors::MATERIAL);
87 }
88 auto& getCommunicatable(std::type_index field) {
89 OLB_ASSERT(field == typeid(descriptors::MATERIAL),
90 "BlockGeometry only offers MATERIAL for communication");
91 return _communicatable;
92 }
93
95 int getIcGlob() const;
98
100 Vector<T,D> getOrigin() const;
102 T getDeltaR() const;
103
105 template <typename... L>
106 std::enable_if_t<sizeof...(L) == D, int>
107 get(L... latticeR) const {
108 return _data[0][this->getCellId(latticeR...)];
109 }
110 int get(LatticeR<D> latticeR) const;
111 int get(const int latticeR[D]) const;
112 int get(std::size_t iCell) const;
113
115 int getMaterial(LatticeR<D> latticeR) const;
116 int getMaterial(const int latticeR[D]) const;
117
118 template <typename... L>
119 std::enable_if_t<sizeof...(L) == D, int>
120 getMaterial(L... latticeR) const {
121 return this->getMaterial(LatticeR<D>{latticeR...});
122 }
123
125 void set(LatticeR<D> latticeR, int material);
126 void set(const int latticeR[D], int material);
127 void set(std::size_t iCell, int material);
128
130 T physR[D];
131 getPhysR(physR, latticeR);
132 return Vector<T,D>(physR);
133 }
135 void getPhysR(T physR[D], const int latticeR[D]) const;
136 void getPhysR(T physR[D], LatticeR<D> latticeR) const;
138 return _cuboid;
139 }
140 const Cuboid<T,D>& getCuboid() const {
141 return _cuboid;
142 }
143
144 template <typename... L>
145 std::enable_if_t<sizeof...(L) == D, void>
146 get(T physR[D],L... latticeR) const {
147 return this->getPhysR(physR[D],LatticeR<D>{latticeR...});
148 }
149
152 template <typename DESCRIPTOR = std::conditional_t<D==2,descriptors::D2Q9<>,descriptors::D3Q27<>>> int clean(bool verbose=true, std::vector<int> bulkMaterials={1});
154 int outerClean(bool verbose=true, std::vector<int> bulkMaterials={1});
156 int innerClean(bool verbose=true);
158 int innerClean(int fromM, bool verbose=true);
159
161 void reset(IndicatorF<T,D>& domain);
162
164 bool find(int material, std::vector<unsigned> offset, std::vector<int> var);
165
167 bool check(int material, std::vector<int> var, std::vector<unsigned> offset);
169 bool checkForErrors(bool verbose=true) const;
170
172 void rename(int fromM, int toM);
174 void rename(int fromM, int toM, IndicatorF<T,D>& condition);
176 void rename(int fromM, int toM, LatticeR<D> offset);
178 void rename(int fromM, int toM, int testM, std::vector<int> testDirection);
180 void rename(int fromM, int toM, int fluidM, IndicatorF<T,D>& condition, Vector<int,D> discreteNormal);
182 void rename(int fromM, int toM, int fluidM, IndicatorF<T,D>& condition);
183
185 void copyMaterialLayer(IndicatorF3D<T>& condition, int discreteNormal[D], int numberOfLayers);
186
188 void regionGrowing(int fromM, int toM, LatticeR<D> seed, std::vector<int> offset, std::map<std::vector<int>, int >* tmp=nullptr);
189
191 void printLayer(std::vector<int> min, std::vector<int> max, bool linenumber = false);
193 void printLayer(int direction, int layer, bool linenumber = false);
195 void printNode(std::vector<int> loc);
196
198 std::size_t getNblock() const override;
200 std::size_t getSerializableSize() const override;
202 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
203
204private:
205 void resetStatistics();
206
207};
208
209template <typename T>
211
212template <typename T>
214
216template<typename T, unsigned D>
218
220
221template <Platform PLATFORM>
223
224};
225
226} // namespace olb
227
228#endif
Representation of a statistic for a 2D geometry – header file.
Representation of a block geometry.
int innerClean(bool verbose=true)
Changes all cell materials which are not 0 or 1 to 1 if there is a non robust constiallation.
void rename(int fromM, int toM)
Replaces all material numbers (fromM) to another (toM)
Platform getPlatform() const
void reset(IndicatorF< T, D > &domain)
Resets all cell materials inside of a domain to 0.
const BlockGeometryStatistics< T, D > & getStatistics() const
Read only access to the associated block statistic.
Vector< T, D > getPhysR(LatticeR< D > latticeR)
int getMaterial(LatticeR< D > latticeR) const
returns the (iX,iY) entry in the 2D scalar field
int clean(bool verbose=true, std::vector< int > bulkMaterials={1})
Changes all cell materials which are not in bulkMaterials to 0 if there is no neighbour from bulkMate...
BlockGeometry(Cuboid< T, D > &cuboid, int padding, int iCglob=-1)
bool find(int material, std::vector< unsigned > offset, std::vector< int > var)
Returns the coordinates (iX,iY) of a voxel with a given material number (material) if there exists an...
int outerClean(bool verbose=true, std::vector< int > bulkMaterials={1})
Changes all cell materials from bulkMaterials to 0 if there is a neighbour with material 0.
bool check(int material, std::vector< int > var, std::vector< unsigned > offset)
Returns true if at position (iX,iY) and in a neighbourhood of size (offsetX,offsetY) only voxels with...
int getIcGlob() const
Read only access to the global iC number which is given !=-1 if the block geometries are part of a su...
static constexpr Platform platform
void regionGrowing(int fromM, int toM, LatticeR< D > seed, std::vector< int > offset, std::map< std::vector< int >, int > *tmp=nullptr)
Replaces all material numbers (fromM) to another (toM) using a seed point and max....
Cuboid< T, D > & getCuboid()
auto & getCommunicatable(std::type_index field)
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
T getDeltaR() const
Read only access to the voxel size given in SI units (meter)
bool hasCommunicatable(std::type_index field) const
const Cuboid< T, D > & getCuboid() const
std::enable_if_t< sizeof...(L)==D, int > getMaterial(L... latticeR) const
bool checkForErrors(bool verbose=true) const
Checks for errors (searches for all outer voxels (=0) with an inner voxel (=1) as a direct neighbour)
void copyMaterialLayer(IndicatorF3D< T > &condition, int discreteNormal[D], int numberOfLayers)
Copy a layer of material numbers inside an indicator in a discrete normal direction.
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
std::enable_if_t< sizeof...(L)==D, void > get(T physR[D], L... latticeR) const
Vector< T, D > getOrigin() const
Read only access to the origin position given in SI units (meter)
void printNode(std::vector< int > loc)
Prints a chosen node and its neighbourhood.
Vector< int, D > getExtent() const
Returns the extend of the block in lattice units.
void printLayer(std::vector< int > min, std::vector< int > max, bool linenumber=false)
Prints a chosen part of the block geometry.
void set(LatticeR< D > latticeR, int material)
Write access to a material number.
std::size_t getSerializableSize() const override
Binary size for the serializer.
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
Base of a regular block.
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
SoA storage for instances of a single FIELD.
class for marking output with some text
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
Definition serializer.h:145
Plain old scalar vector.
Definition vector.h:47
The description of a single 2D cuboid – header file.
Descriptor for all types of 2D and 3D lattices.
Top level namespace for all of OpenLB.
Platform
OpenLB execution targets.
Definition platform.h:36
std::conditional_t< D==2, BlockGeometryStatistics2D< T >, BlockGeometryStatistics3D< T > > BlockGeometryStatistics
Definition aliases.h:178
std::conditional_t< D==2, Cuboid2D< T >, Cuboid3D< T > > Cuboid
Definition aliases.h:37
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45
Curried BlockGeometry template for use in callUsingConcretePlatform.