OpenLB 1.7
Loading...
Searching...
No Matches
blockLatticeIntegralF2D.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_2D_HH
26#define BLOCK_LATTICE_INTEGRAL_F_2D_HH
27
28#include <vector>
29#include <cmath>
30
33#include "blockCalcF2D.h" // for IdentityF
34#include "core/olbDebug.h"
35
36namespace olb {
37
38
39template <typename T, typename DESCRIPTOR>
41 BlockGeometry<T,2>& blockGeometry, int material)
42 : BlockLatticeF2D<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 BlockL1Norm2D<T,DESCRIPTOR>::operator() (T output[], const int input[])
50{
51 BlockIdentity2D<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 if (this->_blockGeometry.getMaterial(iX, iY) == _material) {
58 _f(outputTmp,iX, iY);
59 T tmp = fabs(outputTmp[i]);
60 if (tmp > output[i]) {
61 output[i] = tmp;
62 }
63 }
64 }
65 }
66 }
67 return true;
68}
69
70
71template <typename T, typename DESCRIPTOR>
73 BlockGeometry<T,2>& blockGeometry, int material)
74 : BlockLatticeF2D<T,DESCRIPTOR>(f.getBlock(),f.getTargetDim()),
75 _f(f), _blockGeometry(blockGeometry), _material(material)
76{
77 this->getName() = "L22("+f.getName()+")";
78}
79
80
81template <typename T, typename DESCRIPTOR>
82bool BlockL222D<T,DESCRIPTOR>::operator() (T output[], const int input[])
83{
84 // f.getBlock().communicate();
85 // CuboidGeometry2D<T>& cGeometry = f.getBlock().get_cGeometry();
86 // loadBalancer& load = f.getBlock().get_load();
87
88 output[0]=0;
89 // for (int i=0; i<this->n; i++) {
90
91 // for (int iC=0; iC<load.size(); iC++) {
92 // int nX = cGeometry.get(load.glob(iC)).getNx();
93 // int nY = cGeometry.get(load.glob(iC)).getNy();
94 // int nZ = cGeometry.get(load.glob(iC)).getNz();
95 // T weight = pow(this->blockGeometry.getDeltaR(),3);
96 // for (int iX=0; iX<nX; ++iX) {
97 // for (int iY=0; iY<nY; ++iY) {
98 // for (int iZ=0; iZ<nZ; ++iZ) {
99 // int globX = (int)cGeometry.get(load.glob(iC)).get_globPosX() + iX;
100 // int globY = (int)cGeometry.get(load.glob(iC)).get_globPosY() + iY;
101 // int globZ = (int)cGeometry.get(load.glob(iC)).get_globPosZ() + iZ;
102 // if (this->blockGeometry.get_material({globX, globY, globZ}) == material) {
103 // tmp[i]+=f(load.glob(iC),iX,iY,iZ)[i]*f(load.glob(iC),iX,iY,iZ)[i]*weight;
104 // }
105 // }
106 // }
107 // }
108 // }
109 //#ifdef PARALLEL_MODE_MPI
110 // singleton::mpi().reduceAndBcast(tmp[i], MPI_SUM);
111 //#endif
112 // }
113 return true;
114}
115
116
117template <typename T, typename DESCRIPTOR>
119 BlockLattice<T,DESCRIPTOR>& blockLattice,
120 BlockIndicatorF2D<T>& indicatorF,
121 const UnitConverter<T,DESCRIPTOR>& converter)
122 : BlockLatticePhysF2D<T,DESCRIPTOR>(blockLattice, converter, 2),
123 _indicatorF(indicatorF),
124 _facesF(indicatorF, converter.getConversionFactorLength()),
125 _pBoundForceF(blockLattice, indicatorF, converter),
126 _sumF(_pBoundForceF, indicatorF),
127 _factor(2./( converter.getPhysDensity()*converter.getCharPhysVelocity()*converter.getCharPhysVelocity() ))
128{
129 this->getName() = "physDrag";
130}
131
132template <typename T, typename DESCRIPTOR>
133bool BlockLatticePhysDrag2D<T,DESCRIPTOR>::operator() (T output[], const int input[])
134{
135 T faces[5] = { };
136 T sum[3] = { };
137 _sumF(sum, input);
138 _facesF(faces, input);
139
140 output[0] = _factor * sum[0] / faces[0];
141 output[1] = _factor * sum[1] / faces[1];
142
143 return true;
144}
145
146template <typename T, typename DESCRIPTOR>
148 BlockLattice<T,DESCRIPTOR>& blockLattice,
149 BlockIndicatorF2D<T>& indicatorF,
150 const UnitConverter<T,DESCRIPTOR>& converter)
151 : BlockLatticePhysF2D<T,DESCRIPTOR>(blockLattice, converter, 2),
152 _indicatorF(indicatorF),
153 _facesF(indicatorF, converter.getConversionFactorLength()),
154 _pBoundForceF(blockLattice, indicatorF, converter),
155 _sumF(_pBoundForceF, indicatorF),
156 _factor(2./( converter.getPhysDensity()*converter.getCharPhysVelocity()*converter.getCharPhysVelocity() ))
157{
158 this->getName() = "physCorrDrag";
159}
160
161template <typename T, typename DESCRIPTOR>
163{
164 T faces[5] = { };
165 T sum[3] = { };
166 _facesF(faces, input);
167 _sumF(sum, input);
168
169 output[0] = _factor * sum[0] / faces[0];
170 output[1] = _factor * sum[1] / faces[1];
171
172 return true;
173}
174
175
176} // end namespace olb
177
178#endif
Representation of a block geometry.
identity functor
Base block indicator functor (discrete)
BlockLatticeF2D< T, DESCRIPTOR > & _f
BlockL1Norm2D(BlockLatticeF2D< T, DESCRIPTOR > &f, BlockGeometry< T, 2 > &blockGeometry, int material)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockL222D(BlockLatticeF2D< T, DESCRIPTOR > &f, BlockGeometry< T, 2 > &blockGeometry, int material)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
BlockLatticePhysCorrDrag2D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockIndicatorF2D< T > &indicatorF, const UnitConverter< T, DESCRIPTOR > &converter)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticePhysDrag2D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockIndicatorF2D< 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.
Top level namespace for all of OpenLB.