OpenLB 1.7
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
60#include "io/ostreamManager.h"
63
64
65// All OpenLB code is contained in this namespace.
66namespace olb {
67
68template<typename T, unsigned D>
69class SuperGeometry : public SuperStructure<T,D>
70 , public BufferSerializable {
71private:
73 std::vector<std::unique_ptr<BlockGeometry<T,D>>> _block{};
75 std::unique_ptr<SuperCommunicator<T,SuperGeometry<T,D>>> _communicator{};
77 bool _communicationNeeded{};
79 SuperGeometryStatistics<T,D> _statistics{};
81 mutable OstreamManager clout;
82
83public:
84 constexpr static unsigned d = D;
85
87
88 SuperGeometry(CuboidGeometry<T,D>& cuboidGeometry,
89 LoadBalancer<T>& loadBalancer,
90 int overlap = 3);
91
93 int get(int iCglob, LatticeR<D> latticeR) const;
94 int get(const int latticeR[D+1]) const;
95 int get(LatticeR<D+1> latticeR) const;
96
97 template <typename... L>
98 std::enable_if_t<sizeof...(L) == (D+1), int>
99 get(L... latticeR) const {
100 return get(LatticeR<D+1>{latticeR...});
101 }
102
104 int getAndCommunicate(int iCglob, LatticeR<D> latticeR) const;
105 int getAndCommunicate(LatticeR<D+1> latticeR) const;
106
108 std::vector<T> getPhysR(int iCglob, LatticeR<D> latticeR) const;
110 std::vector<T> getPhysR(LatticeR<D+1> latticeR) const;
112 void getPhysR(T output[D], const int latticeR[D+1]) const;
113 void getPhysR(T output[D], const int iCglob, LatticeR<D> latticeR) 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, std::vector<int> 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();
170
178 std::unique_ptr<SuperIndicatorF<T,D>> getMaterialIndicator(std::vector<int>&& materials);
186 std::unique_ptr<SuperIndicatorF<T,D>> getMaterialIndicator(int material);
187
188 void communicate() override
189 {
190 if (_communicationNeeded) {
191 _communicator->communicate();
192 _communicationNeeded = false;
193 }
194 }
195
197 std::size_t getNblock() const override;
199 std::size_t getSerializableSize() const override;
201 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
202
203};
204
205} // namespace olb
206
207#endif
Representation of the 2D block geometry view – header file.
Representation of a block geometry.
Base class for serializable objects of dynamic size
Definition serializer.h:299
Base class for all LoadBalancer.
class for marking output with some text
Representation of a statistic for a parallel 2D geometry.
SuperGeometry(CuboidGeometry< T, D > &cuboidGeometry, LoadBalancer< T > &loadBalancer, int overlap=3)
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.
int getAndCommunicate(int iCglob, LatticeR< D > latticeR) const
Read only access to the material numbers with global communication to all ranks.
int get(int iCglob, LatticeR< D > latticeR) const
Read only access to the material numbers, error handling: returns 0 if data is not available.
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.
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.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
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.
std::vector< T > getPhysR(int iCglob, LatticeR< D > latticeR) const
Transforms a lattice to physical position (SI unites)
Plain old scalar vector.
Definition vector.h:47
The description of a vector of 2D cuboid – header file.
The description of a vector of 3D cuboid – header file.
This file contains indicator functions.
This file contains indicator functions.
Descriptor for all types of 2D and 3D lattices.
Top level namespace for all of OpenLB.
std::conditional_t< DIM==2, SuperGeometryStatistics2D< T >, SuperGeometryStatistics3D< T > > SuperGeometryStatistics
Definition aliases.h:88
std::conditional_t< D==2, CuboidGeometry2D< T >, CuboidGeometry3D< T > > CuboidGeometry
Definition aliases.h:47
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.