Download data/src/OpenFOAM/fields/expression/expressions.H from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 17.2 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/OpenFOAM/fields/expression/expressions.H
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/OpenFOAM/fields/expression/expressions.H
-
curl -L -o expressions.H https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/OpenFOAM/fields/expression/expressions.H
17.2 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 2026 OpenFOAM Foundation | |
| \\/ M anipulation | | |
| ------------------------------------------------------------------------------- | |
| License | |
| This file is part of OpenFOAM. | |
| OpenFOAM 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 3 of the License, or | |
| (at your option) any later version. | |
| OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. | |
| Description | |
| Unary and binary functions and operators used by the expression | |
| templating system | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| namespace Foam | |
| { | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| // Define a unary function or operator given the global function or operator | |
| // name and the operator class that it uses | |
| // Promotion operator (i.e., unary plus). Has no effect. Just facilitates | |
| // expressions with plus signs added for clarity. | |
| UnaryOperator(+, promote) | |
| // Negation operator (i.e., unary minus). Changes the sign of the operand. | |
| UnaryOperator(-, negate) | |
| UnaryFunction(sqr) | |
| UnaryFunction(mag) | |
| UnaryFunction(magSqr) | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| // Define unary reduction functions | |
| UnaryReduction(sum, gSum); | |
| UnaryReduction(max, gMax); | |
| UnaryReduction(min, gMin); | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| // Define unary average and gAverage functions | |
| template<class Expression, class = EnableIfExpressionable<Expression>> | |
| ElementType<Expression> average | |
| ( | |
| const Expression& e, | |
| const bool globalReduce = ReduceType<Expression>::globalReduce, | |
| const label comm = UPstream::worldComm | |
| ) | |
| { | |
| return ReduceType<Expression>::average(e, globalReduce, comm); | |
| } | |
| template<class Expression, class = EnableIfExpressionable<Expression>> | |
| ElementType<Expression> average(const tmp<Expression>& te) | |
| { | |
| auto x = average(te()); | |
| te.clear(); | |
| return x; | |
| } | |
| template<class Expression, class = EnableIfExpressionable<Expression>> | |
| ElementType<Expression> gAverage | |
| ( | |
| const Expression& e, | |
| const label comm = UPstream::worldComm | |
| ) | |
| { | |
| return average(e, true, comm); | |
| } | |
| template<class Expression, class = EnableIfExpressionable<Expression>> | |
| ElementType<Expression> gAverage | |
| ( | |
| const tmp<Expression>& te, | |
| const label comm = UPstream::worldComm | |
| ) | |
| { | |
| auto x = gAverage(te()); | |
| te.clear(); | |
| return x; | |
| } | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| // Weighted average | |
| template | |
| < | |
| class Expression, | |
| class WeightExpression, | |
| class = EnableIfExpressionable<Expression> | |
| > | |
| ElementType<Expression> weightedAverage | |
| ( | |
| const Expression& e, | |
| const WeightExpression& we, | |
| const bool globalReduce = ReduceType<Expression>::globalReduce, | |
| const label comm = UPstream::worldComm | |
| ) | |
| { | |
| return ReduceType<Expression>::weightedAverage | |
| ( | |
| e, | |
| we, | |
| globalReduce, | |
| comm | |
| ); | |
| } | |
| template | |
| < | |
| class Expression, | |
| class WeightExpression, | |
| class = EnableIfExpressionable<Expression> | |
| > | |
| ElementType<Expression> weightedAverage | |
| ( | |
| const tmp<Expression>& te, | |
| const WeightExpression& we | |
| ) | |
| { | |
| auto x = weightedAverage(te(), we); | |
| te.clear(); | |
| return x; | |
| } | |
| template | |
| < | |
| class Expression, | |
| class WeightExpression, | |
| class = EnableIfExpressionable<Expression> | |
| > | |
| ElementType<Expression> gWeightedAverage | |
| ( | |
| const Expression& e, | |
| const WeightExpression& we, | |
| const label comm = UPstream::worldComm | |
| ) | |
| { | |
| return weightedAverage(e, we, true, comm); | |
| } | |
| template | |
| < | |
| class Expression, | |
| class WeightExpression, | |
| class = EnableIfExpressionable<Expression> | |
| > | |
| ElementType<Expression> gWeightedAverage | |
| ( | |
| const tmp<Expression>& te, | |
| const WeightExpression& we, | |
| const label comm = UPstream::worldComm | |
| ) | |
| { | |
| auto x = gWeightedAverage(te(), we); | |
| te.clear(); | |
| return x; | |
| } | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| // Define a binary function or operator given the global function or operator | |
| // name and the operator class that it uses | |
| // Addition operator and sum function | |
| BinaryOperator(+, add); | |
| // Subtraction operator | |
| BinaryOperator(-, subtract); | |
| // Multiplication and/or outer-product operator | |
| BinaryOperator(*, multiply); | |
| // Division operator | |
| BinaryOperator(/, divide); | |
| // Inner product (dot) operator | |
| BinaryOperator(&, inner); | |
| // Cross product operator | |
| BinaryOperator(^, cross); | |
| // Maximum functions | |
| BinaryFunction(max); | |
| // Minimum function | |
| BinaryFunction(min); | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| } // End namespace Foam | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| // ************************************************************************* // | |