From 86e5b360dba97646f2c7bb785ac44ca1196ed227 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 17 Mar 2016 11:33:54 +0000 Subject: [PATCH] Added cmptSign --- src/foam/fields/Fields/Field/FieldFunctions.C | 24 +++++++++++++++++++ src/foam/fields/Fields/Field/FieldFunctions.H | 10 ++++++++ 2 files changed, 34 insertions(+) diff --git a/src/foam/fields/Fields/Field/FieldFunctions.C b/src/foam/fields/Fields/Field/FieldFunctions.C index 8719f3cf6..1ad527657 100644 --- a/src/foam/fields/Fields/Field/FieldFunctions.C +++ b/src/foam/fields/Fields/Field/FieldFunctions.C @@ -297,6 +297,30 @@ tmp > cmptMag(const tmp >& tf) } +template +void cmptSign(Field& res, const UList& f) +{ + TFOR_ALL_F_OP_FUNC_F(Type, res, =, cmptSign, Type, f) +} + +template +tmp > cmptSign(const UList& f) +{ + tmp > tRes(new Field(f.size())); + cmptSign(tRes(), f); + return tRes; +} + +template +tmp > cmptSign(const tmp >& tf) +{ + tmp > tRes = reuseTmp::New(tf); + cmptSign(tRes(), tf()); + reuseTmp::clear(tf); + return tRes; +} + + #define TMP_UNARY_FUNCTION(ReturnType, Func) \ \ template \ diff --git a/src/foam/fields/Fields/Field/FieldFunctions.H b/src/foam/fields/Fields/Field/FieldFunctions.H index b4a6eb515..7400083d1 100644 --- a/src/foam/fields/Fields/Field/FieldFunctions.H +++ b/src/foam/fields/Fields/Field/FieldFunctions.H @@ -152,6 +152,16 @@ tmp > cmptMag(const UList& f); template tmp > cmptMag(const tmp >& tf); + +template +void cmptSign(Field& res, const UList& f); + +template +tmp > cmptSign(const UList& f); + +template +tmp > cmptSign(const tmp >& tf); + #define TMP_UNARY_FUNCTION(ReturnType, Func) \ \ template \