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/analytical/MakeHeader | 32 + src/functors/analytical/analyticCalcF.cpp | 73 ++ src/functors/analytical/analyticCalcF.h | 242 +++++ src/functors/analytical/analyticCalcF.hh | 544 ++++++++++ src/functors/analytical/analyticalBaseF.cpp | 53 + src/functors/analytical/analyticalBaseF.h | 135 +++ src/functors/analytical/analyticalBaseF.hh | 119 ++ src/functors/analytical/analyticalF.cpp | 80 ++ src/functors/analytical/analyticalF.h | 353 ++++++ src/functors/analytical/analyticalF.hh | 630 +++++++++++ src/functors/analytical/frameChangeF2D.cpp | 41 + src/functors/analytical/frameChangeF2D.h | 171 +++ src/functors/analytical/frameChangeF2D.hh | 297 +++++ src/functors/analytical/frameChangeF3D.cpp | 58 + src/functors/analytical/frameChangeF3D.h | 521 +++++++++ src/functors/analytical/frameChangeF3D.hh | 1142 ++++++++++++++++++++ src/functors/analytical/fringe2D.h | 129 +++ src/functors/analytical/fringe2D.hh | 85 ++ src/functors/analytical/fringe3D.h | 127 +++ src/functors/analytical/fringe3D.hh | 94 ++ src/functors/analytical/functors2D.h | 35 + src/functors/analytical/functors2D.hh | 35 + src/functors/analytical/functors3D.h | 35 + src/functors/analytical/functors3D.hh | 35 + src/functors/analytical/indicator/MakeHeader | 37 + src/functors/analytical/indicator/indicCalc2D.cpp | 56 + src/functors/analytical/indicator/indicCalc2D.h | 127 +++ src/functors/analytical/indicator/indicCalc2D.hh | 202 ++++ src/functors/analytical/indicator/indicCalc3D.cpp | 50 + src/functors/analytical/indicator/indicCalc3D.h | 92 ++ src/functors/analytical/indicator/indicCalc3D.hh | 110 ++ src/functors/analytical/indicator/indicator2D.h | 34 + src/functors/analytical/indicator/indicator2D.hh | 34 + src/functors/analytical/indicator/indicator3D.h | 34 + src/functors/analytical/indicator/indicator3D.hh | 35 + .../analytical/indicator/indicatorBaseF2D.cpp | 35 + .../analytical/indicator/indicatorBaseF2D.h | 106 ++ .../analytical/indicator/indicatorBaseF2D.hh | 210 ++++ .../analytical/indicator/indicatorBaseF3D.cpp | 34 + .../analytical/indicator/indicatorBaseF3D.h | 77 ++ .../analytical/indicator/indicatorBaseF3D.hh | 321 ++++++ src/functors/analytical/indicator/indicatorF2D.cpp | 41 + src/functors/analytical/indicator/indicatorF2D.h | 123 +++ src/functors/analytical/indicator/indicatorF2D.hh | 256 +++++ src/functors/analytical/indicator/indicatorF3D.cpp | 57 + src/functors/analytical/indicator/indicatorF3D.h | 241 +++++ src/functors/analytical/indicator/indicatorF3D.hh | 731 +++++++++++++ src/functors/analytical/indicator/module.mk | 27 + .../indicator/smoothIndicatorBaseF2D.cpp | 34 + .../analytical/indicator/smoothIndicatorBaseF2D.h | 144 +++ .../analytical/indicator/smoothIndicatorBaseF2D.hh | 302 ++++++ .../indicator/smoothIndicatorBaseF3D.cpp | 34 + .../analytical/indicator/smoothIndicatorBaseF3D.h | 146 +++ .../analytical/indicator/smoothIndicatorBaseF3D.hh | 342 ++++++ .../indicator/smoothIndicatorCalcF2D.cpp | 35 + .../analytical/indicator/smoothIndicatorCalcF2D.h | 55 + .../analytical/indicator/smoothIndicatorCalcF2D.hh | 75 ++ .../indicator/smoothIndicatorCalcF3D.cpp | 34 + .../analytical/indicator/smoothIndicatorCalcF3D.h | 55 + .../analytical/indicator/smoothIndicatorCalcF3D.hh | 73 ++ .../analytical/indicator/smoothIndicatorF2D.cpp | 39 + .../analytical/indicator/smoothIndicatorF2D.h | 79 ++ .../analytical/indicator/smoothIndicatorF2D.hh | 239 ++++ .../analytical/indicator/smoothIndicatorF3D.cpp | 40 + .../analytical/indicator/smoothIndicatorF3D.h | 95 ++ .../analytical/indicator/smoothIndicatorF3D.hh | 439 ++++++++ src/functors/analytical/interpolationF2D.cpp | 34 + src/functors/analytical/interpolationF2D.h | 78 ++ src/functors/analytical/interpolationF2D.hh | 275 +++++ src/functors/analytical/interpolationF3D.cpp | 35 + src/functors/analytical/interpolationF3D.h | 91 ++ src/functors/analytical/interpolationF3D.hh | 499 +++++++++ src/functors/analytical/module.mk | 27 + 73 files changed, 11435 insertions(+) create mode 100644 src/functors/analytical/MakeHeader create mode 100644 src/functors/analytical/analyticCalcF.cpp create mode 100644 src/functors/analytical/analyticCalcF.h create mode 100644 src/functors/analytical/analyticCalcF.hh create mode 100644 src/functors/analytical/analyticalBaseF.cpp create mode 100644 src/functors/analytical/analyticalBaseF.h create mode 100644 src/functors/analytical/analyticalBaseF.hh create mode 100644 src/functors/analytical/analyticalF.cpp create mode 100644 src/functors/analytical/analyticalF.h create mode 100644 src/functors/analytical/analyticalF.hh create mode 100644 src/functors/analytical/frameChangeF2D.cpp create mode 100644 src/functors/analytical/frameChangeF2D.h create mode 100644 src/functors/analytical/frameChangeF2D.hh create mode 100644 src/functors/analytical/frameChangeF3D.cpp create mode 100644 src/functors/analytical/frameChangeF3D.h create mode 100644 src/functors/analytical/frameChangeF3D.hh create mode 100644 src/functors/analytical/fringe2D.h create mode 100644 src/functors/analytical/fringe2D.hh create mode 100644 src/functors/analytical/fringe3D.h create mode 100644 src/functors/analytical/fringe3D.hh create mode 100644 src/functors/analytical/functors2D.h create mode 100644 src/functors/analytical/functors2D.hh create mode 100644 src/functors/analytical/functors3D.h create mode 100644 src/functors/analytical/functors3D.hh create mode 100644 src/functors/analytical/indicator/MakeHeader create mode 100644 src/functors/analytical/indicator/indicCalc2D.cpp create mode 100644 src/functors/analytical/indicator/indicCalc2D.h create mode 100644 src/functors/analytical/indicator/indicCalc2D.hh create mode 100644 src/functors/analytical/indicator/indicCalc3D.cpp create mode 100644 src/functors/analytical/indicator/indicCalc3D.h create mode 100644 src/functors/analytical/indicator/indicCalc3D.hh create mode 100644 src/functors/analytical/indicator/indicator2D.h create mode 100644 src/functors/analytical/indicator/indicator2D.hh create mode 100644 src/functors/analytical/indicator/indicator3D.h create mode 100644 src/functors/analytical/indicator/indicator3D.hh create mode 100644 src/functors/analytical/indicator/indicatorBaseF2D.cpp create mode 100644 src/functors/analytical/indicator/indicatorBaseF2D.h create mode 100644 src/functors/analytical/indicator/indicatorBaseF2D.hh create mode 100644 src/functors/analytical/indicator/indicatorBaseF3D.cpp create mode 100644 src/functors/analytical/indicator/indicatorBaseF3D.h create mode 100644 src/functors/analytical/indicator/indicatorBaseF3D.hh create mode 100644 src/functors/analytical/indicator/indicatorF2D.cpp create mode 100644 src/functors/analytical/indicator/indicatorF2D.h create mode 100644 src/functors/analytical/indicator/indicatorF2D.hh create mode 100644 src/functors/analytical/indicator/indicatorF3D.cpp create mode 100644 src/functors/analytical/indicator/indicatorF3D.h create mode 100644 src/functors/analytical/indicator/indicatorF3D.hh create mode 100644 src/functors/analytical/indicator/module.mk create mode 100644 src/functors/analytical/indicator/smoothIndicatorBaseF2D.cpp create mode 100644 src/functors/analytical/indicator/smoothIndicatorBaseF2D.h create mode 100644 src/functors/analytical/indicator/smoothIndicatorBaseF2D.hh create mode 100644 src/functors/analytical/indicator/smoothIndicatorBaseF3D.cpp create mode 100644 src/functors/analytical/indicator/smoothIndicatorBaseF3D.h create mode 100644 src/functors/analytical/indicator/smoothIndicatorBaseF3D.hh create mode 100644 src/functors/analytical/indicator/smoothIndicatorCalcF2D.cpp create mode 100644 src/functors/analytical/indicator/smoothIndicatorCalcF2D.h create mode 100644 src/functors/analytical/indicator/smoothIndicatorCalcF2D.hh create mode 100644 src/functors/analytical/indicator/smoothIndicatorCalcF3D.cpp create mode 100644 src/functors/analytical/indicator/smoothIndicatorCalcF3D.h create mode 100644 src/functors/analytical/indicator/smoothIndicatorCalcF3D.hh create mode 100644 src/functors/analytical/indicator/smoothIndicatorF2D.cpp create mode 100644 src/functors/analytical/indicator/smoothIndicatorF2D.h create mode 100644 src/functors/analytical/indicator/smoothIndicatorF2D.hh create mode 100644 src/functors/analytical/indicator/smoothIndicatorF3D.cpp create mode 100644 src/functors/analytical/indicator/smoothIndicatorF3D.h create mode 100644 src/functors/analytical/indicator/smoothIndicatorF3D.hh create mode 100644 src/functors/analytical/interpolationF2D.cpp create mode 100644 src/functors/analytical/interpolationF2D.h create mode 100644 src/functors/analytical/interpolationF2D.hh create mode 100644 src/functors/analytical/interpolationF3D.cpp create mode 100644 src/functors/analytical/interpolationF3D.h create mode 100644 src/functors/analytical/interpolationF3D.hh create mode 100644 src/functors/analytical/module.mk (limited to 'src/functors/analytical') diff --git a/src/functors/analytical/MakeHeader b/src/functors/analytical/MakeHeader new file mode 100644 index 0000000..a86fd85 --- /dev/null +++ b/src/functors/analytical/MakeHeader @@ -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. + + +generic := + +precompiled := analyticalBaseF \ + analyticalF \ + analyticCalcF \ + frameChangeF2D \ + frameChangeF3D \ + interpolationF2D \ + interpolationF3D diff --git a/src/functors/analytical/analyticCalcF.cpp b/src/functors/analytical/analyticCalcF.cpp new file mode 100644 index 0000000..7598aca --- /dev/null +++ b/src/functors/analytical/analyticCalcF.cpp @@ -0,0 +1,73 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2011-2013 Lukas Baron, Tim Dornieden, 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. +*/ + +#include "analyticCalcF.h" +#include "analyticCalcF.hh" + +namespace olb { + + +// arithmetic helper class for analytical 1d functors + +template class AnalyticCalcF1D; +template class AnalyticCalcF1D; + +template class AnalyticCalcF1D; +template class AnalyticCalcF1D; + +template class AnalyticCalcF1D; +template class AnalyticCalcF1D; + +template class AnalyticCalcF1D; +template class AnalyticCalcF1D; + +// arithmetic helper class for analytical 2d functors + +template class AnalyticCalcF2D; +template class AnalyticCalcF2D; + +template class AnalyticCalcF2D; +template class AnalyticCalcF2D; + +template class AnalyticCalcF2D; +template class AnalyticCalcF2D; + +template class AnalyticCalcF2D; +template class AnalyticCalcF2D; + +// arithmetic helper class for analytical 3d functors + +template class AnalyticCalcF3D; +template class AnalyticCalcF3D; + +template class AnalyticCalcF3D; +template class AnalyticCalcF3D; + +template class AnalyticCalcF3D; +template class AnalyticCalcF3D; + +template class AnalyticCalcF3D; +template class AnalyticCalcF3D; + +} + diff --git a/src/functors/analytical/analyticCalcF.h b/src/functors/analytical/analyticCalcF.h new file mode 100644 index 0000000..7496292 --- /dev/null +++ b/src/functors/analytical/analyticCalcF.h @@ -0,0 +1,242 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012-2018 Lukas Baron, Tim Dornieden, Mathias J. Krause, + * Albert Mink, 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 ANALYTICAL_CALC_F_H +#define ANALYTICAL_CALC_F_H + + +#include "analyticalBaseF.h" +#include "utilities/functorPtr.h" +#include "utilities/arithmetic.h" + + +namespace olb { + +/* + arithmetic helper classes for AnalyticalF1D, AnalyticalF3D, AnalyticalF3D + + pointwise: difference, plus, multiplication, division + +*/ + +//////////////////////////////// AnalyticCalcF1D //////////////////////////////// + +/// arithmetic helper class for analytical 1D functors +template class F> +class AnalyticCalcF1D : public AnalyticalF1D { +protected: + FunctorPtr> _f; + FunctorPtr> _g; +public: + AnalyticCalcF1D(FunctorPtr>&& f, + FunctorPtr>&& g); + + AnalyticCalcF1D(T scalar, FunctorPtr>&& g); + AnalyticCalcF1D(FunctorPtr>&& f, T scalar); + + bool operator() (T output[], const S input[]) override; +}; + +/// addition functor +template +using AnalyticCalcPlus1D = AnalyticCalcF1D; + +/// subtraction functor +template +using AnalyticCalcMinus1D = AnalyticCalcF1D; + +/// multiplication functor +template +using AnalyticCalcMultiplication1D = AnalyticCalcF1D; + +/// division functor +template +using AnalyticCalcDivision1D = AnalyticCalcF1D; + +//////////////////////////////// AnalyticCalcF2D //////////////////////////////// + +/// arithmetic helper class for analytical 2D functors +template class F> +class AnalyticCalcF2D : public AnalyticalF2D { +protected: + FunctorPtr> _f; + FunctorPtr> _g; +public: + AnalyticCalcF2D(FunctorPtr>&& f, + FunctorPtr>&& g); + + AnalyticCalcF2D(T scalar, FunctorPtr>&& g); + AnalyticCalcF2D(FunctorPtr>&& f, T scalar); + + bool operator() (T output[], const S input[]) override; +}; + +/// addition functor +template +using AnalyticCalcPlus2D = AnalyticCalcF2D; + +/// subtraction functor +template +using AnalyticCalcMinus2D = AnalyticCalcF2D; + +/// multiplication functor +template +using AnalyticCalcMultiplication2D = AnalyticCalcF2D; + +/// division functor +template +using AnalyticCalcDivision2D = AnalyticCalcF2D; + +//////////////////////////////// AnalyticCalcF3D //////////////////////////////// + +/// arithmetic helper class for analytical 3D functors +template class F> +class AnalyticCalcF3D : public AnalyticalF3D { +protected: + FunctorPtr> _f; + FunctorPtr> _g; +public: + AnalyticCalcF3D(FunctorPtr>&& f, + FunctorPtr>&& g); + + AnalyticCalcF3D(T scalar, FunctorPtr>&& g); + AnalyticCalcF3D(FunctorPtr>&& f, T scalar); + + bool operator() (T output[], const S input[]) override; +}; + +/// addition functor +template +using AnalyticCalcPlus3D = AnalyticCalcF3D; + +/// subtraction functor +template +using AnalyticCalcMinus3D = AnalyticCalcF3D; + +/// multiplication functor +template +using AnalyticCalcMultiplication3D = AnalyticCalcF3D; + +/// division functor +template +using AnalyticCalcDivision3D = AnalyticCalcF3D; + + +/** + * \name Arithmetic for functors managed by std::shared_ptr + * \{ + **/ + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator+(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator+(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator-(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator-(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator*(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator*(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator/(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator/(T lhs, std::shared_ptr> rhs); + + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator+(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator+(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator-(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator-(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator*(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator*(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator/(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator/(T lhs, std::shared_ptr> rhs); + + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator+(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator+(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator-(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator-(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator*(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator*(T lhs, std::shared_ptr> rhs); + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, std::shared_ptr> rhs); +template +std::shared_ptr> operator/(std::shared_ptr> lhs, T rhs); +template +std::shared_ptr> operator/(T lhs, std::shared_ptr> rhs); + +///\} + + +} // end namespace olb + +#endif diff --git a/src/functors/analytical/analyticCalcF.hh b/src/functors/analytical/analyticCalcF.hh new file mode 100644 index 0000000..bca8f6f --- /dev/null +++ b/src/functors/analytical/analyticCalcF.hh @@ -0,0 +1,544 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012-2018 Lukas Baron, Tim Dornieden, Mathias J. Krause, + * Albert Mink, 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 ANALYTICAL_CALC_F_HH +#define ANALYTICAL_CALC_F_HH + + +#include "analyticCalcF.h" +#include "analyticalF.h" +#include "core/olbDebug.h" + +namespace olb { + + + +//////////////////////////////// AnalyticCalcF1D //////////////////////////////// +template class F> +AnalyticCalcF1D::AnalyticCalcF1D(FunctorPtr>&& f, + FunctorPtr>&& g) + : AnalyticalF1D(f->getTargetDim()), + _f(std::move(f)), + _g(std::move(g)) +{ + OLB_ASSERT(g->getTargetDim() == f->getTargetDim(), + "the dimensions of both functors need to be equal"); + std::swap(f->_ptrCalcC, this->_ptrCalcC); + this->getName() = "(" + _f->getName() + F::symbol + _g->getName() + ")"; +} + +template class F> +AnalyticCalcF1D::AnalyticCalcF1D(T scalar, FunctorPtr>&& g) + : AnalyticCalcF1D( + std::unique_ptr>( + new AnalyticalConst1D(std::vector(g->getTargetDim(), scalar))), + std::forward(g)) +{ } + +template class F> +AnalyticCalcF1D::AnalyticCalcF1D(FunctorPtr>&& f, T scalar) + : AnalyticCalcF1D( + std::forward(f), + std::unique_ptr>( + new AnalyticalConst1D(std::vector(f->getTargetDim(), scalar)))) +{ } + +template class F> +bool AnalyticCalcF1D::operator()(T output[], const S input[]) +{ + T outputTmp[this->_g->getTargetDim()]; + this->_g(outputTmp, input); + this->_f(output, input); + for (int i = 0; i < this->_f->getTargetDim(); ++i) { + output[i] = F()(output[i], outputTmp[i]); + } + return true; +} + + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus1D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus1D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator+(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus1D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus1D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus1D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator-(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus1D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication1D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication1D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator*(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication1D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision1D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision1D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator/(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision1D(lhs, std::move(rhs))); +} + +/////////////////////////////////operator()/// //////////////////////////////// +template +AnalyticalF1D& AnalyticalF1D::operator+(AnalyticalF1D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcPlus1D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF1D& AnalyticalF1D::operator-(AnalyticalF1D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcMinus1D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF1D& AnalyticalF1D::operator*(AnalyticalF1D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcMultiplication1D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF1D& AnalyticalF1D::operator/(AnalyticalF1D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcDivision1D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + + +//////////////////////////////// AnalyticCalcF2D //////////////////////////////// +template class F> +AnalyticCalcF2D::AnalyticCalcF2D(FunctorPtr>&& f, + FunctorPtr>&& g) + : AnalyticalF2D(f->getTargetDim()), + _f(std::move(f)), + _g(std::move(g)) +{ + OLB_ASSERT(g->getTargetDim() == f->getTargetDim(), + "the dimensions of both functors need to be equal"); + // pass through the shared_ptr from the first argument f to the arithmetic class itself. + // used by secsessive calls: e.g. (functorA + functor B) followed by (functorA + functorC) + // the result of the first operation is overwritten by the second. + + // equivalent operations + // std::swap(f._ptrCalcC, this->_ptrCalcC); + // this->_ptrCalcC = f._ptrCalcC; + this->_ptrCalcC.swap(f->_ptrCalcC); + + this->getName() = "(" + _f->getName() + F::symbol + _g->getName() + ")"; +} + +template class F> +AnalyticCalcF2D::AnalyticCalcF2D(T scalar, FunctorPtr>&& g) + : AnalyticCalcF2D( + std::unique_ptr>( + new AnalyticalConst2D(std::vector(g->getTargetDim(), scalar))), + std::forward(g)) +{ } + +template class F> +AnalyticCalcF2D::AnalyticCalcF2D(FunctorPtr>&& f, T scalar) + : AnalyticCalcF2D( + std::forward(f), + std::unique_ptr>( + new AnalyticalConst2D(std::vector(f->getTargetDim(), scalar)))) +{ } + +template class F> +bool AnalyticCalcF2D::operator()(T output[], const S input[]) +{ + T outputTmp[this->_g->getTargetDim()]; + this->_g(outputTmp, input); + this->_f(output, input); + for (int i = 0; i < this->_f->getTargetDim(); ++i) { + output[i] = F()(output[i], outputTmp[i]); + } + return true; +} + + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus2D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus2D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator+(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus2D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus2D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus2D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator-(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus2D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication2D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication2D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator*(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication2D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision2D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision2D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator/(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision2D(lhs, std::move(rhs))); +} + +/////////////////////////////////operator()//////////////////////////////////// +template +AnalyticalF2D& AnalyticalF2D::operator+(AnalyticalF2D& rhs) +{ + // version 1 + // AnalyticalF2D* tmp = new AnalyticCalcPlus2D(*this,rhs); + // std::shared_ptr< GenericF > ptr( tmp ); + // this->_ptrCalcC = ptr; + + // version 2 + // std::shared_ptr< AnalyticalF2D > tmp = std::make_shared< AnalyticCalcPlus2D >(*this,rhs); + + // version 2.5 + // std::shared_ptr< AnalyticCalcPlus2D > tmp( new AnalyticCalcPlus2D(*this,rhs) ); + + // version 3 + auto tmp = std::make_shared< AnalyticCalcPlus2D >(*this,rhs); + + this->_ptrCalcC = tmp; + + // std::cout << "operator+(): " << this->_ptrCalcC.get()->getName() << std::endl; + return *tmp; +} + +template +AnalyticalF2D& AnalyticalF2D::operator-(AnalyticalF2D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcMinus2D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF2D& AnalyticalF2D::operator*(AnalyticalF2D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcMultiplication2D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF2D& AnalyticalF2D::operator/(AnalyticalF2D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcDivision2D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + + +//////////////////////////////// AnalyticCalcF3D //////////////////////////////// +template class F> +AnalyticCalcF3D::AnalyticCalcF3D(FunctorPtr>&& f, + FunctorPtr>&& g): + AnalyticalF3D(f->getTargetDim()), + _f(std::move(f)), + _g(std::move(g)) +{ + OLB_ASSERT(g->getTargetDim() == f->getTargetDim(), + "the dimensions of both functors need to be equal"); + std::swap(f->_ptrCalcC, this->_ptrCalcC); + this->getName() = "(" + _f->getName() + F::symbol + _g->getName() + ")"; +} + +template class F> +AnalyticCalcF3D::AnalyticCalcF3D(T scalar, FunctorPtr>&& g) + : AnalyticCalcF3D( + std::unique_ptr>( + new AnalyticalConst3D(std::vector(g->getTargetDim(), scalar))), + std::forward(g)) +{ } + +template class F> +AnalyticCalcF3D::AnalyticCalcF3D(FunctorPtr>&& f, T scalar) + : AnalyticCalcF3D( + std::forward(f), + std::unique_ptr>( + new AnalyticalConst3D(std::vector(f->getTargetDim(), scalar)))) +{ } + +template class F> +bool AnalyticCalcF3D::operator()(T output[], const S input[]) +{ + T outputTmp[this->_g->getTargetDim()]; + this->_g(outputTmp, input); + this->_f(output, input); + for (int i = 0; i < this->_f->getTargetDim(); ++i) { + output[i] = F()(output[i], outputTmp[i]); + } + return true; +} + + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus3D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator+(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus3D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator+(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcPlus3D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus3D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator-(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus3D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator-(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMinus3D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication3D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator*(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication3D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator*(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcMultiplication3D(lhs, std::move(rhs))); +} + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision3D(std::move(lhs), std::move(rhs))); +} + +template +std::shared_ptr> operator/(std::shared_ptr> lhs, T rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision3D(std::move(lhs), rhs)); +} + +template +std::shared_ptr> operator/(T lhs, std::shared_ptr> rhs) +{ + return std::shared_ptr>( + new AnalyticCalcDivision3D(lhs, std::move(rhs))); +} + +/////////////////////////////////operator()/// //////////////////////////////// +template +AnalyticalF3D& AnalyticalF3D::operator+(AnalyticalF3D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcPlus3D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF3D& AnalyticalF3D::operator-(AnalyticalF3D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcMinus3D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF3D& AnalyticalF3D::operator*(AnalyticalF3D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcMultiplication3D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +template +AnalyticalF3D& AnalyticalF3D::operator/(AnalyticalF3D& rhs) +{ + auto tmp = std::make_shared< AnalyticCalcDivision3D >(*this,rhs); + this->_ptrCalcC = tmp; + return *tmp; +} + +} // end namespace olb + +#endif diff --git a/src/functors/analytical/analyticalBaseF.cpp b/src/functors/analytical/analyticalBaseF.cpp new file mode 100644 index 0000000..f2ec173 --- /dev/null +++ b/src/functors/analytical/analyticalBaseF.cpp @@ -0,0 +1,53 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2011-2013 Lukas Baron, Tim Dornieden, 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. +*/ + +#include "analyticalBaseF.h" +#include "analyticalBaseF.hh" +#include "analyticCalcF.hh" + +namespace olb { + +// 2nd level classes +template class AnalyticalF1D; +template class AnalyticalF1D; + +template class AnalyticalIdentity1D; +template class AnalyticalIdentity1D; + + +template class AnalyticalF2D; +template class AnalyticalF2D; + +template class AnalyticalIdentity2D; +template class AnalyticalIdentity2D; + + +template class AnalyticalF3D; +template class AnalyticalF3D; +template class AnalyticalF3D; // indicatorF + +template class AnalyticalIdentity3D; +template class AnalyticalIdentity3D; + +} + diff --git a/src/functors/analytical/analyticalBaseF.h b/src/functors/analytical/analyticalBaseF.h new file mode 100644 index 0000000..725bbe1 --- /dev/null +++ b/src/functors/analytical/analyticalBaseF.h @@ -0,0 +1,135 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause, Albert Mink + * 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 ANALYTICAL_BASE_F_H +#define ANALYTICAL_BASE_F_H + +#include "functors/genericF.h" +#include "functors/analytical/indicator/indicatorBaseF3D.h" + +/** + * The functor dimensions are given by F: S^m -> T^n (S=source, T=target) + * and are implemented via GenericF(n,m). + * Don't get confused by the flipped order of source and target. + */ + +namespace olb { + +//////////////////////////////////////////////////////////////////////////////// +// 2nd level classes +// note: for LatticeFunctions the number indicates the SOURCE dimension, +// target dim depends on return variable type, so std::vector is used + +template class AnalyticalIdentity2D; +template class AnalyticalIdentity3D; + + +/// AnalyticalF1D are applications from 1D to XD, where X is set by the constructor. +template +class AnalyticalF1D : public GenericF { +protected: + // n denotes the target dimension + AnalyticalF1D(int n); +public: + AnalyticalF1D& operator-(AnalyticalF1D& rhs); + AnalyticalF1D& operator+(AnalyticalF1D& rhs); + AnalyticalF1D& operator*(AnalyticalF1D& rhs); + AnalyticalF1D& operator/(AnalyticalF1D& rhs); +}; + +/// AnalyticalF2D are applications from 2D to XD, where X is set by the constructor. +template +class AnalyticalF2D : public GenericF { +protected: + // n denotes the target dimension + AnalyticalF2D(int n); +public: + using identity_functor_type = AnalyticalIdentity2D; + + AnalyticalF2D& operator-(AnalyticalF2D& rhs); + AnalyticalF2D& operator+(AnalyticalF2D& rhs); + AnalyticalF2D& operator*(AnalyticalF2D& rhs); + AnalyticalF2D& operator/(AnalyticalF2D& rhs); +}; + +/// AnalyticalF3D are applications from 3D to XD, where X is set by the constructor. +template +class AnalyticalF3D : public GenericF { +protected: + // n denotes the target dimension + AnalyticalF3D(int n); +public: + using identity_functor_type = AnalyticalIdentity3D; + + AnalyticalF3D& operator-(AnalyticalF3D& rhs); + AnalyticalF3D& operator+(AnalyticalF3D& rhs); + AnalyticalF3D& operator*(AnalyticalF3D& rhs); + AnalyticalF3D& operator/(AnalyticalF3D& rhs); +}; + +/// AnalyticalIdentity1D stores vectors, result of addition,multiplication, ... +template +class AnalyticalIdentity1D final : public AnalyticalF1D { +protected: + AnalyticalF1D& _f; +public: + AnalyticalIdentity1D(AnalyticalF1D& f); + bool operator() (T output[], const S input[]) override; +}; + +/// AnalyticalIdentity2D stores vectors, result of addition,multiplication, ... +template +class AnalyticalIdentity2D final : public AnalyticalF2D { +protected: + AnalyticalF2D& _f; +public: + AnalyticalIdentity2D(AnalyticalF2D& f); + bool operator() (T output[], const S input[]) override; +}; + +/// AnalyticalIdentity3D stores vectors, result of addition,multiplication, ... +template +class AnalyticalIdentity3D final : public AnalyticalF3D { +protected: + AnalyticalF3D& _f; +public: + AnalyticalIdentity3D(AnalyticalF3D& f); + bool operator() (T output[], const S input[]) override; +}; + + +/// Converts IndicatorF to AnalyticalF (used for Analytical operands for Identity) +template +class AnalyticalFfromIndicatorF3D : public AnalyticalF3D { +protected: + IndicatorF3D& _indicatorF; +public: + AnalyticalFfromIndicatorF3D(IndicatorF3D& indicatorF); + bool operator() (T output[], const S input[]) override; +}; + + + +} // end namespace olb + +#endif diff --git a/src/functors/analytical/analyticalBaseF.hh b/src/functors/analytical/analyticalBaseF.hh new file mode 100644 index 0000000..6d3b385 --- /dev/null +++ b/src/functors/analytical/analyticalBaseF.hh @@ -0,0 +1,119 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause, Albert Mink + * 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 ANALYTICAL_BASE_F_HH +#define ANALYTICAL_BASE_F_HH + +#include "analyticalBaseF.h" + +namespace olb { + + +template +AnalyticalF1D::AnalyticalF1D(int n) : GenericF(n,1) { } + +template +AnalyticalF2D::AnalyticalF2D(int n) : GenericF(n,2) { } + +template +AnalyticalF3D::AnalyticalF3D(int n) : GenericF(n,3) { } + + +// identity to "store results" +template +AnalyticalIdentity1D::AnalyticalIdentity1D(AnalyticalF1D& f) + : AnalyticalF1D(f.getTargetDim()), _f(f) +{ + this->getName() = _f.getName(); + std::swap( _f._ptrCalcC, this->_ptrCalcC ); +} + +template +bool AnalyticalIdentity1D::operator()(T output[], const S input[]) +{ + _f(output,input); + return true; +} + + +// identity to "store results" +template +AnalyticalIdentity2D::AnalyticalIdentity2D(AnalyticalF2D& f) + : AnalyticalF2D(f.getTargetDim()), _f(f) +{ + this->getName() = _f.getName(); + // pass through the shared_ptr from _f, e.g. an arithemticClass, to the identity + std::swap( _f._ptrCalcC, this->_ptrCalcC ); +} + +template +bool AnalyticalIdentity2D::operator()(T output[], const S input[]) +{ + _f(output,input); + return true; +} + + +// identity to "store results" +template +AnalyticalIdentity3D::AnalyticalIdentity3D(AnalyticalF3D& f) + : AnalyticalF3D(f.getTargetDim()), _f(f) +{ + this->getName() = _f.getName(); + std::swap( _f._ptrCalcC, this->_ptrCalcC ); +} + +template +bool AnalyticalIdentity3D::operator()(T output[], const S input[]) +{ + _f(output,input); + return true; +} + + + +template +AnalyticalFfromIndicatorF3D::AnalyticalFfromIndicatorF3D(IndicatorF3D& indicatorF) + : AnalyticalF3D(1), _indicatorF(indicatorF) +{ + this->getName() = "IndicatorFfrom" + _indicatorF.getName(); +} + +template +bool AnalyticalFfromIndicatorF3D::operator() (T output[], const S input[]) +{ + bool tmp = false; + _indicatorF(&tmp, input); + if ( tmp ) { + output[0] = T(1); + } else { + output[0] = T(0); + } + return tmp; +} + + + +} // end namespace olb + +#endif diff --git a/src/functors/analytical/analyticalF.cpp b/src/functors/analytical/analyticalF.cpp new file mode 100644 index 0000000..470c9c2 --- /dev/null +++ b/src/functors/analytical/analyticalF.cpp @@ -0,0 +1,80 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2011-2013 Lukas Baron, Tim Dornieden, 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. +*/ + +#include "analyticalF.h" +#include "analyticalF.hh" + +namespace olb { + + +template class AnalyticalConst1D; +template class AnalyticalConst1D; + +template class AnalyticalLinear1D; +template class AnalyticalLinear1D; + +template class AnalyticalRandom1D; +template class AnalyticalRandom1D; + +template class AnalyticalSquare1D; +template class AnalyticalSquare1D; + +template class PolynomialStartScale; +template class PolynomialStartScale; + +template class SinusStartScale; +template class SinusStartScale; + +template class AnalyticalDiffFD1D; + + +template class AnalyticalComposed2D; +template class AnalyticalComposed2D; + +template class AnalyticalConst2D; +template class AnalyticalConst2D; + +template class AnalyticalLinear2D; +template class AnalyticalLinear2D; + +template class AnalyticalRandom2D; +template class AnalyticalRandom2D; + + +template class AnalyticalComposed3D; +template class AnalyticalComposed3D; + +template class AnalyticalConst3D; +template class AnalyticalConst3D; + +template class AnalyticalLinear3D; +template class AnalyticalLinear3D; + +template class AnalyticalRandom3D; +template class AnalyticalRandom3D; + +template class AnalyticalScaled3D; +template class AnalyticalScaled3D; + +} + diff --git a/src/functors/analytical/analyticalF.h b/src/functors/analytical/analyticalF.h new file mode 100644 index 0000000..0abd70f --- /dev/null +++ b/src/functors/analytical/analyticalF.h @@ -0,0 +1,353 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause, Albert Mink + * 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 ANALYTICAL_F_H +#define ANALYTICAL_F_H + +#include + +#include "analyticalBaseF.h" +#include "indicator/smoothIndicatorF2D.h" +#include "indicator/smoothIndicatorF3D.h" + + +/** + * The functor dimensions are given by F: S^m -> T^n (S=source, T=target) + * and are implemented via GenericF(n,m). + * Don't get confused by the flipped order of source and target. + */ + +namespace olb { + +template class SmoothIndicatorSphere3D; +template class RadiativeUnitConverter; + +//////////////////////////////////////////////////////////////////////////////// +////////implementation of several 1d,2d,3d functors (analyticalFXD)///////////// +//////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////1D//////////////////////////////////////////// + +/// AnalyticalConst1D: 1D -> XD, where XD is defined by value.size() +template +class AnalyticalConst1D : public AnalyticalF1D { +private: + // is constant return value of operator() + std::vector _c; +public: + AnalyticalConst1D(T value); + AnalyticalConst1D(const std::vector& value); + bool operator() (T output[], const S x[]) override; +}; + +/// AnalyticalLinear1D: 1D -> 1D troughout given points (x0,v0) and (x1,v1) +// Punktsteigungsform +template +class AnalyticalLinear1D : public AnalyticalF1D { +private: + T _a; + T _b; +public: + AnalyticalLinear1D(T a, T b); + AnalyticalLinear1D(S x0, T v0, S x1, T v1); + bool operator() (T output[], const S x[]) override; ///< returns line _a*x + _b +}; + +/// AnalyticalRandom1D: 1D -> 1D with random image in (0,1) +template +class AnalyticalRandom1D : public AnalyticalF1D { +public: + AnalyticalRandom1D(); + bool operator() (T output[], const S x[]) override; +}; + + +/// represents an inverse parabola profile like it is used in Poiseuille inflow +/// note: output depends only on first parameter, maps 1D,2D,3D->1D +template +class AnalyticalSquare1D : public AnalyticalF1D { +private: + S _cp; + S _r; + T _maxi; +public: + AnalyticalSquare1D(S cp, S r, T maxi); + bool operator() (T output[], const S x[]) override; +}; + + +/// SinusStartScale: 1D -> 1D a start curve based on sinus for a continuous transition at 0 and 1 +template +class SinusStartScale : public AnalyticalF1D { +protected: + S _numTimeSteps; + T _maxValue; + T _pi; +public: + SinusStartScale(int numTimeSteps=1, T maxValue=1); + bool operator() (T output[], const S x[]) override; +}; + + +/// PolynomialStartScale: 1D -> 1D a start curve based on a polynomial fifth order for a continuous transition at 0 and 1: maxValue*(6*y^5-15*y^4+10*y^3) +template +class PolynomialStartScale : public AnalyticalF1D { +protected: + S _numTimeSteps; + T _maxValue; +public: + PolynomialStartScale(S numTimeSteps=S(1), T maxValue=T(1)); + bool operator() (T output[], const S x[]) override; +}; + +/// Derivative of a given 1D functor computed with a finite difference +template +class AnalyticalDiffFD1D : public AnalyticalF1D { +protected: + AnalyticalF1D& _f; + T _eps; +public: + AnalyticalDiffFD1D(AnalyticalF1D& f, T eps = 1.e-10); + bool operator() (T output[], const T input[]) override; +}; + +//////////////////////////////////2D//////////////////////////////////////////// + +template +class AnalyticalComposed2D final : public AnalyticalF2D { +private: + AnalyticalF2D& _f0; + AnalyticalF2D& _f1; +public: + AnalyticalComposed2D(AnalyticalF2D& f0, AnalyticalF2D& f1); + bool operator() (T output[], const S x[]) override; +}; + +/// AnalyticalConst2D: 2D -> XD, where XD is defined by value.size() +template +class AnalyticalConst2D final : public AnalyticalF2D { +private: + // is constant return value of operator() + std::vector _c; +public: + AnalyticalConst2D(T value); + AnalyticalConst2D(T value0, T value1); + AnalyticalConst2D(T value0, T value1, T value2); + AnalyticalConst2D(const std::vector& value); + bool operator() (T output[], const S x[]) override; +}; + +/// AnalyticalLinear2D: 2D -> 1D troughout given points (x0,y0,v0), (x1,y1,v1), (x2,y2,v2) +template +class AnalyticalLinear2D final : public AnalyticalF2D { +protected: + T _a; + T _b; + T _c; +public: + AnalyticalLinear2D(T a, T b, T c); + AnalyticalLinear2D(S x0, S y0, T v0, S x1, S y1, T v1, S x2, S y2, T v2); + bool operator() (T output[], const S x[]) override; +}; + +/// AnalyticalRandom2D: 2D -> 1D with random image in (0,1) +template +class AnalyticalRandom2D final : public AnalyticalF2D { +public: + AnalyticalRandom2D(); + bool operator() (T output[], const S x[]) override; +}; + +/// AnalyticalRandom2D: 2D -> 1D with maxValue in the center decreasing linearly with the distrance to the center to zero at the radius and zero outside +template +class AnalyticalParticleAdsorptionLinear2D final : public AnalyticalF2D { +protected: + T _center[2]; + T _radius; + T _maxValue; +public: + AnalyticalParticleAdsorptionLinear2D(T center[], T radius, T maxValue); + bool operator() (T output[], const S x[]); +}; + +/** Computes resulting velocity of an object from translational and rotational velocity. + * \param indicator Class defining the object (needs to be a SmoothIndicatorF2D) + * \param u translational velo