diff options
Diffstat (limited to 'src/functors/lattice/integral')
43 files changed, 4791 insertions, 0 deletions
diff --git a/src/functors/lattice/integral/MakeHeader b/src/functors/lattice/integral/MakeHeader new file mode 100644 index 0000000..11f679c --- /dev/null +++ b/src/functors/lattice/integral/MakeHeader @@ -0,0 +1,37 @@ +# This file is part of the OpenLB library +# +# Copyright (C) 2017 Adrian Kummerlaender +# E-mail contact: info@openlb.net +# The most recent release of OpenLB can be downloaded at +# <http://www.openlb.net/> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + + +generic := + +precompiled := superIntegralF3D \ + blockIntegralF3D \ + superPlaneIntegralF3D \ + superPlaneIntegralFluxF3D \ + superPlaneIntegralFluxMass3D \ + superLpNorm3D \ + blockLpNorm3D \ + superLpNorm2D \ + blockLpNorm2D \ + superPlaneIntegralF2D \ + superPlaneIntegralFluxF2D \ + superPlaneIntegralFluxMass2D diff --git a/src/functors/lattice/integral/blockIntegralF3D.cpp b/src/functors/lattice/integral/blockIntegralF3D.cpp new file mode 100644 index 0000000..c82a1cb --- /dev/null +++ b/src/functors/lattice/integral/blockIntegralF3D.cpp @@ -0,0 +1,35 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2018 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "blockIntegralF3D.h" +#include "blockIntegralF3D.hh" + +namespace olb { + +template class BlockSum3D<double,double>; +template class BlockSum3D<double,int>; + +template class BlockIntegral3D<double,double>; +template class BlockIntegral3D<double,int>; + +} diff --git a/src/functors/lattice/integral/blockIntegralF3D.h b/src/functors/lattice/integral/blockIntegralF3D.h new file mode 100644 index 0000000..d986106 --- /dev/null +++ b/src/functors/lattice/integral/blockIntegralF3D.h @@ -0,0 +1,61 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2018 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BLOCK_INTEGRAL_F_3D_H +#define BLOCK_INTEGRAL_F_3D_H + +#include "geometry/cuboid3D.h" +#include "functors/lattice/blockBaseF3D.h" + +namespace olb { + + +/// BlockSum3D sums all components of f over a indicated subset +template <typename T, typename W = T> +class BlockSum3D : public BlockF3D<W> { +private: + BlockF3D<W>& _f; + BlockIndicatorF3D<T>& _indicatorF; +public: + BlockSum3D(BlockF3D<W>& f, + BlockIndicatorF3D<T>& indicatorF); + bool operator() (W output[], const int input[]) override; +}; + + +/// BlockIntegral3D integrates f on a indicated subset +template <typename T, typename W = T> +class BlockIntegral3D final : public BlockF3D<W> { +private: + BlockF3D<W>& _f; + BlockIndicatorF3D<T>& _indicatorF; +public: + BlockIntegral3D(BlockF3D<W>& f, + BlockIndicatorF3D<T>& indicatorF); + bool operator() (W output[], const int input[]) override; +}; + + +} + +#endif diff --git a/src/functors/lattice/integral/blockIntegralF3D.hh b/src/functors/lattice/integral/blockIntegralF3D.hh new file mode 100644 index 0000000..c5d11e4 --- /dev/null +++ b/src/functors/lattice/integral/blockIntegralF3D.hh @@ -0,0 +1,117 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2018 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BLOCK_INTEGRAL_F_3D_HH +#define BLOCK_INTEGRAL_F_3D_HH + +#include "blockIntegralF3D.h" +#include "core/olbDebug.h" +#include "functors/lattice/indicator/blockIndicatorBaseF3D.h" + +namespace olb { + + +template <typename T, typename W> +BlockSum3D<T,W>::BlockSum3D(BlockF3D<W>& f, + BlockIndicatorF3D<T>& indicatorF) + : BlockF3D<W>(f.getBlockStructure(), f.getTargetDim()+1), + _f(f), + _indicatorF(indicatorF) +{ + this->getName() = "BlockSum("+_f.getName()+")"; +} + +template <typename T, typename W> +bool BlockSum3D<T,W>::operator() (W output[], const int input[]) +{ + OLB_ASSERT(_f.getSourceDim() == _indicatorF.getSourceDim(), + "functor source dimension equals indicator source dimension"); + + W outputTmp[_f.getTargetDim()]; + int inputTmp[_f.getSourceDim()]; + std::size_t voxels(0); + + const auto& blockStructure = this->getBlockStructure(); + + for (inputTmp[0] = 0; inputTmp[0] < blockStructure.getNx(); ++inputTmp[0]) { + for (inputTmp[1] = 0; inputTmp[1] < blockStructure.getNy(); ++inputTmp[1]) { + for (inputTmp[2] = 0; inputTmp[2] < blockStructure.getNz(); ++inputTmp[2]) { + if (_indicatorF(inputTmp)) { + _f(outputTmp,inputTmp); + for (int i = 0; i < _f.getTargetDim(); ++i) { + output[i] += outputTmp[i]; + } + voxels += 1; + } + } + } + } + output[_f.getTargetDim()] += voxels; + + return true; +} + + +template <typename T, typename W> +BlockIntegral3D<T,W>::BlockIntegral3D(BlockF3D<W>& f, + BlockIndicatorF3D<T>& indicatorF) + : BlockF3D<W>(f.getBlockStructure(), f.getTargetDim()), + _f(f), + _indicatorF(indicatorF) +{ + this->getName() = "BlockIntegral("+_f.getName()+")"; +} + +template <typename T, typename W> +bool BlockIntegral3D<T,W>::operator() (W output[], const int input[]) +{ + OLB_ASSERT(_f.getSourceDim() == _indicatorF.getSourceDim(), + "functor source dimension equals indicator source dimension"); + + const W weight = pow(_indicatorF.getBlockGeometryStructure().getDeltaR(), 3); + + W outputTmp[_f.getTargetDim()]; + int inputTmp[_f.getSourceDim()]; + + const auto& blockStructure = this->getBlockStructure(); + + for (inputTmp[0] = 0; inputTmp[0] < blockStructure.getNx(); ++inputTmp[0]) { + for (inputTmp[1] = 0; inputTmp[1] < blockStructure.getNy(); ++inputTmp[1]) { + for (inputTmp[2] = 0; inputTmp[2] < blockStructure.getNz(); ++inputTmp[2]) { + if (_indicatorF(inputTmp)) { + _f(outputTmp,inputTmp); + for (int i = 0; i < this->getTargetDim(); ++i) { + output[i] += outputTmp[i] * weight; + } + } + } + } + } + + return true; +} + + +} + +#endif diff --git a/src/functors/lattice/integral/blockLpNorm2D.cpp b/src/functors/lattice/integral/blockLpNorm2D.cpp new file mode 100644 index 0000000..781245b --- /dev/null +++ b/src/functors/lattice/integral/blockLpNorm2D.cpp @@ -0,0 +1,33 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "blockLpNorm2D.h" +#include "blockLpNorm2D.hh" + +namespace olb { + +template class BlockLpNorm2D<double,double,0>; +template class BlockLpNorm2D<double,double,1>; +template class BlockLpNorm2D<double,double,2>; + +} diff --git a/src/functors/lattice/integral/blockLpNorm2D.h b/src/functors/lattice/integral/blockLpNorm2D.h new file mode 100644 index 0000000..2f2ade6 --- /dev/null +++ b/src/functors/lattice/integral/blockLpNorm2D.h @@ -0,0 +1,53 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BLOCK_LP_NORM_2D_H +#define BLOCK_LP_NORM_2D_H + +namespace olb { + +template<typename T> class BlockF2D; +template<typename T> class Cuboid2D; +template<typename T> class BlockIndicatorF2D; + +/// Block level functor that returns the Lp norm over omega of the euklid norm of the input block functor. +/** + * Instances are contained in SuperLpNorm2D::_blockF. + **/ +template <typename T, typename W, int P> +class BlockLpNorm2D final : public BlockF2D<W> { +protected: + BlockF2D<W>& _f; + BlockIndicatorF2D<T>& _indicatorF; +public: + /** + * \param f data functor + * \param indicatorF indicator functor describing the subset to be integrated + **/ + BlockLpNorm2D(BlockF2D<W>& f, BlockIndicatorF2D<T>& indicatorF); + bool operator() (W output[], const int input[]) override; +}; + +} + +#endif diff --git a/src/functors/lattice/integral/blockLpNorm2D.hh b/src/functors/lattice/integral/blockLpNorm2D.hh new file mode 100644 index 0000000..9739fde --- /dev/null +++ b/src/functors/lattice/integral/blockLpNorm2D.hh @@ -0,0 +1,77 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BLOCK_LP_NORM_2D_HH +#define BLOCK_LP_NORM_2D_HH + +#include "blockLpNorm2D.h" +#include "functors/lattice/indicator/blockIndicatorBaseF2D.h" +#include "geometry/cuboid2D.h" +#include "latticeIntegralCommon.h" + +namespace olb { + +template <typename T, typename W, int P> +BlockLpNorm2D<T,W,P>::BlockLpNorm2D(BlockF2D<W>& f, + BlockIndicatorF2D<T>& indicatorF) + : BlockF2D<W>(f.getBlockStructure(), f.getTargetDim()), + _f(f), + _indicatorF(indicatorF) +{ + OLB_ASSERT(_f.getSourceDim() == _indicatorF.getSourceDim(), + "functor source dimension equals indicator source dimension"); + + this->getName() = "BlockL" + std::to_string(P) + "Norm(" + _f.getName() + ")"; +} + +template <typename T, typename W, int P> +bool BlockLpNorm2D<T,W,P>::operator()(W output[], const int input[]) +{ + const auto& blockGeometry = _indicatorF.getBlockGeometryStructure(); + const int nX = blockGeometry.getNx(); + const int nY = blockGeometry.getNy(); + const T weight = pow(blockGeometry.getDeltaR(), 2); + + output[0] = W(0); + W outputTmp[_f.getTargetDim()]; + int inputTmp[_f.getSourceDim()]; + + for (inputTmp[0] = 0; inputTmp[0] < nX; ++inputTmp[0]) { + for (inputTmp[1] = 0; inputTmp[1] < nY; ++inputTmp[1]) { + if (_indicatorF(inputTmp)) { + _f(outputTmp, inputTmp); + for (int iDim = 0; iDim < _f.getTargetDim(); ++iDim) { + output[0] = LpNormImpl<T,W,P>()(output[0], outputTmp[iDim], weight); + } + } + } + } + + output[0] = LpNormImpl<T,W,P>().enclose(output[0]); + + return true; +} + +} + +#endif diff --git a/src/functors/lattice/integral/blockLpNorm3D.cpp b/src/functors/lattice/integral/blockLpNorm3D.cpp new file mode 100644 index 0000000..24145dc --- /dev/null +++ b/src/functors/lattice/integral/blockLpNorm3D.cpp @@ -0,0 +1,33 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "blockLpNorm3D.h" +#include "blockLpNorm3D.hh" + +namespace olb { + +template class BlockLpNorm3D<double,double,0>; +template class BlockLpNorm3D<double,double,1>; +template class BlockLpNorm3D<double,double,2>; + +} diff --git a/src/functors/lattice/integral/blockLpNorm3D.h b/src/functors/lattice/integral/blockLpNorm3D.h new file mode 100644 index 0000000..302cfdd --- /dev/null +++ b/src/functors/lattice/integral/blockLpNorm3D.h @@ -0,0 +1,50 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BLOCK_LP_NORM_3D_H +#define BLOCK_LP_NORM_3D_H + +namespace olb { + +template<typename T> class BlockF3D; +template<typename T> class Cuboid3D; +template<typename T> class BlockIndicatorF3D; + +/// Block level functor that returns the Lp norm over omega of the euklid norm of the input block functor. +template <typename T, typename W, int P> +class BlockLpNorm3D final : public BlockF3D<W> { +protected: + BlockF3D<W>& _f; + BlockIndicatorF3D<T>& _indicatorF; +public: + /** + * \param f data functor + * \param indicatorF indicator functor describing the subset to be integrated + **/ + BlockLpNorm3D(BlockF3D<W>& f, BlockIndicatorF3D<T>& indicatorF); + bool operator() (W output[], const int input[]) override; +}; + +} + +#endif diff --git a/src/functors/lattice/integral/blockLpNorm3D.hh b/src/functors/lattice/integral/blockLpNorm3D.hh new file mode 100644 index 0000000..301d3ee --- /dev/null +++ b/src/functors/lattice/integral/blockLpNorm3D.hh @@ -0,0 +1,80 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BLOCK_LP_NORM_3D_HH +#define BLOCK_LP_NORM_3D_HH + +#include "blockLpNorm3D.h" +#include "functors/lattice/indicator/blockIndicatorBaseF3D.h" +#include "geometry/cuboid3D.h" +#include "latticeIntegralCommon.h" + +namespace olb { + +template <typename T, typename W, int P> +BlockLpNorm3D<T,W,P>::BlockLpNorm3D(BlockF3D<W>& f, + BlockIndicatorF3D<T>& indicatorF) + : BlockF3D<W>(f.getBlockStructure(), f.getTargetDim()), + _f(f), + _indicatorF(indicatorF) +{ + OLB_ASSERT(_f.getSourceDim() == _indicatorF.getSourceDim(), + "functor source dimension equals indicator source dimension"); + + this->getName() = "BlockL" + std::to_string(P) + "Norm(" + _f.getName() + ")"; +} + +template <typename T, typename W, int P> +bool BlockLpNorm3D<T,W,P>::operator()(W output[], const int input[]) +{ + const auto& blockGeometry = _indicatorF.getBlockGeometryStructure(); + const int nX = blockGeometry.getNx(); + const int nY = blockGeometry.getNy(); + const int nZ = blockGeometry.getNz(); + const T weight = pow(blockGeometry.getDeltaR(), 3); + + output[0] = W(0); + W outputTmp[_f.getTargetDim()]; + int inputTmp[_f.getSourceDim()]; + + for (inputTmp[0] = 0; inputTmp[0] < nX; ++inputTmp[0]) { + for (inputTmp[1] = 0; inputTmp[1] < nY; ++inputTmp[1]) { + for (inputTmp[2] = 0; inputTmp[2] < nZ; ++inputTmp[2]) { + if (_indicatorF(inputTmp)) { + _f(outputTmp, inputTmp); + for (int iDim = 0; iDim < _f.getTargetDim(); ++iDim) { + output[0] = LpNormImpl<T,W,P>()(output[0], outputTmp[iDim], weight); + } + } + } + } + } + + output[0] = LpNormImpl<T,W,P>().enclose(output[0]); + + return true; +} + +} + +#endif diff --git a/src/functors/lattice/integral/integral2D.h b/src/functors/lattice/integral/integral2D.h new file mode 100644 index 0000000..fc21c9b --- /dev/null +++ b/src/functors/lattice/integral/integral2D.h @@ -0,0 +1,32 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2017 Adrian Kummerlaender + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * <http://www.openlb.net/> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +/** \file + * Groups all include files for the directory functors/lattice/integral. + */ + +#include "superLpNorm2D.h" +#include "blockLpNorm2D.h" +#include "superPlaneIntegralF2D.h" +#include "superPlaneIntegralFluxF2D.h" +#include "superPlaneIntegralFluxMass2D.h" |