OpenLB 1.7
Loading...
Searching...
No Matches
blockLatticeIntegralF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012-2017 Lukas Baron, Mathias J. Krause,
4 * Albert Mink, Adrian Kummeränder
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
25#ifndef BLOCK_LATTICE_INTEGRAL_F_3D_HH
26#define BLOCK_LATTICE_INTEGRAL_F_3D_HH
27
28#include <vector>
29#include "utilities/omath.h"
30
33#include "blockCalcF3D.h" // for IdentityF
34#include "core/olbDebug.h"
35
36namespace olb {
37
38
39template <typename T, typename DESCRIPTOR>
41 BlockGeometry<T,3>& blockGeometry, int material)
42 : BlockLatticeF3D<T,DESCRIPTOR>(f.getBlock(),f.getTargetDim()),
43 _f(f), _blockGeometry(blockGeometry), _material(material)
44{
45 this->getName() = "L1("+_f.getName()+")";
46}
47
48template <typename T, typename DESCRIPTOR>
49bool BlockL1Norm3D<T,DESCRIPTOR>::operator() (T output[], const int input[])
50{
51 BlockIdentity3D<T> ff(_f); // exists only to prevent f from being deleted
52 T outputTmp[this->getTargetDim()];
53 for (int i = 0; i < this->getTargetDim(); ++i) {
54 output[i] = T(0);
55 for (int iX = 0; iX < _f.getBlock().getNx(); ++iX) {
56 for (int iY = 0; iY < _f.getBlock().getNy(); ++iY) {
57 for (int iZ = 0; iZ < _f.getBlock().getNz(); ++iZ) {
58 if (this->_blockGeometry.getMaterial(iX, iY, iZ) == _material) {
59 _f(outputTmp, {iX, iY, iZ});
60 T tmp = util::fabs(outputTmp[i]);
61 if (tmp > output[i]) {
62 output[i] = tmp;
63 }
64 }
65 }
66 }
67 }
68 }
69 return true;
70}
71
72
73template <typename T, typename DESCRIPTOR>
75 BlockGeometry<T,3>& blockGeometry, int material)
76 : BlockLatticeF3D<T,DESCRIPTOR>(f.getBlock(),f.getTargetDim()),
77 _f(f), _blockGeometry(blockGeometry), _material(material)
78{
79 this->getName() = "L22("+f.getName()+")";
80}
81
82
83template <typename T, typename DESCRIPTOR>
84bool BlockL223D<T,DESCRIPTOR>::operator() (T output[], const int input[])
85{
86 // f.getBlock().communicate();
87 // CuboidGeometry3D<T>& cGeometry = f.getBlock().get_cGeometry();
88 // loadBalancer& load = f.getBlock().get_load();
89
90 output[0]=0;
91 // for (int i=0; i<this->n; i++) {
92
93 // for (int iC=0; iC<load.size(); iC++) {
94 // int nX = cGeometry.get(load.glob(iC)).getNx();
95 // int nY = cGeometry.get(load.glob(iC)).getNy();
96 // int nZ = cGeometry.get(load.glob(iC)).getNz();
97 // T weight = util::pow(this->blockGeometry.getDeltaR(),3);
98 // for (int iX=0; iX<nX; ++iX) {
99 // for (int iY=0; iY<nY; ++iY) {
100 // for (int iZ=0; iZ<nZ; ++iZ) {
101 // int globX = (int)cGeometry.get(load.glob(iC)).get_globPosX() + iX;
102 // int globY = (int)cGeometry.get(load.glob(iC)).get_globPosY() + iY;
103 // int globZ = (int)cGeometry.get(load.glob(iC)).get_globPosZ() + iZ;
104 // if (this->blockGeometry.get_material(globX, globY, globZ) == material) {
105 // tmp[i]+=f(load.glob(iC),iX,iY,iZ)[i]*f(load.glob(iC),iX,iY,iZ)[i]*weight;
106 // }
107 // }
108 // }
109 // }
110 // }
111 //#ifdef PARALLEL_MODE_MPI
112 // singleton::mpi().reduceAndBcast(tmp[i], MPI_SUM);
113 //#endif
114 // }
115 return true;
116}
117
118
119template <typename T, typename DESCRIPTOR>
121 BlockLattice<T,DESCRIPTOR>& blockLattice,
122 BlockIndicatorF3D<T>& indicatorF,
123 const UnitConverter<T,DESCRIPTOR>& converter)
124 : BlockLatticePhysF3D<T,DESCRIPTOR>(blockLattice, converter, 3),
125 _indicatorF(indicatorF),
126 _facesF(indicatorF, converter.getConversionFactorLength()),
127 _pBoundForceF(blockLattice, indicatorF, converter),
128 _sumF(_pBoundForceF, indicatorF),
129 _factor(2./( converter.getPhysDensity()*converter.getCharPhysVelocity()*converter.getCharPhysVelocity() ))
130{
131 this->getName() = "physDrag";
132}
133
134template <typename T, typename DESCRIPTOR>
135bool BlockLatticePhysDrag3D<T,DESCRIPTOR>::operator() (T output[], const int input[])
136{
137 T faces[7] = { };
138 T sum[4] = { };
139 _sumF(sum, input);
140 _facesF(faces, input);
141
142 output[0] = _factor * sum[0] / faces[0];
143 output[1] = _factor * sum[1] / faces[1];
144 output[2] = _factor * sum[2] / faces[2];
145
146 return true;
147}
148
149template <typename T, typename DESCRIPTOR>
151 BlockLattice<T,DESCRIPTOR>& blockLattice,
152 BlockIndicatorF3D<T>& indicatorF,
153 const UnitConverter<T,DESCRIPTOR>& converter)
154 : BlockLatticePhysF3D<T,DESCRIPTOR>(blockLattice, converter, 3),
155 _indicatorF(indicatorF),
156 _facesF(indicatorF, converter.getConversionFactorLength()),
157 _pBoundForceF(blockLattice, indicatorF, converter),
158 _sumF(_pBoundForceF, indicatorF),
159 _factor(2./( converter.getPhysDensity()*converter.getCharPhysVelocity()*converter.getCharPhysVelocity() ))
160{
161 this->getName() = "physCorrDrag";
162}
163
164template <typename T, typename DESCRIPTOR>
166{
167 T faces[7] = { };
168 T sum[4] = { };
169 _facesF(faces, input);
170 _sumF(sum, input);
171
172 output[0] = _factor * sum[0] / faces[0];
173 output[1] = _factor * sum[1] / faces[1];
174 output[2] = _factor * sum[2] / faces[2];
175
176 return true;
177}
178
179
180} // end namespace olb
181
182#endif
Representation of a block geometry.
identity functor
Base block indicator functor.
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeF3D< T, DESCRIPTOR > & _f
BlockL1Norm3D(BlockLatticeF3D< T, DESCRIPTOR > &f, BlockGeometry< T, 3 > &blockGeometry, int material)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockL223D(BlockLatticeF3D< T, DESCRIPTOR > &f, BlockGeometry< T, 3 > &blockGeometry, int material)
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
BlockLatticePhysCorrDrag3D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockIndicatorF3D< T > &indicatorF, const UnitConverter< T, DESCRIPTOR > &converter)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticePhysDrag3D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockIndicatorF3D< T > &indicatorF, const UnitConverter< T, DESCRIPTOR > &converter)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(),...
Platform-abstracted block lattice for external access and inter-block interaction.
std::string & getName()
read and write access to name
Definition genericF.hh:51
Conversion between physical and lattice units, as well as discretization.
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
Top level namespace for all of OpenLB.