mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improved handling for clamping
- proper component-wise clamping for MinMax clamp(). - construct clampOp from components - propagate clamp() method from GeometricField to FieldField and Field - clamp_min() and clamp_max() for one-sided clamping, as explicit alternative to min/max free functions which can be less intuitive and often involve additional field copies. - top-level checks to skip applying invalid min/max ranges and bypass the internal checks of MinMax::clamp() etc.
This commit is contained in:
@ -1279,7 +1279,7 @@ void write_scalarField
|
||||
continue;
|
||||
}
|
||||
|
||||
os << limits.clip(fld(cellIdx)) << nl;
|
||||
os << limits.clamp(fld(cellIdx)) << nl;
|
||||
}
|
||||
|
||||
os << token::END_LIST << token::END_STATEMENT << nl;
|
||||
|
||||
@ -58,12 +58,11 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Read porosity, change to blockage. Clamp values [0-1] silently
|
||||
static const scalarMinMax limits01(scalarMinMax::zero_one());
|
||||
|
||||
// Volume porosity -> blockage
|
||||
inline scalar getPorosity(const dictionary& dict)
|
||||
{
|
||||
return 1 - limits01.clip(dict.getOrDefault<scalar>("porosity", 0));
|
||||
return 1 - clamp(dict.getOrDefault<scalar>("porosity", 0), 0, 1);
|
||||
}
|
||||
|
||||
// Direction porosities -> blockage
|
||||
@ -75,7 +74,7 @@ inline vector getPorosities(const dictionary& dict)
|
||||
{
|
||||
for (scalar& val : blockage)
|
||||
{
|
||||
val = 1 - limits01.clip(val);
|
||||
val = 1 - clamp(val, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user