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.
This commit is contained in:
Will Bainbridge
2023-06-22 15:33:27 +01:00
parent 6f38550879
commit 4c62933e7f
3 changed files with 9 additions and 77 deletions

View File

@ -67,14 +67,12 @@ template<>
const char* Foam::NamedEnum const char* Foam::NamedEnum
< <
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType, Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
16 14
>::names[] = >::names[] =
{ {
"none", "none",
"sum", "sum",
"sumMag", "sumMag",
"sumDirection",
"sumDirectionBalance",
"orientedSum", "orientedSum",
"average", "average",
"areaAverage", "areaAverage",
@ -97,7 +95,7 @@ const Foam::NamedEnum
const Foam::NamedEnum const Foam::NamedEnum
< <
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType, Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
16 14
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_; > Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
@ -548,19 +546,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
{ {
switch (operation_) 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: default:
{ {
// Fall through to same-type operations // Fall through to same-type operations
@ -600,53 +585,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
} }
default: default:
{ {
// No fall through. Different types.
return false; return false;
} }
} }
} }
bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
(
const Field<vector>& values,
const scalarField& signs,
const scalarField& weights,
const vectorField& Sf,
vector& result
) const
{
switch (operation_)
{
case operationType::sumDirection:
{
const vector n = normalised(dict_.lookup<vector>("direction"));
const scalarField nv(n & values);
result = gSum(weights*pos0(nv)*n*(nv));
return true;
}
case operationType::sumDirectionBalance:
{
const vector n = normalised(dict_.lookup<vector>("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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue

View File

@ -114,8 +114,6 @@ Usage
none | no operation none | no operation
sum | sum sum | sum
sumMag | sum of component magnitudes 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 orientedSum | sum with face orientations
average | ensemble average average | ensemble average
areaAverage | area weighted average areaAverage | area weighted average
@ -206,8 +204,6 @@ public:
none, none,
sum, sum,
sumMag, sumMag,
sumDirection,
sumDirectionBalance,
orientedSum, orientedSum,
average, average,
areaAverage, areaAverage,
@ -222,7 +218,7 @@ public:
}; };
//- Operation type names //- Operation type names
static const NamedEnum<operationType, 16> operationTypeNames_; static const NamedEnum<operationType, 14> operationTypeNames_;
private: private:
@ -347,7 +343,8 @@ protected:
Type& result Type& result
) const; ) 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<class Type> template<class Type>
bool processValues bool processValues
( (
@ -370,7 +367,8 @@ protected:
scalar& result scalar& result
) const; ) 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 bool processValues
( (
const Field<vector>& values, const Field<vector>& values,
@ -380,18 +378,6 @@ protected:
scalar& result scalar& result
) const; ) const;
//- Apply vector -> vector operation to the values. Tries to apply
// vector -> vector specific operations, otherwise calls
// processValuesTypeType.
bool processValues
(
const Field<vector>& values,
const scalarField& signs,
const scalarField& weights,
const vectorField& Sf,
vector& result
) const;
//- Apply a Type -> Type operation to the values //- Apply a Type -> Type operation to the values
template<class Type> template<class Type>
bool processValuesTypeType bool processValuesTypeType

View File

@ -182,6 +182,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
} }
default: default:
{ {
// No fall through
return false; return false;
} }
} }