/* This file is part of the OpenLB library * * Copyright (C) 2012-2017 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 SUPER_CALC_F_3D_H #define SUPER_CALC_F_3D_H #include "utilities/arithmetic.h" #include "superBaseF3D.h" #include "utilities/functorPtr.h" #include /** Note: Throughout the whole source code directory genericFunctions, the * template parameters for i/o dimensions are: * F: S^m -> T^n (S=source, T=target) */ namespace olb { /// Arithmetic operations for SuperF3D functors /** * \tparam F Function object defining the arithmetic operation to be perfomed * e.g. std::minus for substraction * * Block level functors are instantiated for operations if at least one input * functor exposes block level functors. See BlockCalcF3D. * * All operations are performed componentwise if functor target dimensions are * equal. If at least one of the target dimensions is equal to 1 it is applied * to the other functor as a scalar (i.e. scalar multiplication, addition...). * * Warning: Allocation error possible in functors that have multiple functor * evaluation like SuperSum3D **/ template class F> class SuperCalcF3D : public SuperF3D { protected: FunctorPtr> _f; FunctorPtr> _g; public: SuperCalcF3D(FunctorPtr>&& f, FunctorPtr>&& g); SuperCalcF3D(W scalar, FunctorPtr>&& g); SuperCalcF3D(FunctorPtr>&& f, W scalar); bool operator() (W output[], const int input[]) override; }; /// Addition functor (W==bool: Union) template using SuperCalcPlus3D = SuperCalcF3D; /// Subtraction functor (W==bool: Without) template using SuperCalcMinus3D = SuperCalcF3D; /// Multiplication functor (W==bool: Intersection) template using SuperCalcMultiplication3D = SuperCalcF3D; /// Division functor template using SuperCalcDivision3D = SuperCalcF3D; /// Power functor template using SuperCalcPower3D = SuperCalcF3D; /** * \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, W rhs); template std::shared_ptr> operator+(W 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, W rhs); template std::shared_ptr> operator-(W 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, W rhs); template std::shared_ptr> operator*(W 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, W rhs); template std::shared_ptr> operator/(W lhs, std::shared_ptr> rhs); ///\} } // end namespace olb #endif