diff options
Initialize at openlb-1-3
Diffstat (limited to 'src/functors/analytical/indicator')
42 files changed, 5330 insertions, 0 deletions
diff --git a/src/functors/analytical/indicator/MakeHeader b/src/functors/analytical/indicator/MakeHeader new file mode 100644 index 0000000..66496d7 --- /dev/null +++ b/src/functors/analytical/indicator/MakeHeader @@ -0,0 +1,37 @@ +# 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
+# <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 := indicatorBaseF2D \
+ indicatorBaseF3D \
+ indicatorF2D \
+ indicatorF3D \
+ indicCalc2D \
+ indicCalc3D \
+ smoothIndicatorF2D \
+ smoothIndicatorF3D \
+ smoothIndicatorBaseF2D \
+ smoothIndicatorBaseF3D \
+ smoothIndicatorCalcF2D \
+ smoothIndicatorCalcF3D
diff --git a/src/functors/analytical/indicator/indicCalc2D.cpp b/src/functors/analytical/indicator/indicCalc2D.cpp new file mode 100644 index 0000000..ba54bde --- /dev/null +++ b/src/functors/analytical/indicator/indicCalc2D.cpp @@ -0,0 +1,56 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2014-2016 Mathias J. Krause, Cyril Masquelier, + * Benjamin Förster, Albert Mink + * 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 "indicCalc2D.h" +#include "indicCalc2D.hh" + + +namespace olb { + +// arithmetic helper class for Indical 1d functors +template class IndicCalc1D<double>; +template class IndicPlus1D<double>; +template class IndicMinus1D<double>; +template class IndicMultiplication1D<double>; + +// arithmetic helper class for Indical 2d functors +template class IndicCalc2D<double,util::plus>; +template class IndicCalc2D<double,util::minus>; +template class IndicCalc2D<double,util::multiplies>; + +template std::shared_ptr<IndicatorF2D<double>> operator+(std::shared_ptr<IndicatorF2D<double>> lhs, + std::shared_ptr<IndicatorF2D<double>> rhs); +template std::shared_ptr<IndicatorF2D<double>> operator-(std::shared_ptr<IndicatorF2D<double>> lhs, + std::shared_ptr<IndicatorF2D<double>> rhs); +template std::shared_ptr<IndicatorF2D<double>> operator*(std::shared_ptr<IndicatorF2D<double>> lhs, + std::shared_ptr<IndicatorF2D<double>> rhs); + +template std::shared_ptr<IndicatorF2D<double>> operator+(IndicatorIdentity2D<double> & lhs, + std::shared_ptr<IndicatorF2D<double>>); +template std::shared_ptr<IndicatorF2D<double>> operator-(IndicatorIdentity2D<double> & lhs, + std::shared_ptr<IndicatorF2D<double>>); +template std::shared_ptr<IndicatorF2D<double>> operator*(IndicatorIdentity2D<double> & lhs, + std::shared_ptr<IndicatorF2D<double>>); + +} diff --git a/src/functors/analytical/indicator/indicCalc2D.h b/src/functors/analytical/indicator/indicCalc2D.h new file mode 100644 index 0000000..a5f6449 --- /dev/null +++ b/src/functors/analytical/indicator/indicCalc2D.h @@ -0,0 +1,127 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2014-2016 Mathias J. Krause, Cyril Masquelier, + * Benjamin Förster, Albert Mink + * 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 INDIC_CALC_2D_H +#define INDIC_CALC_2D_H + +#include "indicatorBaseF2D.h" +#include "utilities/arithmetic.h" + +namespace olb { + + +/* + * arithmetic helper classes for IndicatorF1D, IndicatorF2D, smoothIndicator2D + * UNION + + * WITHOUT - + * INTERSECTION * +*/ + +//////////////////////////////// IndicCalc1D //////////////////////////////// +/// arithmetic helper class for Indicator 1d functors +template <typename S> +class IndicCalc1D : public IndicatorF1D<S> { +protected: + IndicatorF1D<S>& _f; + IndicatorF1D<S>& _g; +public: + // set image/target dimensions of IndicCalc1D as well + IndicCalc1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g); +}; + +/// addition functor acts as union +template <typename S> +class IndicPlus1D : public IndicCalc1D<S> { +public: + IndicPlus1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g); + bool operator() (bool output[], const S input[]) override; +}; + +/// subtraction functor acts as without +template <typename S> +class IndicMinus1D : public IndicCalc1D<S> { +public: + IndicMinus1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g); + bool operator() (bool output[], const S input[]) override; +}; + +/// multiplication functor acts as intersection +template <typename S> +class IndicMultiplication1D : public IndicCalc1D<S> { +public: + IndicMultiplication1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g); + bool operator() (bool output[], const S input[]) override; +}; + + + +//////////////////////////////// indicCalc2D //////////////////////////////// +/// arithmetic helper class for Indicator 2D functors +template <typename S, template<typename U> class F> +class IndicCalc2D : public IndicatorF2D<S> { +protected: + std::shared_ptr<IndicatorF2D<S>> _f; + std::shared_ptr<IndicatorF2D<S>> _g; +public: + IndicCalc2D( std::shared_ptr<IndicatorF2D<S>> f, std::shared_ptr<IndicatorF2D<S>> g ); + + bool operator() (bool output[], const S input[2]) override; +}; + +/// Addition functor (W==bool: Union) +template <typename S> +using IndicPlus2D = IndicCalc2D<S,util::plus>; +template <typename S> +using IndicMinus2D = IndicCalc2D<S,util::minus>; +template <typename S> +using IndicMultiplication2D = IndicCalc2D<S,util::multiplies>; + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorF2D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF2D<S>> operator+(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorF2D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF2D<S>> operator-(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorF2D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF2D<S>> operator*(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorIdentity2D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF2D<S>> operator+(F1<S> & lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorIdentity2D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF2D<S>> operator-(F1<S> & lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorIdentity2D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF2D<S>> operator*(F1<S> & lhs, std::shared_ptr<F2<S>> rhs); + + +} // end namespace olb + +#endif diff --git a/src/functors/analytical/indicator/indicCalc2D.hh b/src/functors/analytical/indicator/indicCalc2D.hh new file mode 100644 index 0000000..f325bc7 --- /dev/null +++ b/src/functors/analytical/indicator/indicCalc2D.hh @@ -0,0 +1,202 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2014-2016 Mathias J. Krause, Cyril Masquelier, + * Benjamin Förster, Albert Mink + * 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 INDIC_CALC_2D_HH +#define INDIC_CALC_2D_HH + +#include "indicCalc2D.h" + +namespace olb { + + +//////////////////////////////// IndicCalc1D //////////////////////////////// +template <typename S> +IndicCalc1D<S>::IndicCalc1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g) + : _f(f), _g(g) +{ + this->_myMin[0] = std::min(f.getMin()[0], g.getMin()[0]); + this->_myMax[0] = std::max(f.getMax()[0], g.getMax()[0]); + std::swap(f._ptrCalcC, this->_ptrCalcC); +} + + +template <typename S> +IndicPlus1D<S>::IndicPlus1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g) + : IndicCalc1D<S>(f, g) +{} + +// returns 1 if( f==1 || g==1 ) UNION +template <typename S> +bool IndicPlus1D<S>::operator() (bool output[], const S input[]) +{ + this->_f(output, input); + bool tmp; + this->_g(&tmp, input); + output[0] |= tmp; + return true; +} + + +template <typename S> +IndicMinus1D<S>::IndicMinus1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g) + : IndicCalc1D<S>(f, g) +{} + +// returns 1 if( f==1 && g==0 ) WITHOUT +template <typename S> +bool IndicMinus1D<S>::operator()(bool output[], const S input[]) +{ + this->_f(output, input); + bool tmp; + this->_g(&tmp, input); + output[0] &= !tmp; + return true; +} + + + +template <typename S> +IndicMultiplication1D<S>::IndicMultiplication1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g) + : IndicCalc1D<S>(f, g) +{} + +// returns 1 if( f==1 && g==1 ) INTERSECTION +template <typename S> +bool IndicMultiplication1D<S>::operator() (bool output[], const S input[]) +{ + this->_f(output, input); + bool tmp; + this->_g(&tmp, input); + output[0] &= tmp; + return true; +} + + + +template <typename S> +IndicatorF1D<S>& IndicatorF1D<S>::operator+(IndicatorF1D<S>& rhs) +{ + auto tmp = std::make_shared< IndicPlus1D<S> >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template <typename S> +IndicatorF1D<S>& IndicatorF1D<S>::operator-(IndicatorF1D<S>& rhs) +{ + auto tmp = std::make_shared< IndicMinus1D<S> >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template <typename S> +IndicatorF1D<S>& IndicatorF1D<S>::operator*(IndicatorF1D<S>& rhs) +{ + auto tmp = std::make_shared< IndicMultiplication1D<S> >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + + + + +//////////////////////////////// IndicCalc2D //////////////////////////////// +template <typename S, template<typename U> class F> +IndicCalc2D<S,F>::IndicCalc2D(std::shared_ptr<IndicatorF2D<S>> f, std::shared_ptr<IndicatorF2D<S>> g) + : _f(f), _g(g) +{ + for ( int i=0; i<2; i++) { + this->_myMin[i] = std::min(_f->getMin()[i], _g->getMin()[i]); + this->_myMax[i] = std::max(_f->getMax()[i], _g->getMax()[i]); + } +} + +template <typename S, template<typename U> class F> +bool IndicCalc2D<S,F>::operator()( bool output[], const S input[2]) +{ + // componentwise operation on equidimensional functors + bool* outputF = output; + _f->operator()(outputF, input); + + bool outputG[this->getTargetDim()]; + _g->operator()(outputG, input); + + for (int i = 0; i < this->getTargetDim(); i++) { + output[i] = F<S>()(outputF[i], outputG[i]); + } + return output; +} + + + + + +//// no association to a operator+ from a class is needed, thus we have these free functions +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename> +std::shared_ptr<IndicatorF2D<S>> operator+(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs) +{ + return std::make_shared<IndicPlus2D<S>>(lhs, rhs); +} + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename> +std::shared_ptr<IndicatorF2D<S>> operator-(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs) +{ + return std::make_shared<IndicMinus2D<S>>(lhs, rhs); +} + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename> +std::shared_ptr<IndicatorF2D<S>> operator*(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs) +{ + return std::make_shared<IndicMultiplication2D<S>>(lhs, rhs); +} + +// template specialization for indicatorIdentity +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename> +std::shared_ptr<IndicatorF2D<S>> operator+(F1<S> & lhs, std::shared_ptr<F2<S>> rhs) +{ + return lhs._f + rhs; +} + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename> +std::shared_ptr<IndicatorF2D<S>> operator-(F1<S> & lhs, std::shared_ptr<F2<S>> rhs) +{ + return lhs._f - rhs; +} + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename> +std::shared_ptr<IndicatorF2D<S>> operator*(F1<S> & lhs, std::shared_ptr<F2<S>> rhs) +{ + return lhs._f * rhs; +} + + +} // end namespace olb + +#endif diff --git a/src/functors/analytical/indicator/indicCalc3D.cpp b/src/functors/analytical/indicator/indicCalc3D.cpp new file mode 100644 index 0000000..8ae86cf --- /dev/null +++ b/src/functors/analytical/indicator/indicCalc3D.cpp @@ -0,0 +1,50 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2018 Albert Mink + * 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 "indicCalc3D.h" +#include "indicCalc3D.hh" + + +namespace olb { + +// arithmetic helper class for indicator 3d functors +template class IndicCalc3D<double,util::plus>; +template class IndicCalc3D<double,util::minus>; +template class IndicCalc3D<double,util::multiplies>; + +template std::shared_ptr<IndicatorF3D<double>> operator+(std::shared_ptr<IndicatorF3D<double>> lhs, + std::shared_ptr<IndicatorF3D<double>> rhs); +template std::shared_ptr<IndicatorF3D<double>> operator-(std::shared_ptr<IndicatorF3D<double>> lhs, + std::shared_ptr<IndicatorF3D<double>> rhs); +template std::shared_ptr<IndicatorF3D<double>> operator*(std::shared_ptr<IndicatorF3D<double>> lhs, + std::shared_ptr<IndicatorF3D<double>> rhs); + +template std::shared_ptr<IndicatorF3D<double>> operator+(IndicatorIdentity3D<double> & lhs, + std::shared_ptr<IndicatorF3D<double>>); +template std::shared_ptr<IndicatorF3D<double>> operator-(IndicatorIdentity3D<double> & lhs, + std::shared_ptr<IndicatorF3D<double>>); +template std::shared_ptr<IndicatorF3D<double>> operator*(IndicatorIdentity3D<double> & lhs, + std::shared_ptr<IndicatorF3D<double>>); + +} + diff --git a/src/functors/analytical/indicator/indicCalc3D.h b/src/functors/analytical/indicator/indicCalc3D.h new file mode 100644 index 0000000..8d7f667 --- /dev/null +++ b/src/functors/analytical/indicator/indicCalc3D.h @@ -0,0 +1,92 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2018 Albert Mink + * 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 INDIC_CALC_3D_H +#define INDIC_CALC_3D_H + +#include "utilities/arithmetic.h" +#include "indicatorBaseF3D.h" + +namespace olb { + + +/* + * arithmetic helper classes for IndicatorF3D, smoothIndicator3D + * UNION + + * WITHOUT - + * INTERSECTION * +*/ + +//////////////////////////////// indicCalc3D //////////////////////////////// +/// arithmetic helper class for Indicator 3d functors +template <typename S, template<typename U> class F> +class IndicCalc3D : public IndicatorF3D<S> { +protected: + std::shared_ptr<IndicatorF3D<S>> _f; + std::shared_ptr<IndicatorF3D<S>> _g; +public: + IndicCalc3D( std::shared_ptr<IndicatorF3D<S>> f, std::shared_ptr<IndicatorF3D<S>> g ); + + bool operator() (bool output[], const S input[3]) override; +}; + +/// Addition functor (W==bool: Union) +template <typename S> +using IndicPlus3D = IndicCalc3D<S,util::plus>; +template <typename S> +using IndicMinus3D = IndicCalc3D<S,util::minus>; +template <typename S> +using IndicMultiplication3D = IndicCalc3D<S,util::multiplies>; + +/** Free function implements lhs+rhs, only for IndicaotrsF3D types through enable_if and is_base_of + * + * \tparam S usual type for source dimension of the functor + * \tparam F1 lhs has to be derived from IndicatorF3D, otherwise function is disabled + * \tparam F2 rhs + */ +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorF3D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF3D<S>> operator+(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorF3D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF3D<S>> operator-(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorF3D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF3D<S>> operator*(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorIdentity3D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF3D<S>> operator+(F1<S> & lhs, std::shared_ptr<F2<S>> rhs); + +template<typename S, template <typename U> class F1, template <typename V> class F2, + typename=typename std::enable_if<std::is_base_of<IndicatorIdentity3D<S>, F1<S>>::value>::type> +std::shared_ptr<IndicatorF3D<S>> operator-(F1<S> & lhs, std::shared_ptr<F2<S |