OpenLB 1.7
Loading...
Searching...
No Matches
blockLpNorm3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2017 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 BLOCK_LP_NORM_3D_HH
25#define BLOCK_LP_NORM_3D_HH
26
27#include "blockLpNorm3D.h"
29#include "geometry/cuboid3D.h"
31
32namespace olb {
33
34template <typename T, typename W, int P>
36 BlockIndicatorF3D<T>& indicatorF)
37 : BlockF3D<W>(f.getBlockStructure(), f.getTargetDim()),
38 _f(f),
39 _indicatorF(indicatorF)
40{
41 OLB_ASSERT(_f.getSourceDim() == _indicatorF.getSourceDim(),
42 "functor source dimension equals indicator source dimension");
43
44 this->getName() = "BlockL" + std::to_string(P) + "Norm(" + _f.getName() + ")";
45}
46
47template <typename T, typename W, int P>
48bool BlockLpNorm3D<T,W,P>::operator()(W output[], const int input[])
49{
50 const auto& blockGeometry = _indicatorF.getBlockGeometry();
51 const int nX = blockGeometry.getNx();
52 const int nY = blockGeometry.getNy();
53 const int nZ = blockGeometry.getNz();
54 const T weight = util::pow(blockGeometry.getDeltaR(), 3);
55
56 output[0] = W(0);
57 W outputTmp[_f.getTargetDim()];
58 int inputTmp[_f.getSourceDim()];
59
60 for (inputTmp[0] = 0; inputTmp[0] < nX; ++inputTmp[0]) {
61 for (inputTmp[1] = 0; inputTmp[1] < nY; ++inputTmp[1]) {
62 for (inputTmp[2] = 0; inputTmp[2] < nZ; ++inputTmp[2]) {
63 if (_indicatorF(inputTmp)) {
64 _f(outputTmp, inputTmp);
65 for (int iDim = 0; iDim < _f.getTargetDim(); ++iDim) {
66 output[0] = LpNormImpl<T,W,P>()(output[0], outputTmp[iDim], weight);
67 }
68 }
69 }
70 }
71 }
72
73 output[0] = LpNormImpl<T,W,P>().enclose(output[0]);
74
75 return true;
76}
77
78}
79
80#endif
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
Base block indicator functor.
BlockIndicatorF3D< T > & _indicatorF
BlockLpNorm3D(BlockF3D< W > &f, BlockIndicatorF3D< T > &indicatorF)
bool operator()(W output[], const int input[]) override
BlockF3D< W > & _f
int getSourceDim() const
read only access to member variable _m
Definition genericF.hh:39
std::string & getName()
read and write access to name
Definition genericF.hh:51
The description of a single 3D cuboid – header file.
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
Top level namespace for all of OpenLB.
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45
Lp norm functor implementation details specific to the P parameter.