diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C index 95b301284c..be6d03ea88 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C @@ -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(); diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C index 07c640f895..60b7adf9e2 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C @@ -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; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 82a5482d60..28049136c7 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -1095,17 +1095,6 @@ void Foam::GeometricField::replace } -template class PatchField, class GeoMesh> -void Foam::GeometricField::max -( - const dimensioned& dt -) -{ - Foam::max(primitiveFieldRef(), primitiveField(), dt.value()); - Foam::max(boundaryFieldRef(), boundaryField(), dt.value()); -} - - template class PatchField, class GeoMesh> void Foam::GeometricField::min ( @@ -1118,16 +1107,49 @@ void Foam::GeometricField::min template class PatchField, class GeoMesh> -void Foam::GeometricField::maxMin +void Foam::GeometricField::max ( - const dimensioned& minDt, - const dimensioned& maxDt + const dimensioned& 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 PatchField, class GeoMesh> +void Foam::GeometricField::clip +( + const dimensioned>& range +) +{ + Foam::clip(primitiveFieldRef(), primitiveField(), range.value()); + Foam::clip(boundaryFieldRef(), boundaryField(), range.value()); +} + + +template class PatchField, class GeoMesh> +void Foam::GeometricField::clip +( + const dimensioned& minVal, + const dimensioned& maxVal +) +{ + MinMax range(minVal.value(), maxVal.value()); + + Foam::clip(primitiveFieldRef(), primitiveField(), range); + Foam::clip(boundaryFieldRef(), boundaryField(), range); +} + + +template class PatchField, class GeoMesh> +void Foam::GeometricField::maxMin +( + const dimensioned& minVal, + const dimensioned& maxVal +) +{ + this->clip(minVal, maxVal); } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 5226c1c4f9..039b7e41a4 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -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& dt); + //- Clip the field to be bounded within the specified range + void clip(const dimensioned>& range); + + //- Clip the field to be bounded within the specified range + void clip + ( + const dimensioned& minVal, + const dimensioned& maxVal + ); + + //- Deprecated(2019-01) identical to clip() + // \deprecated(2019-01) identical to clip() void maxMin ( - const dimensioned& minDt, - const dimensioned& maxDt - ); + const dimensioned& minVal, + const dimensioned& maxVal + ) FOAM_DEPRECATED_FOR(2019-01, "clip() method"); // Member Operators