From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 24 Jun 2019 14:43:36 +0200 Subject: Initialize at openlb-1-3 --- src/functors/lattice/indicator/MakeHeader | 33 +++ .../lattice/indicator/blockIndicatorBaseF2D.cpp | 32 +++ .../lattice/indicator/blockIndicatorBaseF2D.h | 87 ++++++++ .../lattice/indicator/blockIndicatorBaseF2D.hh | 87 ++++++++ .../lattice/indicator/blockIndicatorBaseF3D.cpp | 32 +++ .../lattice/indicator/blockIndicatorBaseF3D.h | 107 ++++++++++ .../lattice/indicator/blockIndicatorBaseF3D.hh | 88 ++++++++ .../lattice/indicator/blockIndicatorF2D.cpp | 35 ++++ src/functors/lattice/indicator/blockIndicatorF2D.h | 144 +++++++++++++ .../lattice/indicator/blockIndicatorF2D.hh | 215 +++++++++++++++++++ .../lattice/indicator/blockIndicatorF3D.cpp | 35 ++++ src/functors/lattice/indicator/blockIndicatorF3D.h | 140 +++++++++++++ .../lattice/indicator/blockIndicatorF3D.hh | 228 +++++++++++++++++++++ src/functors/lattice/indicator/indicator2D.h | 32 +++ src/functors/lattice/indicator/indicator2D.hh | 32 +++ src/functors/lattice/indicator/indicator3D.h | 32 +++ src/functors/lattice/indicator/indicator3D.hh | 32 +++ src/functors/lattice/indicator/module.mk | 27 +++ .../lattice/indicator/superIndicatorBaseF2D.cpp | 32 +++ .../lattice/indicator/superIndicatorBaseF2D.h | 95 +++++++++ .../lattice/indicator/superIndicatorBaseF2D.hh | 102 +++++++++ .../lattice/indicator/superIndicatorBaseF3D.cpp | 32 +++ .../lattice/indicator/superIndicatorBaseF3D.h | 104 ++++++++++ .../lattice/indicator/superIndicatorBaseF3D.hh | 102 +++++++++ .../lattice/indicator/superIndicatorF2D.cpp | 34 +++ src/functors/lattice/indicator/superIndicatorF2D.h | 119 +++++++++++ .../lattice/indicator/superIndicatorF2D.hh | 164 +++++++++++++++ .../lattice/indicator/superIndicatorF3D.cpp | 35 ++++ src/functors/lattice/indicator/superIndicatorF3D.h | 129 ++++++++++++ .../lattice/indicator/superIndicatorF3D.hh | 171 ++++++++++++++++ 30 files changed, 2537 insertions(+) create mode 100644 src/functors/lattice/indicator/MakeHeader create mode 100644 src/functors/lattice/indicator/blockIndicatorBaseF2D.cpp create mode 100644 src/functors/lattice/indicator/blockIndicatorBaseF2D.h create mode 100644 src/functors/lattice/indicator/blockIndicatorBaseF2D.hh create mode 100644 src/functors/lattice/indicator/blockIndicatorBaseF3D.cpp create mode 100644 src/functors/lattice/indicator/blockIndicatorBaseF3D.h create mode 100644 src/functors/lattice/indicator/blockIndicatorBaseF3D.hh create mode 100644 src/functors/lattice/indicator/blockIndicatorF2D.cpp create mode 100644 src/functors/lattice/indicator/blockIndicatorF2D.h create mode 100644 src/functors/lattice/indicator/blockIndicatorF2D.hh create mode 100644 src/functors/lattice/indicator/blockIndicatorF3D.cpp create mode 100644 src/functors/lattice/indicator/blockIndicatorF3D.h create mode 100644 src/functors/lattice/indicator/blockIndicatorF3D.hh create mode 100644 src/functors/lattice/indicator/indicator2D.h create mode 100644 src/functors/lattice/indicator/indicator2D.hh create mode 100644 src/functors/lattice/indicator/indicator3D.h create mode 100644 src/functors/lattice/indicator/indicator3D.hh create mode 100644 src/functors/lattice/indicator/module.mk create mode 100644 src/functors/lattice/indicator/superIndicatorBaseF2D.cpp create mode 100644 src/functors/lattice/indicator/superIndicatorBaseF2D.h create mode 100644 src/functors/lattice/indicator/superIndicatorBaseF2D.hh create mode 100644 src/functors/lattice/indicator/superIndicatorBaseF3D.cpp create mode 100644 src/functors/lattice/indicator/superIndicatorBaseF3D.h create mode 100644 src/functors/lattice/indicator/superIndicatorBaseF3D.hh create mode 100644 src/functors/lattice/indicator/superIndicatorF2D.cpp create mode 100644 src/functors/lattice/indicator/superIndicatorF2D.h create mode 100644 src/functors/lattice/indicator/superIndicatorF2D.hh create mode 100644 src/functors/lattice/indicator/superIndicatorF3D.cpp create mode 100644 src/functors/lattice/indicator/superIndicatorF3D.h create mode 100644 src/functors/lattice/indicator/superIndicatorF3D.hh (limited to 'src/functors/lattice/indicator') diff --git a/src/functors/lattice/indicator/MakeHeader b/src/functors/lattice/indicator/MakeHeader new file mode 100644 index 0000000..29e478d --- /dev/null +++ b/src/functors/lattice/indicator/MakeHeader @@ -0,0 +1,33 @@ +# This file is part of the OpenLB library +# +# Copyright (C) 2007 Mathias Krause +# E-mail contact: info@openlb.net +# The most recent release of OpenLB can be downloaded at +# +# +# 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 := blockIndicatorF2D \ + blockIndicatorF3D \ + blockIndicatorBaseF2D \ + blockIndicatorBaseF3D \ + superIndicatorBaseF2D \ + superIndicatorBaseF3D \ + superIndicatorF2D \ + superIndicatorF3D diff --git a/src/functors/lattice/indicator/blockIndicatorBaseF2D.cpp b/src/functors/lattice/indicator/blockIndicatorBaseF2D.cpp new file mode 100644 index 0000000..7852fac --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorBaseF2D.cpp @@ -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 + * + * + * 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 "blockIndicatorBaseF2D.h" +#include "blockIndicatorBaseF2D.hh" + +namespace olb { + +template class BlockIndicatorF2D; + +} diff --git a/src/functors/lattice/indicator/blockIndicatorBaseF2D.h b/src/functors/lattice/indicator/blockIndicatorBaseF2D.h new file mode 100644 index 0000000..f556de8 --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorBaseF2D.h @@ -0,0 +1,87 @@ +/* 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 + * + * + * 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_INDICATOR_BASE_F_2D_H +#define BLOCK_INDICATOR_BASE_F_2D_H + +#include "functors/lattice/blockBaseF2D.h" +#include "core/blockData2D.h" +#include "core/blockStructure2D.h" + +namespace olb { + +/// Base block indicator functor (discrete) +template +class BlockIndicatorF2D : public BlockF2D { +protected: + BlockGeometryStructure2D& _blockGeometryStructure; + const BlockData2D* _cachedData; +public: + using BlockF2D::operator(); + + BlockIndicatorF2D(BlockGeometryStructure2D& geometry); + /// Get underlying block geometry structure + /** + * \returns _blockGeometryStructure + **/ + BlockGeometryStructure2D& getBlockGeometryStructure(); + /// Block indicator specific function operator overload + /** + * The boolean return value of `operator()(T output[], S input[])` describes + * the call's success and by convention must not describe the indicated domain. + * + * \return Domain indicator i.e. `true` iff the input lies within the described subset. + **/ + bool operator() (const int input[]); + /// Block indicator specific function operator overload + /** + * The boolean return value of `operator()(T output[], S input[])` describes + * the call's success and by convention must not describe the indicated domain. + * + * \return Domain indicator i.e. `true` iff the input lies within the described subset. + **/ + bool operator() (int iX, int iY); + + /// Set bool-mask cache to be used by indicator operator overloads + void setCache(const BlockData2D& cache); + + /// Returns true only if the indicated domain subset is empty + /** + * May return false even if the indicated domain subset is in fact empty. + * Primarily implemented to minimize block accesses if an empty domain can + * be inferred by e.g. BlockGeometryStatistics2D data. + * + * i.e. only override this method if the domain can be checked for emptyness + * in an efficient fashion. + **/ + virtual bool isEmpty(); + /// Returns min lattice position of the indicated subset's bounding box + virtual Vector getMin() = 0; + /// Returns max lattice position of the indicated subset's bounding box + virtual Vector getMax() = 0; + +}; + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorBaseF2D.hh b/src/functors/lattice/indicator/blockIndicatorBaseF2D.hh new file mode 100644 index 0000000..4a64ddd --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorBaseF2D.hh @@ -0,0 +1,87 @@ +/* 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 + * + * + * 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_INDICATOR_BASE_F_2D_HH +#define BLOCK_INDICATOR_BASE_F_2D_HH + +#include "blockIndicatorBaseF2D.h" +#include "geometry/blockGeometry2D.h" + +namespace olb { + +template +BlockIndicatorF2D::BlockIndicatorF2D(BlockGeometryStructure2D& geometry) + : BlockF2D(geometry.getBlockStructure(), 1), + _blockGeometryStructure(geometry), + _cachedData{nullptr} +{ } + +template +BlockGeometryStructure2D& BlockIndicatorF2D::getBlockGeometryStructure() +{ + return _blockGeometryStructure; +} + +template +bool BlockIndicatorF2D::operator() (const int input[]) +{ + bool output{}; + if (_cachedData == nullptr) { + this->operator()(&output, input); + } + else { + _cachedData->get(input[0], input[1]); + } + return output; +} + +template +bool BlockIndicatorF2D::operator() (int iX, int iY) +{ + bool output{}; + if (_cachedData == nullptr) { + this->operator()(&output, iX, iY); + } + else { + _cachedData->get(iX, iY); + } + return output; +} + +template +void BlockIndicatorF2D::setCache(const BlockData2D& cache) +{ + _cachedData = &cache; +} + +template +bool BlockIndicatorF2D::isEmpty() +{ + // There is no way to determine domain emptyness in a fashion that is both + // generic and efficient. + return false; +} + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorBaseF3D.cpp b/src/functors/lattice/indicator/blockIndicatorBaseF3D.cpp new file mode 100644 index 0000000..487d27d --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorBaseF3D.cpp @@ -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 + * + * + * 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 "blockIndicatorBaseF3D.h" +#include "blockIndicatorBaseF3D.hh" + +namespace olb { + +template class BlockIndicatorF3D; + +} diff --git a/src/functors/lattice/indicator/blockIndicatorBaseF3D.h b/src/functors/lattice/indicator/blockIndicatorBaseF3D.h new file mode 100644 index 0000000..96dd05a --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorBaseF3D.h @@ -0,0 +1,107 @@ +/* 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 + * + * + * 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_INDICATOR_BASE_F_3D_H +#define BLOCK_INDICATOR_BASE_F_3D_H + +#include "functors/lattice/superBaseF3D.h" +#include "functors/lattice/blockBaseF3D.h" +#include "core/blockData3D.h" +#include "core/blockStructure3D.h" + +namespace olb { + +/// Base block indicator functor +/** + * Derived functors implement a indicator function on the full domain given by + * BlockGeometryStructure3D. Note the distinction between normal and extended + * block geometries exposed by SuperGeometry3D. + * + * By convention SuperIndicatorF3D::_blockF functors are expected to operate on + * overlap-less domains i.e. BlockGeometryView3D instances. + * + * Block indicators to be queried on a full block including its overlap must be + * constructed on extended BlockGeometry3D instances such as those exposed by + * SuperGeometry3D::getExtendedBlockGeometry + **/ +template +class BlockIndicatorF3D : public BlockF3D { +protected: + BlockGeometryStructure3D& _blockGeometryStructure; + const BlockData3D* _cachedData; +public: + using BlockF3D::operator(); + + /// Constructor + /** + * \param geometry Any implementation of BlockGeometryStructure3D + * e.g. BlockGeometry3D or BlockGeometryView3D + **/ + BlockIndicatorF3D(BlockGeometryStructure3D& geometry); + + /// Get underlying block geometry structure + /** + * \returns _blockGeometryStructure + **/ + BlockGeometryStructure3D& getBlockGeometryStructure(); + + /// Block indicator specific function operator overload + /** + * The boolean return value of `operator()(T output[], S input[])` describes + * the call's success and by convention must not describe the indicated domain. + * + * \return Domain indicator i.e. `true` iff the input lies within the described subset. + **/ + bool operator() (const int input[]); + /// Block indicator specific function operator overload + /** + * The boolean return value of `operator()(T output[], S input[])` describes + * the call's success and by convention must not describe the indicated domain. + * + * \return Domain indicator i.e. `true` iff the input lies within the described subset. + **/ + bool operator() (int iX, int iY, int iZ); + + /// Set bool-mask cache to be used by indicator operator overloads + void setCache(const BlockData3D& cache); + + /// Returns true only if the indicated domain subset is empty + /** + * May return false even if the indicated domain subset is in fact empty. + * Primarily implemented to minimize block accesses if an empty domain can + * be inferred by e.g. BlockGeometryStatistics3D data. + * + * i.e. only override this method if the domain can be checked for emptyness + * in an efficient fashion. + **/ + virtual bool isEmpty(); + /// Returns min lattice position of the indicated subset's bounding box + virtual Vector getMin() = 0; + /// Returns max lattice position of the indicated subset's bounding box + virtual Vector getMax() = 0; + +}; + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorBaseF3D.hh b/src/functors/lattice/indicator/blockIndicatorBaseF3D.hh new file mode 100644 index 0000000..dc0cc1a --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorBaseF3D.hh @@ -0,0 +1,88 @@ +/* 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 + * + * + * 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_INDICATOR_BASE_F_3D_HH +#define BLOCK_INDICATOR_BASE_F_3D_HH + +#include "blockIndicatorBaseF3D.h" +#include "geometry/blockGeometry3D.h" + +namespace olb { + +template +BlockIndicatorF3D::BlockIndicatorF3D(BlockGeometryStructure3D& geometry) + : BlockF3D(geometry.getBlockStructure(), 1), + _blockGeometryStructure(geometry), + _cachedData{nullptr} +{ } + +template +BlockGeometryStructure3D& BlockIndicatorF3D::getBlockGeometryStructure() +{ + return _blockGeometryStructure; +} + +template +bool BlockIndicatorF3D::operator() (const int input[]) +{ + bool output{}; + if (_cachedData == nullptr) { + this->operator()(&output, input); + } + else { + _cachedData->get(input[0], input[1], input[2]); + } + return output; +} + +template +bool BlockIndicatorF3D::operator() (int iX, int iY, int iZ) +{ + bool output{}; + if (_cachedData == nullptr) { + this->operator()(&output, iX, iY, iZ); + } + else { + _cachedData->get(iX, iY, iZ); + } + return output; +} + +template +void BlockIndicatorF3D::setCache(const BlockData3D& cache) +{ + _cachedData = &cache; +} + +template +bool BlockIndicatorF3D::isEmpty() +{ + // There is no way to determine domain emptyness in a fashion that is both + // generic and efficient. + return false; +} + + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorF2D.cpp b/src/functors/lattice/indicator/blockIndicatorF2D.cpp new file mode 100644 index 0000000..073e173 --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorF2D.cpp @@ -0,0 +1,35 @@ +/* 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 + * + * + * 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 "blockIndicatorF2D.h" +#include "blockIndicatorF2D.hh" + +namespace olb { + +template class BlockIndicatorFfromIndicatorF2D; +template class BlockIndicatorFfromSmoothIndicatorF2D; +template class BlockIndicatorMaterial2D; +template class BlockIndicatorIdentity2D; + +} diff --git a/src/functors/lattice/indicator/blockIndicatorF2D.h b/src/functors/lattice/indicator/blockIndicatorF2D.h new file mode 100644 index 0000000..a0bdb3a --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorF2D.h @@ -0,0 +1,144 @@ +/* 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 + * + * + * 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_INDICATOR_F_2D_H +#define BLOCK_INDICATOR_F_2D_H + +#include "blockIndicatorBaseF2D.h" +#include "geometry/blockGeometryView2D.h" +#include "functors/analytical/indicator/smoothIndicatorBaseF2D.h" + +namespace olb { + +/// BlockIndicatorF2D from IndicatorF2D +template +class BlockIndicatorFfromIndicatorF2D : public BlockIndicatorF2D { +protected: + IndicatorF2D& _indicatorF; +public: + /** + * \param indicatorF Indicator to be reduced to lattice space + * \param blockGeometry Block geometry structure to be used for conversion + * between lattice and physical coordinates. + **/ + BlockIndicatorFfromIndicatorF2D(IndicatorF2D& indicatorF, + BlockGeometryStructure2D& blockGeometry); + + using BlockIndicatorF2D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + + +/// BlockIndicatorF2D from SmoothIndicatorF2D +/** + * Note on get(Min,Max): SmoothIndicatorF2D currently doesn't expose a bounding box + * which is why these methods return the full block domain. + **/ +template +class BlockIndicatorFfromSmoothIndicatorF2D : public BlockIndicatorF2D { +protected: + SmoothIndicatorF2D& _indicatorF; +public: + /** + * \param indicatorF Smooth indicator to be reduced to lattice space + * \param blockGeometry Block geometry structure to be used for conversion + * between lattice and physical coordinates. + **/ + BlockIndicatorFfromSmoothIndicatorF2D(SmoothIndicatorF2D& indicatorF, + BlockGeometryStructure2D& blockGeometry); + + using BlockIndicatorF2D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns a min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns a max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + + +/// Block indicator functor from material numbers +template +class BlockIndicatorMaterial2D : public BlockIndicatorF2D { +protected: + const std::vector _materials; +public: + /** + * \param blockGeometry Block geometry structue to be queried + * \param materials Material number vector + **/ + BlockIndicatorMaterial2D(BlockGeometryStructure2D& blockGeometry, + std::vector materials); + /** + * \param blockGeometry Block geometry structure to be queried + * \param materials Material number list + **/ + BlockIndicatorMaterial2D(BlockGeometryStructure2D& blockGeometry, + std::list materials); + /** + * \param blockGeometry Block geometry structure to be queried + * \param material Material number + **/ + BlockIndicatorMaterial2D(BlockGeometryStructure2D& blockGeometry, + int material); + + using BlockIndicatorF2D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns true iff indicated domain subset is empty + bool isEmpty() override; + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + + +/// Block indicator identity +template +class BlockIndicatorIdentity2D : public BlockIndicatorF2D { +protected: + BlockIndicatorF2D& _indicatorF; +public: + /** + * \param indicatorF Block indicator to be proxied + **/ + BlockIndicatorIdentity2D(BlockIndicatorF2D& indicatorF); + + using BlockIndicatorF2D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorF2D.hh b/src/functors/lattice/indicator/blockIndicatorF2D.hh new file mode 100644 index 0000000..8d01a6b --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorF2D.hh @@ -0,0 +1,215 @@ +/* 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 + * + * + * 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_INDICATOR_F_2D_HH +#define BLOCK_INDICATOR_F_2D_HH + +#include + +#include "blockIndicatorF2D.h" +#include "core/util.h" + +namespace olb { + +template +BlockIndicatorFfromIndicatorF2D::BlockIndicatorFfromIndicatorF2D( + IndicatorF2D& indicatorF, BlockGeometryStructure2D& blockGeometry) + : BlockIndicatorF2D(blockGeometry), + _indicatorF(indicatorF) +{ } + +template +bool BlockIndicatorFfromIndicatorF2D::operator() (bool output[], const int input[]) +{ + T physR[2]; + this->_blockGeometryStructure.getPhysR(physR,input); + return _indicatorF(output,physR); +} + +template +Vector BlockIndicatorFfromIndicatorF2D::getMin() +{ + const Vector min = _indicatorF.getMin(); + return Vector { + static_cast(floor(min[0])), + static_cast(floor(min[1])) + }; +} + +template +Vector BlockIndicatorFfromIndicatorF2D::getMax() +{ + const Vector max = _indicatorF.getMax(); + return Vector { + static_cast(ceil(max[0])), + static_cast(ceil(max[1])) + }; +} + + +template +BlockIndicatorFfromSmoothIndicatorF2D::BlockIndicatorFfromSmoothIndicatorF2D( + SmoothIndicatorF2D& indicatorF, BlockGeometryStructure2D& blockGeometry) + : BlockIndicatorF2D(blockGeometry), + _indicatorF(indicatorF) +{ } + +template +bool BlockIndicatorFfromSmoothIndicatorF2D::operator() (bool output[], const int input[]) +{ + T physR[2]; + T inside[1]; + this->_blockGeometryStructure.getPhysR(physR,input); + _indicatorF(inside, physR); + return !util::nearZero(inside[0]); +} + +template +Vector BlockIndicatorFfromSmoothIndicatorF2D::getMin() +{ + return Vector{0,0}; +} + +template +Vector BlockIndicatorFfromSmoothIndicatorF2D::getMax() +{ + return this->_blockGeometryStructure.getExtend() - Vector{1,1}; +} + + +template +BlockIndicatorMaterial2D::BlockIndicatorMaterial2D( + BlockGeometryStructure2D& blockGeometry, std::vector materials) + : BlockIndicatorF2D(blockGeometry), + _materials(materials) +{ } + +template +BlockIndicatorMaterial2D::BlockIndicatorMaterial2D( + BlockGeometryStructure2D& blockGeometry, std::list materials) + : BlockIndicatorMaterial2D(blockGeometry, + std::vector(materials.begin(), materials.end())) +{ } + +template +BlockIndicatorMaterial2D::BlockIndicatorMaterial2D( + BlockGeometryStructure2D& blockGeometry, int material) + : BlockIndicatorMaterial2D(blockGeometry, std::vector(1,material)) +{ } + +template +bool BlockIndicatorMaterial2D::operator() (bool output[], const int input[]) +{ + // read material number explicitly using the const version + // of BlockGeometry2D::get to avoid resetting geometry + // statistics: + const BlockGeometryStructure2D& blockGeometry = this->_blockGeometryStructure; + const int current = blockGeometry.get(input[0], input[1]); + output[0] = std::any_of(_materials.cbegin(), + _materials.cend(), + [current](int material) { return current == material; }); + + return true; +} + +template +bool BlockIndicatorMaterial2D::isEmpty() +{ + auto& statistics = this->getBlockGeometryStructure().getStatistics(); + + return std::none_of(_materials.cbegin(), _materials.cend(), + [&statistics](int material) -> bool { + return statistics.getNvoxel(material) > 0; + }); +} + +template +Vector BlockIndicatorMaterial2D::getMin() +{ + auto& blockGeometry = this->getBlockGeometryStructure(); + auto& statistics = blockGeometry.getStatistics(); + + Vector globalMin{ + blockGeometry.getNx()-1, + blockGeometry.getNy()-1 + }; + + for ( int material : _materials ) { + if ( statistics.getNvoxel(material) > 0 ) { + const Vector localMin = statistics.getMinLatticeR(material); + for ( int d = 0; d < 2; ++d ) { + globalMin[d] = localMin[d] < globalMin[d] ? localMin[d] : globalMin[d]; + } + } + } + + return globalMin; +} + +template +Vector BlockIndicatorMaterial2D::getMax() +{ + auto& statistics = this->getBlockGeometryStructure().getStatistics(); + + Vector globalMax{ 0, 0 }; + + for ( int material : _materials ) { + if ( statistics.getNvoxel(material) > 0 ) { + const Vector localMax = statistics.getMaxLatticeR(material); + for ( int d = 0; d < 2; ++d ) { + globalMax[d] = localMax[d] > globalMax[d] ? localMax[d] : globalMax[d]; + } + } + } + + return globalMax; +} + + +template +BlockIndicatorIdentity2D::BlockIndicatorIdentity2D(BlockIndicatorF2D& indicatorF) + : BlockIndicatorF2D(indicatorF.getBlockGeometryStructure()), + _indicatorF(indicatorF) +{ } + +template +bool BlockIndicatorIdentity2D::operator() (bool output[], const int input[]) +{ + return _indicatorF(output, input); +} + +template +Vector BlockIndicatorIdentity2D::getMin() +{ + return _indicatorF.getMin(); +} + +template +Vector BlockIndicatorIdentity2D::getMax() +{ + return _indicatorF.getMax(); +} + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorF3D.cpp b/src/functors/lattice/indicator/blockIndicatorF3D.cpp new file mode 100644 index 0000000..a3fe2a8 --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorF3D.cpp @@ -0,0 +1,35 @@ +/* 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 + * + * + * 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 "blockIndicatorF3D.h" +#include "blockIndicatorF3D.hh" + +namespace olb { + +template class BlockIndicatorFfromIndicatorF3D; +template class BlockIndicatorFfromSmoothIndicatorF3D; +template class BlockIndicatorMaterial3D; +template class BlockIndicatorIdentity3D; + +} diff --git a/src/functors/lattice/indicator/blockIndicatorF3D.h b/src/functors/lattice/indicator/blockIndicatorF3D.h new file mode 100644 index 0000000..6455121 --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorF3D.h @@ -0,0 +1,140 @@ +/* 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 + * + * + * 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_INDICATOR_F_3D_H +#define BLOCK_INDICATOR_F_3D_H + +#include "blockIndicatorBaseF3D.h" +#include "geometry/blockGeometryView3D.h" +#include "functors/analytical/indicator/smoothIndicatorBaseF3D.h" + +namespace olb { + +/// BlockIndicatorF3D from IndicatorF3D +template +class BlockIndicatorFfromIndicatorF3D : public BlockIndicatorF3D { +protected: + IndicatorF3D& _indicatorF; +public: + /** + * \param indicatorF Indicator to be reduced to lattice space + * \param blockGeometry Block geometry structure to be used for conversion + * between lattice and physical coordinates. + **/ + BlockIndicatorFfromIndicatorF3D(IndicatorF3D& indicatorF, + BlockGeometryStructure3D& blockGeometry); + + using BlockIndicatorF3D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + + +/// BlockIndicatorF3D from SmoothIndicatorF3D +template +class BlockIndicatorFfromSmoothIndicatorF3D : public BlockIndicatorF3D { +protected: + SmoothIndicatorF3D& _indicatorF; +public: + /** + * \param indicatorF Smooth indicator to be reduced to lattice space + * \param blockGeometry Block geometry structure to be used for conversion + * between lattice and physical coordinates. + **/ + BlockIndicatorFfromSmoothIndicatorF3D(SmoothIndicatorF3D& indicatorF, + BlockGeometryStructure3D& blockGeometry); + + using BlockIndicatorF3D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + + +/// Block indicator functor from material numbers +template +class BlockIndicatorMaterial3D : public BlockIndicatorF3D { +protected: + const std::vector _materials; +public: + /** + * \param blockGeometry Block geometry structure to be queried + * \param materials Material number vector + **/ + BlockIndicatorMaterial3D(BlockGeometryStructure3D& blockGeometry, + std::vector materials); + /** + * \param blockGeometry Block geometry structure to be queried + * \param materials Material number list + **/ + BlockIndicatorMaterial3D(BlockGeometryStructure3D& blockGeometry, + std::list materials); + /** + * \param blockGeometry Block geometry structure to be queried + * \param material Material number + **/ + BlockIndicatorMaterial3D(BlockGeometryStructure3D& blockGeometry, + int material); + + using BlockIndicatorF3D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns true iff indicated domain subset is empty + bool isEmpty() override; + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + + +/// Block indicator identity +template +class BlockIndicatorIdentity3D : public BlockIndicatorF3D { +protected: + BlockIndicatorF3D& _indicatorF; +public: + /** + * \param indicatorF Block indicator to be proxied + **/ + BlockIndicatorIdentity3D(BlockIndicatorF3D& indicatorF); + + using BlockIndicatorF3D::operator(); + bool operator() (bool output[], const int input[]) override; + + /// Returns min lattice position of the indicated domain's bounding box + Vector getMin() override; + /// Returns max lattice position of the indicated domain's bounding box + Vector getMax() override; +}; + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/blockIndicatorF3D.hh b/src/functors/lattice/indicator/blockIndicatorF3D.hh new file mode 100644 index 0000000..dcf2f5f --- /dev/null +++ b/src/functors/lattice/indicator/blockIndicatorF3D.hh @@ -0,0 +1,228 @@ +/* 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 + * + * + * 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_INDICATOR_F_3D_HH +#define BLOCK_INDICATOR_F_3D_HH + +#include + +#include "blockIndicatorF3D.h" +#include "core/util.h" + +namespace olb { + +template +BlockIndicatorFfromIndicatorF3D::BlockIndicatorFfromIndicatorF3D( + IndicatorF3D& indicatorF, BlockGeometryStructure3D& blockGeometry) + : BlockIndicatorF3D(blockGeometry), + _indicatorF(indicatorF) +{ } + +template +bool BlockIndicatorFfromIndicatorF3D::operator() (bool output[], const int input[]) +{ + T physR[3]; + this->_blockGeometryStructure.getPhysR(physR,input); + return _indicatorF(output,physR); +} + +template +Vector BlockIndicatorFfromIndicatorF3D::getMin() +{ + const Vector min = _indicatorF.getMin(); + return Vector { + static_cast(floor(min[0])), + static_cast(floor(min[1])), + static_cast(floor(min[2])) + }; +} + +template +Vector BlockIndicatorFfromIndicatorF3D::getMax() +{ + const Vector max = _indicatorF.getMax(); + return Vector { + static_cast(ceil(max[0])), + static_cast(ceil(max[1])), + static_cast(ceil(max[2])) + }; +} + + +template +BlockIndicatorFfromSmoothIndicatorF3D::BlockIndicatorFfromSmoothIndicatorF3D( + SmoothIndicatorF3D& indicatorF, BlockGeometryStructure3D& blockGeometry) + : BlockIndicatorF3D(blockGeometry), + _indicatorF(indicatorF) +{ } + +template +bool BlockIndicatorFfromSmoothIndicatorF3D::operator() (bool output[], const int input[]) +{ + T physR[3]; + T inside[1]; + this->_blockGeometryStructure.getPhysR(physR,input); + _indicatorF(inside, physR); + return !util::nearZero(inside[0]); +} + +template +Vector BlockIndicatorFfromSmoothIndicatorF3D::getMin() +{ + const T min = -_indicatorF.getCircumRadius(); + return Vector { + static_cast(floor(min)), + static_cast(floor(min)), + static_cast(floor(min)) + }; +} + +template +Vector BlockIndicatorFfromSmoothIndicatorF3D::getMax() +{ + const T max = _indicatorF.getCircumRadius(); + return Vector { + static_cast(ceil(max)), + static_cast(ceil(max)), + static_cast(ceil(max)) + }; +} + + +template +BlockIndicatorMaterial3D::BlockIndicatorMaterial3D( + BlockGeometryStructure3D& blockGeometry, std::vector materials) + : BlockIndicatorF3D(blockGeometry), + _materials(materials) +{ } + +template +BlockIndicatorMaterial3D::BlockIndicatorMaterial3D( + BlockGeometryStructure3D& blockGeometry, std::list materials) + : BlockIndicatorMaterial3D(blockGeometry, + std::vector(materials.begin(), materials.end())) +{ } + +template +BlockIndicatorMaterial3D::BlockIndicatorMaterial3D( + BlockGeometryStructure3D& blockGeometry, int material) + : BlockIndicatorMaterial3D(blockGeometry, std::vector(1,material)) +{ } + +template +bool BlockIndicatorMaterial3D::operator() (bool output[], const int input[]) +{ + // read material number explicitly using the const version + // of BlockGeometry3D::get to avoid resetting geometry + // statistics: + const BlockGeometryStructure3D& blockGeometry = this->_blockGeometryStructure; + const int current = blockGeometry.get(input[0], input[1], input[2]); + output[0] = std::any_of(_materials.cbegin(), + _materials.cend(), + [current](int material) { return current == material; }); + + return true; +} + +template +bool BlockIndicatorMaterial3D::isEmpty() +{ + auto& statistics = this->getBlockGeometryStructure().getStatistics(); + + return std::none_of(_materials.cbegin(), _materials.cend(), + [&statistics](int material) -> bool { + return statistics.getNvoxel(material) > 0; + }); +} + +template +Vector BlockIndicatorMaterial3D::getMin() +{ + auto& blockGeometry = this->getBlockGeometryStructure(); + auto& statistics = blockGeometry.getStatistics(); + + Vector globalMin{ + blockGeometry.getNx()-1, + blockGeometry.getNy()-1, + blockGeometry.getNz()-1, + }; + + for ( int material : _materials ) { + if ( statistics.getNvoxel(material) > 0 ) { + const Vector localMin = statistics.getMinLatticeR(material); + for ( int d = 0; d < 3; ++d ) { + globalMin[d] = localMin[d] < globalMin[d] ? localMin[d] : globalMin[d]; + } + } + } + + return globalMin; +} + +template +Vector BlockIndicatorMaterial3D::getMax() +{ + auto& statistics = this->getBlockGeometryStructure().getStatistics(); + + Vector globalMax{ 0, 0, 0 }; + + for ( int material : _materials ) { + if ( statistics.getNvoxel(material) > 0 ) { + const Vector localMax = statistics.getMaxLatticeR(material); + for ( int d = 0; d < 3; ++d ) { + globalMax[d] = localMax[d] > globalMax[d] ? localMax[d] : globalMax[d]; + } + } + } + + return globalMax; +} + + +template +BlockIndicatorIdentity3D::BlockIndicatorIdentity3D(BlockIndicatorF3D& indicatorF) + : BlockIndicatorF3D(indicatorF.getBlockGeometryStructure()), + _indicatorF(indicatorF) +{ } + +template +bool BlockIndicatorIdentity3D::operator() (bool output[], const int input[]) +{ + return _indicatorF(output, input); +} + +template +Vector BlockIndicatorIdentity3D::getMin() +{ + return _indicatorF.getMin(); +} + +template +Vector BlockIndicatorIdentity3D::getMax() +{ + return _indicatorF.getMax(); +} + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/indicator2D.h b/src/functors/lattice/indicator/indicator2D.h new file mode 100644 index 0000000..e763a80 --- /dev/null +++ b/src/functors/lattice/indicator/indicator2D.h @@ -0,0 +1,32 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012 Lukas Baron, Mathias J. Krause + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * 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 genericFunctions. + */ + +#include "superIndicatorBaseF2D.h" +#include "superIndicatorF2D.h" + +#include "blockIndicatorBaseF2D.h" +#include "blockIndicatorF2D.h" diff --git a/src/functors/lattice/indicator/indicator2D.hh b/src/functors/lattice/indicator/indicator2D.hh new file mode 100644 index 0000000..2274c18 --- /dev/null +++ b/src/functors/lattice/indicator/indicator2D.hh @@ -0,0 +1,32 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012 Lukas Baron, Mathias J. Krause + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * 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 genericFunctions. + */ + +#include "superIndicatorBaseF2D.hh" +#include "superIndicatorF2D.hh" + +#include "blockIndicatorBaseF2D.hh" +#include "blockIndicatorF2D.hh" diff --git a/src/functors/lattice/indicator/indicator3D.h b/src/functors/lattice/indicator/indicator3D.h new file mode 100644 index 0000000..5e15422 --- /dev/null +++ b/src/functors/lattice/indicator/indicator3D.h @@ -0,0 +1,32 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012-2016 Lukas Baron, Mathias J. Krause, Albert Mink, Benjamin Förster + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * 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 genericFunctions. + */ + +#include "superIndicatorBaseF3D.h" +#include "superIndicatorF3D.h" + +#include "blockIndicatorBaseF3D.h" +#include "blockIndicatorF3D.h" diff --git a/src/functors/lattice/indicator/indicator3D.hh b/src/functors/lattice/indicator/indicator3D.hh new file mode 100644 index 0000000..ef9cd5b --- /dev/null +++ b/src/functors/lattice/indicator/indicator3D.hh @@ -0,0 +1,32 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012-2016 Lukas Baron, Mathias J. Krause, Albert Mink, Benjamin Förster + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * 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 genericFunctions. + */ + +#include "superIndicatorBaseF3D.hh" +#include "superIndicatorF3D.hh" + +#include "blockIndicatorBaseF3D.hh" +#include "blockIndicatorF3D.hh" diff --git a/src/functors/lattice/indicator/module.mk b/src/functors/lattice/indicator/module.mk new file mode 100644 index 0000000..6e42e3e --- /dev/null +++ b/src/functors/lattice/indicator/module.mk @@ -0,0 +1,27 @@ +# This file is part of the OpenLB library +# +# Copyright (C) 2017 Markus Mohrhard +# E-mail contact: info@openlb.net +# The most recent release of OpenLB can be downloaded at +# +# +# 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. + +current_dir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) + +include $(addsuffix /MakeHeader, $(current_dir)) + +LIB_OBJECTS += $(foreach file, $($(BUILDTYPE)), $(OBJDIR)/$(current_dir)$(file).o) diff --git a/src/functors/lattice/indicator/superIndicatorBaseF2D.cpp b/src/functors/lattice/indicator/superIndicatorBaseF2D.cpp new file mode 100644 index 0000000..99c5742 --- /dev/null +++ b/src/functors/lattice/indicator/superIndicatorBaseF2D.cpp @@ -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 + * + * + * 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 "superIndicatorBaseF2D.h" +#include "superIndicatorBaseF2D.hh" + +namespace olb { + +template class SuperIndicatorF2D; + +} diff --git a/src/functors/lattice/indicator/superIndicatorBaseF2D.h b/src/functors/lattice/indicator/superIndicatorBaseF2D.h new file mode 100644 index 0000000..6e1ca14 --- /dev/null +++ b/src/functors/lattice/indicator/superIndicatorBaseF2D.h @@ -0,0 +1,95 @@ +/* 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 + * + * + * 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 SUPER_INDICATOR_BASE_F_2D_H +#define SUPER_INDICATOR_BASE_F_2D_H + +#include "functors/genericF.h" +#include "functors/lattice/superBaseF2D.h" +#include "communication/superStructure2D.h" +#include "core/superData2D.h" +#include "blockIndicatorBaseF2D.h" + +namespace olb { + +template class SuperF2D; +template class SuperGeometry2D; +template class SuperIndicatorIdentity2D; + +template +class SuperIndicatorF2D : public SuperF2D { +protected: + SuperGeometry2D& _superGeometry; + + std::unique_ptr> _cachedData; + std::vector>> _extendedBlockF; +public: + using SuperF2D::operator(); + using identity_functor_type = SuperIndicatorIdentity2D; + + SuperIndicatorF2D(SuperGeometry2D& geometry); + /** + * Get block indicator + * + * \returns _blockF[iCloc] cast as BlockIndicatorF2D& + **/ + BlockIndicatorF2D& getBlockIndicatorF(int iCloc); + /** + * Get extended block indicator + * + * \returns _extendedBlockF[iCloc] cast as BlockIndicatorF2D& + **/ + BlockIndicatorF2D& getExtendedBlockIndicatorF(int iCloc); + /** + * Get underlying super geometry + * + * \returns _superGeometry + **/ + SuperGeometry2D& getSuperGeometry(); + /** + * Indicator specific function operator overload + * + * The boolean return value of `operator()(T output[], S input[])` describes + * the call's success and by convention must not describe the indicated domain. + * + * \return Domain indicator i.e. `true` iff the input lies within the described domain. + **/ + bool operator() (const int input[]); + /** + * Indicator specific function operator overload + * + * The boolean return value of `operator()(T output[], S input[])` describes + * the call's success and by convention must not describe the indicated domain. + * + * \return Domain indicator i.e. `true` iff the input lies within the described domain. + **/ + bool operator() (int iC, int iX, int iY); + + /// Optional: initialize _cachedData for faster access + void cache(); +}; + + +} // namespace olb + +#endif diff --git a/src/functors/lattice/indicator/superIndicatorBaseF2D.hh b/src/functors/lattice/indicator/superIndicatorBaseF2D.hh new file mode 100644 index 0000000..587563e --- /dev/null +++ b/src/functors/lattice/indicator/superIndicatorBaseF2D.hh @@ -0,0 +1,102 @@ +/* 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 + * + * + * 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 SUPER_INDICATOR_BASE_F_2D_HH +#define SUPER_INDICATOR_BASE_F_2D_HH + +#include "superIndicatorBaseF2D.h" +#include "geometry/superGeometry2D.h" + +namespace olb { + + +template +SuperIndicatorF2D::SuperIndicatorF2D(SuperGeometry2D& geometry) + : SuperF2D(geometry, 1), + _superGeometry(geometry) +{ } + +template +BlockIndicatorF2D& SuperIndicatorF2D::getBlockIndicatorF(int iCloc) +{ + OLB_ASSERT(size_t(iCloc) < this->_blockF.size() && iCloc >= 0, + "block functor index within bounds"); + // Note: The type system doesn't guarantee this operation to be valid + // as blockF may contain any implementation of the BlockF2D interface. + return *static_cast*>(this->_blockF[iCloc].get()); +} + +template +BlockIndicatorF2D& SuperIndicatorF2D::getExtendedBlockIndicatorF(int iCloc) +{ + OLB_ASSERT(iCloc < int(this->_extendedBlockF.size()) && iCloc >= 0, + "block functor index within bounds"); + return *(this->_extendedBlockF[iCloc]); +} + +template +SuperGeometry2D& SuperIndicatorF2D::getSuperGeometry() +{ + return this->_superGeometry; +} + +template +bool SuperIndicatorF2D::operator() (const int input[]) +{ + bool output; + if (_cachedData) { + output = _cachedData->get(input[0], input[1], input[2]); + } + else { + this->operator()(&output, input); + } + return output; +} + +template +bool SuperIndicatorF2D::operator() (int iC, int iX, int iY) +{ + bool output; + if (_cachedData) { + output = _cachedData->get(iC, iX, iY); + } + else { + this->operator()(&output, iC, iX, iY); + } + return output; +} + +template +void SuperIndicatorF2D::cache() +{ + _cachedData = std::unique_ptr>( + new SuperData2D(*this)); + for (unsigned iC = 0; iC < this->_extendedBlockF.size(); ++iC)