OpenLB 1.8.1
Loading...
Searching...
No Matches
superGeometry.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2013, 2014 Mathias J. Krause, Peter Weisbrod
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
43#ifndef SUPER_GEOMETRY_H
44#define SUPER_GEOMETRY_H
45
46#include <vector>
47#include <iostream>
48#include <string>
49
59#include "io/ostreamManager.h"
62
63
64// All OpenLB code is contained in this namespace.
65namespace olb {
66
67template<typename T, unsigned D>
68class SuperGeometry : public SuperStructure<T,D>
69 , public BufferSerializable {
70private:
72 std::vector<std::unique_ptr<BlockGeometry<T,D>>> _block{};
74 std::unique_ptr<SuperCommunicator<T,SuperGeometry<T,D>>> _communicator{};
76 bool _communicationNeeded{};
78 SuperGeometryStatistics<T,D> _statistics{};
80 OstreamManager _clout;
81
83 std::size_t _iConstructionT;
85 bool _writeIncrementalVtkEnabled;
87 void writeIncrementalVTK();
88
89public:
90 constexpr static unsigned d = D;
91
93
94 SuperGeometry(CuboidDecomposition<T,D>& cuboidDecomposition,
95 LoadBalancer<T>& loadBalancer,
96 int overlap = 3);
97
99 int get(LatticeR<D+1> latticeR) const;
100
101 template <typename... L>
102 std::enable_if_t<sizeof...(L) == (D+1), int>
103 get(L... latticeR) const {
104 return get(LatticeR<D+1>{latticeR...});
105 }
106
108 int getAndCommunicate(LatticeR<D+1> latticeR) const;
109
111 Vector<T,D> getPhysR(LatticeR<D+1> latticeR) const;
113 void getPhysR(T output[D], const int latticeR[D+1]) const;
114
118 BlockGeometry<T,D> const& getBlockGeometry(int locIC) const;
119
121 template <typename BLOCK = BlockGeometry<T,D>>
122 BLOCK& getBlock(int locIC);
124 template <typename BLOCK = BlockGeometry<T,D>>
125 const BLOCK& getBlock(int locIC) const;
126
132 bool& getStatisticsStatus();
134 bool const& getStatisticsStatus() const;
136 void updateStatistics(bool verbose=true);
137
140 template <typename DESCRIPTOR=std::conditional_t<D==2,descriptors::D2Q9<>,descriptors::D3Q27<>>>
141 int clean(bool verbose=true, std::vector<int> bulkMaterials={1});
143 int outerClean(bool verbose=true, std::vector<int> bulkMaterials={1});
145 int innerClean(bool verbose=true);
147 int innerClean(int material, bool verbose=true);
149 bool checkForErrors(bool verbose=true);
150
152 void reset(IndicatorF<T,D>& domain);
153
155 void rename(int fromM, int toM);
157 void rename(int fromM, int toM, FunctorPtr<IndicatorF<T,D>>&& condition);
159 void rename(int fromM, int toM, LatticeR<D> offset);
161 void rename(int fromM, int toM, int testM, Vector<int,D> testDirection);
163 void rename(int fromBcMat, int toBcMat, int fluidMat, IndicatorF<T,D>& condition);
165 void rename(int fromBcMat, int toBcMat, int fluidMat, FunctorPtr<IndicatorF<T,D>>&& condition);
166
167
169 void print();
171 void setWriteIncrementalVTK(bool state) {
172 _writeIncrementalVtkEnabled = state;
173 }
175 {
176 return _writeIncrementalVtkEnabled;
177 }
178
179 // print the materials of all the neighbours of a given voxel
180 void print(const T physR[D], int offset);
181
189 std::unique_ptr<SuperIndicatorF<T,D>> getMaterialIndicator(std::vector<int>&& materials);
197 std::unique_ptr<SuperIndicatorF<T,D>> getMaterialIndicator(int material);
198
199 void communicate() override
200 {
201 if (_communicationNeeded) {
202 _communicator->communicate();
203 _communicationNeeded = false;
204 }
205 }
206
208 std::size_t getNblock() const override;
210 std::size_t getSerializableSize() const override;
212 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
213
214};
215
216} // namespace olb
217
218#endif
Representation of the 2D block geometry view – header file.
Representation of a block geometry.
Decomposition of a physical volume into a set of disjoint cuboids.
Base class for all LoadBalancer.
Definition vtiWriter.h:42
int get(LatticeR< D+1 > latticeR) const
Read only access to the material numbers, error handling: returns 0 if data is not available.
std::size_t getSerializableSize() const override
Binary size for the serializer.
int clean(bool verbose=true, std::vector< int > bulkMaterials={1})
Executes an outer cleaning: Sets all material numbers which are not bulk-materials to 0 if there is n...
bool & getStatisticsStatus()
Read and write access to the statistic status flag, update needed = true.
SuperGeometry(CuboidDecomposition< T, D > &cuboidDecomposition, LoadBalancer< T > &loadBalancer, int overlap=3)
Vector< T, D > getPhysR(LatticeR< D+1 > latticeR) const
Transforms a lattice to physical position (SI units)
void communicate() override
void print()
Prints some information about the super geometry.
void updateStatistics(bool verbose=true)
Updates the super geometry at the boundaries if needed and afterwards the statisics if needed.
bool getWriteIncrementalVTKState()
void reset(IndicatorF< T, D > &domain)
reset all cell materials inside of a domain to 0
bool checkForErrors(bool verbose=true)
check for errors (searches for all outer voxels (=0) with an inner voxel (=1) as a direct neighbour)
int innerClean(bool verbose=true)
inner cleaning for all boundary types
static constexpr unsigned d
SuperGeometryStatistics< T, D > & getStatistics()
Returns the statistics object.
void rename(int fromM, int toM)
replace one material with another
std::enable_if_t< sizeof...(L)==(D+1), int > get(L... latticeR) const
std::unique_ptr< SuperIndicatorF< T, D > > getMaterialIndicator(std::vector< int > &&materials)
Returns a material indicator using the given vector of materials.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
int getAndCommunicate(LatticeR< D+1 > latticeR) const
Read only access to the material numbers with global communication to all ranks.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
void setWriteIncrementalVTK(bool state)
Toggles whether geometry should be written out as VTK after every modification.
BLOCK & getBlock(int locIC)
Read and write access to a single extended block geometry.
int outerClean(bool verbose=true, std::vector< int > bulkMaterials={1})
Removes not needed fluid cells from the outer domain.
Plain old scalar vector.
This file contains indicator functions.
This file contains indicator functions.
Top level namespace for all of OpenLB.
std::conditional_t< DIM==2, SuperGeometryStatistics2D< T >, SuperGeometryStatistics3D< T > > SuperGeometryStatistics
Definition aliases.h:68
Vector< std::int32_t, D > LatticeR
Type for spatial block-local lattice coordinates.
Curried BlockGeometry template for use in callUsingConcretePlatform.
Representation of a statistic for a parallel 2D geometry – header file.
Representation of a statistic for a parallel 3D geometry – header file.