From 912d801aa9133337c029dc602c31729eb3d112f9 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Tue, 16 Jan 2018 15:00:12 +0100 Subject: [PATCH] Added ifEqEqAssignFirstOp into ops.H Basically compares the two values and if they are not equal, assigns default value to the first argument. Needed for syncing processor data in polyhedralRefinement. --- src/foam/primitives/ops/ops.H | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/foam/primitives/ops/ops.H b/src/foam/primitives/ops/ops.H index 1a72b73d0..0bb6f6cff 100644 --- a/src/foam/primitives/ops/ops.H +++ b/src/foam/primitives/ops/ops.H @@ -377,6 +377,20 @@ template class greaterEqOp { public: T operator()(const T& x, const T& y) const { return x >= y; } }; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +class ifEqEqAssignFirstOp +{ +public: + + void operator()(T& x, const T& y) const + { + x = (x == y) ? x : defaultValue; + } +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam