OpenLB 1.7
Loading...
Searching...
No Matches
superIndicatorF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2016-2018 Benjamin Förster, Adrian Kummerlaender
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
24#ifndef SUPER_INDICATOR_F_3D_HH
25#define SUPER_INDICATOR_F_3D_HH
26
27#include <numeric>
28
29#include "superIndicatorF3D.h"
30#include "blockIndicatorF3D.h"
31#include "core/util.h"
32
33namespace olb {
34
35template <typename T>
37 FunctorPtr<IndicatorF3D<T>>&& indicatorF, SuperGeometry<T,3>& geometry)
38 : SuperIndicatorF3D<T>(geometry),
39 _indicatorF(std::move(indicatorF))
40{
41 this->getName() = "SuperIndicator_from_" + _indicatorF->getName();
42
44
45 for (int iC = 0; iC < load.size(); ++iC) {
46 this->_blockF.emplace_back(
48 *_indicatorF, geometry.getBlockGeometry(iC))
49 );
50 }
51}
52
53template <typename T>
54bool SuperIndicatorFfromIndicatorF3D<T>::operator() (bool output[], const int input[])
55{
56 T physR[3];
57 this->_superStructure.getCuboidGeometry().getPhysR(physR, input);
58 return _indicatorF(output, physR);
59}
60
61
62template <typename T, bool HLBM>
65 SuperGeometry<T,3>& geometry)
66 : SuperIndicatorF3D<T>(geometry),
67 _indicatorF(std::move(indicatorF))
68{
69 this->getName() = "SuperIndicator_from_" + _indicatorF->getName();
70
72
73 for (int iC = 0; iC < load.size(); ++iC) {
74 this->_blockF.emplace_back(
76 *_indicatorF, geometry.getBlockGeometry(iC))
77 );
78 }
79}
80
81template <typename T, bool HLBM>
83{
84 T physR[3];
85 T inside[1];
86 this->_superStructure.getCuboidGeometry().getPhysR(physR, input);
87 _indicatorF(inside, physR);
88 return !util::nearZero(inside[0]);
89}
90
91template <typename T>
93 SuperGeometry<T,3>& geometry, std::vector<int> materials)
94 : SuperIndicatorF3D<T>(geometry)
95{
96 geometry.updateStatistics(false);
97 const std::string matString = std::accumulate(
98 materials.begin()+1,
99 materials.end(),
100 std::to_string(materials[0]),
101 [](const std::string& a, int b) {
102 return a + '_' + std::to_string(b);
103 });
104 this->getName() = "SuperIndicator_on_Material_" + matString;
105
106 for (int iC = 0; iC < this->_superGeometry.getLoadBalancer().size(); ++iC) {
107 this->_blockF.emplace_back(
109 materials)
110 );
111 }
112}
113
114template <typename T>
116 SuperGeometry<T,3>& geometry, std::list<int> materials)
117 : SuperIndicatorMaterial3D(geometry,
118 std::vector<int>(materials.begin(), materials.end()))
119{ }
120
121template <typename T>
122bool SuperIndicatorMaterial3D<T>::operator() (bool output[], const int input[])
123{
124 output[0] = false;
125
126 LoadBalancer<T>& load = this->_superGeometry.getLoadBalancer();
127
128 if (!this->_blockF.empty() && load.isLocal(input[0])) {
129 // query material number of appropriate block indicator
130 return this->getBlockF(load.loc(input[0]))(output,&input[1]);
131 }
132 else {
133 return false;
134 }
135}
136
137template <typename T>
139 : SuperIndicatorF3D<T>(indicatorF->getSuperGeometry()),
140 _indicatorF(std::move(indicatorF))
141{
142 this->getName() = _indicatorF->getName();
143
144 for (int iC = 0; iC < _indicatorF->getBlockFSize(); ++iC) {
145 this->_blockF.emplace_back(
146 new BlockIndicatorLayer3D<T>(_indicatorF->getBlockIndicatorF(iC)));
147 }
148}
149
150template <typename T>
151bool SuperIndicatorLayer3D<T>::operator()(bool output[], const int input[])
152{
153 _indicatorF(output, input);
154 for (int iPop=1; iPop < descriptors::D3Q27<>::q; ++iPop) {
155 bool tmpOutput{};
156 Vector<int,4> tmpInput(input);
157 auto c_i = descriptors::c<descriptors::D3Q27<>>(iPop);
158 tmpInput += Vector<int,4>{0, c_i[0], c_i[1], c_i[2]};
159 _indicatorF(&tmpOutput, tmpInput.data());
160 output[0] |= tmpOutput;
161 }
162 return true;
163}
164
165template <typename T>
167 : SuperIndicatorF3D<T>(indicatorF->getSuperGeometry()),
168 _indicatorF(std::move(indicatorF))
169{
170 this->getName() = _indicatorF->getName();
171
172 for (int iC = 0; iC < _indicatorF->getBlockFSize(); ++iC) {
173 this->_blockF.emplace_back(
174 new BlockIndicatorIdentity3D<T>(_indicatorF->getBlockIndicatorF(iC)));
175 }
176}
177
178template <typename T>
179bool SuperIndicatorIdentity3D<T>::operator()(bool output[], const int input[])
180{
181 return _indicatorF(output, input);
182}
183
184template <typename T>
188 : SuperIndicatorF3D<T>(f->getSuperGeometry()),
189 _f(std::move(f)), _g(std::move(g))
190{
191 this->getName() = _f->getName() + " * " + _g->getName();
192
193 for (int iC = 0; iC < _f->getBlockFSize(); ++iC) {
194 this->_blockF.emplace_back(
196 _f->getBlockIndicatorF(iC),
197 _g->getBlockIndicatorF(iC)));
198 }
199}
200
201template <typename T>
203 bool output[], const int input[])
204{
205 _f(output, input);
206 if (output[0]) {
207 _g(output, input);
208 }
209 return output[0];
210}
211
212template <typename T>
214 : SuperIndicatorF3D<T>(indicatorF->getSuperGeometry()),
215 _indicatorF(std::move(indicatorF)),
216 _overlap(overlap)
217{
218 this->getName() = "SuperIndicatorBoundaryNeighbor_for_BoundaryMaterial_" + _indicatorF->getName();
219
220 for (int iC = 0; iC < _indicatorF->getBlockFSize(); ++iC) {
221 this->_blockF.emplace_back(
222 new BlockIndicatorBoundaryNeighbor3D<T>(_indicatorF->getBlockIndicatorF(iC), _overlap));
223 }
224}
225
226template <typename T>
227bool SuperIndicatorBoundaryNeighbor3D<T>::operator() (bool output[], const int input[])
228{
229 output[0] = false;
230
231 LoadBalancer<T>& load = this->_superGeometry.getLoadBalancer();
232
233 if (load.isLocal(input[0])) {
234 return this->getBlockF(load.loc(input[0]))(output, &input[1]);
235 }
236 else {
237 return false;
238 }
239}
240
241} // namespace olb
242
243#endif
Block indicator identifying neighbors of boundary cells.
BlockIndicatorF3D from IndicatorF3D.
BlockIndicatorF3D from SmoothIndicatorF3D.
Block indicator identity.
Block indicator extended by a layer.
Block indicator functor from material numbers.
Block indicator intersection.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
std::string & getName()
read and write access to name
Definition genericF.hh:51
IndicatorF3D is an application from .
Base class for all LoadBalancer.
bool isLocal(const int &glob)
returns whether glob is on this process
int loc(const int &glob)
SuperStructure< T, 3 > & getSuperStructure()
std::vector< std::unique_ptr< BlockF3D< bool > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
Representation of a statistic for a parallel 2D geometry.
void updateStatistics(bool verbose=true)
Updates the super geometry at the boundaries if needed and afterwards the statisics if needed.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
FunctorPtr< SuperIndicatorF3D< T > > _indicatorF
bool operator()(bool output[], const int input[]) override
SuperIndicatorBoundaryNeighbor3D(FunctorPtr< SuperIndicatorF3D< T > > &&indicatorF, int overlap)
Base indicator functor (discrete)
SuperGeometry< T, 3 > & _superGeometry
FunctorPtr< IndicatorF3D< T > > _indicatorF
SuperIndicatorFfromIndicatorF3D(FunctorPtr< IndicatorF3D< T > > &&indicatorF, SuperGeometry< T, 3 > &geometry)
bool operator()(bool output[], const int input[]) override
FunctorPtr< SmoothIndicatorF3D< T, T, HLBM > > _indicatorF
bool operator()(bool output[], const int input[]) override
SuperIndicatorFfromSmoothIndicatorF3D(FunctorPtr< SmoothIndicatorF3D< T, T, HLBM > > &&indicatorF, SuperGeometry< T, 3 > &geometry)
SuperIndicatorIdentity3D(FunctorPtr< SuperIndicatorF3D< T > > &&indicatorF)
bool operator()(bool output[], const int input[]) override
FunctorPtr< SuperIndicatorF3D< T > > _indicatorF
SuperIndicatorLayer3D(FunctorPtr< SuperIndicatorF3D< T > > &&indicatorF)
bool operator()(bool output[], const int input[]) override
Indicator functor from material numbers.
bool operator()(bool output[], const int input[]) override
SuperIndicatorMaterial3D(SuperGeometry< T, 3 > &geometry, std::vector< int > materials)
FunctorPtr< SuperIndicatorF3D< T > > _f
FunctorPtr< SuperIndicatorF3D< T > > _g
SuperIndicatorMultiplication3D(FunctorPtr< SuperIndicatorF3D< T > > &&f, FunctorPtr< SuperIndicatorF3D< T > > &&g)
bool operator()(bool output[], const int input[]) override
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Plain old scalar vector.
Definition vector.h:47
constexpr const T * data() const any_platform
Definition vector.h:161
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
Top level namespace for all of OpenLB.
Set of functions commonly used in LB computations – header file.