From 4c62933e7fd6e8a677f58e54a512f49f2bc83e5e Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 22 Jun 2023 15:33:27 +0100 Subject: [PATCH] surfaceFieldValue: Removed sumDirection and sumDirectionBalance operations The purpose of these operations was unclear, and there was no documentation or examples of their usage. The differences between these operations behaviours for scalar and vector input seemed arbitrary. These operations have in some cases become the subject of confusion. They have therefore been removed. Equivalent functionality could be easily reinstated as and when a clear need and application becomes apparent. --- .../surfaceFieldValue/surfaceFieldValue.C | 61 +------------------ .../surfaceFieldValue/surfaceFieldValue.H | 24 ++------ .../surfaceFieldValueTemplates.C | 1 + 3 files changed, 9 insertions(+), 77 deletions(-) diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index a7e2e0d724..bf906548a3 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -67,14 +67,12 @@ template<> const char* Foam::NamedEnum < Foam::functionObjects::fieldValues::surfaceFieldValue::operationType, - 16 + 14 >::names[] = { "none", "sum", "sumMag", - "sumDirection", - "sumDirectionBalance", "orientedSum", "average", "areaAverage", @@ -97,7 +95,7 @@ const Foam::NamedEnum const Foam::NamedEnum < Foam::functionObjects::fieldValues::surfaceFieldValue::operationType, - 16 + 14 > Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_; @@ -548,19 +546,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues { switch (operation_) { - case operationType::sumDirection: - { - const vector n(dict_.lookup("direction")); - result = gSum(weights*pos0(values*(Sf & n))*mag(values)); - return true; - } - case operationType::sumDirectionBalance: - { - const vector n(dict_.lookup("direction")); - const scalarField nv(values*(Sf & n)); - result = gSum(weights*(pos0(nv)*mag(values) - neg(nv)*mag(values))); - return true; - } default: { // Fall through to same-type operations @@ -600,53 +585,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues } default: { + // No fall through. Different types. return false; } } } -bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues -( - const Field& values, - const scalarField& signs, - const scalarField& weights, - const vectorField& Sf, - vector& result -) const -{ - switch (operation_) - { - case operationType::sumDirection: - { - const vector n = normalised(dict_.lookup("direction")); - const scalarField nv(n & values); - result = gSum(weights*pos0(nv)*n*(nv)); - return true; - } - case operationType::sumDirectionBalance: - { - const vector n = normalised(dict_.lookup("direction")); - const scalarField nv(n & values); - result = gSum(weights*pos0(nv)*n*(nv)); - return true; - } - default: - { - // Fall through to same-type operations - return processValuesTypeType - ( - values, - signs, - weights, - Sf, - result - ); - } - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H index f004456812..67708536f3 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H @@ -114,8 +114,6 @@ Usage none | no operation sum | sum sumMag | sum of component magnitudes - sumDirection | sum values which are positive in given direction - sumDirectionBalance | sum of balance of values in given direction orientedSum | sum with face orientations average | ensemble average areaAverage | area weighted average @@ -206,8 +204,6 @@ public: none, sum, sumMag, - sumDirection, - sumDirectionBalance, orientedSum, average, areaAverage, @@ -222,7 +218,7 @@ public: }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: @@ -347,7 +343,8 @@ protected: Type& result ) const; - //- Apply Type -> scalar operation to the values + //- Apply Type -> scalar operation to the values. Tries to apply + // Type -> scalar specific operations, otherwise does nothing. template bool processValues ( @@ -370,7 +367,8 @@ protected: scalar& result ) const; - //- Apply vector -> vector operation to the values. + //- Apply vector -> scalar operation to the values. Tries to apply + // vector -> scalar specific operations, otherwise does nothing. bool processValues ( const Field& values, @@ -380,18 +378,6 @@ protected: scalar& result ) const; - //- Apply vector -> vector operation to the values. Tries to apply - // vector -> vector specific operations, otherwise calls - // processValuesTypeType. - bool processValues - ( - const Field& values, - const scalarField& signs, - const scalarField& weights, - const vectorField& Sf, - vector& result - ) const; - //- Apply a Type -> Type operation to the values template bool processValuesTypeType diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index e75895b1b4..819c83643f 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -182,6 +182,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues } default: { + // No fall through return false; } }