ENH: add clip() method to GeometricField

This commit is contained in:
Mark Olesen 2019-01-10 09:56:12 +01:00
parent 9a7029004c
commit 5c226864a8
4 changed files with 58 additions and 24 deletions

View File

@ -692,7 +692,7 @@ void Foam::multiphaseSystem::solve()
phase.alphaRhoPhi() = fvc::interpolate(phase.rho())*phase.alphaPhi();
// Ensure the phase-fractions are bounded
phase.maxMin(0, 1);
phase.clip(0, 1);
}
calcAlphas();

View File

@ -403,7 +403,7 @@ void Foam::twoPhaseSystem::solve()
<< endl;
// Ensure the phase-fractions are bounded
alpha1.maxMin(0, 1);
alpha1.clip(0, 1);
// Update the phase-fraction of the other phase
alpha2 = scalar(1) - alpha1;

View File

@ -1095,17 +1095,6 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::replace
}
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::max
(
const dimensioned<Type>& dt
)
{
Foam::max(primitiveFieldRef(), primitiveField(), dt.value());
Foam::max(boundaryFieldRef(), boundaryField(), dt.value());
}
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::min
(
@ -1118,16 +1107,49 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::min
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::maxMin
void Foam::GeometricField<Type, PatchField, GeoMesh>::max
(
const dimensioned<Type>& minDt,
const dimensioned<Type>& maxDt
const dimensioned<Type>& dt
)
{
Foam::max(primitiveFieldRef(), primitiveField(), minDt.value());
Foam::max(boundaryFieldRef(), boundaryField(), minDt.value());
Foam::min(primitiveFieldRef(), primitiveField(), maxDt.value());
Foam::min(boundaryFieldRef(), boundaryField(), maxDt.value());
Foam::max(primitiveFieldRef(), primitiveField(), dt.value());
Foam::max(boundaryFieldRef(), boundaryField(), dt.value());
}
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::clip
(
const dimensioned<MinMax<Type>>& range
)
{
Foam::clip(primitiveFieldRef(), primitiveField(), range.value());
Foam::clip(boundaryFieldRef(), boundaryField(), range.value());
}
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::clip
(
const dimensioned<Type>& minVal,
const dimensioned<Type>& maxVal
)
{
MinMax<Type> range(minVal.value(), maxVal.value());
Foam::clip(primitiveFieldRef(), primitiveField(), range);
Foam::clip(boundaryFieldRef(), boundaryField(), range);
}
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::maxMin
(
const dimensioned<Type>& minVal,
const dimensioned<Type>& maxVal
)
{
this->clip(minVal, maxVal);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -598,11 +598,23 @@ public:
// This sets the \em floor on the field values
void max(const dimensioned<Type>& dt);
//- Clip the field to be bounded within the specified range
void clip(const dimensioned<MinMax<Type>>& range);
//- Clip the field to be bounded within the specified range
void clip
(
const dimensioned<Type>& minVal,
const dimensioned<Type>& maxVal
);
//- Deprecated(2019-01) identical to clip()
// \deprecated(2019-01) identical to clip()
void maxMin
(
const dimensioned<Type>& minDt,
const dimensioned<Type>& maxDt
);
const dimensioned<Type>& minVal,
const dimensioned<Type>& maxVal
) FOAM_DEPRECATED_FOR(2019-01, "clip() method");
// Member Operators