OpenLB 1.8.1
Loading...
Searching...
No Matches
superIndicatorF2D.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_2D_HH
25#define SUPER_INDICATOR_F_2D_HH
26
27#include <numeric>
28
29#include "superIndicatorF2D.h"
30#include "blockIndicatorF2D.h"
31#include "core/util.h"
32
33namespace olb {
34
35template <typename T>
37 FunctorPtr<IndicatorF2D<T>>&& indicatorF, SuperGeometry<T,2>& geometry)
38 : SuperIndicatorF2D<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 SuperIndicatorFfromIndicatorF2D<T>::operator() (bool output[], const int input[])
55{
56 LatticeR<3> latticeR(input);
57 auto physR = this->_superStructure.getCuboidDecomposition().getPhysR(input);
58 return _indicatorF(output, physR.data());
59}
60
61
62template <typename T, bool HLBM>
65 SuperGeometry<T,2>& geometry)
66 : SuperIndicatorF2D<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[2];
85 T inside[1];
86 this->_superStructure.getCuboidDecomposition().getPhysR(physR, input);
87 _indicatorF(inside, physR);
88 return !util::nearZero(inside[0]);
89}
90
91template <typename T>
93 SuperGeometry<T,2>& geometry, std::vector<int> materials)
94 : SuperIndicatorF2D<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,2>& geometry, std::list<int> materials)
117 : SuperIndicatorMaterial2D(geometry,
118 std::vector<int>(materials.begin(), materials.end()))
119{ }
120
121template <typename T>
122bool SuperIndicatorMaterial2D<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 : SuperIndicatorF2D<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 BlockIndicatorIdentity2D<T>(_indicatorF->getBlockIndicatorF(iC)));
147 }
148}
149
150template <typename T>
151bool SuperIndicatorIdentity2D<T>::operator()(bool output[], const int input[])
152{
153 return _indicatorF(output, input);
154}
155
156template <typename T>
158 : SuperIndicatorF2D<T>(indicatorF->getSuperGeometry()),
159 _indicatorF(std::move(indicatorF)),
160 _overlap(overlap)
161{
162 this->getName() = "SuperIndicatorBoundaryNeighbor_for_BoundaryMaterial_" + _indicatorF->getName();
163
164 for (int iC = 0; iC < _indicatorF->getBlockFSize(); ++iC) {
165 this->_blockF.emplace_back(
166 new BlockIndicatorBoundaryNeighbor2D<T>(_indicatorF->getBlockIndicatorF(iC), _overlap));
167 }
168}
169
170template <typename T>
171bool SuperIndicatorBoundaryNeighbor2D<T>::operator() (bool output[], const int input[])
172{
173 output[0] = false;
174
175 LoadBalancer<T>& load = this->_superGeometry.getLoadBalancer();
176
177 if (load.isLocal(input[0])) {
178 return this->getBlockF(load.loc(input[0]))(output, &input[1]);
179 }
180 else {
181 return false;
182 }
183}
184
185} // namespace olb
186
187#endif
Block indicator identifying neighbors of boundary cells.
Definition aliases.h:223
BlockIndicatorF2D from IndicatorF2D.
Definition aliases.h:233
BlockIndicatorF2D from SmoothIndicatorF2D.
Block indicator identity.
Block indicator functor from material numbers.
Definition aliases.h:213
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
std::string & getName()
Definition genericF.hh:51
IndicatorF2D is an application from .
Definition aliases.h:243
Base class for all LoadBalancer.
Definition vtiWriter.h:42
bool isLocal(const int &glob) const
returns whether glob is on this process
int loc(const int &glob)
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
SuperStructure< T, 2 > & getSuperStructure()
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.
bool operator()(bool output[], const int input[]) override
SuperIndicatorBoundaryNeighbor2D(FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF, int overlap)
FunctorPtr< SuperIndicatorF2D< T > > _indicatorF
SuperGeometry< T, 2 > & _superGeometry
SuperIndicatorFfromIndicatorF2D(FunctorPtr< IndicatorF2D< T > > &&indicatorF, SuperGeometry< T, 2 > &geometry)
bool operator()(bool output[], const int input[]) override
FunctorPtr< IndicatorF2D< T > > _indicatorF
SuperIndicatorFfromSmoothIndicatorF2D(FunctorPtr< SmoothIndicatorF2D< T, T, HLBM > > &&indicatorF, SuperGeometry< T, 2 > &geometry)
FunctorPtr< SmoothIndicatorF2D< T, T, HLBM > > _indicatorF
bool operator()(bool output[], const int input[]) override
bool operator()(bool output[], const int input[]) override
SuperIndicatorIdentity2D(FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF)
FunctorPtr< SuperIndicatorF2D< T > > _indicatorF
Indicator functor from material numbers.
Definition aliases.h:283
SuperIndicatorMaterial2D(SuperGeometry< T, 2 > &geometry, std::vector< int > materials)
bool operator()(bool output[], const int input[]) override
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Plain old scalar vector.
bool nearZero(T a) any_platform
return true if a is close to zero
Definition util.h:402
Top level namespace for all of OpenLB.
Set of functions commonly used in LB computations – header file.