From 6c20df28080126a8149456b2b8337bec1da79245 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 2 Apr 2025 11:19:04 +0200
Subject: [PATCH 1/5] ENH: additional in-place clamp_min(), clamp_max() field
 methods

- these already existed for a single value, but now handle the full
  field. This is more memory-friendly.

      fld.clamp_min(lower);  OLD: fld = max(fld, lower);
      fld.clamp_max(upper);  OLD: fld = min(fld, upper);
---
 .../combustion/reactingFoam/setRDeltaT.H      | 46 ++++++++++--------
 .../chtMultiRegionSimpleFoam/fluid/pEqn.H     |  4 +-
 .../lagrangian/coalChemistryFoam/setRDeltaT.H | 45 +++++++++--------
 .../reactingParcelFoam/setRDeltaT.H           | 48 ++++++++++---------
 .../simpleReactingParcelFoam/pEqn.H           |  3 +-
 .../lagrangian/simpleCoalParcelFoam/pEqn.H    |  3 +-
 .../solvers/lagrangian/sprayFoam/pEqn.H       |  6 +--
 .../lagrangian/sprayFoam/sprayDyMFoam/pEqn.H  |  6 +--
 .../solvers/multiphase/VoF/setRDeltaT.H       | 29 ++++++-----
 applications/test/minMax2/Test-minMax2.cxx    | 32 ++++++++++++-
 .../FieldFields/FieldField/FieldField.C       | 32 ++++++++++++-
 .../FieldFields/FieldField/FieldField.H       |  8 +++-
 src/OpenFOAM/fields/Fields/Field/Field.C      | 35 ++++++++++++++
 src/OpenFOAM/fields/Fields/Field/Field.H      |  9 +++-
 .../GeometricField/GeometricField.C           | 32 +++++++++++++
 .../GeometricField/GeometricField.H           | 16 +++++--
 .../faScalarMatrix/faScalarMatrix.C           |  4 +-
 .../basic/rhoThermo/rhoThermo.C               |  3 +-
 18 files changed, 258 insertions(+), 103 deletions(-)

diff --git a/applications/solvers/combustion/reactingFoam/setRDeltaT.H b/applications/solvers/combustion/reactingFoam/setRDeltaT.H
index 6bf4cf8375f..7b449fd9007 100644
--- a/applications/solvers/combustion/reactingFoam/setRDeltaT.H
+++ b/applications/solvers/combustion/reactingFoam/setRDeltaT.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2013-2016 OpenFOAM Foundation
-    Copyright (C) 2020 OpenCFD Ltd.
+    Copyright (C) 2020,2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -57,10 +57,22 @@ License
     // (relative to reference value)
     scalar alphaY(pimpleDict.getOrDefault<scalar>("alphaY", 1.0));
 
-    Info<< "Time scales min/max:" << endl;
 
-    // Cache old reciprocal time scale field
-    volScalarField rDeltaT0("rDeltaT0", rDeltaT);
+    // The old reciprocal time scale field, with any damping factor
+    tmp<volScalarField> rDeltaT0_damped;
+
+    // Calculate damped value before applying any other changes
+    if
+    (
+        rDeltaTDampingCoeff < 1
+     && runTime.timeIndex() > runTime.startTimeIndex() + 1
+    )
+    {
+        rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
+    }
+
+
+    Info<< "Time scales min/max:" << endl;
 
     // Flow time scale
     {
@@ -70,8 +82,8 @@ License
            /((2*maxCo)*mesh.V()*rho())
         );
 
-        // Limit the largest time scale
-        rDeltaT.max(1/maxDeltaT);
+        // Limit the largest time scale (=> smallest reciprocal time)
+        rDeltaT.clamp_min(1/maxDeltaT);
 
         Info<< "    Flow        = "
             << 1/gMax(rDeltaT.primitiveField()) << ", "
@@ -86,11 +98,11 @@ License
             mag(Qdot)/(alphaTemp*rho*thermo.Cp()*T)
         );
 
+        rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
+
         Info<< "    Temperature = "
             << 1/(gMax(rDeltaTT.field()) + VSMALL) << ", "
             << 1/(gMin(rDeltaTT.field()) + VSMALL) << endl;
-
-        rDeltaT.ref() = max(rDeltaT(), rDeltaTT);
     }
 
     // Reaction rate time scale
@@ -138,11 +150,11 @@ License
 
         if (foundY)
         {
+            rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY);
+
             Info<< "    Composition = "
                 << 1/(gMax(rDeltaTY.field()) + VSMALL) << ", "
                 << 1/(gMin(rDeltaTY.field()) + VSMALL) << endl;
-
-            rDeltaT.ref() = max(rDeltaT(), rDeltaTY);
         }
         else
         {
@@ -161,20 +173,12 @@ License
         fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
     }
 
-    // Limit rate of change of time scale
+    // Limit rate of change of time scale (=> smallest reciprocal time)
     // - reduce as much as required
     // - only increase at a fraction of old time scale
-    if
-    (
-        rDeltaTDampingCoeff < 1
-     && runTime.timeIndex() > runTime.startTimeIndex() + 1
-    )
+    if (rDeltaT0_damped)
     {
-        rDeltaT = max
-        (
-            rDeltaT,
-            (scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
-        );
+        rDeltaT.clamp_min(rDeltaT0_damped());
     }
 
     // Update tho boundary values of the reciprocal time-step
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
index fe3d7428164..d4dd47300ec 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
@@ -78,8 +78,8 @@
     }
 
     rho = thermo.rho();
-    rho = max(rho, rhoMin[i]);
-    rho = min(rho, rhoMax[i]);
+
+    rho.clamp_range(rhoMin[i], rhoMax[i]);
     rho.relax();
 
     Info<< "Min/max rho:" << min(rho).value() << ' '
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H b/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H
index bda1cc2d883..aabfd0e0156 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H
+++ b/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2020 OpenCFD Ltd.
+    Copyright (C) 2020,2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -54,10 +54,21 @@ License
     scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
 
 
-    Info<< "Time scales min/max:" << endl;
+    // The old reciprocal time scale field, with any damping factor
+    tmp<volScalarField> rDeltaT0_damped;
+
+    // Calculate damped value before applying any other changes
+    if
+    (
+        rDeltaTDampingCoeff < 1
+     && runTime.timeIndex() > runTime.startTimeIndex() + 1
+    )
+    {
+        rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
+    }
 
-    // Cache old reciprocal time scale field
-    volScalarField rDeltaT0("rDeltaT0", rDeltaT);
+
+    Info<< "Time scales min/max:" << endl;
 
     // Flow time scale
     {
@@ -67,8 +78,8 @@ License
            /((2*maxCo)*mesh.V()*rho())
         );
 
-        // Limit the largest time scale
-        rDeltaT.max(1/maxDeltaT);
+        // Limit the largest time scale (=> smallest reciprocal time)
+        rDeltaT.clamp_min(1/maxDeltaT);
 
         Info<< "    Flow        = "
             << gMin(1/rDeltaT.primitiveField()) << ", "
@@ -93,15 +104,11 @@ License
            )
         );
 
+        rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
+
         Info<< "    Temperature = "
             << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
             << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
-
-        rDeltaT.ref() = max
-        (
-            rDeltaT(),
-            rDeltaTT
-        );
     }
 
     // Update tho boundary values of the reciprocal time-step
@@ -113,20 +120,12 @@ License
         fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
     }
 
-    // Limit rate of change of time scale
+    // Limit rate of change of time scale (=> smallest reciprocal time)
     // - reduce as much as required
     // - only increase at a fraction of old time scale
-    if
-    (
-        rDeltaTDampingCoeff < 1.0
-     && runTime.timeIndex() > runTime.startTimeIndex() + 1
-    )
+    if (rDeltaT0_damped)
     {
-        rDeltaT = max
-        (
-            rDeltaT,
-            (scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
-        );
+        rDeltaT.clamp_min(rDeltaT0_damped());
     }
 
     Info<< "    Overall     = "
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H b/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H
index 5977b18fe67..8ef4cd1eb23 100644
--- a/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H
+++ b/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2020 OpenCFD Ltd.
+    Copyright (C) 2020,2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -54,10 +54,21 @@ License
     scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
 
 
-    Info<< "Time scales min/max:" << endl;
+    // The old reciprocal time scale field, with any damping factor
+    tmp<volScalarField> rDeltaT0_damped;
+
+    // Calculate damped value before applying any other changes
+    if
+    (
+        rDeltaTDampingCoeff < 1
+     && runTime.timeIndex() > runTime.startTimeIndex() + 1
+    )
+    {
+        rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
+    }
+
 
-    // Cache old reciprocal time scale field
-    volScalarField rDeltaT0("rDeltaT0", rDeltaT);
+    Info<< "Time scales min/max:" << endl;
 
     // Flow time scale
     {
@@ -67,8 +78,8 @@ License
            /((2*maxCo)*mesh.V()*rho())
         );
 
-        // Limit the largest time scale
-        rDeltaT.max(1/maxDeltaT);
+        // Limit the largest time scale (=> smallest reciprocal time)
+        rDeltaT.clamp_min(1/maxDeltaT);
 
         Info<< "    Flow        = "
             << gMin(1/rDeltaT.primitiveField()) << ", "
@@ -92,15 +103,11 @@ License
            )
         );
 
+        rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
+
         Info<< "    Temperature = "
             << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
             << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
-
-        rDeltaT.ref() = max
-        (
-            rDeltaT(),
-            rDeltaTT
-        );
     }
 
     // Update the boundary values of the reciprocal time-step
@@ -112,22 +119,17 @@ License
         fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
     }
 
-    // Limit rate of change of time scale
+    // Limit rate of change of time scale (=> smallest reciprocal time)
     // - reduce as much as required
     // - only increase at a fraction of old time scale
-    if
-    (
-        rDeltaTDampingCoeff < 1.0
-     && runTime.timeIndex() > runTime.startTimeIndex() + 1
-    )
+    if (rDeltaT0_damped)
     {
-        rDeltaT = max
-        (
-            rDeltaT,
-            (scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
-        );
+        rDeltaT.clamp_min(rDeltaT0_damped());
     }
 
+    // Update the boundary values of the reciprocal time-step
+    rDeltaT.correctBoundaryConditions();
+
     Info<< "    Overall     = "
         << gMin(1/rDeltaT.primitiveField())
         << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/pEqn.H
index 1ce5db0ec8f..2b3d264c626 100644
--- a/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/pEqn.H
+++ b/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/pEqn.H
@@ -48,8 +48,7 @@ U.correctBoundaryConditions();
 fvOptions.correct(U);
 
 rho = thermo.rho();
-rho = max(rho, rhoMin);
-rho = min(rho, rhoMax);
+rho.clamp_range(rhoMin, rhoMax);
 rho.relax();
 
 Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
diff --git a/applications/solvers/lagrangian/simpleCoalParcelFoam/pEqn.H b/applications/solvers/lagrangian/simpleCoalParcelFoam/pEqn.H
index 055eff6f0b3..1c85828e24a 100644
--- a/applications/solvers/lagrangian/simpleCoalParcelFoam/pEqn.H
+++ b/applications/solvers/lagrangian/simpleCoalParcelFoam/pEqn.H
@@ -49,8 +49,7 @@
     fvOptions.correct(U);
 
     rho = thermo.rho();
-    rho = max(rho, rhoMin);
-    rho = min(rho, rhoMax);
+    rho.clamp_range(rhoMin, rhoMax);
     rho.relax();
 
     Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
diff --git a/applications/solvers/lagrangian/sprayFoam/pEqn.H b/applications/solvers/lagrangian/sprayFoam/pEqn.H
index 198bf00d52c..fbdcc577908 100644
--- a/applications/solvers/lagrangian/sprayFoam/pEqn.H
+++ b/applications/solvers/lagrangian/sprayFoam/pEqn.H
@@ -1,6 +1,5 @@
 rho = thermo.rho();
-rho = max(rho, rhoMin);
-rho = min(rho, rhoMax);
+rho.clamp_range(rhoMin, rhoMax);
 rho.relax();
 
 volScalarField rAU(1.0/UEqn.A());
@@ -94,8 +93,7 @@ p.relax();
 
 // Recalculate density from the relaxed pressure
 rho = thermo.rho();
-rho = max(rho, rhoMin);
-rho = min(rho, rhoMax);
+rho.clamp_range(rhoMin, rhoMax);
 rho.relax();
 Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
 
diff --git a/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/pEqn.H b/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/pEqn.H
index a7850a5e903..92bd8c2564b 100644
--- a/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/pEqn.H
+++ b/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/pEqn.H
@@ -1,6 +1,5 @@
 rho = thermo.rho();
-rho = max(rho, rhoMin);
-rho = min(rho, rhoMax);
+rho.clamp_range(rhoMin, rhoMax);
 rho.relax();
 
 volScalarField rAU(1.0/UEqn.A());
@@ -94,8 +93,7 @@ p.relax();
 
 // Recalculate density from the relaxed pressure
 rho = thermo.rho();
-rho = max(rho, rhoMin);
-rho = min(rho, rhoMax);
+rho.clamp_range(rhoMin, rhoMax);
 rho.relax();
 Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
 
diff --git a/applications/solvers/multiphase/VoF/setRDeltaT.H b/applications/solvers/multiphase/VoF/setRDeltaT.H
index 313fca2e33b..b690f0accc6 100644
--- a/applications/solvers/multiphase/VoF/setRDeltaT.H
+++ b/applications/solvers/multiphase/VoF/setRDeltaT.H
@@ -53,6 +53,21 @@
         pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
     );
 
+
+    // The old reciprocal time scale field, with any damping factor
+    tmp<volScalarField> rDeltaT0_damped;
+
+    // Calculate damped value before applying any other changes
+    if
+    (
+        rDeltaTDampingCoeff < 1
+     && runTime.timeIndex() > runTime.startTimeIndex() + 1
+    )
+    {
+        rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
+    }
+
+
     volScalarField rDeltaT0("rDeltaT0", rDeltaT);
 
     // Set the reciprocal time-step from the local Courant number
@@ -114,20 +129,12 @@
         << gMin(1/rDeltaT.primitiveField())
         << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
 
-    // Limit rate of change of time scale
+    // Limit rate of change of time scale (=> smallest reciprocal time)
     // - reduce as much as required
     // - only increase at a fraction of old time scale
-    if
-    (
-        rDeltaTDampingCoeff < 1.0
-     && runTime.timeIndex() > runTime.startTimeIndex() + 1
-    )
+    if (rDeltaT0_damped)
     {
-        rDeltaT = max
-        (
-            rDeltaT,
-            (scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
-        );
+        rDeltaT.clamp_min(rDeltaT0_damped());
 
         Info<< "Damped flow time scale min/max = "
             << gMin(1/rDeltaT.primitiveField())
diff --git a/applications/test/minMax2/Test-minMax2.cxx b/applications/test/minMax2/Test-minMax2.cxx
index e228f0dce2c..b58363c7448 100644
--- a/applications/test/minMax2/Test-minMax2.cxx
+++ b/applications/test/minMax2/Test-minMax2.cxx
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019-2023 OpenCFD Ltd.
+    Copyright (C) 2019-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -175,6 +175,36 @@ int main(int argc, char *argv[])
             << nl;
     }
 
+    {
+        scalarField field1(10);
+        scalarField field2(10);
+        scalarField work;
+
+        Random rnd(4567);
+        for (scalar& val : field1)
+        {
+            val = rnd.position(scalar(-0.2), scalar(1.2));
+        }
+        for (scalar& val : field2)
+        {
+            val = rnd.position(scalar(-0.1), scalar(1.1));
+        }
+
+        Info<< nl
+            << "field1: " << flatOutput(field1) << nl
+            << "field2: " << flatOutput(field2) << nl;
+
+        work = field1;
+        work.clamp_min(field2);
+
+        Info<< "clamp_min: " << flatOutput(work) << nl;
+
+        work = field1;
+        work.clamp_max(field2);
+
+        Info<< "clamp_max: " << flatOutput(work) << nl;
+    }
+
     Info<< nl << "\nDone\n" << endl;
     return 0;
 }
diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C
index 17d07fb2f06..1cd6a54c6b2 100644
--- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C
+++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2019-2023 OpenCFD Ltd.
+    Copyright (C) 2019-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -308,6 +308,36 @@ void FieldField<Field, Type>::clamp_max
 }
 
 
+template<template<class> class Field, class Type>
+void FieldField<Field, Type>::clamp_min
+(
+    const FieldField<Field, Type>& lower
+)
+{
+    const label loopLen = this->size();
+
+    for (label i = 0; i < loopLen; ++i)
+    {
+        (*this)[i].clamp_min(lower[i]);
+    }
+}
+
+
+template<template<class> class Field, class Type>
+void FieldField<Field, Type>::clamp_max
+(
+    const FieldField<Field, Type>& upper
+)
+{
+    const label loopLen = this->size();
+
+    for (label i = 0; i < loopLen; ++i)
+    {
+        (*this)[i].clamp_max(upper[i]);
+    }
+}
+
+
 template<template<class> class Field, class Type>
 void FieldField<Field, Type>::clamp_range
 (
diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H
index d8dbbcdf0e0..f1c9fda937f 100644
--- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H
+++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2022-2023 OpenCFD Ltd.
+    Copyright (C) 2022-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -152,9 +152,15 @@ public:
         //- Impose lower (floor) clamp on the field values (in-place)
         void clamp_min(const Type& lower);
 
+        //- Impose lower (floor) clamp on the field values (in-place)
+        void clamp_min(const FieldField<Field, Type>& lower);
+
         //- Impose upper (ceiling) clamp on the field values (in-place)
         void clamp_max(const Type& upper);
 
+        //- Impose upper (ceiling) clamp on the field values (in-place)
+        void clamp_max(const FieldField<Field, Type>& upper);
+
         //- Clamp field values (in-place) to the specified range.
         //  Does not check if range is valid or not.
         void clamp_range(const Type& lower, const Type& upper);
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C
index 0372523102a..1b500ff6c97 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.C
+++ b/src/OpenFOAM/fields/Fields/Field/Field.C
@@ -669,6 +669,7 @@ void Foam::Field<Type>::clamp_min(const Type& lower)
     }
 }
 
+
 template<class Type>
 void Foam::Field<Type>::clamp_max(const Type& upper)
 {
@@ -681,6 +682,40 @@ void Foam::Field<Type>::clamp_max(const Type& upper)
 }
 
 
+template<class Type>
+void Foam::Field<Type>::clamp_min(const UList<Type>& lower)
+{
+    // Use free function max() [sic] to impose component-wise clamp_min
+    std::transform
+    (
+        // Can use (std::execution::par_unseq | std::execution::unseq)
+        this->begin(),
+        // this->end() but with some extra range safety
+        this->begin(lower.size()),
+        lower.begin(),
+        this->begin(),
+        maxOp<Type>()
+    );
+}
+
+
+template<class Type>
+void Foam::Field<Type>::clamp_max(const UList<Type>& upper)
+{
+    // Use free function min() [sic] to impose component-wise clamp_max
+    std::transform
+    (
+        // Can use (std::execution::par_unseq | std::execution::unseq)
+        this->begin(),
+        // this->end() but with some extra range safety
+        this->begin(upper.size()),
+        upper.begin(),
+        this->begin(),
+        minOp<Type>()
+    );
+}
+
+
 template<class Type>
 void Foam::Field<Type>::clamp_range(const Type& lower, const Type& upper)
 {
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H
index fb7851edc6d..3441a50e0b5 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.H
+++ b/src/OpenFOAM/fields/Fields/Field/Field.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2015-2023 OpenCFD Ltd.
+    Copyright (C) 2015-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -50,6 +50,7 @@ SourceFiles
 #include "direction.H"
 #include "labelList.H"
 #include "keyType.H"
+#include "ops.H"
 #include "scalarList.H"
 #include "VectorSpace.H"
 #include "IOobjectOption.H"
@@ -441,9 +442,15 @@ public:
         //- Impose lower (floor) clamp on the field values (in-place)
         void clamp_min(const Type& lower);
 
+        //- Impose lower (floor) clamp on the field values (in-place)
+        void clamp_min(const UList<Type>& lower);
+
         //- Impose upper (ceiling) clamp on the field values (in-place)
         void clamp_max(const Type& upper);
 
+        //- Impose upper (ceiling) clamp on the field values (in-place)
+        void clamp_max(const UList<Type>& upper);
+
         //- Clamp field values (in-place) to the specified range.
         //  Does not check if range is valid or not.
         void clamp_range(const Type& lower, const Type& upper);
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
index 2ef9c028ade..7667b784355 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
@@ -1276,6 +1276,38 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_max
 }
 
 
+template<class Type, template<class> class PatchField, class GeoMesh>
+void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_min
+(
+    const GeometricField<Type, PatchField, GeoMesh>& lower
+)
+{
+    primitiveFieldRef().clamp_min(lower.primitiveField());
+    boundaryFieldRef().clamp_min(lower.boundaryField());
+    correctLocalBoundaryConditions();
+    if (GeometricBoundaryField<Type, PatchField, GeoMesh>::debug)
+    {
+        boundaryField().check();
+    }
+}
+
+
+template<class Type, template<class> class PatchField, class GeoMesh>
+void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_max
+(
+    const GeometricField<Type, PatchField, GeoMesh>& upper
+)
+{
+    primitiveFieldRef().clamp_max(upper.primitiveField());
+    boundaryFieldRef().clamp_max(upper.boundaryField());
+    correctLocalBoundaryConditions();
+    if (GeometricBoundaryField<Type, PatchField, GeoMesh>::debug)
+    {
+        boundaryField().check();
+    }
+}
+
+
 template<class Type, template<class> class PatchField, class GeoMesh>
 void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_range
 (
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H
index 5ff69df5cab..2345159762d 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H
@@ -936,17 +936,25 @@ public:
         //- Impose lower (floor) clamp on the field values (in-place)
         void clamp_min(const Type& lower);
 
-        //- Impose upper (ceiling) clamp on the field values (in-place)
-        void clamp_max(const Type& upper);
-
         //- Impose lower (floor) clamp on the field values (in-place)
         //  No dimension checking
         void clamp_min(const dimensioned<Type>& lower);
 
+        //- Impose lower (floor) clamp on the field values (in-place)
+        //  No dimension checking
+        void clamp_min(const GeometricField<Type, PatchField, GeoMesh>& lower);
+
+        //- Impose upper (ceiling) clamp on the field values (in-place)
+        void clamp_max(const Type& upper);
+
         //- Impose upper (ceiling) clamp on the field values (in-place)
         //  No dimension checking
         void clamp_max(const dimensioned<Type>& upper);
 
+        //- Impose upper (ceiling) clamp on the field values (in-place)
+        //  No dimension checking
+        void clamp_max(const GeometricField<Type, PatchField, GeoMesh>& upper);
+
         //- Clamp field values (in-place) to the specified range.
         //  Does not check if range is valid or not. No dimension checking.
         void clamp_range(const dimensioned<MinMax<Type>>& range);
@@ -1055,11 +1063,13 @@ public:
         //- Use minimum of the field and specified value. ie, clamp_max().
         //  This sets the \em ceiling on the field values
         //  \deprecated(2023-01) prefer clamp_max()
+        FOAM_DEPRECATED_STRICT(2023-01, "clamp_max() method")
         void min(const dimensioned<Type>& upper) { this->clamp_max(upper); }
 
         //- Use maximum of the field and specified value. ie, clamp_min().
         //  This sets the \em floor on the field values
         //  \deprecated(2023-01) prefer clamp_min()
+        FOAM_DEPRECATED_STRICT(2023-01, "clamp_min() method")
         void max(const dimensioned<Type>& lower) { this->clamp_min(lower); }
 
         //- Deprecated(2019-01) identical to clamp_range()
diff --git a/src/finiteArea/faMatrices/faScalarMatrix/faScalarMatrix.C b/src/finiteArea/faMatrices/faScalarMatrix/faScalarMatrix.C
index f9d39a7d00d..d944b639285 100644
--- a/src/finiteArea/faMatrices/faScalarMatrix/faScalarMatrix.C
+++ b/src/finiteArea/faMatrices/faScalarMatrix/faScalarMatrix.C
@@ -85,7 +85,7 @@ Foam::solverPerformance Foam::faMatrix<Foam::scalar>::solve
         internalCoeffs_,
         psi_.boundaryField().scalarInterfaces(),
         solverControls
-    )->solve(psi.ref(), totalSource);
+    )->solve(psi.primitiveFieldRef(), totalSource);
 
     if (logLevel)
     {
@@ -146,7 +146,7 @@ Foam::tmp<Foam::areaScalarField> Foam::faMatrix<Foam::scalar>::H() const
     Hphi.primitiveFieldRef() = (lduMatrix::H(psi_.primitiveField()) + source_);
     addBoundarySource(Hphi.primitiveFieldRef());
 
-    Hphi.ref() /= psi_.mesh().S();
+    Hphi.primitiveFieldRef() /= psi_.mesh().S();
     Hphi.correctBoundaryConditions();
 
     return tHphi;
diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C
index 074cccfde8f..9ad65f87485 100644
--- a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C
+++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C
@@ -256,8 +256,7 @@ void Foam::rhoThermo::correctRho
 )
 {
     rho_ += deltaRho;
-    rho_ = max(rho_, rhoMin);
-    rho_ = min(rho_, rhoMax);
+    rho_.clamp_range(rhoMin, rhoMax);
 }
 
 void Foam::rhoThermo::correctRho(const Foam::volScalarField& deltaRho)
-- 
GitLab


From a7e8a43f4a4b3b76a44c6961f3d57ce79174f00a Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 9 Apr 2025 14:23:49 +0200
Subject: [PATCH 2/5] ENH: add writeContents() static methods for IOList etc.

- encapsulates IOListRef etc into a simpler syntax

ENH: use UList instead of refPtr for IOListRef (avoids List cast etc)
---
 applications/test/IOField/Test-IOField.cxx    |  4 +--
 .../manipulation/checkMesh/checkTopology.C    | 16 +++-------
 .../manipulation/renumberMesh/renumberMesh.C  |  8 ++---
 .../decomposePar/domainDecomposition.C        | 17 +++++------
 .../reconstructParMesh/reconstructParMesh.C   |  8 ++---
 .../redistributePar/redistributePar.C         | 29 +++++++------------
 src/OpenFOAM/db/IOobjects/IOList/IOList.C     | 23 +++++++++++++--
 src/OpenFOAM/db/IOobjects/IOList/IOList.H     | 17 ++++++-----
 .../mapDistribute/IOmapDistributePolyMesh.C   | 19 +++++++++++-
 .../mapDistribute/IOmapDistributePolyMesh.H   | 13 ++++++++-
 src/conversion/ccm/reader/ccmReader.H         |  2 +-
 src/conversion/ccm/reader/ccmReaderAux.C      |  2 +-
 src/conversion/common/reader/meshReader.H     |  2 +-
 src/conversion/common/reader/meshReaderAux.C  |  2 +-
 .../polyTopoChange/hexRef8/hexRef8Data.C      |  4 +--
 .../polyTopoChange/hexRef8/hexRef8Data.H      |  4 +--
 .../faDecompose/faMeshDecomposition.C         | 10 +++----
 .../faReconstruct/faMeshReconstructor.C       | 12 ++++----
 18 files changed, 110 insertions(+), 82 deletions(-)

diff --git a/applications/test/IOField/Test-IOField.cxx b/applications/test/IOField/Test-IOField.cxx
index 96f91d5e7e5..e9f6123e405 100644
--- a/applications/test/IOField/Test-IOField.cxx
+++ b/applications/test/IOField/Test-IOField.cxx
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2017 OpenFOAM Foundation
-    Copyright (C) 2019-2022 OpenCFD Ltd.
+    Copyright (C) 2019-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -269,7 +269,7 @@ int main(int argc, char *argv[])
         ioOutput.rename(args.executable() + "-labels");
         Info<< "write " << ioOutput.objectRelPath() << endl;
         {
-            IOListRef<label>(ioOutput, ints).write();
+            IOList<label>::writeContents(ioOutput, ints);
         }
 
         ioOutput.rename(args.executable() + "-points");
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C
index 1c2decf3c23..8842ee73c9d 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2017-2023 OpenCFD Ltd.
+    Copyright (C) 2017-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -700,19 +700,11 @@ Foam::label Foam::checkTopology
                 << mesh.time().timeName()/"cellToRegion"
                 << endl;
 
-            IOListRef<label>
+            IOList<label>::writeContents
             (
-                IOobject
-                (
-                    "cellToRegion",
-                    mesh.time().timeName(),
-                    mesh,
-                    IOobject::NO_READ,
-                    IOobject::NO_WRITE,
-                    IOobject::NO_REGISTER
-                ),
+                IOobject("cellToRegion", mesh.time().timeName(), mesh),
                 rs
-            ).write();
+            );
 
 
             // Points in multiple regions
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
index 9a3eb426477..c5763634bd3 100644
--- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
+++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2016-2024 OpenCFD Ltd.
+    Copyright (C) 2016-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -1913,13 +1913,13 @@ int main(int argc, char *argv[])
                 );
 
                 meshMapIO.resetHeader("cellMap");
-                IOListRef<label>(meshMapIO, map().cellMap()).write();
+                IOList<label>::writeContents(meshMapIO, map().cellMap());
 
                 meshMapIO.resetHeader("faceMap");
-                IOListRef<label>(meshMapIO, map().faceMap()).write();
+                IOList<label>::writeContents(meshMapIO, map().faceMap());
 
                 meshMapIO.resetHeader("pointMap");
-                IOListRef<label>(meshMapIO, map().pointMap()).write();
+                IOList<label>::writeContents(meshMapIO, map().pointMap());
             }
         }
 
diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
index b77f2777fb3..36967082146 100644
--- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
+++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2019-2024 OpenCFD Ltd.
+    Copyright (C) 2019-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -846,12 +846,9 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
                     "boundaryProcAddressing",
                     procMesh.facesInstance(),
                     polyMesh::meshSubDir/pointMesh::meshSubDir,
-                    procPointMesh.thisDb(),
-                    IOobject::NO_READ,
-                    IOobject::NO_WRITE,
-                    IOobject::NO_REGISTER
+                    procPointMesh.thisDb()
                 );
-                IOListRef<label>(ioAddr, boundaryProcAddressing).write();
+                IOList<label>::writeContents(ioAddr, boundaryProcAddressing);
             }
         }
 
@@ -1013,15 +1010,15 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
 
         // pointProcAddressing
         ioAddr.rename("pointProcAddressing");
-        IOListRef<label>(ioAddr, procPointAddressing_[proci]).write();
+        IOList<label>::writeContents(ioAddr, procPointAddressing_[proci]);
 
         // faceProcAddressing
         ioAddr.rename("faceProcAddressing");
-        IOListRef<label>(ioAddr, procFaceAddressing_[proci]).write();
+        IOList<label>::writeContents(ioAddr, procFaceAddressing_[proci]);
 
         // cellProcAddressing
         ioAddr.rename("cellProcAddressing");
-        IOListRef<label>(ioAddr, procCellAddressing_[proci]).write();
+        IOList<label>::writeContents(ioAddr, procCellAddressing_[proci]);
 
         // Write patch map for backwards compatibility.
         // (= identity map for original patches, -1 for processor patches)
@@ -1031,7 +1028,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
 
         // boundaryProcAddressing
         ioAddr.rename("boundaryProcAddressing");
-        IOListRef<label>(ioAddr, procBoundaryAddr).write();
+        IOList<label>::writeContents(ioAddr, procBoundaryAddr);
     }
 
 
diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
index 56eaa1d4d9c..d4611d3f25b 100644
--- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
+++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2016-2024 OpenCFD Ltd.
+    Copyright (C) 2016-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -502,7 +502,7 @@ void writeMaps
 
     Info<< "    pointProcAddressing" << endl;
     ioAddr.rename("pointProcAddressing");
-    IOListRef<label>(ioAddr, pointProcAddressing).write();
+    IOList<label>::writeContents(ioAddr, pointProcAddressing);
 
     // From processor face to reconstructed mesh face
     Info<< "    faceProcAddressing" << endl;
@@ -551,13 +551,13 @@ void writeMaps
     // From processor cell to reconstructed mesh cell
     Info<< "    cellProcAddressing" << endl;
     ioAddr.rename("cellProcAddressing");
-    IOListRef<label>(ioAddr, cellProcAddressing).write();
+    IOList<label>::writeContents(ioAddr, cellProcAddressing);
 
 
     // From processor patch to reconstructed mesh patch
     Info<< "    boundaryProcAddressing" << endl;
     ioAddr.rename("boundaryProcAddressing");
-    IOListRef<label>(ioAddr, boundProcAddressing).write();
+    IOList<label>::writeContents(ioAddr, boundProcAddressing);
 
     Info<< endl;
 }
diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
index 305ec95aca6..4ac8fd1acb6 100644
--- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
+++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2017 OpenFOAM Foundation
-    Copyright (C) 2015-2024 OpenCFD Ltd.
+    Copyright (C) 2015-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -461,19 +461,12 @@ void writeDecomposition
 {
     // Write the decomposition as labelList for use with 'manual'
     // decomposition method.
-    IOListRef<label>
+    IOList<label>::writeContents
     (
-        IOobject
-        (
-            "cellDecomposition",
-            mesh.facesInstance(),  // mesh read from facesInstance
-            mesh,
-            IOobjectOption::NO_READ,
-            IOobjectOption::NO_WRITE,
-            IOobjectOption::NO_REGISTER
-        ),
+        // NB: mesh read from facesInstance
+        IOobject("cellDecomposition", mesh.facesInstance(), mesh),
         decomp
-    ).write();
+    );
 
     InfoOrPout
         << "Writing wanted cell distribution to volScalarField " << name
@@ -991,7 +984,8 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
             polyMesh::meshSubDir,
             mesh.thisDb(),
             IOobjectOption::NO_READ,
-            IOobjectOption::AUTO_WRITE
+            IOobjectOption::AUTO_WRITE,
+            IOobjectOption::REGISTER
         ),
         distMap()
     );
@@ -3029,20 +3023,17 @@ int main(int argc, char *argv[])
                 {
                     auto oldHandler = fileOperation::fileHandler(writeHandler);
 
-                    IOmapDistributePolyMeshRef
+                    IOmapDistributePolyMesh::writeContents
                     (
                         IOobject
                         (
                             "procAddressing",
                             areaProcMeshPtr->facesInstance(),
                             faMesh::meshSubDir,
-                            areaProcMeshPtr->thisDb(),
-                            IOobjectOption::NO_READ,
-                            IOobjectOption::NO_WRITE,
-                            IOobjectOption::NO_REGISTER
+                            areaProcMeshPtr->thisDb()
                         ),
                         faDistMap
-                    ).write();
+                    );
 
                     areaProcMeshPtr->write();
 
diff --git a/src/OpenFOAM/db/IOobjects/IOList/IOList.C b/src/OpenFOAM/db/IOobjects/IOList/IOList.C
index a6a0bbb2002..1e535c861d4 100644
--- a/src/OpenFOAM/db/IOobjects/IOList/IOList.C
+++ b/src/OpenFOAM/db/IOobjects/IOList/IOList.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2016-2024 OpenCFD Ltd.
+    Copyright (C) 2016-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -118,7 +118,7 @@ template<class T>
 Foam::IOListRef<T>::IOListRef
 (
     const IOobject& io,
-    const List<T>& content
+    const UList<T>& content
 )
 :
     regIOobject(io),
@@ -143,6 +143,23 @@ Foam::List<T> Foam::IOList<T>::readContents(const IOobject& io)
 }
 
 
+template<class T>
+void Foam::IOList<T>::writeContents
+(
+    const IOobject& io,
+    const UList<T>& content
+)
+{
+    IOListRef<T> writer
+    (
+        IOobject(io, IOobjectOption::NO_REGISTER),
+        content
+    );
+
+    writer.write();
+}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class T>
@@ -156,7 +173,7 @@ bool Foam::IOList<T>::writeData(Ostream& os) const
 template<class T>
 bool Foam::IOListRef<T>::writeData(Ostream& os) const
 {
-    os << contentRef_.cref();
+    os << contentRef_;
     return os.good();
 }
 
diff --git a/src/OpenFOAM/db/IOobjects/IOList/IOList.H b/src/OpenFOAM/db/IOobjects/IOList/IOList.H
index 636fab73dbb..40f62c6d032 100644
--- a/src/OpenFOAM/db/IOobjects/IOList/IOList.H
+++ b/src/OpenFOAM/db/IOobjects/IOList/IOList.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2018-2024 OpenCFD Ltd.
+    Copyright (C) 2018-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -96,6 +96,10 @@ public:
         //- Read and return contents. The IOobject is never registered
         static List<T> readContents(const IOobject& io);
 
+        //- Write contents. The IOobject is never registered.
+        //  Uses IOListRef internally.
+        static void writeContents(const IOobject& io, const UList<T>& content);
+
 
     //- Destructor
     virtual ~IOList() = default;
@@ -121,7 +125,7 @@ public:
                           Class IOListRef Declaration
 \*---------------------------------------------------------------------------*/
 
-//- A IOList wrapper for writing external data.
+//- A IOList wrapper for writing external List data
 template<class T>
 class IOListRef
 :
@@ -130,7 +134,7 @@ class IOListRef
     // Private Data
 
         //- Reference to the external content
-        refPtr<List<T>> contentRef_;
+        UList<T> contentRef_;
 
 
 public:
@@ -161,7 +165,7 @@ public:
     // Constructors
 
         //- Construct from IOobject and const data reference
-        IOListRef(const IOobject& io, const List<T>& content);
+        IOListRef(const IOobject& io, const UList<T>& content);
 
 
     //- Destructor
@@ -171,10 +175,9 @@ public:
     // Member Functions
 
         //- Allow cast to const content
-        //  Fatal if content is not set
-        operator const List<T>&() const
+        operator const UList<T>&() const
         {
-            return contentRef_.cref();
+            return contentRef_;
         }
 
         //- The writeData method for regIOobject write operation
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C
index 8f35bbedaa2..0557a63f547 100644
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2015 OpenFOAM Foundation
-    Copyright (C) 2022-2024 OpenCFD Ltd.
+    Copyright (C) 2022-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -124,6 +124,23 @@ Foam::IOmapDistributePolyMeshRef::IOmapDistributePolyMeshRef
 ///     contentRef_.ref(map);  // writable reference
 /// }
 
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+void Foam::IOmapDistributePolyMesh::writeContents
+(
+    const IOobject& io,
+    const mapDistributePolyMesh& map
+)
+{
+    IOmapDistributePolyMeshRef writer
+    (
+        IOobject(io, IOobjectOption::NO_REGISTER),
+        map
+    );
+
+    writer.write();
+}
+
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.H
index b0d85a2afd7..92fb1390c62 100644
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2015 OpenFOAM Foundation
-    Copyright (C) 2022-2024 OpenCFD Ltd.
+    Copyright (C) 2022-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -88,6 +88,17 @@ public:
         );
 
 
+    // Factory Methods
+
+        //- Write contents. The IOobject is never registered.
+        //  Uses IOmapDistributePolyMeshRef internally.
+        static void writeContents
+        (
+            const IOobject& io,
+            const mapDistributePolyMesh& map
+        );
+
+
     //- Destructor
     virtual ~IOmapDistributePolyMesh() = default;
 
diff --git a/src/conversion/ccm/reader/ccmReader.H b/src/conversion/ccm/reader/ccmReader.H
index 147c320a4d8..ab05dc2c0ee 100644
--- a/src/conversion/ccm/reader/ccmReader.H
+++ b/src/conversion/ccm/reader/ccmReader.H
@@ -393,7 +393,7 @@ private:
         (
             const objectRegistry& registry,
             const word& propertyName,
-            const labelList& list,
+            const labelUList& list,
             IOstreamOption streamOpt
         ) const;
 
diff --git a/src/conversion/ccm/reader/ccmReaderAux.C b/src/conversion/ccm/reader/ccmReaderAux.C
index 3e119be25c0..eb5167095ab 100644
--- a/src/conversion/ccm/reader/ccmReaderAux.C
+++ b/src/conversion/ccm/reader/ccmReaderAux.C
@@ -145,7 +145,7 @@ void Foam::ccm::reader::writeMeshLabelList
 (
     const objectRegistry& registry,
     const word& propertyName,
-    const labelList& list,
+    const labelUList& list,
     IOstreamOption streamOpt
 ) const
 {
diff --git a/src/conversion/common/reader/meshReader.H b/src/conversion/common/reader/meshReader.H
index 68baf6a7750..3bd02e90bc1 100644
--- a/src/conversion/common/reader/meshReader.H
+++ b/src/conversion/common/reader/meshReader.H
@@ -192,7 +192,7 @@ private:
         (
             const objectRegistry& registry,
             const word& propertyName,
-            const labelList& list,
+            const labelUList& list,
             IOstreamOption streamOpt
         ) const;
 
diff --git a/src/conversion/common/reader/meshReaderAux.C b/src/conversion/common/reader/meshReaderAux.C
index d4b4d5f426e..bdf234e9494 100644
--- a/src/conversion/common/reader/meshReaderAux.C
+++ b/src/conversion/common/reader/meshReaderAux.C
@@ -108,7 +108,7 @@ void Foam::meshReader::writeMeshLabelList
 (
     const objectRegistry& registry,
     const word& propertyName,
-    const labelList& list,
+    const labelUList& list,
     IOstreamOption streamOpt
 ) const
 {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.C
index 78bb1bfe48d..e3f66c35037 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.C
@@ -101,8 +101,8 @@ Foam::hexRef8Data::hexRef8Data
 (
     const IOobject& io,
     const hexRef8Data& data,
-    const labelList& cellMap,
-    const labelList& pointMap
+    const labelUList& cellMap,
+    const labelUList& pointMap
 )
 {
     if (data.cellLevelPtr_)
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H
index 8363c3839a8..9e5b4706f6e 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H
@@ -93,8 +93,8 @@ public:
         (
             const IOobject& io,
             const hexRef8Data&,
-            const labelList& cellMap,
-            const labelList& pointMap
+            const labelUList& cellMap,
+            const labelUList& pointMap
         );
 
         //- Construct from multiple hexRef8Data
diff --git a/src/parallel/decompose/faDecompose/faMeshDecomposition.C b/src/parallel/decompose/faDecompose/faMeshDecomposition.C
index 006b556e5ad..63806592796 100644
--- a/src/parallel/decompose/faDecompose/faMeshDecomposition.C
+++ b/src/parallel/decompose/faDecompose/faMeshDecomposition.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2016-2017 Wikki Ltd
-    Copyright (C) 2018-2024 OpenCFD Ltd.
+    Copyright (C) 2018-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -1318,19 +1318,19 @@ bool Foam::faMeshDecomposition::writeDecomposition()
 
         // pointProcAddressing
         ioAddr.rename("pointProcAddressing");
-        IOListRef<label>(ioAddr, procPatchPointAddressing_[procI]).write();
+        IOList<label>::writeContents(ioAddr, procPatchPointAddressing_[procI]);
 
         // edgeProcAddressing
         ioAddr.rename("edgeProcAddressing");
-        IOListRef<label>(ioAddr, procEdgeAddressing_[procI]).write();
+        IOList<label>::writeContents(ioAddr, procEdgeAddressing_[procI]);
 
         // faceProcAddressing
         ioAddr.rename("faceProcAddressing");
-        IOListRef<label>(ioAddr, procFaceAddressing_[procI]).write();
+        IOList<label>::writeContents(ioAddr, procFaceAddressing_[procI]);
 
         // boundaryProcAddressing
         ioAddr.rename("boundaryProcAddressing");
-        IOListRef<label>(ioAddr, procBoundaryAddressing_[procI]).write();
+        IOList<label>::writeContents(ioAddr, procBoundaryAddressing_[procI]);
     }
 
 
diff --git a/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C b/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C
index 4f6002839da..8786ffb3955 100644
--- a/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C
+++ b/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2021-2024 OpenCFD Ltd.
+    Copyright (C) 2021-2025 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -693,19 +693,19 @@ void Foam::faMeshReconstructor::writeAddressing
 
     // boundaryProcAddressing
     ioAddr.rename("boundaryProcAddressing");
-    IOListRef<label>(ioAddr, faBoundaryProcAddr).write();
+    IOList<label>::writeContents(ioAddr, faBoundaryProcAddr);
 
     // faceProcAddressing
     ioAddr.rename("faceProcAddressing");
-    IOListRef<label>(ioAddr, faFaceProcAddr).write();
+    IOList<label>::writeContents(ioAddr, faFaceProcAddr);
 
     // pointProcAddressing
     ioAddr.rename("pointProcAddressing");
-    IOListRef<label>(ioAddr, faPointProcAddr).write();
+    IOList<label>::writeContents(ioAddr, faPointProcAddr);
 
     // edgeProcAddressing
     ioAddr.rename("edgeProcAddressing");
-    IOListRef<label>(ioAddr, faEdgeProcAddr).write();
+    IOList<label>::writeContents(ioAddr, faEdgeProcAddr);
 }
 
 
@@ -760,7 +760,7 @@ void Foam::faMeshReconstructor::writeMesh
         IOobject io(fullMesh.boundary());
 
         io.rename("faceLabels");
-        IOListRef<label>(io, singlePatchFaceLabels).write();
+        IOList<label>::writeContents(io, singlePatchFaceLabels);
 
         fullMesh.boundary().write();
 
-- 
GitLab


From 01727c84f13e567e35d813245cc7a50892ff1aa4 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 2 Apr 2025 12:01:28 +0200
Subject: [PATCH 3/5] ENH: use gMinMax() instead of separate gMin(), gMax()

- for reciprocal values, gMinMax() first and then calculate the
  reciprocal, which avoids creating temporaries

STYLE: prefer MinMax to separate min/max accounting

COMP: namespace qualify min/max for deltaT, CourantNo, etc (#3348)
---
 .../solvers/combustion/PDRFoam/setDeltaT.H    |   6 +-
 .../solvers/combustion/chemFoam/setDeltaT.H   |   3 +-
 .../fireFoam/setMultiRegionDeltaT.H           |  13 +-
 .../combustion/reactingFoam/setRDeltaT.H      |  24 ++--
 .../compressible/rhoCentralFoam/setRDeltaT.H  |  10 +-
 .../compressible/rhoPimpleFoam/setRDeltaT.H   |  26 ++--
 .../fluid/compressibleMultiRegionCourantNo.H  |   2 +-
 ...woPhaseRadCoupledMixedFvPatchScalarField.C |  37 +++--
 .../fluid/compressibleMultiRegionCourantNo.H  |   6 +-
 .../fluid/compressibleMultiRegionCourantNo.H  |   4 +-
 .../include/setInitialMultiRegionDeltaT.H     |   6 +-
 .../include/setMultiRegionDeltaT.H            |  12 +-
 .../solid/solidRegionDiffusionNo.H            |   2 +-
 .../heatTransfer/solidFoam/solidDiffusionNo.H |   2 +-
 .../incompressible/pimpleFoam/setRDeltaT.H    |  26 ++--
 .../lagrangian/coalChemistryFoam/setRDeltaT.H |  18 ++-
 .../reactingParcelFoam/setMultiRegionDeltaT.H |  11 +-
 .../reactingParcelFoam/setRDeltaT.H           |  18 ++-
 .../solvers/multiphase/VoF/setDeltaT.H        |   7 +-
 .../solvers/multiphase/VoF/setRDeltaT.H       |  25 ++--
 .../multiphase/cavitatingFoam/setDeltaT.H     |   7 +-
 .../cavitatingFoam/setInitialDeltaT.H         |   8 +-
 .../setDeltaT.H                               |  12 +-
 .../reactingMultiphaseEulerFoam/setRDeltaT.H  |   6 +-
 .../reactingTwoPhaseEulerFoam/CourantNos.H    |   2 +-
 .../reactingTwoPhaseEulerFoam/setRDeltaT.H    |   6 +-
 .../multiphase/twoPhaseEulerFoam/CourantNos.H |   2 +-
 .../test/fieldMapping/Test-fieldMapping.C     |  27 ++--
 applications/test/hexRef8/Test-hexRef8.C      |  27 ++--
 .../advanced/refineHexMesh/refineHexMesh.C    |  27 ++--
 .../mesh/advanced/selectCells/edgeStats.C     | 123 +++++++++--------
 .../snappyRefineMesh/snappyRefineMesh.C       | 119 ++++++++--------
 .../mesh/manipulation/refineMesh/refineMesh.C | 116 +++++++---------
 .../createBoxTurb/createBoxTurb.C             |  14 +-
 .../setAlphaField/setAlphaField.C             |  13 +-
 src/combustionModels/EDC/EDC.C                |   5 +-
 .../interfaceTrackingFvMesh.C                 |   7 +-
 .../motionSmoother/motionSmootherAlgo.C       |  17 ++-
 .../componentDisplacementMotionSolver.C       |   4 +-
 .../displacementInterpolationMotionSolver.C   |  23 ++--
 .../displacementLayeredMotionMotionSolver.C   |  24 ++--
 .../edgeLimitedFaGrad/edgeLimitedFaGrads.C    |  18 ++-
 .../faceLimitedFaGrad/faceLimitedFaGrads.C    |  18 ++-
 .../cfdTools/general/include/setDeltaT.H      |   6 +-
 .../general/include/setInitialDeltaT.H        |   4 +-
 ...lectrostaticDepositionFvPatchScalarField.C |  13 +-
 .../mappedField/mappedFieldFvPatchField.C     |   9 +-
 .../mappedMixedFieldFvPatchField.C            |   9 +-
 .../mappedFixedValueFvPatchField.C            |   9 +-
 .../mappedMixed/mappedMixedFvPatchField.C     |   9 +-
 .../timeVaryingMappedFixedValueFvPatchField.C |   9 +-
 .../turbulentDFSEMInletFvPatchVectorField.C   |   4 +-
 .../waveSurfacePressureFvPatchScalarField.C   |   8 +-
 .../ddtSchemes/ddtScheme/ddtScheme.C          |  16 +--
 .../cellLimitedGrad/cellLimitedGrad.C         |   9 +-
 .../faceLimitedGrad/faceLimitedGrads.C        |  18 ++-
 .../averageNeighbourFvGeometryScheme.C        |   8 +-
 .../highAspectRatio/cellAspectRatio.C         |   7 +-
 .../highAspectRatioFvGeometryScheme.C         |   7 +-
 .../field/AMIWeights/AMIWeights.C             | 128 +++++++++---------
 src/functionObjects/field/yPlus/yPlus.C       |  17 ++-
 ...meVaryingMappedFixedValuePointPatchField.C |   9 +-
 .../effectivenessTable/effectivenessTable.C   |  16 +--
 .../Templates/KinematicCloud/KinematicCloud.C |  11 +-
 .../clouds/Templates/MPPICCloud/MPPICCloud.C  |  11 +-
 .../snappyHexMeshDriver/snappyLayerDriver.C   |   3 +-
 .../snappyHexMeshDriver/snappySnapDriver.C    |   6 +-
 .../AMIInterpolation/AMIInterpolation.C       |  42 +++---
 .../cyclicPeriodicAMIPolyPatch.C              |  35 +++--
 .../PatchFunction1/MappedFile/MappedFile.C    |  10 +-
 .../regularisationPDE/Helmoltz/Helmholtz.C    |   2 +-
 .../ThermalPhaseChangePhaseSystem.C           |  33 +++--
 ...allBoilingWallFunctionFvPatchScalarField.C |  33 ++---
 ...ixedMultiPhaseHeatFluxFvPatchScalarField.C |   7 +-
 .../reactingOneDim/reactingOneDim.C           |   7 +-
 .../thermoSingleLayer/thermoSingleLayer.C     |   7 +-
 ...pedMassWallTemperatureFvPatchScalarField.C |   9 +-
 .../thermalBaffle1DFvPatchScalarField.C       |  10 +-
 ...tureCoupledBaffleMixedFvPatchScalarField.C |   9 +-
 .../enthalpySorptionFvPatchScalarField.C      |   8 +-
 .../speciesSorptionFvPatchScalarField.C       |   8 +-
 .../movingConeTopoFvMesh.C                    |   4 +-
 .../isoAdvection/isoAdvection.C               |   8 +-
 .../isoAdvection/isoAdvectionTemplates.C      |  22 +--
 84 files changed, 837 insertions(+), 646 deletions(-)

diff --git a/applications/solvers/combustion/PDRFoam/setDeltaT.H b/applications/solvers/combustion/PDRFoam/setDeltaT.H
index 365126ce90c..177fc1fa7fe 100644
--- a/applications/solvers/combustion/PDRFoam/setDeltaT.H
+++ b/applications/solvers/combustion/PDRFoam/setDeltaT.H
@@ -36,11 +36,13 @@ Description
 if (adjustTimeStep)
 {
     scalar maxDeltaTFact = maxCo/(CoNum + StCoNum + SMALL);
-    scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
+
+    const scalar deltaTFact =
+        Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
             deltaTFact*runTime.deltaTValue(),
             maxDeltaT
diff --git a/applications/solvers/combustion/chemFoam/setDeltaT.H b/applications/solvers/combustion/chemFoam/setDeltaT.H
index ef50a970269..93f68ceb6c9 100644
--- a/applications/solvers/combustion/chemFoam/setDeltaT.H
+++ b/applications/solvers/combustion/chemFoam/setDeltaT.H
@@ -1,5 +1,6 @@
 if (adjustTimeStep)
 {
-    runTime.setDeltaT(min(dtChem, maxDeltaT));
+    runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
+
     Info<< "deltaT = " <<  runTime.deltaTValue() << endl;
 }
diff --git a/applications/solvers/combustion/fireFoam/setMultiRegionDeltaT.H b/applications/solvers/combustion/fireFoam/setMultiRegionDeltaT.H
index 31c9e675fcd..a5ac0fcc9a6 100644
--- a/applications/solvers/combustion/fireFoam/setMultiRegionDeltaT.H
+++ b/applications/solvers/combustion/fireFoam/setMultiRegionDeltaT.H
@@ -54,9 +54,18 @@ if (adjustTimeStep)
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
-            dt0*min(min(TFactorFluid, min(TFactorFilm, TFactorSolid)), 1.2),
+            dt0
+          * Foam::min
+            (
+                Foam::min
+                (
+                    TFactorFluid,
+                    Foam::min(TFactorFilm, TFactorSolid)
+                ),
+                1.2
+            ),
             maxDeltaT
         )
     );
diff --git a/applications/solvers/combustion/reactingFoam/setRDeltaT.H b/applications/solvers/combustion/reactingFoam/setRDeltaT.H
index 7b449fd9007..67a2b00f914 100644
--- a/applications/solvers/combustion/reactingFoam/setRDeltaT.H
+++ b/applications/solvers/combustion/reactingFoam/setRDeltaT.H
@@ -85,9 +85,11 @@ License
         // Limit the largest time scale (=> smallest reciprocal time)
         rDeltaT.clamp_min(1/maxDeltaT);
 
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "    Flow        = "
-            << 1/gMax(rDeltaT.primitiveField()) << ", "
-            << 1/gMin(rDeltaT.primitiveField()) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 
     // Heat release rate time scale
@@ -100,9 +102,11 @@ License
 
         rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
 
+        auto limits = gMinMax(rDeltaTT.field());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "    Temperature = "
-            << 1/(gMax(rDeltaTT.field()) + VSMALL) << ", "
-            << 1/(gMin(rDeltaTT.field()) + VSMALL) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 
     // Reaction rate time scale
@@ -152,9 +156,11 @@ License
         {
             rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY);
 
+            auto limits = gMinMax(rDeltaTY.field());
+            limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
             Info<< "    Composition = "
-                << 1/(gMax(rDeltaTY.field()) + VSMALL) << ", "
-                << 1/(gMin(rDeltaTY.field()) + VSMALL) << endl;
+                << limits.min() << ", " << limits.max() << endl;
         }
         else
         {
@@ -184,9 +190,11 @@ License
     // Update tho boundary values of the reciprocal time-step
     rDeltaT.correctBoundaryConditions();
 
+    auto limits = gMinMax(rDeltaT.field());
+    limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
     Info<< "    Overall     = "
-        << 1/gMax(rDeltaT.primitiveField())
-        << ", " << 1/gMin(rDeltaT.primitiveField()) << endl;
+        << limits.min() << ", " << limits.max() << endl;
 }
 
 
diff --git a/applications/solvers/compressible/rhoCentralFoam/setRDeltaT.H b/applications/solvers/compressible/rhoCentralFoam/setRDeltaT.H
index 5e2a2b302ca..8f9560b7429 100644
--- a/applications/solvers/compressible/rhoCentralFoam/setRDeltaT.H
+++ b/applications/solvers/compressible/rhoCentralFoam/setRDeltaT.H
@@ -23,7 +23,11 @@
 
     fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
 
-    Info<< "Flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
+        Info<< "Flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 }
diff --git a/applications/solvers/compressible/rhoPimpleFoam/setRDeltaT.H b/applications/solvers/compressible/rhoPimpleFoam/setRDeltaT.H
index e818402eff6..51ecac9f07a 100644
--- a/applications/solvers/compressible/rhoPimpleFoam/setRDeltaT.H
+++ b/applications/solvers/compressible/rhoPimpleFoam/setRDeltaT.H
@@ -52,18 +52,26 @@
     // Update the boundary values of the reciprocal time-step
     rDeltaT.correctBoundaryConditions();
 
-    Info<< "Flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
+        Info<< "Flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 
     if (rDeltaTSmoothingCoeff < 1.0)
     {
         fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
     }
 
-    Info<< "Smoothed flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
+        Info<< "Smoothed flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 
     // Limit rate of change of time scale
     // - reduce as much as required
@@ -78,8 +86,10 @@
             rDeltaT0
            *max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
 
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "Damped flow time scale min/max = "
-            << gMin(1/rDeltaT.primitiveField())
-            << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 }
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H
index 3ca2f685819..5ccc00d3ad4 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H
@@ -1,7 +1,7 @@
     scalar CoNum = -GREAT;
     forAll(fluidRegions, regionI)
     {
-        CoNum = max
+        CoNum = Foam::max
         (
             compressibleCourantNo
             (
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
index 33d1c05548a..a0232c0b1cd 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
@@ -387,15 +387,18 @@ updateCoeffs()
         {
             scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
 
-                Info<< "T solid : " << nl << endl;
-
-                Info
-                    << " heat transfer rate from solid:" << Q
-                    << " walltemperature "
-                    << " min:" << gMin(Tp)
-                    << " max:" << gMax(Tp)
-                    << " avg:" << gAverage(Tp) << nl
-                    << endl;
+            auto limits = gMinMax(Tp);
+            auto avg = gAverage(Tp);
+
+            Info<< "T solid : " << nl << endl;
+
+            Info
+                << " heat transfer rate from solid:" << Q
+                << " walltemperature "
+                << " min:" << limits.min()
+                << " max:" << limits.max()
+                << " avg:" << avg << nl
+                << endl;
         }
     }
     else if (regionType_ == fluid)
@@ -445,10 +448,16 @@ updateCoeffs()
             scalarField qLiq((Tp - Tc)*KdeltaLiq);
             scalarField qVap((Tp - Tv.patchInternalField())*KdeltaVap);
 
+            auto infoT = gMinMax(Tp);
+            auto avgT = gAverage(Tp);
+
+            auto infoLiq = gMinMax(qLiq);
+            auto infoVap = gMinMax(qVap);
+
             Info<< "T flow : " << nl << endl;
 
-            Info<< "  qLiq: " << gMin(qLiq) << " - " << gMax(qLiq) << endl;
-            Info<< "  qVap: " << gMin(qVap) << " - " << gMax(qVap) << endl;
+            Info<< "  qLiq: " << infoLiq.min() << " - " << infoLiq.max() << nl
+                << "  qVap: " << infoVap.min() << " - " << infoVap.max() << nl;
 
             scalar QLiq = gSum(qLiq*patch().magSf());
             scalar QVap = gSum(qVap*patch().magSf());
@@ -457,9 +466,9 @@ updateCoeffs()
             Info<<  " Heat transfer to Vap: " << QVap << endl;
 
             Info<< " walltemperature "
-                << " min:" << gMin(Tp)
-                << " max:" << gMax(Tp)
-                << " avg:" << gAverage(Tp)
+                << " min:" << infoT.min()
+                << " max:" << infoT.max()
+                << " avg:" << avgT
                 << endl;
         }
     }
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H
index 290bb596cf4..392d74f6a3c 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H
@@ -31,7 +31,7 @@
             );
 
 
-            CoNum =
+            scalar regionCoNum =
                 0.5*gMax
                 (
                     sumPhi/fluidRegions[regioni].V().field()
@@ -41,9 +41,9 @@
             (
                 fvc::surfaceSum(mag(phi1 - phi2))().primitiveField()
               / fluidRegions[regioni].V().field()
-            )*runTime.deltaTValue(),
+            )*runTime.deltaTValue();
 
-            CoNum = max(UrCoNum, CoNum);
+            CoNum = Foam::max(CoNum, Foam::max(regionCoNum, UrCoNum));
         }
     }
 
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H
index dd129047dc3..d5b5c7ceaa4 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H
@@ -2,7 +2,7 @@
 
     forAll(fluidRegions, regioni)
     {
-        CoNum = max
+        CoNum = Foam::max
         (
             compressibleCourantNo
             (
@@ -17,7 +17,7 @@
 /*
     forAll(porousFluidRegions, porousi)
     {
-        CoNum = max
+        CoNum = Foam::max
         (
             compressibleCourantNo
             (
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H
index 09f4a717a96..8be63457654 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H
@@ -47,10 +47,10 @@ if (adjustTimeStep)
 
         runTime.setDeltaT
         (
-            min
+            Foam::min
             (
-                min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
-                min(runTime.deltaTValue(), maxDeltaT)
+                Foam::min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
+                Foam::min(runTime.deltaTValue(), maxDeltaT)
             )
         );
         Info<< "deltaT = " <<  runTime.deltaTValue() << endl;
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H
index 8eed82dd5c8..d81d374f41c 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H
@@ -48,18 +48,14 @@ if (adjustTimeStep)
     scalar maxDeltaTFluid = maxCo/(CoNum + SMALL);
     scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
 
-    scalar deltaTFluid =
-        min
-        (
-            min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
-            1.2
-        );
+    const scalar deltaTFluid =
+        Foam::min(Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
-            min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
+            Foam::min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
             maxDeltaT
         )
     );
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H
index 6e87fb92034..8c6111d2767 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H
@@ -22,7 +22,7 @@ forAll(solidRegions, i)
     tmp<volScalarField> trho = thermo.rho();
     const volScalarField& rho = trho();
 
-    DiNum = max
+    DiNum = Foam::max
     (
         solidRegionDiffNo
         (
diff --git a/applications/solvers/heatTransfer/solidFoam/solidDiffusionNo.H b/applications/solvers/heatTransfer/solidFoam/solidDiffusionNo.H
index 90317f67c61..3484c35b9fe 100644
--- a/applications/solvers/heatTransfer/solidFoam/solidDiffusionNo.H
+++ b/applications/solvers/heatTransfer/solidFoam/solidDiffusionNo.H
@@ -17,7 +17,7 @@ scalar DiNum = -GREAT;
     tmp<volScalarField> trho = thermo.rho();
     const volScalarField& rho = trho();
 
-    DiNum = max
+    DiNum = Foam::max
     (
         solidRegionDiffNo
         (
diff --git a/applications/solvers/incompressible/pimpleFoam/setRDeltaT.H b/applications/solvers/incompressible/pimpleFoam/setRDeltaT.H
index 962bfa8766c..3acc01c5fa3 100644
--- a/applications/solvers/incompressible/pimpleFoam/setRDeltaT.H
+++ b/applications/solvers/incompressible/pimpleFoam/setRDeltaT.H
@@ -36,18 +36,26 @@
     // Update the boundary values of the reciprocal time-step
     rDeltaT.correctBoundaryConditions();
 
-    Info<< "Flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
+        Info<< "Flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 
     if (rDeltaTSmoothingCoeff < 1.0)
     {
         fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
     }
 
-    Info<< "Smoothed flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
+        Info<< "Smoothed flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 
     // Limit rate of change of time scale
     // - reduce as much as required
@@ -62,8 +70,10 @@
             rDeltaT0
            *max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
 
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "Damped flow time scale min/max = "
-            << gMin(1/rDeltaT.primitiveField())
-            << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 }
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H b/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H
index aabfd0e0156..745249cfdf6 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H
+++ b/applications/solvers/lagrangian/coalChemistryFoam/setRDeltaT.H
@@ -81,9 +81,11 @@ License
         // Limit the largest time scale (=> smallest reciprocal time)
         rDeltaT.clamp_min(1/maxDeltaT);
 
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "    Flow        = "
-            << gMin(1/rDeltaT.primitiveField()) << ", "
-            << gMax(1/rDeltaT.primitiveField()) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 
     // Reaction source time scale
@@ -106,9 +108,11 @@ License
 
         rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
 
+        auto limits = gMinMax(rDeltaTT.field());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "    Temperature = "
-            << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
-            << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 
     // Update tho boundary values of the reciprocal time-step
@@ -128,9 +132,11 @@ License
         rDeltaT.clamp_min(rDeltaT0_damped());
     }
 
+    auto limits = gMinMax(rDeltaT.primitiveField());
+    limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
     Info<< "    Overall     = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+        << limits.min() << ", " << limits.max() << endl;
 }
 
 
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/setMultiRegionDeltaT.H b/applications/solvers/lagrangian/reactingParcelFoam/setMultiRegionDeltaT.H
index 70d55cb8c87..1257447f3ec 100644
--- a/applications/solvers/lagrangian/reactingParcelFoam/setMultiRegionDeltaT.H
+++ b/applications/solvers/lagrangian/reactingParcelFoam/setMultiRegionDeltaT.H
@@ -36,13 +36,18 @@ Description
 if (adjustTimeStep)
 {
     const scalar maxDeltaTFact =
-        min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
+        Foam::min
+        (
+            maxCo/(CoNum + SMALL),
+            maxCo/(surfaceFilm.CourantNumber() + SMALL)
+        );
+
     const scalar deltaTFact =
-        min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
+        Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
             deltaTFact*runTime.deltaTValue(),
             maxDeltaT
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H b/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H
index 8ef4cd1eb23..42e187ed3c3 100644
--- a/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H
+++ b/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H
@@ -81,9 +81,11 @@ License
         // Limit the largest time scale (=> smallest reciprocal time)
         rDeltaT.clamp_min(1/maxDeltaT);
 
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "    Flow        = "
-            << gMin(1/rDeltaT.primitiveField()) << ", "
-            << gMax(1/rDeltaT.primitiveField()) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 
     // Reaction source time scale
@@ -105,9 +107,11 @@ License
 
         rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
 
+        auto limits = gMinMax(rDeltaTT.field());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "    Temperature = "
-            << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
-            << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 
     // Update the boundary values of the reciprocal time-step
@@ -130,9 +134,11 @@ License
     // Update the boundary values of the reciprocal time-step
     rDeltaT.correctBoundaryConditions();
 
+    auto limits = gMinMax(rDeltaT.primitiveField());
+    limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
     Info<< "    Overall     = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+        << limits.min() << ", " << limits.max() << endl;
 }
 
 
diff --git a/applications/solvers/multiphase/VoF/setDeltaT.H b/applications/solvers/multiphase/VoF/setDeltaT.H
index ac59647e7e8..79fbe90c4fd 100644
--- a/applications/solvers/multiphase/VoF/setDeltaT.H
+++ b/applications/solvers/multiphase/VoF/setDeltaT.H
@@ -36,13 +36,14 @@ Description
 if (adjustTimeStep)
 {
     scalar maxDeltaTFact =
-        min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
+        Foam::min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
 
-    scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
+    const scalar deltaTFact =
+        Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
             deltaTFact*runTime.deltaTValue(),
             maxDeltaT
diff --git a/applications/solvers/multiphase/VoF/setRDeltaT.H b/applications/solvers/multiphase/VoF/setRDeltaT.H
index b690f0accc6..bcc6e3b56d4 100644
--- a/applications/solvers/multiphase/VoF/setRDeltaT.H
+++ b/applications/solvers/multiphase/VoF/setRDeltaT.H
@@ -98,10 +98,13 @@
     // Update tho boundary values of the reciprocal time-step
     rDeltaT.correctBoundaryConditions();
 
-    Info<< "Flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
 
+        Info<< "Flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
     if (rDeltaTSmoothingCoeff < 1.0)
     {
         fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
@@ -125,9 +128,13 @@
         fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff);
     }
 
-    Info<< "Smoothed flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+    {
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
+        Info<< "Smoothed flow time scale min/max = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 
     // Limit rate of change of time scale (=> smallest reciprocal time)
     // - reduce as much as required
@@ -136,8 +143,10 @@
     {
         rDeltaT.clamp_min(rDeltaT0_damped());
 
+        auto limits = gMinMax(rDeltaT.primitiveField());
+        limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
         Info<< "Damped flow time scale min/max = "
-            << gMin(1/rDeltaT.primitiveField())
-            << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+            << limits.min() << ", " << limits.max() << endl;
     }
 }
diff --git a/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H b/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H
index e1e7427fe0d..1d2dd28f6bf 100644
--- a/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H
+++ b/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H
@@ -36,13 +36,14 @@ Description
 if (adjustTimeStep)
 {
     scalar maxDeltaTFact =
-        min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
+        Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
 
-    scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
+    const scalar deltaTFact =
+        Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
             deltaTFact*runTime.deltaTValue(),
             maxDeltaT
diff --git a/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H b/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H
index 69fbe573338..435b2e4b0b5 100644
--- a/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H
+++ b/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H
@@ -37,11 +37,15 @@ if (adjustTimeStep)
     if (CoNum > SMALL)
     {
         scalar maxDeltaTFact =
-            min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
+            Foam::min
+            (
+                maxCo/(CoNum + SMALL),
+                maxAcousticCo/(acousticCoNum + SMALL)
+            );
 
         runTime.setDeltaT
         (
-            min
+            Foam::min
             (
                 maxDeltaTFact*runTime.deltaTValue(),
                 maxDeltaT
diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/setDeltaT.H b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/setDeltaT.H
index 026fb506bbc..9a67a63d136 100644
--- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/setDeltaT.H
+++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/setDeltaT.H
@@ -36,13 +36,13 @@ Description
 if (adjustTimeStep)
 {
     scalar maxDeltaTFact =
-        min
+        Foam::min
         (
             maxCo/(CoNum + SMALL),
-            min
+            Foam::min
             (
                 maxAlphaCo/(alphaCoNum + SMALL),
-                min
+                Foam::min
                 (
                     maxAlphaDdt/(ddtAlphaNum + SMALL),
                     maxDi/(DiNum + SMALL)
@@ -50,16 +50,18 @@ if (adjustTimeStep)
             )
         );
 
-    scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
+    const scalar deltaTFact =
+        Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
             deltaTFact*runTime.deltaTValue(),
             maxDeltaT
         )
     );
+
     Info<< "deltaT = " <<  runTime.deltaTValue() << endl;
 }
 
diff --git a/applications/solvers/multiphase/reactingMultiphaseEulerFoam/setRDeltaT.H b/applications/solvers/multiphase/reactingMultiphaseEulerFoam/setRDeltaT.H
index 1d0c65b1539..c15dfe4a9f8 100644
--- a/applications/solvers/multiphase/reactingMultiphaseEulerFoam/setRDeltaT.H
+++ b/applications/solvers/multiphase/reactingMultiphaseEulerFoam/setRDeltaT.H
@@ -38,7 +38,9 @@
 
     fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
 
+    auto limits = gMinMax(rDeltaT.primitiveField());
+    limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
     Info<< "Flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+        << limits.min() << ", " << limits.max() << endl;
 }
diff --git a/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/CourantNos.H b/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/CourantNos.H
index 13c45ad51c1..1bd1d9d036b 100644
--- a/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/CourantNos.H
+++ b/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/CourantNos.H
@@ -8,5 +8,5 @@
 
     Info<< "Max Ur Courant Number = " << UrCoNum << endl;
 
-    CoNum = max(CoNum, UrCoNum);
+    CoNum = Foam::max(CoNum, UrCoNum);
 }
diff --git a/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/setRDeltaT.H b/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/setRDeltaT.H
index 10a7c9e0f09..45d9e6c74a2 100644
--- a/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/setRDeltaT.H
+++ b/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/setRDeltaT.H
@@ -31,7 +31,9 @@
 
     fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
 
+    auto limits = gMinMax(rDeltaT.primitiveField());
+    limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
+
     Info<< "Flow time scale min/max = "
-        << gMin(1/rDeltaT.primitiveField())
-        << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
+        << limits.min() << ", " << limits.max() << endl;
 }
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/CourantNos.H b/applications/solvers/multiphase/twoPhaseEulerFoam/CourantNos.H
index d828f32769d..96e1ece1ac2 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/CourantNos.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/CourantNos.H
@@ -8,5 +8,5 @@
 
     Info<< "Max Ur Courant Number = " << UrCoNum << endl;
 
-    CoNum = max(CoNum, UrCoNum);
+    CoNum = Foam::max(CoNum, UrCoNum);
 }
diff --git a/applications/test/fieldMapping/Test-fieldMapping.C b/applications/test/fieldMapping/Test-fieldMapping.C
index bb4ad0576bd..f2bd3a87c9c 100644
--- a/applications/test/fieldMapping/Test-fieldMapping.C
+++ b/applications/test/fieldMapping/Test-fieldMapping.C
@@ -262,13 +262,12 @@ int main(int argc, char *argv[])
 
         // Check constant profile
         {
-            const scalar max = gMax(one);
-            const scalar min = gMin(one);
+            auto limits =  gMinMax(one);
 
-            Info<< "Uniform one field min = " << min
-                << "  max = " << max << endl;
+            Info<< "Uniform one field min = "
+                << limits.min() << "  max = " << limits.max() << endl;
 
-            if (isNotEqual(max, 1) || isNotEqual(min, 1))
+            if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
             {
                 FatalErrorInFunction
                     << "Uniform volVectorField not preserved."
@@ -286,13 +285,12 @@ int main(int argc, char *argv[])
         {
             const scalarField diff = ccX-mesh.C().component(0);
 
-            const scalar max = gMax(diff);
-            const scalar min = gMin(diff);
+            auto limits =  gMinMax(diff);
 
-            Info<< "Linear profile field min = " << min
-                << "  max = " << max << endl;
+            Info<< "Linear profile field min = "
+                << limits.min() << "  max = " << limits.max() << endl;
 
-            if (isNotEqual(max, 0) || isNotEqual(min, 0))
+            if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
             {
                 FatalErrorInFunction
                     << "Linear profile not preserved."
@@ -309,13 +307,12 @@ int main(int argc, char *argv[])
         // Check face field mapping
         if (surfaceOne.size())
         {
-            const scalar max = gMax(surfaceOne.primitiveField());
-            const scalar min = gMin(surfaceOne.primitiveField());
+            auto limits =  gMinMax(surfaceOne.primitiveField());
 
-            Info<< "Uniform surface field min = " << min
-                << "  max = " << max << endl;
+            Info<< "Uniform surface field min = "
+                << limits.min() << "  max = " << limits.max() << endl;
 
-            if (isNotEqual(max, 1) || isNotEqual(min, 1))
+            if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
             {
                 FatalErrorInFunction
                     << "Uniform surfaceScalarField not preserved."
diff --git a/applications/test/hexRef8/Test-hexRef8.C b/applications/test/hexRef8/Test-hexRef8.C
index 12c6d5e38e4..f122a6a92ec 100644
--- a/applications/test/hexRef8/Test-hexRef8.C
+++ b/applications/test/hexRef8/Test-hexRef8.C
@@ -344,13 +344,12 @@ int main(int argc, char *argv[])
 
         // Check constant profile
         {
-            const scalar max = gMax(one);
-            const scalar min = gMin(one);
+            auto limits =  gMinMax(one);
 
-            Info<< "Uniform one field min = " << min
-                << "  max = " << max << endl;
+            Info<< "Uniform one field min = "
+                << limits.min() << "  max = " << limits.max() << endl;
 
-            if (isNotEqual(min, 1) || isNotEqual(max, 1))
+            if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
             {
                 FatalErrorInFunction
                     << "Uniform volVectorField not preserved."
@@ -368,13 +367,12 @@ int main(int argc, char *argv[])
         {
             const scalarField diff = ccX-mesh.C().component(0);
 
-            const scalar max = gMax(diff);
-            const scalar min = gMin(diff);
+            auto limits =  gMinMax(diff);
 
-            Info<< "Linear profile field min = " << min
-                << "  max = " << max << endl;
+            Info<< "Linear profile field min = "
+                << limits.min() << "  max = " << limits.max() << endl;
 
-            if (isNotEqual(min, 0) || isNotEqual(max, 0))
+            if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
             {
                 Info<< "Linear profile not preserved."
                     << " Min and max should both be 0.0. min:" << min
@@ -389,13 +387,12 @@ int main(int argc, char *argv[])
         // Check face field mapping
         if (surfaceOne.size())
         {
-            const scalar max = gMax(surfaceOne.primitiveField());
-            const scalar min = gMin(surfaceOne.primitiveField());
+            auto limits =  gMinMax(surfaceOne.primitiveField());
 
-            Info<< "Uniform surface field min = " << min
-                << "  max = " << max << endl;
+            Info<< "Uniform surface field min = "
+                << limits.min() << "  max = " << limits.max() << endl;
 
-            if (isNotEqual(min, 1) || isNotEqual(max, 1))
+            if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
             {
                 FatalErrorInFunction
                     << "Uniform surfaceScalarField not preserved."
diff --git a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C
index 0da12172dbf..fa387d01168 100644
--- a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C
+++ b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C
@@ -145,17 +145,22 @@ int main(int argc, char *argv[])
     hexRef8 meshCutter(mesh);
 
     // Some stats
-    Info<< "Read mesh:" << nl
-        << "    cells:" << mesh.globalData().nTotalCells() << nl
-        << "    faces:" << mesh.globalData().nTotalFaces() << nl
-        << "    points:" << mesh.globalData().nTotalPoints() << nl
-        << "    cellLevel :"
-        << " min:" << gMin(meshCutter.cellLevel())
-        << " max:" << gMax(meshCutter.cellLevel()) << nl
-        << "    pointLevel :"
-        << " min:" << gMin(meshCutter.pointLevel())
-        << " max:" << gMax(meshCutter.pointLevel()) << nl
-        << endl;
+    {
+        auto cellLimits = gMinMax(meshCutter.cellLevel());
+        auto pointLimits = gMinMax(meshCutter.pointLevel());
+
+        Info<< "Read mesh:" << nl
+            << "    cells:" << mesh.globalData().nTotalCells() << nl
+            << "    faces:" << mesh.globalData().nTotalFaces() << nl
+            << "    points:" << mesh.globalData().nTotalPoints() << nl
+            << "    cellLevel :"
+            << " min:" << cellLimits.min()
+            << " max:" << cellLimits.max() << nl
+            << "    pointLevel :"
+            << " min:" << pointLimits.min()
+            << " max:" << pointLimits.max() << nl
+            << endl;
+    }
 
 
     // Maintain 2:1 ratio
diff --git a/applications/utilities/mesh/advanced/selectCells/edgeStats.C b/applications/utilities/mesh/advanced/selectCells/edgeStats.C
index 579a989b4dc..1f54ceb7932 100644
--- a/applications/utilities/mesh/advanced/selectCells/edgeStats.C
+++ b/applications/utilities/mesh/advanced/selectCells/edgeStats.C
@@ -37,7 +37,6 @@ License
 const Foam::scalar Foam::edgeStats::edgeTol_ = 1e-3;
 
 
-
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 Foam::direction Foam::edgeStats::getNormalDir
@@ -45,26 +44,25 @@ Foam::direction Foam::edgeStats::getNormalDir
     const twoDPointCorrector* correct2DPtr
 ) const
 {
-    direction dir = 3;
-
     if (correct2DPtr)
     {
         const vector& normal = correct2DPtr->planeNormal();
 
-        if (mag(normal & vector(1, 0, 0)) > 1-edgeTol_)
+        if (mag(normal.x()) > 1-edgeTol_)
         {
-            dir = 0;
+            return vector::X;
         }
-        else if (mag(normal & vector(0, 1, 0)) > 1-edgeTol_)
+        else if (mag(normal.y()) > 1-edgeTol_)
         {
-            dir = 1;
+            return vector::Y;
         }
-        else if (mag(normal & vector(0, 0, 1)) > 1-edgeTol_)
+        else if (mag(normal.z()) > 1-edgeTol_)
         {
-            dir = 2;
+            return vector::Z;
         }
     }
-    return dir;
+
+    return direction(3);
 }
 
 
@@ -95,12 +93,9 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
         {
             Info<< "Correcting for 2D motion" << endl << endl;
 
-            autoPtr<twoDPointCorrector> correct2DPtr
-            (
-                new twoDPointCorrector(mesh)
-            );
+            twoDPointCorrector correct2D(mesh);
 
-            normalDir_ = getNormalDir(&correct2DPtr());
+            normalDir_ = getNormalDir(&correct2D);
         }
     }
 }
@@ -122,24 +117,15 @@ Foam::edgeStats::edgeStats
 
 Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
 {
-    label nX = 0;
-    label nY = 0;
-    label nZ = 0;
+    label nAny(0);
+    label nX(0);
+    label nY(0);
+    label nZ(0);
 
-    scalar minX = GREAT;
-    scalar maxX = -GREAT;
-    vector x(1, 0, 0);
-
-    scalar minY = GREAT;
-    scalar maxY = -GREAT;
-    vector y(0, 1, 0);
-
-    scalar minZ = GREAT;
-    scalar maxZ = -GREAT;
-    vector z(0, 0, 1);
-
-    scalar minOther = GREAT;
-    scalar maxOther = -GREAT;
+    scalarMinMax limitsAny(GREAT, -GREAT);
+    scalarMinMax limitsX(limitsAny);
+    scalarMinMax limitsY(limitsAny);
+    scalarMinMax limitsZ(limitsAny);
 
     const edgeList& edges = mesh_.edges();
 
@@ -151,58 +137,75 @@ Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
 
         eVec /= eMag;
 
-        if (mag(eVec & x) > 1-edgeTol_)
+        if (mag(eVec.x()) > 1-edgeTol_)
         {
-            minX = min(minX, eMag);
-            maxX = max(maxX, eMag);
+            limitsX.add(eMag);
             nX++;
         }
-        else if (mag(eVec & y) > 1-edgeTol_)
+        else if (mag(eVec.y()) > 1-edgeTol_)
         {
-            minY = min(minY, eMag);
-            maxY = max(maxY, eMag);
+            limitsY.add(eMag);
             nY++;
         }
-        else if (mag(eVec & z) > 1-edgeTol_)
+        else if (mag(eVec.z()) > 1-edgeTol_)
         {
-            minZ = min(minZ, eMag);
-            maxZ = max(maxZ, eMag);
+            limitsZ.add(eMag);
             nZ++;
         }
         else
         {
-            minOther = min(minOther, eMag);
-            maxOther = max(maxOther, eMag);
+            limitsAny.add(eMag);
+            nAny++;
         }
     }
 
     os  << "Mesh bounding box:" << boundBox(mesh_.points()) << nl << nl
         << "Mesh edge statistics:" << nl
-        << "    x aligned :  number:" << nX << "\tminLen:" << minX
-        << "\tmaxLen:" << maxX << nl
-        << "    y aligned :  number:" << nY << "\tminLen:" << minY
-        << "\tmaxLen:" << maxY << nl
-        << "    z aligned :  number:" << nZ << "\tminLen:" << minZ
-        << "\tmaxLen:" << maxZ << nl
-        << "    other     :  number:" << mesh_.nEdges() - nX - nY - nZ
-        << "\tminLen:" << minOther
-        << "\tmaxLen:" << maxOther << nl << endl;
-
-    if (normalDir_ == 0)
+        << "    x aligned :  number:" << nX
+        << "\tminLen:" << limitsX.min() << "\tmaxLen:" << limitsX.max() << nl
+        << "    y aligned :  number:" << nY
+        << "\tminLen:" << limitsY.min() << "\tmaxLen:" << limitsY.max() << nl
+        << "    z aligned :  number:" << nZ
+        << "\tminLen:" << limitsZ.min() << "\tmaxLen:" << limitsZ.max() << nl
+        << "    other     :  number:" << nAny
+        << "\tminLen:" << limitsAny.min()
+        << "\tmaxLen:" << limitsAny.max() << nl << endl;
+
+    if (normalDir_ == vector::X)
     {
-        return min(minY, min(minZ, minOther));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min(limitsY.min(), limitsZ.min())
+        );
     }
-    else if (normalDir_ == 1)
+    else if (normalDir_ == vector::Y)
     {
-        return min(minX, min(minZ, minOther));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min(limitsX.min(), limitsZ.min())
+        );
     }
-    else if (normalDir_ == 2)
+    else if (normalDir_ == vector::Z)
     {
-        return min(minX, min(minY, minOther));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min(limitsX.min(), limitsY.min())
+        );
     }
     else
     {
-        return min(minX, min(minY, min(minZ, minOther)));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min
+            (
+                limitsX.min(),
+                Foam::min(limitsY.min(), limitsZ.min())
+            )
+        );
     }
 }
 
diff --git a/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C b/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C
index 6aa76e6653e..2b537081fee 100644
--- a/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C
+++ b/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C
@@ -81,26 +81,25 @@ void writeSet(const cellSet& cells, const string& msg)
 
 direction getNormalDir(const twoDPointCorrector* correct2DPtr)
 {
-    direction dir = 3;
-
     if (correct2DPtr)
     {
         const vector& normal = correct2DPtr->planeNormal();
 
-        if (mag(normal & vector(1, 0, 0)) > 1-edgeTol)
+        if (mag(normal.x()) > 1-edgeTol)
         {
-            dir = 0;
+            return vector::X;
         }
-        else if (mag(normal & vector(0, 1, 0)) > 1-edgeTol)
+        else if (mag(normal.y()) > 1-edgeTol)
         {
-            dir = 1;
+            return vector::Y;
         }
-        else if (mag(normal & vector(0, 0, 1)) > 1-edgeTol)
+        else if (mag(normal.z()) > 1-edgeTol)
         {
-            dir = 2;
+            return vector::Z;
         }
     }
-    return dir;
+
+    return direction(3);
 }
 
 
@@ -109,89 +108,95 @@ direction getNormalDir(const twoDPointCorrector* correct2DPtr)
 // directions but exclude component (0=x, 1=y, 2=z, other=none)
 scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt)
 {
-    label nX = 0;
-    label nY = 0;
-    label nZ = 0;
-
-    scalar minX = GREAT;
-    scalar maxX = -GREAT;
-    vector x(1, 0, 0);
-
-    scalar minY = GREAT;
-    scalar maxY = -GREAT;
-    vector y(0, 1, 0);
+    label nAny(0);
+    label nX(0);
+    label nY(0);
+    label nZ(0);
 
-    scalar minZ = GREAT;
-    scalar maxZ = -GREAT;
-    vector z(0, 0, 1);
-
-    scalar minOther = GREAT;
-    scalar maxOther = -GREAT;
+    scalarMinMax limitsAny(GREAT, -GREAT);
+    scalarMinMax limitsX(limitsAny);
+    scalarMinMax limitsY(limitsAny);
+    scalarMinMax limitsZ(limitsAny);
 
     const edgeList& edges = mesh.edges();
 
-    forAll(edges, edgei)
+    for (const edge& e : edges)
     {
-        const edge& e = edges[edgei];
-
         vector eVec(e.vec(mesh.points()));
 
         scalar eMag = mag(eVec);
 
         eVec /= eMag;
 
-        if (mag(eVec & x) > 1-edgeTol)
+        if (mag(eVec.x()) > 1-edgeTol)
         {
-            minX = min(minX, eMag);
-            maxX = max(maxX, eMag);
+            limitsX.add(eMag);
             nX++;
         }
-        else if (mag(eVec & y) > 1-edgeTol)
+        else if (mag(eVec.y()) > 1-edgeTol)
         {
-            minY = min(minY, eMag);
-            maxY = max(maxY, eMag);
+            limitsY.add(eMag);
             nY++;
         }
-        else if (mag(eVec & z) > 1-edgeTol)
+        else if (mag(eVec.z()) > 1-edgeTol)
         {
-            minZ = min(minZ, eMag);
-            maxZ = max(maxZ, eMag);
+            limitsZ.add(eMag);
             nZ++;
         }
         else
         {
-            minOther = min(minOther, eMag);
-            maxOther = max(maxOther, eMag);
+            limitsAny.add(eMag);
+            nAny++;
         }
     }
 
     Info<< "Mesh bounding box:" << boundBox(mesh.points()) << nl << nl
         << "Mesh edge statistics:" << nl
-        << "    x aligned :  number:" << nX << "\tminLen:" << minX
-        << "\tmaxLen:" << maxX << nl
-        << "    y aligned :  number:" << nY << "\tminLen:" << minY
-        << "\tmaxLen:" << maxY << nl
-        << "    z aligned :  number:" << nZ << "\tminLen:" << minZ
-        << "\tmaxLen:" << maxZ << nl
-        << "    other     :  number:" << mesh.nEdges() - nX - nY - nZ
-        << "\tminLen:" << minOther
-        << "\tmaxLen:" << maxOther << nl << endl;
-
-    if (excludeCmpt == 0)
+        << "    x aligned :  number:" << nX
+        << "\tminLen:" << limitsX.min() << "\tmaxLen:" << limitsX.max() << nl
+        << "    y aligned :  number:" << nY
+        << "\tminLen:" << limitsY.min() << "\tmaxLen:" << limitsY.max() << nl
+        << "    z aligned :  number:" << nZ
+        << "\tminLen:" << limitsZ.min() << "\tmaxLen:" << limitsZ.max() << nl
+        << "    other     :  number:" << nAny
+        << "\tminLen:" << limitsAny.min()
+        << "\tmaxLen:" << limitsAny.max() << nl << endl;
+
+    if (excludeCmpt == vector::X)
     {
-        return min(minY, min(minZ, minOther));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min(limitsY.min(), limitsZ.min())
+        );
     }
-    else if (excludeCmpt == 1)
+    else if (excludeCmpt == vector::Y)
     {
-        return min(minX, min(minZ, minOther));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min(limitsX.min(), limitsZ.min())
+        );
     }
-    else if (excludeCmpt == 2)
+    else if (excludeCmpt == vector::Z)
     {
-        return min(minX, min(minY, minOther));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min(limitsX.min(), limitsY.min())
+        );
     }
     else
     {
-        return min(minX, min(minY, min(minZ, minOther)));
+        return Foam::min
+        (
+            limitsAny.min(),
+            Foam::min
+            (
+                limitsX.min(),
+                Foam::min(limitsY.min(), limitsZ.min())
+            )
+        );
     }
 }
 
diff --git a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C
index 00765975347..3a51efb2988 100644
--- a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C
+++ b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C
@@ -63,96 +63,72 @@ static const scalar edgeTol = 1e-3;
 // Print edge statistics on mesh.
 void printEdgeStats(const polyMesh& mesh)
 {
-    label nX = 0;
-    label nY = 0;
-    label nZ = 0;
+    label nAny(0);
+    label nX(0);
+    label nY(0);
+    label nZ(0);
 
-    scalar minX = GREAT;
-    scalar maxX = -GREAT;
-    static const vector x(1, 0, 0);
-
-    scalar minY = GREAT;
-    scalar maxY = -GREAT;
-    static const vector y(0, 1, 0);
-
-    scalar minZ = GREAT;
-    scalar maxZ = -GREAT;
-    static const vector z(0, 0, 1);
-
-    scalar minOther = GREAT;
-    scalar maxOther = -GREAT;
+    scalarMinMax limitsAny(GREAT, -GREAT);
+    scalarMinMax limitsX(limitsAny);
+    scalarMinMax limitsY(limitsAny);
+    scalarMinMax limitsZ(limitsAny);
 
     bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
 
     const edgeList& edges = mesh.edges();
 
-    forAll(edges, edgeI)
+    for (const label edgei : isMasterEdge)
     {
-        if (isMasterEdge.test(edgeI))
-        {
-            const edge& e = edges[edgeI];
+        const edge& e = edges[edgei];
 
-            vector eVec(e.vec(mesh.points()));
+        vector eVec(e.vec(mesh.points()));
 
-            scalar eMag = mag(eVec);
+        scalar eMag = mag(eVec);
 
-            eVec /= eMag;
+        eVec /= eMag;
 
-            if (mag(eVec & x) > 1-edgeTol)
-            {
-                minX = min(minX, eMag);
-                maxX = max(maxX, eMag);
-                nX++;
-            }
-            else if (mag(eVec & y) > 1-edgeTol)
-            {
-                minY = min(minY, eMag);
-                maxY = max(maxY, eMag);
-                nY++;
-            }
-            else if (mag(eVec & z) > 1-edgeTol)
-            {
-                minZ = min(minZ, eMag);
-                maxZ = max(maxZ, eMag);
-                nZ++;
-            }
-            else
-            {
-                minOther = min(minOther, eMag);
-                maxOther = max(maxOther, eMag);
-            }
+        if (mag(eVec.x()) > 1-edgeTol)
+        {
+            limitsX.add(eMag);
+            nX++;
+        }
+        else if (mag(eVec.y()) > 1-edgeTol)
+        {
+            limitsY.add(eMag);
+            nY++;
+        }
+        else if (mag(eVec.z()) > 1-edgeTol)
+        {
+            limitsZ.add(eMag);
+            nZ++;
+        }
+        else
+        {
+            limitsAny.add(eMag);
+            nAny++;
         }
     }
 
-    label nEdges = mesh.nEdges();
-    reduce(nEdges, sumOp<label>());
     reduce(nX, sumOp<label>());
     reduce(nY, sumOp<label>());
     reduce(nZ, sumOp<label>());
+    reduce(nAny, sumOp<label>());
 
-    reduce(minX, minOp<scalar>());
-    reduce(maxX, maxOp<scalar>());
-
-    reduce(minY, minOp<scalar>());
-    reduce(maxY, maxOp<scalar>());
-
-    reduce(minZ, minOp<scalar>());
-    reduce(maxZ, maxOp<scalar>());
-
-    reduce(minOther, minOp<scalar>());
-    reduce(maxOther, maxOp<scalar>());
-
+    reduce(limitsX, sumOp<scalarMinMax>());
+    reduce(limitsY, sumOp<scalarMinMax>());
+    reduce(limitsZ, sumOp<scalarMinMax>());
+    reduce(limitsAny, sumOp<scalarMinMax>());
 
     Info<< "Mesh edge statistics:" << nl
-        << "    x aligned :  number:" << nX << "\tminLen:" << minX
-        << "\tmaxLen:" << maxX << nl
-        << "    y aligned :  number:" << nY << "\tminLen:" << minY
-        << "\tmaxLen:" << maxY << nl
-        << "    z aligned :  number:" << nZ << "\tminLen:" << minZ
-        << "\tmaxLen:" << maxZ << nl
-        << "    other     :  number:" << nEdges - nX - nY - nZ
-        << "\tminLen:" << minOther
-        << "\tmaxLen:" << maxOther << nl << endl;
+        << "    x aligned :  number:" << nX
+        << "\tminLen:" << limitsX.min() << "\tmaxLen:" << limitsX.max() << nl
+        << "    y aligned :  number:" << nY
+        << "\tminLen:" << limitsY.min() << "\tmaxLen:" << limitsY.max() << nl
+        << "    z aligned :  number:" << nZ
+        << "\tminLen:" << limitsZ.min() << "\tmaxLen:" << limitsZ.max() << nl
+        << "    other     :  number:" << nAny
+        << "\tminLen:" << limitsAny.min()
+        << "\tmaxLen:" << limitsAny.max() << nl << endl;
 }
 
 
diff --git a/applications/utilities/preProcessing/createBoxTurb/createBoxTurb.C b/applications/utilities/preProcessing/createBoxTurb/createBoxTurb.C
index 5e01b77ada5..4c1400fc08d 100644
--- a/applications/utilities/preProcessing/createBoxTurb/createBoxTurb.C
+++ b/applications/utilities/preProcessing/createBoxTurb/createBoxTurb.C
@@ -167,18 +167,24 @@ int main(int argc, char *argv[])
         Info<< "Generating kinetic energy field" << endl;
         volScalarField k("k", 0.5*magSqr(U));
         k.write();
+
+        auto limits = gMinMax(k);
+        auto avg = gAverage(k);
+
         Info<< "min/max/average k = "
-            << gMin(k) << ", " << gMax(k) << ", " << gAverage(k)
-            << endl;
+            << limits.min() << ", " << limits.max() << ", " << avg << endl;
     }
 
     {
         Info<< "Generating div(U) field" << endl;
         volScalarField divU(fvc::div(U));
         divU.write();
+
+        auto limits = gMinMax(divU);
+        auto avg = gAverage(divU);
+
         Info<< "min/max/average div(U) = "
-            << gMin(divU) << ", " << gMax(divU) << ", " << gAverage(divU)
-            << endl;
+            << limits.min() << ", " << limits.max() << ", " << avg << endl;
     }
 
     Info<< nl;
diff --git a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C
index 89e10cd4449..867e8762b79 100644
--- a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C
+++ b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C
@@ -223,11 +223,16 @@ int main(int argc, char *argv[])
     Info<< "Writing new alpha field " << alpha1.name() << endl;
     alpha1.write();
 
-    const scalarField& alpha = alpha1.internalField();
+    {
+        const auto& alpha = alpha1.primitiveField();
+
+        auto limits = gMinMax(alpha);
+        auto total = gWeightedSum(mesh.V(), alpha);
 
-    Info<< "sum(alpha*V):" << gSum(mesh.V()*alpha)
-        << ", 1-max(alpha1): " << 1 - gMax(alpha)
-        << " min(alpha1): " << gMin(alpha) << endl;
+        Info<< "sum(alpha*V):" << total
+            << ", 1-max(alpha1): " << 1 - limits.max()
+            << " min(alpha1): " << limits.min() << endl;
+    }
 
     Info<< "\nEnd\n" << endl;
 
diff --git a/src/combustionModels/EDC/EDC.C b/src/combustionModels/EDC/EDC.C
index 90fc7e26051..977270aa9d1 100644
--- a/src/combustionModels/EDC/EDC.C
+++ b/src/combustionModels/EDC/EDC.C
@@ -180,8 +180,9 @@ void Foam::combustionModels::EDC<ReactionThermo>::correct()
             kappa_.correctBoundaryConditions();
         }
 
-        Info<< "Chemistry time solved max/min : "
-            << gMax(tauStar) << " / " << gMin(tauStar) << endl;
+        auto limits = gMinMax(tauStar);
+        Info<< "Chemistry time solved min/max : "
+            << limits.min() << ", " << limits.max() << endl;
 
         this->chemistryPtr_->solve(tauStar);
     }
diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C
index aa5bf5a4fd5..d74fe5b006b 100644
--- a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C
+++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C
@@ -2022,8 +2022,11 @@ bool Foam::interfaceTrackingFvMesh::update()
 
         const scalarField& K = aMesh().faceCurvatures().internalField();
 
-        Info<< "Free surface curvature: min = " << gMin(K)
-            << ", max = " << gMax(K) << ", average = " << gAverage(K) << nl;
+        auto limits = gMinMax(K);
+
+        Info<< "Free surface curvature: min = " << limits.min()
+            << ", max = " << limits.max()
+            << ", average = " << gAverage(K) << nl;
 
         timeIndex_ = mesh().time().timeIndex();
     }
diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C
index 93d9c97a8a2..7f209b9ef60 100644
--- a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C
+++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C
@@ -879,10 +879,13 @@ bool Foam::motionSmootherAlgo::scaleMesh
         vector::zero    // null value
     );
 
-    Info<< "Moving mesh using displacement scaling :"
-        << " min:" << gMin(scale_.primitiveField())
-        << "  max:" << gMax(scale_.primitiveField())
-        << endl;
+    {
+        auto limits = gMinMax(scale_.primitiveField());
+        Info<< "Moving mesh using displacement scaling :"
+            << " min:" << limits.min()
+            << " max:" << limits.max()
+            << endl;
+    }
 
     // Get points using current displacement and scale. Optionally 2D corrected.
     pointField newPoints(curPoints());
@@ -1018,9 +1021,11 @@ bool Foam::motionSmootherAlgo::scaleMesh
 
         if (debug)
         {
+            auto limits = gMinMax(scale_);
+
             Pout<< "scale_ after smoothing :"
-                << " min:" << Foam::gMin(scale_)
-                << " max:" << Foam::gMax(scale_)
+                << " min:" << limits.min()
+                << " max:" << limits.max()
                 << endl;
         }
 
diff --git a/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C b/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C
index b0a98da1995..01b0642f873 100644
--- a/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C
+++ b/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C
@@ -166,9 +166,7 @@ void Foam::componentDisplacementMotionSolver::updateMesh(const mapPolyMesh& mpm)
     );
 
     // Get extents of points0 and points and determine scale
-    const scalar scale =
-        (gMax(points0_)-gMin(points0_))
-       /(gMax(points)-gMin(points));
+    const scalar scale = gMinMax(points0_).span() / gMinMax(points).span();
 
     scalarField newPoints0(mpm.pointMap().size());
 
diff --git a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C
index 2026e4e09e4..24b07f17181 100644
--- a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C
+++ b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C
@@ -138,16 +138,18 @@ void Foam::displacementInterpolationMotionSolver::calcInterpolation()
             scalar minCoord = VGREAT;
             scalar maxCoord = -VGREAT;
 
-            forAll(fz().meshPoints(), localI)
+            scalarMinMax limits;
+
+            for (const label pointi : fz().meshPoints())
             {
-                label pointi = fz().meshPoints()[localI];
                 const scalar coord = points0()[pointi][dir];
-                minCoord = min(minCoord, coord);
-                maxCoord = max(maxCoord, coord);
+                limits.add(coord);
             }
 
-            zoneCoordinates[2*i] = returnReduce(minCoord, minOp<scalar>());
-            zoneCoordinates[2*i+1] = returnReduce(maxCoord, maxOp<scalar>());
+            reduce(limits, sumOp<scalarMinMax>());
+
+            zoneCoordinates[2*i] = limits.min();
+            zoneCoordinates[2*i+1] = limits.max();
 
             if (debug)
             {
@@ -167,8 +169,13 @@ void Foam::displacementInterpolationMotionSolver::calcInterpolation()
         // Check if we have static min and max mesh bounds
         const scalarField meshCoords(points0().component(dir));
 
-        scalar minCoord = gMin(meshCoords);
-        scalar maxCoord = gMax(meshCoords);
+        scalar minCoord, maxCoord;
+        {
+            auto limits = gMinMax(meshCoords);
+
+            minCoord = limits.min();
+            maxCoord = limits.max();
+        }
 
         if (debug)
         {
diff --git a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C
index 645be3cea28..14b8ed41c7c 100644
--- a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C
+++ b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C
@@ -386,15 +386,21 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve
             patchi
         );
 
-        DebugInfo
-            << "For cellZone:" << cellZoneI
-            << " for faceZone:" << fz.name()
-            << " nPoints:" << tseed().size()
-            << " have patchField:"
-            << " max:" << gMax(tseed())
-            << " min:" << gMin(tseed())
-            << " avg:" << gAverage(tseed())
-            << endl;
+        if (debug)
+        {
+            auto limits = gMinMax(tseed());
+            auto avg = gAverage(tseed());
+
+            Info
+                << "For cellZone:" << cellZoneI
+                << " for faceZone:" << fz.name()
+                << " nPoints:" << tseed().size()
+                << " have patchField:"
+                << " min:" << limits.min()
+                << " max:" << limits.max()
+                << " avg:" << avg
+                << endl;
+        }
 
 
         // Set distance and transported value
diff --git a/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/edgeLimitedFaGrad/edgeLimitedFaGrads.C b/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/edgeLimitedFaGrad/edgeLimitedFaGrads.C
index a68d4f63ec7..2e11e21291a 100644
--- a/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/edgeLimitedFaGrad/edgeLimitedFaGrads.C
+++ b/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/edgeLimitedFaGrad/edgeLimitedFaGrads.C
@@ -175,10 +175,13 @@ tmp<areaVectorField> edgeLimitedGrad<scalar>::calcGrad
 
     if (fa::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vsf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     g.primitiveFieldRef() *= limiter;
@@ -312,10 +315,13 @@ tmp<areaTensorField> edgeLimitedGrad<vector>::calcGrad
 
     if (fa::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vvf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     g.primitiveFieldRef() *= limiter;
diff --git a/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C b/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C
index eb0cc9bcbd0..80a2a60a6a1 100644
--- a/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C
+++ b/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C
@@ -221,10 +221,13 @@ tmp<areaVectorField> faceLimitedGrad<scalar>::calcGrad
 
     if (fa::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vsf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     g.primitiveFieldRef() *= limiter;
@@ -370,10 +373,13 @@ tmp<areaTensorField> faceLimitedGrad<vector>::calcGrad
 
     if (fa::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vsf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     tensorField& gIf = g.primitiveFieldRef();
diff --git a/src/finiteVolume/cfdTools/general/include/setDeltaT.H b/src/finiteVolume/cfdTools/general/include/setDeltaT.H
index 25ee3713ddf..aa808932034 100644
--- a/src/finiteVolume/cfdTools/general/include/setDeltaT.H
+++ b/src/finiteVolume/cfdTools/general/include/setDeltaT.H
@@ -36,11 +36,13 @@ Description
 if (adjustTimeStep)
 {
     scalar maxDeltaTFact = maxCo/(CoNum + SMALL);
-    scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
+
+    const scalar deltaTFact =
+        Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
 
     runTime.setDeltaT
     (
-        min
+        Foam::min
         (
             deltaTFact*runTime.deltaTValue(),
             maxDeltaT
diff --git a/src/finiteVolume/cfdTools/general/include/setInitialDeltaT.H b/src/finiteVolume/cfdTools/general/include/setInitialDeltaT.H
index 55f23f13e14..1f45166220d 100644
--- a/src/finiteVolume/cfdTools/general/include/setInitialDeltaT.H
+++ b/src/finiteVolume/cfdTools/general/include/setInitialDeltaT.H
@@ -38,10 +38,10 @@ if (adjustTimeStep)
     {
         runTime.setDeltaT
         (
-            min
+            Foam::min
             (
                 maxCo*runTime.deltaTValue()/CoNum,
-                min(runTime.deltaTValue(), maxDeltaT)
+                Foam::min(runTime.deltaTValue(), maxDeltaT)
             )
         );
     }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/electrostaticDeposition/electrostaticDepositionFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/electrostaticDeposition/electrostaticDepositionFvPatchScalarField.C
index 2ffd8892c11..61e2959eacf 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/electrostaticDeposition/electrostaticDepositionFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/electrostaticDeposition/electrostaticDepositionFvPatchScalarField.C
@@ -496,16 +496,15 @@ void Foam::electrostaticDepositionFvPatchScalarField::updateCoeffs()
     timei_ = db().time().timeIndex();
 
     {
-        const scalar hMin = gMin(h_);
-        const scalar hMax = gMax(h_);
-        const scalar hAvg = gAverage(h_);
+        auto limits = gMinMax(h_);
+        auto avg = gAverage(h_);
 
-        if (Pstream::master())
+        if (UPstream::master())
         {
             Info<< "    patch: " << patch().name()
-                << ", h: min = " << hMin
-                << ", max = " << hMax
-                << ", average = " << hAvg << nl
+                << ", h: min = " << limits.min()
+                << ", max = " << limits.max()
+                << ", average = " << avg << nl
                 << endl;
         }
     }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C
index cd3da655042..3ad72845068 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C
@@ -175,11 +175,14 @@ void Foam::mappedFieldFvPatchField<Type>::updateCoeffs()
 
     if (debug)
     {
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
         Info<< "operating on field:" << this->internalField().name()
             << " patch:" << this->patch().name()
-            << "  avg:" << gAverage(*this)
-            << "  min:" << gMin(*this)
-            << "  max:" << gMax(*this)
+            << "  avg:" << avg
+            << "  min:" << limits.min()
+            << "  max:" << limits.max()
             << endl;
     }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C
index d0a225f0e4f..643b4957725 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C
@@ -173,6 +173,9 @@ void Foam::mappedMixedFieldFvPatchField<Type>::updateCoeffs()
 
     if (debug)
     {
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
         Info<< this->patch().boundaryMesh().mesh().name() << ':'
             << this->patch().name() << ':'
             << this->internalField().name() << " <- "
@@ -180,9 +183,9 @@ void Foam::mappedMixedFieldFvPatchField<Type>::updateCoeffs()
             << this->mapper_.samplePatch() << ':'
             << this->fieldName_ << " :"
             << " value "
-            << " min:" << gMin(*this)
-            << " max:" << gMax(*this)
-            << " avg:" << gAverage(*this)
+            << " min:" << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg
             << endl;
     }
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C
index ec190df0f18..58970edd6e6 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C
@@ -122,12 +122,15 @@ void Foam::mappedFixedValueFvPatchField<Type>::updateCoeffs()
 
     if (debug)
     {
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
         Info<< "mapped on field:"
             << this->internalField().name()
             << " patch:" << this->patch().name()
-            << "  avg:" << gAverage(*this)
-            << "  min:" << gMin(*this)
-            << "  max:" << gMax(*this)
+            << "  avg:" << avg
+            << "  min:" << limits.min()
+            << "  max:" << limits.max()
             << endl;
     }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C
index f3d9870e0d4..95d553d508b 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C
@@ -215,6 +215,9 @@ void Foam::mappedMixedFvPatchField<Type>::updateCoeffs()
 
     if (debug)
     {
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
         Info<< this->patch().boundaryMesh().mesh().name() << ':'
             << this->patch().name() << ':'
             << this->internalField().name() << " <- "
@@ -222,9 +225,9 @@ void Foam::mappedMixedFvPatchField<Type>::updateCoeffs()
             << this->mapper_.samplePatch() << ':'
             << this->fieldName_ << " :"
             << " value "
-            << " min:" << gMin(*this)
-            << " max:" << gMax(*this)
-            << " avg:" << gAverage(*this)
+            << " min:" << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg
             << endl;
     }
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
index 40dc0780ccd..f5a3a61818f 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
@@ -181,9 +181,12 @@ void Foam::timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
 
     if (debug)
     {
-        Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
-            << " max:" << gMax(*this)
-            << " avg:" << gAverage(*this) << endl;
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
+        Pout<< "updateCoeffs : set fixedValue to min:" << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg << endl;
     }
 
     fixedValueFvPatchField<Type>::updateCoeffs();
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
index 888e5bc6c00..24114e2055f 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
@@ -962,6 +962,8 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs()
 
         if (debug)
         {
+            auto limits = gMinMax(*this);
+
             Info<< "Magnitude of bulk velocity: " << UBulk << endl;
 
             Info<< "Number of eddies: "
@@ -969,7 +971,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs()
                 << endl;
 
             Info<< "Patch:" << patch().patch().name()
-                << " min/max(U):" << gMin(U) << ", " << gMax(U)
+                << " min/max(U):" << limits.min() << ", " << limits.max()
                 << endl;
 
             if (db().time().writeTime())
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C
index 0eb44f87fa6..e98f7f20b01 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C
@@ -210,8 +210,12 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs()
     }
 
 
-    Info<< "min/max zetap = " << gMin(zetap & nf()) << ", "
-        << gMax(zetap & nf()) << endl;
+    {
+        auto limits = gMinMax(zetap & nf());
+
+        Info<< "min/max zetap = "
+            << limits.min() << ", " << limits.max() << endl;
+    }
 
     // Update the surface pressure
     const uniformDimensionedVectorField& g =
diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C
index 06209c1334c..9f339aecc5e 100644
--- a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C
+++ b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C
@@ -186,12 +186,12 @@ tmp<surfaceScalarField> ddtScheme<Type>::fvcDdtPhiCoeff
 
     if (debug > 1)
     {
+        auto limits = gMinMax(ddtCouplingCoeff.primitiveField());
+        auto avg = gAverage(ddtCouplingCoeff.primitiveField());
+
         InfoInFunction
             << "ddtCouplingCoeff mean max min = "
-            << gAverage(ddtCouplingCoeff.primitiveField())
-            << " " << gMax(ddtCouplingCoeff.primitiveField())
-            << " " << gMin(ddtCouplingCoeff.primitiveField())
-            << endl;
+            << avg << ' ' << limits.max() << ' ' << limits.min() << endl;
     }
 
     return tddtCouplingCoeff;
@@ -267,12 +267,12 @@ tmp<surfaceScalarField> ddtScheme<Type>::fvcDdtPhiCoeffExperimental
 
     if (debug > 1)
     {
+        auto limits = gMinMax(ddtCouplingCoeff.primitiveField());
+        auto avg = gAverage(ddtCouplingCoeff.primitiveField());
+
         InfoInFunction
             << "ddtCouplingCoeff mean max min = "
-            << gAverage(ddtCouplingCoeff.primitiveField())
-            << " " << gMax(ddtCouplingCoeff.primitiveField())
-            << " " << gMin(ddtCouplingCoeff.primitiveField())
-            << endl;
+            << avg << ' ' << limits.max() << ' ' << limits.min() << endl;
     }
 
     return tddtCouplingCoeff;
diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C
index f259794f1f1..0d6605cbfc7 100644
--- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C
+++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C
@@ -215,10 +215,13 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
 
     if (fv::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vsf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     limitGradient(limiter, g);
diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C
index 5ef4594ef7d..a6591c366e8 100644
--- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C
+++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C
@@ -162,10 +162,13 @@ Foam::fv::faceLimitedGrad<Foam::scalar>::calcGrad
 
     if (fv::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vsf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     g.primitiveFieldRef() *= limiter;
@@ -323,10 +326,13 @@ Foam::fv::faceLimitedGrad<Foam::vector>::calcGrad
 
     if (fv::debug)
     {
+        auto limits = gMinMax(limiter);
+        auto avg = gAverage(limiter);
+
         Info<< "gradient limiter for: " << vvf.name()
-            << " max = " << gMax(limiter)
-            << " min = " << gMin(limiter)
-            << " average: " << gAverage(limiter) << endl;
+            << " min = " << limits.min()
+            << " max = " << limits.max()
+            << " average: " << avg << endl;
     }
 
     g.primitiveFieldRef() *= limiter;
diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C
index 6cfef0e9448..feb35be095f 100644
--- a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C
+++ b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C
@@ -814,6 +814,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
                         Foam::acos(faceOrthogonality)
                     )
                 );
+
                 Pout<< "    iter:" << iter
                     << " nClipped:" << nClipped
                     << " average displacement:" << gAverage(magCorrection)
@@ -845,10 +846,13 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
 
         if (debug)
         {
+            auto limits = gMinMax(cellWeight);
+            auto avg = gAverage(cellWeight);
+
             Pout<< "averageNeighbourFvGeometryScheme::movePoints() :"
                 << " averageNeighbour weight"
-                << " max:" << gMax(cellWeight) << " min:" << gMin(cellWeight)
-                << " average:" << gAverage(cellWeight) << endl;
+                << " min:" << limits.min() << " max:" << limits.max()
+                << " average:" << avg << endl;
 
             // Dump lines from old to new location
             const fileName tp(mesh_.time().timePath());
diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/cellAspectRatio.C b/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/cellAspectRatio.C
index efa5a01fd9e..ce87146904a 100644
--- a/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/cellAspectRatio.C
+++ b/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/cellAspectRatio.C
@@ -120,8 +120,11 @@ void Foam::cellAspectRatio::calcAspectRatio()
 
     if (debug)
     {
-        InfoInFunction << "Calculated cell aspect ratio min:" << gMin(aRatio)
-            << " max:" << gMax(aRatio) << " average:" << gAverage(aRatio)
+        auto limits = gMinMax(aRatio);
+        auto avg = gAverage(aRatio);
+
+        InfoInFunction << "Calculated cell aspect ratio min:" << limits.min()
+            << " max:" << limits.max() << " average:" << avg
             << endl;
     }
 }
diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C
index 0f64298abc1..6e60a2eac32 100644
--- a/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C
+++ b/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C
@@ -434,10 +434,13 @@ void Foam::highAspectRatioFvGeometryScheme::movePoints()
 
         if (debug)
         {
+            auto limits = gMinMax(cellWeight);
+            auto avg = gAverage(cellWeight);
+
             Pout<< "highAspectRatioFvGeometryScheme::movePoints() :"
                 << " highAspectRatio weight"
-                << " max:" << gMax(cellWeight) << " min:" << gMin(cellWeight)
-                << " average:" << gAverage(cellWeight) << endl;
+                << " min:" << limits.max() << " max:" << limits.max()
+                << " average:" << avg << endl;
         }
 
         vectorField faceAreas(mesh_.faceAreas());
diff --git a/src/functionObjects/field/AMIWeights/AMIWeights.C b/src/functionObjects/field/AMIWeights/AMIWeights.C
index 7ec095d55dc..a3a49b20aad 100644
--- a/src/functionObjects/field/AMIWeights/AMIWeights.C
+++ b/src/functionObjects/field/AMIWeights/AMIWeights.C
@@ -88,52 +88,52 @@ void Foam::functionObjects::AMIWeights::reportPatch
     const Switch distributed = pp.AMI().distributed();
 
     const scalarField& srcWeightsSum = pp.AMI().srcWeightsSum();
-    const scalar srcMinWeight = gMin(srcWeightsSum);
-    const scalar srcMaxWeight = gMax(srcWeightsSum);
-    const scalar srcAveWeight = gAverage(srcWeightsSum);
+    const auto srcWeightLimits = gMinMax(srcWeightsSum);
+    const auto srcWeightAvg = gAverage(srcWeightsSum);
 
     const labelListList& srcAddress = pp.AMI().srcAddress();
-    label srcMinNbr = labelMax;
-    label srcMaxNbr = labelMin;
-    scalar srcAveNbr = 0;
+
+    labelMinMax srcNbrLimits(labelMax, labelMin);
+    scalar srcNbrAvg(0);
     for (const labelList& srcFace : srcAddress)
     {
         const label n = srcFace.size();
-        srcAveNbr += n;
-        srcMinNbr = min(srcMinNbr, n);
-        srcMaxNbr = max(srcMaxNbr, n);
+
+        srcNbrAvg += n;
+        srcNbrLimits.add(n);
     }
 
-    reduce(srcMinNbr, minOp<label>());
-    reduce(srcMaxNbr, maxOp<label>());
+    {
+        reduce(srcNbrLimits, sumOp<labelMinMax>());
 
-    srcAveNbr =
-        returnReduce(srcAveNbr, sumOp<scalar>())
-       /(returnReduce(srcAddress.size(), sumOp<scalar>()) + ROOTVSMALL);
+        label count = srcAddress.size();
+        sumReduce(srcNbrAvg, count);
+        srcNbrAvg /= (count + ROOTVSMALL);
+    }
 
     const scalarField& tgtWeightsSum = pp.AMI().tgtWeightsSum();
-    const scalar tgtMinWeight = gMin(tgtWeightsSum);
-    const scalar tgtMaxWeight = gMax(tgtWeightsSum);
-    const scalar tgtAveWeight = gAverage(tgtWeightsSum);
+    const auto tgtWeightLimits = gMinMax(tgtWeightsSum);
+    const auto tgtWeightAvg = gAverage(tgtWeightsSum);
 
     const labelListList& tgtAddress = pp.AMI().tgtAddress();
-    label tgtMinNbr = labelMax;
-    label tgtMaxNbr = labelMin;
-    scalar tgtAveNbr = 0;
+
+    labelMinMax tgtNbrLimits(labelMax, labelMin);
+    scalar tgtNbrAvg(0);
     for (const labelList& tgtFace : tgtAddress)
     {
         const label n = tgtFace.size();
-        tgtAveNbr += n;
-        tgtMinNbr = min(tgtMinNbr, n);
-        tgtMaxNbr = max(tgtMaxNbr, n);
+
+        tgtNbrAvg += n;
+        tgtNbrLimits.add(n);
     }
 
-    reduce(tgtMinNbr, minOp<label>());
-    reduce(tgtMaxNbr, maxOp<label>());
+    {
+        reduce(tgtNbrLimits, sumOp<labelMinMax>());
 
-    tgtAveNbr =
-        returnReduce(tgtAveNbr, sumOp<scalar>())
-       /(returnReduce(tgtAddress.size(), sumOp<scalar>()) + ROOTVSMALL);
+        label count = tgtAddress.size();
+        sumReduce(tgtNbrAvg, count);
+        tgtNbrAvg /= (count + ROOTVSMALL);
+    }
 
     file()
         << mesh_.time().timeName() << tab
@@ -147,18 +147,18 @@ void Foam::functionObjects::AMIWeights::reportPatch
     }
 
     file()
-        << srcMinWeight << tab
-        << srcMaxWeight << tab
-        << srcAveWeight << tab
-        << srcMinNbr << tab
-        << srcMaxNbr << tab
-        << srcAveNbr << tab
-        << tgtMinWeight << tab
-        << tgtMaxWeight << tab
-        << tgtAveWeight << tab
-        << tgtMinNbr << tab
-        << tgtMaxNbr << tab
-        << tgtAveNbr << tab
+        << srcWeightLimits.min() << tab
+        << srcWeightLimits.max() << tab
+        << srcWeightAvg << tab
+        << srcNbrLimits.min() << tab
+        << srcNbrLimits.max() << tab
+        << srcNbrAvg << tab
+        << tgtWeightLimits.min() << tab
+        << tgtWeightLimits.max() << tab
+        << tgtWeightAvg << tab
+        << tgtNbrLimits.min() << tab
+        << tgtNbrLimits.max() << tab
+        << tgtNbrAvg
         << endl;
 
     Log << "    Patches: " << nl
@@ -176,34 +176,34 @@ void Foam::functionObjects::AMIWeights::reportPatch
 
     Log << "                     | " << setw(w) << pp.name()
         << " | " << setw(w) << nbrPatchName << " | " << nl
-        << "        min(weight)  | " << setw(w) << srcMinWeight
-        << " | " << setw(w) << tgtMinWeight << " | " << nl
-        << "        max(weight)  | " << setw(w) << srcMaxWeight
-        << " | " << setw(w) << tgtMaxWeight << " | " << nl
-        << "        ave(weight)  | " << setw(w) << srcAveWeight
-        << " | " << setw(w) << tgtAveWeight << " | " << nl
-        << "        min(address) | " << setw(w) << srcMinNbr
-        << " | " << setw(w) << tgtMinNbr << " | " << nl
-        << "        max(address) | " << setw(w) << srcMaxNbr
-        << " | " << setw(w) << tgtMaxNbr << " | " << nl
-        << "        ave(address) | " << setw(w) << srcAveNbr
-        << " | " << setw(w) << tgtAveNbr << " | " << nl
+        << "        min(weight)  | " << setw(w) << srcWeightLimits.min()
+        << " | " << setw(w) << tgtWeightLimits.min() << " | " << nl
+        << "        max(weight)  | " << setw(w) << srcWeightLimits.max()
+        << " | " << setw(w) << tgtWeightLimits.max() << " | " << nl
+        << "        ave(weight)  | " << setw(w) << srcWeightAvg
+        << " | " << setw(w) << tgtWeightAvg << " | " << nl
+        << "        min(address) | " << setw(w) << srcNbrLimits.min()
+        << " | " << setw(w) << tgtNbrLimits.min() << " | " << nl
+        << "        max(address) | " << setw(w) << srcNbrLimits.max()
+        << " | " << setw(w) << tgtNbrLimits.max() << " | " << nl
+        << "        ave(address) | " << setw(w) << srcNbrAvg
+        << " | " << setw(w) << tgtNbrAvg << " | " << nl
         << endl;
 
     setResult(pp.name() + ":src", pp.name());
     setResult(pp.name() + ":tgt", nbrPatchName);
-    setResult(pp.name() + ":src:min(weight)", srcMinWeight);
-    setResult(pp.name() + ":src:max(weight)", srcMaxWeight);
-    setResult(pp.name() + ":src:ave(weight)", srcAveWeight);
-    setResult(pp.name() + ":src:min(address)", srcMinNbr);
-    setResult(pp.name() + ":src:max(address)", srcMaxNbr);
-    setResult(pp.name() + ":src:ave(address)", srcAveNbr);
-    setResult(pp.name() + ":tgt:min(weight)", tgtMinWeight);
-    setResult(pp.name() + ":tgt:max(weight)", tgtMaxWeight);
-    setResult(pp.name() + ":tgt:ave(weight)", tgtAveWeight);
-    setResult(pp.name() + ":tgt:min(address)", tgtMinNbr);
-    setResult(pp.name() + ":tgt:max(address)", tgtMaxNbr);
-    setResult(pp.name() + ":tgt:ave(address)", tgtAveNbr);
+    setResult(pp.name() + ":src:min(weight)", srcWeightLimits.min());
+    setResult(pp.name() + ":src:max(weight)", srcWeightLimits.max());
+    setResult(pp.name() + ":src:ave(weight)", srcWeightAvg);
+    setResult(pp.name() + ":src:min(address)", srcNbrLimits.min());
+    setResult(pp.name() + ":src:max(address)", srcNbrLimits.max());
+    setResult(pp.name() + ":src:ave(address)", srcNbrAvg);
+    setResult(pp.name() + ":tgt:min(weight)", tgtWeightLimits.min());
+    setResult(pp.name() + ":tgt:max(weight)", tgtWeightLimits.max());
+    setResult(pp.name() + ":tgt:ave(weight)", tgtWeightAvg);
+    setResult(pp.name() + ":tgt:min(address)", tgtNbrLimits.min());
+    setResult(pp.name() + ":tgt:max(address)", tgtNbrLimits.max());
+    setResult(pp.name() + ":tgt:ave(address)", tgtNbrAvg);
 }
 
 
diff --git a/src/functionObjects/field/yPlus/yPlus.C b/src/functionObjects/field/yPlus/yPlus.C
index f9b5f3a3b53..f767e00f5bd 100644
--- a/src/functionObjects/field/yPlus/yPlus.C
+++ b/src/functionObjects/field/yPlus/yPlus.C
@@ -211,25 +211,24 @@ bool Foam::functionObjects::yPlus::write()
         {
             const scalarField& yPlusp = yPlusBf[patchi];
 
-            const scalar minYplus = gMin(yPlusp);
-            const scalar maxYplus = gMax(yPlusp);
-            const scalar avgYplus = gAverage(yPlusp);
+            auto limits = gMinMax(yPlusp);
+            auto avg = gAverage(yPlusp);
 
             if (UPstream::master())
             {
                 writeCurrentTime(file());
                 file()
                     << token::TAB << patch.name()
-                    << token::TAB << minYplus
-                    << token::TAB << maxYplus
-                    << token::TAB << avgYplus
+                    << token::TAB << limits.min()
+                    << token::TAB << limits.max()
+                    << token::TAB << avg
                     << endl;
             }
 
             Log << "    patch " << patch.name()
-                << " y+ : min = " << minYplus
-                << ", max = " << maxYplus
-                << ", average = " << avgYplus << endl;
+                << " y+ : min = " << limits.min()
+                << ", max = " << limits.max()
+                << ", average = " << avg << endl;
         }
     }
 
diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C
index 73f89234392..d57ddb09a9a 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C
@@ -552,9 +552,12 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs()
 
     if (debug)
     {
-        Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
-            << " max:" << gMax(*this)
-            << " avg:" << gAverage(*this) << endl;
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
+        Pout<< "updateCoeffs : set fixedValue to min:" << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg << endl;
     }
 
     fixedValuePointPatchField<Type>::updateCoeffs();
diff --git a/src/fvOptions/sources/derived/heatExchangerSource/heatExchangerModels/effectivenessTable/effectivenessTable.C b/src/fvOptions/sources/derived/heatExchangerSource/heatExchangerModels/effectivenessTable/effectivenessTable.C
index 08af91be268..b5e42d1af59 100644
--- a/src/fvOptions/sources/derived/heatExchangerSource/heatExchangerModels/effectivenessTable/effectivenessTable.C
+++ b/src/fvOptions/sources/derived/heatExchangerSource/heatExchangerModels/effectivenessTable/effectivenessTable.C
@@ -195,23 +195,23 @@ Foam::heatExchangerModels::effectivenessTable::energyDensity
         secondaryInletT_ += targetQdotRelax_*dT;
     }
 
-    const scalarField TCells(T, cells);
-    scalarField deltaTCells(cells.size(), Zero);
+    // start with a copy
+    scalarField deltaTCells(T, cells);
     Tref_ = 0;
     if (Qt_ > 0)
     {
-        Tref_ = gMax(TCells);
-        forAll(deltaTCells, i)
+        Tref_ = gMax(deltaTCells);
+        for (scalar& delta : deltaTCells)
         {
-            deltaTCells[i] = max(Tref_ - TCells[i], scalar(0));
+            delta = Foam::max(Tref_ - delta, scalar(0));
         }
     }
     else
     {
-        Tref_ = gMin(TCells);
-        forAll(deltaTCells, i)
+        Tref_ = gMin(deltaTCells);
+        for (scalar& delta : deltaTCells)
         {
-            deltaTCells[i] = max(TCells[i] - Tref_, scalar(0));
+            delta = Foam::max(delta - Tref_, scalar(0));
         }
     }
 
diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C
index 776d3af8110..a513fb2ffb2 100644
--- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C
+++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C
@@ -950,13 +950,12 @@ void Foam::KinematicCloud<CloudType>::info()
             alpha().write();
         }
 
-        const scalar alphaMin = gMin(alpha().primitiveField());
-        const scalar alphaMax = gMax(alpha().primitiveField());
+        auto limits = gMinMax(alpha().primitiveField());
 
-        Log_<< "    Min cell volume fraction        = " << alphaMin << nl
-            << "    Max cell volume fraction        = " << alphaMax << endl;
+        Log_<< "    Min cell volume fraction        = " << limits.min() << nl
+            << "    Max cell volume fraction        = " << limits.max() << endl;
 
-        if (alphaMax < SMALL)
+        if (limits.max() < SMALL)
         {
             return;
         }
@@ -969,7 +968,7 @@ void Foam::KinematicCloud<CloudType>::info()
 
             if (n > 0)
             {
-                const scalar nPack = n*alphaMax/alpha()[celli];
+                const scalar nPack = n*limits.max()/alpha()[celli];
 
                 if (nPack < nMin)
                 {
diff --git a/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C b/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C
index 14dcb633edc..3e7bb385603 100644
--- a/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C
+++ b/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C
@@ -283,13 +283,12 @@ void Foam::MPPICCloud<CloudType>::info()
 
     tmp<volScalarField> alpha = this->theta();
 
-    const scalar alphaMin = gMin(alpha().primitiveField());
-    const scalar alphaMax = gMax(alpha().primitiveField());
+    auto limits = gMinMax(alpha().primitiveField());
 
-    Log_ << "    Min cell volume fraction        = " << alphaMin << nl
-         << "    Max cell volume fraction        = " << alphaMax << endl;
+    Log_ << "    Min cell volume fraction        = " << limits.min() << nl
+         << "    Max cell volume fraction        = " << limits.max() << endl;
 
-    if (alphaMax < SMALL)
+    if (limits.max() < SMALL)
     {
         return;
     }
@@ -302,7 +301,7 @@ void Foam::MPPICCloud<CloudType>::info()
 
         if (n > 0)
         {
-            const scalar nPack = n*alphaMax/alpha()[celli];
+            const scalar nPack = n*limits.max()/alpha()[celli];
 
             if (nPack < nMin)
             {
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
index d362fabd284..181a588f871 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
@@ -1676,8 +1676,7 @@ void Foam::snappyLayerDriver::calculateLayerThickness
         GREAT               // null value
     );
 
-    //Info<< "calculateLayerThickness : min:" << gMin(thickness)
-    //    << " max:" << gMax(thickness) << endl;
+    //Info<< "calculateLayerThickness : " << gMinMax(thickness) << endl;
 
     // Print a bit
     {
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C
index a37f5de3410..d4372068a6a 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C
@@ -2087,10 +2087,12 @@ Foam::vectorField Foam::snappySnapDriver::calcNearestSurface
 
             scalarField magDisp(mag(patchDisp));
 
+            auto limits = gMinMax(magDisp);
+
             Info<< "Wanted displacement : average:"
                 <<  meshRefinement::gAverage(isPatchMasterPoint, magDisp)
-                << " min:" << gMin(magDisp)
-                << " max:" << gMax(magDisp) << endl;
+                << " min:" << limits.min()
+                << " max:" << limits.max() << endl;
         }
     }
 
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
index 4d2ab16688c..472aaff4496 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
@@ -279,37 +279,31 @@ void Foam::AMIInterpolation::normaliseWeights
         }
     }
 
-    if (output && comm != -1)
+    if (output && comm != -1 && returnReduceOr(wght.size(), comm))
     {
-        // Note: change global communicator since gMin,gAverage etc don't
-        // support user communicator
-        const label oldWorldComm(UPstream::worldComm);
-        UPstream::worldComm = comm;
+        auto limits = gMinMax(wghtSum, comm);
+        auto avg = gAverage(wghtSum, comm);
 
-        if (returnReduceOr(wght.size()))
+        label nLow =
+            returnReduce(nLowWeight, sumOp<label>(), UPstream::msgType(), comm);
+
+        Info.masterStream(comm)
+            << indent
+            << "AMI: Patch " << patchName
+            << " sum(weights)"
+            << " min:" << limits.min()
+            << " max:" << limits.max()
+            << " average:" << avg << nl;
+
+        if (nLow)
         {
             Info.masterStream(comm)
                 << indent
                 << "AMI: Patch " << patchName
-                << " sum(weights)"
-                << " min:" << gMin(wghtSum)
-                << " max:" << gMax(wghtSum)
-                << " average:" << gAverage(wghtSum) << nl;
-
-            const label nLow = returnReduce(nLowWeight, sumOp<label>());
-
-            if (nLow)
-            {
-                Info.masterStream(comm)
-                    << indent
-                    << "AMI: Patch " << patchName
-                    << " identified " << nLow
-                    << " faces with weights less than " << lowWeightTol
-                    << endl;
-            }
+                << " identified " << nLow
+                << " faces with weights less than " << lowWeightTol
+                << endl;
         }
-
-        UPstream::worldComm = oldWorldComm;
     }
 }
 
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
index 410a797230c..6aba9c7b533 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
@@ -513,18 +513,29 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI() const
                 tgtWghtSum[faceI] = sum(AMIPtr_->tgtWeights()[faceI]);
             }
 
-            Info<< indent
-                << "AMI: Patch " << name()
-                << " sum(weights)"
-                << " min:" << gMin(srcWghtSum)
-                << " max:" << gMax(srcWghtSum)
-                << " average:" << gAverage(srcWghtSum) << nl;
-            Info<< indent
-                << "AMI: Patch " << neighbPatch().name()
-                << " sum(weights)"
-                << " min:" << gMin(tgtWghtSum)
-                << " max:" << gMax(tgtWghtSum)
-                << " average:" << gAverage(tgtWghtSum) << nl;
+            {
+                auto limits = gMinMax(srcWghtSum);
+                auto avg = gAverage(srcWghtSum);
+
+                Info<< indent
+                    << "AMI: Patch " << name()
+                    << " sum(weights)"
+                    << " min:" << limits.min()
+                    << " max:" << limits.max()
+                    << " average:" << avg << nl;
+            }
+
+            {
+                auto limits = gMinMax(tgtWghtSum);
+                auto avg = gAverage(tgtWghtSum);
+
+                Info<< indent
+                    << "AMI: Patch " << neighbPatch().name()
+                    << " sum(weights)"
+                    << " min:" << limits.min()
+                    << " max:" << limits.max()
+                    << " average:" << avg << nl;
+            }
         }
     }
 }
diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C
index ef0856fe7bb..2e6adb35f54 100644
--- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C
+++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C
@@ -747,9 +747,13 @@ Foam::PatchFunction1Types::MappedFile<Type>::value
 
     if (debug)
     {
-        Pout<< "MappedFile<Type>::value : set fixedValue to min:" << gMin(fld)
-            << " max:" << gMax(fld)
-            << " avg:" << gAverage(fld) << endl;
+        auto limits = gMinMax(fld);
+        auto avg = gAverage(fld);
+
+        Pout<< "MappedFile<Type>::value : set fixedValue to min:"
+            << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg << endl;
     }
 
     return this->transform(tfld);
diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/regularisation/regularisationPDE/Helmoltz/Helmholtz.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/regularisation/regularisationPDE/Helmoltz/Helmholtz.C
index 39980eece8b..ced36121cb0 100644
--- a/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/regularisation/regularisationPDE/Helmoltz/Helmholtz.C
+++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/regularisation/regularisationPDE/Helmoltz/Helmholtz.C
@@ -231,7 +231,7 @@ void Foam::Helmholtz::regularise
             );
             // Map result back to original field
             result.rmap(resultSub, cellMap);
-            Info<< "min max " << gMin(result) << " " << gMax(result) << endl;
+            Info<< "min max " << gMinMax(result) << endl;
             return;
         }
     }
diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C
index e3a2be4b9ab..ac4ee7ca4c1 100644
--- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C
+++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C
@@ -430,21 +430,29 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::correctInterfaceThermo()
 
         Tf = (H1*T1 + H2*T2 + iDmdtNew*L)/(H1 + H2);
 
-        Info<< "Tf." << pair.name()
-            << ": min = " << gMin(Tf.primitiveField())
-            << ", mean = " << gAverage(Tf.primitiveField())
-            << ", max = " << gMax(Tf.primitiveField())
-            << endl;
+        {
+            auto limits = gMinMax(Tf.primitiveField());
+            auto avg = gAverage(Tf.primitiveField());
+
+            Info<< "Tf." << pair.name()
+                << ": min = " << limits.min()
+                << ", mean = " << avg
+                << ", max = " << limits.max()
+                << endl;
+        }
 
         scalar iDmdtRelax(this->mesh().fieldRelaxationFactor("iDmdt"));
         iDmdt = (1 - iDmdtRelax)*iDmdt + iDmdtRelax*iDmdtNew;
 
         if (phaseChange_)
         {
+            auto limits = gMinMax(iDmdt.primitiveField());
+            auto avg = gAverage(iDmdt.primitiveField());
+
             Info<< "iDmdt." << pair.name()
-                << ": min = " << gMin(iDmdt.primitiveField())
-                << ", mean = " << gAverage(iDmdt.primitiveField())
-                << ", max = " << gMax(iDmdt.primitiveField())
+                << ": min = " << limits.min()
+                << ", mean = " << avg
+                << ", max = " << limits.max()
                 << ", integral = " << fvc::domainIntegrate(iDmdt).value()
                 << endl;
         }
@@ -525,10 +533,13 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::correctInterfaceThermo()
 
         if (wallBoilingActive)
         {
+            auto limits = gMinMax(wDmdt.primitiveField());
+            auto avg = gAverage(wDmdt.primitiveField());
+
             Info<< "wDmdt." << pair.name()
-                << ": min = " << gMin(wDmdt.primitiveField())
-                << ", mean = " << gAverage(wDmdt.primitiveField())
-                << ", max = " << gMax(wDmdt.primitiveField())
+                << ": min = " << limits.min()
+                << ", mean = " << avg
+                << ", max = " << limits.max()
                 << ", integral = " << fvc::domainIntegrate(wDmdt).value()
                 << endl;
         }
diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
index 56cdee16f87..efca2b963cc 100644
--- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
+++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
@@ -505,13 +505,12 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
             {
                 Info<< "alphat for vapour : " << nl << endl;
 
-                Info<< "  alphatEffv: " << gMin(vaporw*(*this + alphaw))
-                    << " - " << gMax(vaporw*(*this + alphaw)) << endl;
+                Info<< "  alphatEffv: " << gMinMax(vaporw*(*this + alphaw))
+                    << endl;
 
                 const scalarField qEff(vaporw*(*this + alphaw)*hewv.snGrad());
 
-                 Info<< "  qEffVap: " << gMin(qEff) << " - "
-                     << gMax(qEff) << endl;
+                Info<< "  qEffVap: " << gMinMax(qEff) << endl;
 
                 scalar Qeff = gWeightedSum(patch().magSf(), qEff);
                 Info<< " Effective heat transfer rate to vapor:" << Qeff
@@ -1096,24 +1095,16 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
                     fLiquid*liquidw*(*this + alphaw)*hew.snGrad()
                 );
 
-                Info<< "alphat for liquid:  " <<  nl << endl;
+                Info<< "alphat for liquid:  " <<  nl << nl;
+                Info<< "  qEffLiq: " << gMinMax(qEff) << nl;
+                Info<< "  alphatl: " << gMinMax(*this) << nl;
+                Info<< "  dmdt: " << gMinMax(dmdt_) << nl;
+                Info<< "  alphatlEff: "
+                    << gMinMax(liquidw*(*this + alphaw)) << nl;
 
-                Info<< "  qEffLiq: " << gMin(qEff) << " - "
-                    << gMax(qEff) << endl;
-
-
-                Info<< "  alphatl: " << gMin((*this)) << " - "
-                    << gMax((*this)) << endl;
-
-                Info<< "  dmdt: " << gMin((dmdt_)) << " - "
-                    << gMax((dmdt_)) << endl;
-
-                Info<< "  alphatlEff: " << gMin(liquidw*(*this + alphaw))
-                    << " - " << gMax(liquidw*(*this + alphaw)) << endl;
-
-                scalar Qeff = gWeightedSum(patch().magSf(), qEff);
-                Info<< " Effective heat transfer rate to liquid: " << Qeff
-                    << endl << nl;
+                Info<< " Effective heat transfer rate to liquid: "
+                    << gWeightedSum(patch().magSf(), qEff)
+                    << nl << endl;
 
                 if (debug == 2)
                 {
diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
index 3f327410330..9139ea3a549 100644
--- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
+++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
@@ -147,8 +147,11 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
             const scalarField q0(T.snGrad()*alpha*kappaEff);
             Q += q0;
 
+            auto limits = gMinMax(q0);
+
             Info<< patch().name() << " " << phase.name()
-                << ": Heat flux " << gMin(q0) << " - " << gMax(q0) << endl;
+                << ": Heat flux "
+                << limits.min() << " - " << limits.max() << endl;
         }
 
         A += T.patchInternalField()*alpha*kappaEff*patch().deltaCoeffs();
@@ -157,7 +160,7 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
 
     if (debug)
     {
-        MinMax<scalar> limits = gMinMax(Q);
+        auto limits = gMinMax(Q);
 
         Info<< patch().name() << " " << ": overall heat flux "
             << limits.min() << " - " << limits.max() << " W/m2, power: "
diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C
index acadb10b20b..2c81e9ac7c0 100644
--- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C
+++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C
@@ -694,11 +694,10 @@ void reactingOneDim::evolveRegion()
 
     solidThermo_->correct();
 
+    auto limits = gMinMax(solidThermo_->T().primitiveField());
+
     Info<< "pyrolysis min/max(T) = "
-        << gMin(solidThermo_->T().primitiveField())
-        << ", "
-        << gMax(solidThermo_->T().primitiveField())
-        << endl;
+        << limits.min() << ", " << limits.max() << endl;
 }
 
 
diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C
index ba9bf0b0cbd..b62a18da607 100644
--- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C
+++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C
@@ -697,10 +697,11 @@ void thermoSingleLayer::info()
 
     const scalarField& Tinternal = T_;
 
+    auto limits = gMinMax(Tinternal);
+    auto avg = gAverage(Tinternal);
+
     Info<< indent << "min/mean/max(T)    = "
-        << gMin(Tinternal) << ", "
-        << gAverage(Tinternal) << ", "
-        << gMax(Tinternal) << nl;
+        << limits.min() << ", " << avg << ", " << limits.max() << nl;
 
     phaseChange_->info(Info);
 }
diff --git a/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
index df66f3288c5..215d17698fd 100644
--- a/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
+++ b/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
@@ -195,14 +195,17 @@ void Foam::lumpedMassWallTemperatureFvPatchScalarField::updateCoeffs()
             }
         }
 
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
         Info<< patch().boundaryMesh().mesh().name() << ':'
             << patch().name() << ':'
             << this->internalField().name() << " :"
             << " heat transfer rate:" << Q
             << " wall temperature "
-            << " min:" << gMin(*this)
-            << " max:" << gMax(*this)
-            << " avg:" << gAverage(*this)
+            << " min:" << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg
             << " Qin [W]:" << Qin
             << " Qout [W]:" << Qout
             << endl;
diff --git a/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C
index bb3532b43d3..c73f38cd620 100644
--- a/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C
+++ b/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C
@@ -400,6 +400,10 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
         if (debug)
         {
             scalar Q = gAverage(kappaw*snGrad());
+
+            auto limits = gMinMax(*this);
+            auto avg = gAverage(*this);
+
             Info<< patch().boundaryMesh().mesh().name() << ':'
                 << patch().name() << ':'
                 << this->internalField().name() << " <- "
@@ -407,9 +411,9 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
                 << this->internalField().name() << " :"
                 << " heat[W]:" << Q
                 << " walltemperature "
-                << " min:" << gMin(*this)
-                << " max:" << gMax(*this)
-                << " avg:" << gAverage(*this)
+                << " min:" << limits.min()
+                << " max:" << limits.max()
+                << " avg:" << avg
                 << endl;
         }
     }
diff --git a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
index d2066bec6d8..dcd7821636c 100644
--- a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
+++ b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
@@ -385,6 +385,9 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
     {
         scalar Q = gSum(kappaTp*patch().magSf()*snGrad());
 
+        auto limits = gMinMax(*this);
+        auto avg = gAverage(*this);
+
         Info<< patch().boundaryMesh().mesh().name() << ':'
             << patch().name() << ':'
             << this->internalField().name() << " <- "
@@ -393,9 +396,9 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
             << this->internalField().name() << " :"
             << " heat transfer rate:" << Q
             << " walltemperature "
-            << " min:" << gMin(*this)
-            << " max:" << gMax(*this)
-            << " avg:" << gAverage(*this)
+            << " min:" << limits.min()
+            << " max:" << limits.max()
+            << " avg:" << avg
             << endl;
     }
 
diff --git a/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/enthalpySorption/enthalpySorptionFvPatchScalarField.C b/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/enthalpySorption/enthalpySorptionFvPatchScalarField.C
index ca9bee458fa..3a8d0004eef 100644
--- a/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/enthalpySorption/enthalpySorptionFvPatchScalarField.C
+++ b/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/enthalpySorption/enthalpySorptionFvPatchScalarField.C
@@ -234,8 +234,10 @@ patchSource() const
 
     if (debug)
     {
+        auto limits = gMinMax(dhdt);
+
         Info<< " Patch enthalpy rate min/max [J/m3/sec]: "
-            << gMin(dhdt) << " - " << gMax(dhdt) << endl;
+            << limits.min() << " - " << limits.max() << endl;
     }
 
     return tmp<scalarField>::New(dhdt);
@@ -282,8 +284,10 @@ void Foam::enthalpySorptionFvPatchScalarField::updateCoeffs()
 
     if (debug)
     {
+        auto limits = gMinMax(dhdt_);
+
         Info<< "  Enthalpy change min/max [J/kg]: "
-            << gMin(dhdt_) << " - " << gMax(dhdt_) << endl;
+            << limits.min() << " - " << limits.max() << endl;
     }
 
     zeroGradientFvPatchScalarField::updateCoeffs();
diff --git a/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C b/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C
index 26a4a27fd63..2318c265508 100644
--- a/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C
+++ b/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C
@@ -321,8 +321,10 @@ patchSource() const
 
     if (debug)
     {
+        auto limits = gMinMax(dfldp);
+
         Info<< " Patch mass rate min/max [kg/m3/sec]: "
-            << gMin(dfldp) << " - " << gMax(dfldp) << endl;
+            << limits.min() << " - " << limits.max() << endl;
     }
 
     return tmp<scalarField>::New(dfldp);
@@ -391,8 +393,10 @@ void Foam::speciesSorptionFvPatchScalarField::updateCoeffs()
 
     if (debug)
     {
+        auto limits = gMinMax(dfldp_);
+
         Info<< "  Absorption rate min/max [mol/kg/sec]: "
-            << gMin(dfldp_) << " - " << gMax(dfldp_) << endl;
+            << limits.min() << " - " << limits.max() << endl;
     }
 
     zeroGradientFvPatchScalarField::updateCoeffs();
diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C
index 0b0d1e8bef5..be8b4aab607 100644
--- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C
+++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C
@@ -134,7 +134,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
          && fc[facei].x() < -0.003499
         )
         {
-            if ((fa[facei] & vector(1, 0, 0)) < 0)
+            if (fa[facei].x() < 0)
             {
                 flipZone1[nZoneFaces1] = true;
             }
@@ -152,7 +152,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
         {
             zone2[nZoneFaces2] = facei;
 
-            if ((fa[facei] & vector(1, 0, 0)) > 0)
+            if (fa[facei].x() > 0)
             {
                 flipZone2[nZoneFaces2] = true;
             }
diff --git a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C
index 6ecf2ad0176..d34604b2566 100644
--- a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C
+++ b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C
@@ -160,11 +160,9 @@ Foam::isoAdvection::isoAdvection
 
         if (porosityPtr_)
         {
-            if
-            (
-                gMin(porosityPtr_->primitiveField()) <= 0
-             || gMax(porosityPtr_->primitiveField()) > 1 + SMALL
-            )
+            auto limits = gMinMax(porosityPtr_->primitiveField());
+
+            if (limits.min() <= 0 || limits.max() > 1 + SMALL)
             {
                 FatalErrorInFunction
                     << "Porosity field has values <= 0 or > 1"
diff --git a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvectionTemplates.C b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvectionTemplates.C
index 422d86c8963..b0dc0607d77 100644
--- a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvectionTemplates.C
+++ b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvectionTemplates.C
@@ -121,9 +121,11 @@ void Foam::isoAdvection::limitFluxes
     addProfilingInFunction(geometricVoF);
     DebugInFunction << endl;
 
+    auto alpha1Limits = gMinMax(alpha1_);
+
     const scalar aTol = 100*SMALL;          // Note: tolerances
-    scalar maxAlphaMinus1 = gMax(alpha1_) - 1;      // max(alphaNew - 1);
-    scalar minAlpha = gMin(alpha1_);           // min(alphaNew);
+    scalar maxAlphaMinus1 = alpha1Limits.max() - 1;  // max(alphaNew - 1);
+    scalar minAlpha = alpha1Limits.min();            // min(alphaNew);
     const label nOvershoots = 20;         // sum(pos0(alphaNew - 1 - aTol));
 
     const labelList& owner = mesh_.faceOwner();
@@ -232,8 +234,10 @@ void Foam::isoAdvection::limitFluxes
             break;
         }
 
-        maxAlphaMinus1 = gMax(alpha1_) - 1;     // max(alphaNew - 1);
-        minAlpha = gMin(alpha1_);               // min(alphaNew);
+        alpha1Limits = gMinMax(alpha1_);
+
+        maxAlphaMinus1 = alpha1Limits.max() - 1;  // max(alphaNew - 1);
+        minAlpha = alpha1Limits.min();            // min(alphaNew);
 
         if (debug)
         {
@@ -486,11 +490,13 @@ void Foam::isoAdvection::advect(const SpType& Sp, const SuType& Su)
     // Adjust dVf for unbounded cells
     limitFluxes(Sp, Su);
 
-    scalar maxAlphaMinus1 = gMax(alpha1In_) - 1;
-    scalar minAlpha = gMin(alpha1In_);
+    {
+        auto limits = gMinMax(alpha1In_);
 
-    Info<< "isoAdvection: After conservative bounding: min(alpha) = "
-        << minAlpha << ", max(alpha) = 1 + " << maxAlphaMinus1 << endl;
+        Info<< "isoAdvection: After conservative bounding:"
+            << " min(alpha) = " << limits.min()
+            << ", max(alpha) = 1 + " << (limits.max()-1) << endl;
+    }
 
     // Apply non-conservative bounding mechanisms (clipping and snapping)
     // Note: We should be able to write out alpha before this is done!
-- 
GitLab


From 0be19b7fae79259447ae9683e5e06645c1c6de17 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 2 Apr 2025 21:23:16 +0200
Subject: [PATCH 4/5] COMP: namespace qualify min/max functions (#3348)

FIX: missing patch face index writeFields (#3347)
---
 .../compressibleInterFoam/alphaSuSp.H         |  6 +-
 .../compressibleInterIsoFoam/alphaSuSp.H      |  6 +-
 .../overCompressibleInterDyMFoam/alphaSuSp.H  |  6 +-
 .../makeFaMesh/checkPatchTopology.H           |  4 +-
 .../utilities/mesh/advanced/PDRMesh/PDRMesh.C |  3 +-
 .../mesh/conversion/cfx4ToFoam/cfx4ToFoam.C   | 10 +--
 .../conversion/gambitToFoam/gambitToFoam.L    |  4 +-
 .../ideasUnvToFoam/ideasUnvToFoam.C           |  4 +-
 .../mesh/conversion/kivaToFoam/checkPatch.H   |  6 +-
 .../mesh/conversion/kivaToFoam/readKivaGrid.H |  6 +-
 .../netgenNeutralToFoam/netgenNeutralToFoam.C |  2 +-
 .../extrudeToRegionMesh/extrudeToRegionMesh.C | 14 ++--
 .../mesh/manipulation/checkMesh/writeFields.C | 68 +++++++++----------
 .../manipulation/renumberMesh/renumberMesh.C  |  8 ++-
 .../mesh/manipulation/setSet/setSet.C         |  6 +-
 .../mesh/manipulation/subsetMesh/subsetMesh.C |  3 +-
 .../reconstructParMesh/reconstructParMesh.C   |  2 +-
 .../redistributePar/redistributePar.C         |  6 +-
 .../particleTracks/particleTracks.C           |  4 +-
 .../PDR/pdrFields/PDRarraysCalc.C             | 14 ++--
 .../PDR/pdrFields/PDRutilsOverlap.C           | 18 ++---
 .../preProcessing/engineSwirl/engineSwirl.C   |  4 +-
 .../surface/surfaceCheck/surfaceCheck.C       |  4 +-
 .../surface/surfaceHookUp/surfaceHookUp.C     |  2 +-
 .../surface/surfaceInflate/surfaceInflate.C   | 12 ++--
 .../surfaceMeshExtract/surfaceMeshExtract.C   |  2 +-
 .../adiabaticFlameT/adiabaticFlameT.C         |  4 +-
 .../equilibriumFlameT/equilibriumFlameT.C     | 12 ++--
 .../faDecompose/faMeshDecomposition.C         |  9 ++-
 .../pyrolysisModel/pyrolysisModelCollection.C |  6 +-
 30 files changed, 127 insertions(+), 128 deletions(-)

diff --git a/applications/solvers/multiphase/compressibleInterFoam/alphaSuSp.H b/applications/solvers/multiphase/compressibleInterFoam/alphaSuSp.H
index ce2e5520015..cc698aefed8 100644
--- a/applications/solvers/multiphase/compressibleInterFoam/alphaSuSp.H
+++ b/applications/solvers/multiphase/compressibleInterFoam/alphaSuSp.H
@@ -26,12 +26,12 @@ forAll(dgdt, celli)
 {
     if (dgdt[celli] > 0.0)
     {
-        Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
-        Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
+        Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
+        Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
     }
     else if (dgdt[celli] < 0.0)
     {
-        Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
+        Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
     }
 }
 
diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/alphaSuSp.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/alphaSuSp.H
index 65c5750ff94..457f40891af 100644
--- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/alphaSuSp.H
+++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/alphaSuSp.H
@@ -26,12 +26,12 @@ forAll(dgdt, celli)
 {
     if (dgdt[celli] > 0.0)
     {
-        Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
-        Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
+        Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
+        Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
     }
     else if (dgdt[celli] < 0.0)
     {
-        Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
+        Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
     }
 }
 
diff --git a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/alphaSuSp.H b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/alphaSuSp.H
index 65c5750ff94..457f40891af 100644
--- a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/alphaSuSp.H
+++ b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/alphaSuSp.H
@@ -26,12 +26,12 @@ forAll(dgdt, celli)
 {
     if (dgdt[celli] > 0.0)
     {
-        Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
-        Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
+        Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
+        Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
     }
     else if (dgdt[celli] < 0.0)
     {
-        Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
+        Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
     }
 }
 
diff --git a/applications/utilities/finiteArea/makeFaMesh/checkPatchTopology.H b/applications/utilities/finiteArea/makeFaMesh/checkPatchTopology.H
index a38666a544f..6202b67cd86 100644
--- a/applications/utilities/finiteArea/makeFaMesh/checkPatchTopology.H
+++ b/applications/utilities/finiteArea/makeFaMesh/checkPatchTopology.H
@@ -108,13 +108,13 @@ Input
             if (numNbrs == 1)
             {
                 //if (pointSetPtr) pointSetPtr->insert(mesh.edges()[meshEdgei]);
-                labelTyp = max(labelTyp, TopoType::OPEN);
+                labelTyp = Foam::max(labelTyp, TopoType::OPEN);
             }
             else if (numNbrs == 0 || numNbrs > 2)
             {
                 if (pointSetPtr) pointSetPtr->insert(mesh.edges()[meshEdgei]);
                 if (badEdgesPtr) badEdgesPtr->insert(edgei);
-                labelTyp = max(labelTyp, TopoType::ILLEGAL);
+                labelTyp = Foam::max(labelTyp, TopoType::ILLEGAL);
             }
         }
         reduce(labelTyp, maxOp<label>());
diff --git a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C
index 645a5073d18..f2e6a8be6d7 100644
--- a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C
+++ b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C
@@ -368,7 +368,8 @@ void subsetTopoSets
 
         Info<< "Subsetting " << set.type() << ' ' << set.name() << endl;
 
-        labelHashSet subset(2*min(set.size(), map.size()));
+        labelHashSet subset;
+        subset.reserve(Foam::min(set.size(), map.size()));
 
         // Map the data
         forAll(map, i)
diff --git a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C
index c8294f55be9..c6388a0e5b9 100644
--- a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C
+++ b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C
@@ -271,7 +271,7 @@ int main(int argc, char *argv[])
                     if (blockPFacePointi != blockPFacePointi2)
                     {
                         sqrMergeTol =
-                            min
+                            Foam::min
                             (
                                 sqrMergeTol,
                                 magSqr
@@ -338,16 +338,16 @@ int main(int argc, char *argv[])
                         blockNFacePoints[blockNFacePointi]
                       + blockOffsets[blockNlabel];
 
-                    label minPN = min(PpointLabel, NpointLabel);
+                    label minPN = Foam::min(PpointLabel, NpointLabel);
 
                     if (pointMergeList[PpointLabel] != -1)
                     {
-                        minPN = min(minPN, pointMergeList[PpointLabel]);
+                        minPN = Foam::min(minPN, pointMergeList[PpointLabel]);
                     }
 
                     if (pointMergeList[NpointLabel] != -1)
                     {
-                        minPN = min(minPN, pointMergeList[NpointLabel]);
+                        minPN = Foam::min(minPN, pointMergeList[NpointLabel]);
                     }
 
                     pointMergeList[PpointLabel]
@@ -411,7 +411,7 @@ int main(int argc, char *argv[])
 
                         pointMergeList[PpointLabel]
                       = pointMergeList[NpointLabel]
-                      = min
+                      = Foam::min
                         (
                             pointMergeList[PpointLabel],
                             pointMergeList[NpointLabel]
diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
index c29bff53e58..23739c02ca2 100644
--- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
+++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
@@ -350,7 +350,7 @@ mtype                 {space}"MTYPE:"{space}
         // Find out how many labels are expected. If less or equal to
         // seven, read them all and finish with it. If there is more,
         // set read of the next line
-        label labelsToRead = min(8, nVertices);
+        label labelsToRead = Foam::min(8, nVertices);
         label labelI = 0;
         for (; labelI < labelsToRead; labelI++)
         {
@@ -387,7 +387,7 @@ mtype                 {space}"MTYPE:"{space}
 
         labelList& curLabels = cellLabels[curNumberOfCells];
 
-        label labelsToRead = min
+        label labelsToRead = Foam::min
         (
             (nCellContinuationLines + 1)*7,
             curLabels.size()
diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C
index cfc923bcf30..36f89a1814e 100644
--- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C
+++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C
@@ -269,7 +269,7 @@ void readCells
     label maxUnvPoint = 0;
     forAll(unvPointID, pointi)
     {
-        maxUnvPoint = max(maxUnvPoint, unvPointID[pointi]);
+        maxUnvPoint = Foam::max(maxUnvPoint, unvPointID[pointi]);
     }
     labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));
 
@@ -784,7 +784,7 @@ int main(int argc, char *argv[])
     label maxUnvPoint = 0;
     forAll(unvPointID, pointi)
     {
-        maxUnvPoint = max(maxUnvPoint, unvPointID[pointi]);
+        maxUnvPoint = Foam::max(maxUnvPoint, unvPointID[pointi]);
     }
     labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));
 
diff --git a/applications/utilities/mesh/conversion/kivaToFoam/checkPatch.H b/applications/utilities/mesh/conversion/kivaToFoam/checkPatch.H
index 6e9eaae3819..708b9664f53 100644
--- a/applications/utilities/mesh/conversion/kivaToFoam/checkPatch.H
+++ b/applications/utilities/mesh/conversion/kivaToFoam/checkPatch.H
@@ -8,10 +8,10 @@
         {
             if (kivaVersion == kiva3v)
             {
-                regionIndex = max
+                regionIndex = Foam::max
                 (
-                    max(idface[quadFace[0]], idface[quadFace[1]]),
-                    max(idface[quadFace[2]], idface[quadFace[3]])
+                    Foam::max(idface[quadFace[0]], idface[quadFace[1]]),
+                    Foam::max(idface[quadFace[2]], idface[quadFace[3]])
                 );
 
                 if (regionIndex > 0)
diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H
index fa8c5548dd0..6c7c23137ab 100644
--- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H
+++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H
@@ -148,9 +148,7 @@ for (label i=0; i<nPoints; i++)
                     end = pointMap[end];
                 }
 
-                label minLabel = min(start, end);
-
-                pointMap[start] = pointMap[end] = minLabel;
+                pointMap[start] = pointMap[end] = Foam::min(start, end);
             }
         }
 
@@ -331,7 +329,7 @@ if
     {
         forAll(pf, pfi)
         {
-            minz = min(minz, points[pf[pfi]].z());
+            minz = Foam::min(minz, points[pf[pfi]].z());
         }
     }
 
diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C
index c9cbabe10b5..7c719aa8536 100644
--- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C
+++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
         }
 
 
-        maxPatch = max(maxPatch, patchi);
+        maxPatch = Foam::max(maxPatch, patchi);
 
         triFace tri(readLabel(str)-1, readLabel(str)-1, readLabel(str)-1);
 
diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C
index d1fb66a6056..c536d2c840d 100644
--- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C
+++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C
@@ -556,8 +556,8 @@ void calcEdgeMinMaxZone
             forAll(eFaces, i)
             {
                 label zoneI = mappedZoneID[eFaces[i]];
-                minZoneID[edgeI] = min(minZoneID[edgeI], zoneI);
-                maxZoneID[edgeI] = max(maxZoneID[edgeI], zoneI);
+                minZoneID[edgeI] = Foam::min(minZoneID[edgeI], zoneI);
+                maxZoneID[edgeI] = Foam::max(maxZoneID[edgeI], zoneI);
             }
         }
     }
@@ -813,8 +813,8 @@ void addCoupledPatches
             forAll(eFaces, i)
             {
                 label proci = procID[eFaces[i]];
-                minProcID[edgeI] = min(minProcID[edgeI], proci);
-                maxProcID[edgeI] = max(maxProcID[edgeI], proci);
+                minProcID[edgeI] = Foam::min(minProcID[edgeI], proci);
+                maxProcID[edgeI] = Foam::max(maxProcID[edgeI], proci);
             }
         }
     }
@@ -1291,7 +1291,7 @@ void extrudeGeometricProperties
             label celli = regionMesh.faceOwner()[facei];
             if (regionMesh.isInternalFace(facei))
             {
-                celli = max(celli, regionMesh.faceNeighbour()[facei]);
+                celli = Foam::max(celli, regionMesh.faceNeighbour()[facei]);
             }
 
             // Calculate layer from cell numbering (see createShellMesh)
@@ -2210,8 +2210,8 @@ int main(int argc, char *argv[])
 
             if (addSidePatches && (zone0 != zone1)) // || (cos(angle) > blabla))
             {
-                label minZone = min(zone0,zone1);
-                label maxZone = max(zone0,zone1);
+                label minZone = Foam::min(zone0,zone1);
+                label maxZone = Foam::max(zone0,zone1);
                 label index = minZone*zoneNames.size()+maxZone;
 
                 ePatches.setSize(eFaces.size());
diff --git a/applications/utilities/mesh/manipulation/checkMesh/writeFields.C b/applications/utilities/mesh/manipulation/checkMesh/writeFields.C
index c16334b9e3f..8dd9c08459b 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/writeFields.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/writeFields.C
@@ -21,19 +21,16 @@ void maxFaceToCell
     scalarField& cellFld = cellData.ref();
 
     cellFld = -GREAT;
-    forAll(cells, cellI)
+    forAll(cells, celli)
     {
-        const cell& cFaces = cells[cellI];
-        forAll(cFaces, i)
+        for (const label facei : cells[celli])
         {
-            cellFld[cellI] = max(cellFld[cellI], faceData[cFaces[i]]);
+            cellFld[celli] = Foam::max(cellFld[celli], faceData[facei]);
         }
     }
 
-    forAll(cellData.boundaryField(), patchI)
+    for (fvPatchScalarField& fvp : cellData.boundaryFieldRef())
     {
-        fvPatchScalarField& fvp = cellData.boundaryFieldRef()[patchI];
-
         fvp = fvp.patch().patchSlice(faceData);
     }
     cellData.correctBoundaryConditions();
@@ -51,19 +48,16 @@ void minFaceToCell
     scalarField& cellFld = cellData.ref();
 
     cellFld = GREAT;
-    forAll(cells, cellI)
+    forAll(cells, celli)
     {
-        const cell& cFaces = cells[cellI];
-        forAll(cFaces, i)
+        for (const label facei : cells[celli])
         {
-            cellFld[cellI] = min(cellFld[cellI], faceData[cFaces[i]]);
+            cellFld[celli] = Foam::min(cellFld[celli], faceData[facei]);
         }
     }
 
-    forAll(cellData.boundaryField(), patchI)
+    for (fvPatchScalarField& fvp : cellData.boundaryFieldRef())
     {
-        fvPatchScalarField& fvp = cellData.boundaryFieldRef()[patchI];
-
         fvp = fvp.patch().patchSlice(faceData);
     }
     cellData.correctBoundaryConditions();
@@ -77,7 +71,7 @@ void minFaceToCell
     const bool correctBoundaryConditions
 )
 {
-    scalarField& cellFld = cellData.ref();
+    scalarField& cellFld = cellData.primitiveFieldRef();
 
     cellFld = GREAT;
 
@@ -87,19 +81,19 @@ void minFaceToCell
     // Internal faces
     forAll(own, facei)
     {
-        cellFld[own[facei]] = min(cellFld[own[facei]], faceData[facei]);
-        cellFld[nei[facei]] = min(cellFld[nei[facei]], faceData[facei]);
+        cellFld[own[facei]] = Foam::min(cellFld[own[facei]], faceData[facei]);
+        cellFld[nei[facei]] = Foam::min(cellFld[nei[facei]], faceData[facei]);
     }
 
     // Patch faces
-    forAll(faceData.boundaryField(), patchi)
+    for (const fvsPatchScalarField& fvp : faceData.boundaryField())
     {
-        const fvsPatchScalarField& fvp = faceData.boundaryField()[patchi];
-        const labelUList& fc = fvp.patch().faceCells();
+        label pfacei = 0;
 
-        forAll(fc, i)
+        for (const label celli : fvp.patch().faceCells())
         {
-            cellFld[fc[i]] = min(cellFld[fc[i]], fvp[i]);
+            cellFld[celli] = Foam::max(cellFld[celli], fvp[pfacei]);
+            ++pfacei;
         }
     }
 
@@ -163,7 +157,7 @@ void Foam::writeFields
     if (selectedFields.found("nonOrthoAngle"))
     {
         //- Face based orthogonality
-        const scalarField faceOrthogonality
+        scalarField faceOrthogonality
         (
             polyMeshTools::faceOrthogonality
             (
@@ -172,14 +166,12 @@ void Foam::writeFields
                 mesh.cellCentres()
             )
         );
+        faceOrthogonality.clamp_range(-1, 1);
 
         //- Face based angle
         const scalarField nonOrthoAngle
         (
-            radToDeg
-            (
-                Foam::acos(min(scalar(1), max(scalar(-1), faceOrthogonality)))
-            )
+            radToDeg(Foam::acos(faceOrthogonality))
         );
 
         //- Cell field - max of either face
@@ -534,7 +526,7 @@ void Foam::writeFields
                         ownCc,
                         fc
                     ).quality();
-                    ownVol = min(ownVol, tetQual);
+                    ownVol = Foam::min(ownVol, tetQual);
                 }
             }
             if (mesh.isInternalFace(facei))
@@ -550,7 +542,7 @@ void Foam::writeFields
                         fc,
                         neiCc
                     ).quality();
-                    neiVol = min(neiVol, tetQual);
+                    neiVol = Foam::min(neiVol, tetQual);
                 }
             }
         }
@@ -602,19 +594,23 @@ void Foam::writeFields
         // Internal faces
         forAll(own, facei)
         {
-            cellFld[own[facei]] = min(cellFld[own[facei]], ownPyrVol[facei]);
-            cellFld[nei[facei]] = min(cellFld[nei[facei]], neiPyrVol[facei]);
+            cellFld[own[facei]] =
+                Foam::min(cellFld[own[facei]], ownPyrVol[facei]);
+            cellFld[nei[facei]] =
+                Foam::min(cellFld[nei[facei]], neiPyrVol[facei]);
         }
 
         // Patch faces
         for (const auto& fvp : minPyrVolume.boundaryField())
         {
-            const labelUList& fc = fvp.patch().faceCells();
+            label meshFacei = fvp.patch().start();
 
-            forAll(fc, i)
+            for (const label celli : fvp.patch().faceCells())
             {
-                const label meshFacei = fvp.patch().start();
-                cellFld[fc[i]] = min(cellFld[fc[i]], ownPyrVol[meshFacei]);
+                cellFld[celli] =
+                    Foam::min(cellFld[celli], ownPyrVol[meshFacei]);
+
+                ++meshFacei;
             }
         }
 
@@ -625,7 +621,7 @@ void Foam::writeFields
         if (writeFaceFields)
         {
             scalarField minFacePyrVol(neiPyrVol);
-            minFacePyrVol = min
+            minFacePyrVol = Foam::min
             (
                 minFacePyrVol,
                 SubField<scalar>(ownPyrVol, mesh.nInternalFaces())
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
index c5763634bd3..b0a30a0a787 100644
--- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
+++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
@@ -465,7 +465,7 @@ labelList getRegionFaceOrder
 
     // Do region interfaces
     {
-        const label nRegions = max(cellToRegion)+1;
+        const label nRegions = Foam::max(cellToRegion)+1;
 
         // Sort in increasing region
         SortableList<label> sortKey(mesh.nInternalFaces(), labelMax);
@@ -478,8 +478,10 @@ labelList getRegionFaceOrder
             if (ownRegion != neiRegion)
             {
                 sortKey[facei] =
-                    min(ownRegion, neiRegion)*nRegions
-                   +max(ownRegion, neiRegion);
+                (
+                    Foam::min(ownRegion, neiRegion)*nRegions
+                  + Foam::max(ownRegion, neiRegion)
+                );
             }
         }
 
diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C
index af462ed6d94..3ca4aedf7b7 100644
--- a/applications/utilities/mesh/manipulation/setSet/setSet.C
+++ b/applications/utilities/mesh/manipulation/setSet/setSet.C
@@ -320,10 +320,10 @@ bool doCommand
     const globalMeshData& parData = mesh.globalData();
 
     label typSize =
-        max
+        Foam::max
         (
             parData.nTotalCells(),
-            max
+            Foam::max
             (
                 parData.nTotalFaces(),
                 parData.nTotalPoints()
@@ -375,7 +375,7 @@ bool doCommand
 
                 topoSet& currentSet = currentSetPtr();
                 // Presize it according to current mesh data.
-                currentSet.reserve(max(currentSet.size(), typSize));
+                currentSet.reserve(Foam::max(currentSet.size(), typSize));
             }
         }
 
diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
index 1b195acc032..22c781a7ad2 100644
--- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
+++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
@@ -295,7 +295,8 @@ void subsetTopoSets
 
         Info<< "Subsetting " << set.type() << " " << set.name() << endl;
 
-        labelHashSet subset(2*min(set.size(), map.size()));
+        labelHashSet subset;
+        subset.reserve(Foam::min(set.size(), map.size()));
 
         // Map the data
         forAll(map, i)
diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
index d4611d3f25b..35add854354 100644
--- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
+++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
@@ -1131,7 +1131,7 @@ int main(int argc, char *argv[])
                         for
                         (
                             label addedI=next;
-                            addedI<min(proci+step, nProcs);
+                            addedI < Foam::min(proci+step, nProcs);
                             addedI++
                         )
                         {
diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
index 4ac8fd1acb6..f1461bac18d 100644
--- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
+++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
@@ -403,11 +403,11 @@ void printMeshData(const polyMesh& mesh)
                 << nBndFaces-nProcFaces << endl;
         }
 
-        maxProcCells = max(maxProcCells, nLocalCells);
+        maxProcCells = Foam::max(maxProcCells, nLocalCells);
         totProcFaces += nProcFaces;
         totProcPatches += nei.size();
-        maxProcFaces = max(maxProcFaces, nProcFaces);
-        maxProcPatches = max(maxProcPatches, nei.size());
+        maxProcFaces = Foam::max(maxProcFaces, nProcFaces);
+        maxProcPatches = Foam::max(maxProcPatches, nei.size());
     }
 
     // Summary stats
diff --git a/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C b/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C
index 2202574ad88..1e6af8563f9 100644
--- a/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C
+++ b/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
     args.readIfPresent("format", setFormat);
 
     args.readIfPresent("stride", sampleFrequency);
-    sampleFrequency = max(1, sampleFrequency);  // sanity
+    sampleFrequency = Foam::max(1, sampleFrequency);  // sanity
 
     // Setup the writer
     auto writerPtr =
@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
                     maxIds.resize(origProc+1, -1);
                 }
 
-                maxIds[origProc] = max(maxIds[origProc], origId);
+                maxIds[origProc] = Foam::max(maxIds[origProc], origId);
             }
         }
 
diff --git a/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C b/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C
index 382086b80b4..f25ede0b3e4 100644
--- a/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C
+++ b/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C
@@ -1056,7 +1056,7 @@ void calc_drag_etc
     const scalar expon =
     (
         br > 0.0
-      ? min(max((surr_br / br - 0.25) * 4.0 / 3.0, scalar(0)), scalar(1))
+      ? Foam::clamp((surr_br / br - 0.25) * 4.0 / 3.0, Foam::zero_one{})
       : 0.0
     );
 
@@ -1114,16 +1114,16 @@ void Foam::PDRarrays::blockageSummary() const
                 totVolBlock += v_block(ijk) * pdrBlock.V(ijk);
                 totArea += surf(ijk);
 
-                totCount += max(0, obs_count(ijk));
+                totCount += Foam::max(0, obs_count(ijk));
 
-                totDrag.x() += max(0, drag_s(ijk).xx());
-                totDrag.y() += max(0, drag_s(ijk).yy());
-                totDrag.z() += max(0, drag_s(ijk).zz());
+                totDrag.x() += Foam::max(0, drag_s(ijk).xx());
+                totDrag.y() += Foam::max(0, drag_s(ijk).yy());
+                totDrag.z() += Foam::max(0, drag_s(ijk).zz());
 
                 for (direction cmpt=0; cmpt < vector::nComponents; ++cmpt)
                 {
-                    totBlock[cmpt] += max(0, area_block_s(ijk)[cmpt]);
-                    totBlock[cmpt] += max(0, area_block_r(ijk)[cmpt]);
+                    totBlock[cmpt] += Foam::max(0, area_block_s(ijk)[cmpt]);
+                    totBlock[cmpt] += Foam::max(0, area_block_r(ijk)[cmpt]);
                 }
             }
         }
diff --git a/applications/utilities/preProcessing/PDR/pdrFields/PDRutilsOverlap.C b/applications/utilities/preProcessing/PDR/pdrFields/PDRutilsOverlap.C
index 1c27f536cfe..b79311b49ae 100644
--- a/applications/utilities/preProcessing/PDR/pdrFields/PDRutilsOverlap.C
+++ b/applications/utilities/preProcessing/PDR/pdrFields/PDRutilsOverlap.C
@@ -302,7 +302,7 @@ void Foam::PDRutils::circle_overlap
                     scalar da = ac - 0.5 * (a1 + a2);
                     scalar db = bc - 0.5 * (b1 + b2);
                     scalar dc = std::hypot(da, db);
-                    scalar rat1 = min(max((dc / sqrt(area) - 0.3) * 1.4, 0), 1);
+                    scalar rat1 = Foam::min(Foam::max((dc / sqrt(area) - 0.3) * 1.4, 0), 1);
                     scalar drg0 = c_drag(ia,ib).xx();
                     scalar drg1 = c_drag(ia,ib).yy();
                     scalar drg = std::hypot(drg0, drg1);
@@ -449,8 +449,8 @@ scalar block_overlap
             {
                 PDRobstacle over;
 
-                over.pt = max(blk1.pt, blk2.pt);
-                over.span = min(max1, max2) - over.pt;
+                over.pt = Foam::max(blk1.pt, blk2.pt);
+                over.span = Foam::min(max1, max2) - over.pt;
 
                 assert(cmptProduct(over.span) > 0.0);
 
@@ -603,11 +603,11 @@ scalar block_cylinder_overlap
 
                     over.x() = a_centre - 0.5 * a_lblk;
                     over.y() = b_centre - 0.5 * b_lblk;
-                    over.z() = max(blk1.z(), cyl2.z());
+                    over.z() = Foam::max(blk1.z(), cyl2.z());
 
                     over.span.x() = a_lblk;
                     over.span.y() = b_lblk;
-                    over.span.z() = min(max1.z(), cyl2.z() + cyl2.len()) - over.z();
+                    over.span.z() = Foam::min(max1.z(), cyl2.z() + cyl2.len()) - over.z();
                     assert(over.x() > -200.0);
                     assert(over.x() < 2000.0);
                 }
@@ -668,11 +668,11 @@ scalar block_cylinder_overlap
 
                     over.z() = a_centre - a_lblk * 0.5;
                     over.x() = b_centre - b_lblk * 0.5;
-                    over.y() = max(blk1.y(), cyl2.y());
+                    over.y() = Foam::max(blk1.y(), cyl2.y());
 
                     over.span.z() = a_lblk;
                     over.span.x() = b_lblk;
-                    over.span.y() = min(max1.y(), cyl2.y() + cyl2.len()) - over.y();
+                    over.span.y() = Foam::min(max1.y(), cyl2.y() + cyl2.len()) - over.y();
                 }
                 break;
 
@@ -734,11 +734,11 @@ scalar block_cylinder_overlap
 
                     over.y() = a_centre - a_lblk * 0.5;
                     over.z() = b_centre - b_lblk * 0.5;
-                    over.x() = max(blk1.x(), cyl2.x());
+                    over.x() = Foam::max(blk1.x(), cyl2.x());
 
                     over.span.y() = a_lblk;
                     over.span.z() = b_lblk;
-                    over.span.x() = min(max1.x(), cyl2.x() + cyl2.len()) - over.x();
+                    over.span.x() = Foam::min(max1.x(), cyl2.x() + cyl2.len()) - over.x();
                 }
                 break;
             }
diff --git a/applications/utilities/preProcessing/engineSwirl/engineSwirl.C b/applications/utilities/preProcessing/engineSwirl/engineSwirl.C
index cb50df54859..9c1d70e96a4 100644
--- a/applications/utilities/preProcessing/engineSwirl/engineSwirl.C
+++ b/applications/utilities/preProcessing/engineSwirl/engineSwirl.C
@@ -71,9 +71,9 @@ int main(int argc, char *argv[])
         {
             scalar b = j1(swirlProfile*r/cylinderRadius).value();
             scalar vEff = omega*b;
-            r = max(r, SMALL);
+            r = Foam::max(r, SMALL);
             U[celli] = ((vEff/r)*(c & yT))*xT + (-(vEff/r)*(c & xT))*yT;
-            Umax = max(Umax, mag(U[celli]));
+            Umax = Foam::max(Umax, mag(U[celli]));
         }
     }
 
diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C
index 7c6be507e17..15ec124430b 100644
--- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C
+++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C
@@ -887,7 +887,7 @@ int main(int argc, char *argv[])
             writeParts
             (
                 surf,
-                min(outputThreshold, numZones),
+                Foam::min(outputThreshold, numZones),
                 faceZone,
                 surfFilePath,
                 surfFileStem
@@ -953,7 +953,7 @@ int main(int argc, char *argv[])
             writeParts
             (
                 surf,
-                min(outputThreshold, numNormalZones),
+                Foam::min(outputThreshold, numNormalZones),
                 normalZone,
                 surfFilePath,
                 surfFileStem + "_normal"
diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C
index 603f07b43fd..ef0b74fdcf7 100644
--- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C
+++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C
@@ -280,7 +280,7 @@ int main(int argc, char *argv[])
     const IOdictionary dict(dictIO);
 
     const scalar dist(args.get<scalar>(1));
-    const scalar matchTolerance(max(1e-6*dist, SMALL));
+    const scalar matchTolerance(Foam::max(1e-6*dist, SMALL));
     const label maxIters = 100;
 
     Info<< "Hooking distance = " << dist << endl;
diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C
index 3292780ef73..4a16e37c8b5 100644
--- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C
+++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C
@@ -276,7 +276,7 @@ label detectIntersectionPoints
 
     // 1. Extrusion offset vectors intersecting new surface location
     {
-        scalar tol = max(tolerance, 10*s.tolerance());
+        scalar tol = Foam::max(tolerance, 10*s.tolerance());
 
         // Collect all the edge vectors. Slightly shorten the edges to prevent
         // finding lots of intersections. The fast triangle intersection routine
@@ -296,7 +296,7 @@ label detectIntersectionPoints
             &&  !localFaces[hits[pointI].index()].found(pointI)
             )
             {
-                scale[pointI] = max(0.0, scale[pointI]-0.2);
+                scale[pointI] = Foam::max(0.0, scale[pointI]-0.2);
 
                 isPointOnHitEdge.set(pointI);
                 nHits++;
@@ -330,7 +330,7 @@ label detectIntersectionPoints
                         << pt
                         << endl;
 
-                    scale[e[0]] = max(0.0, scale[e[0]]-0.2);
+                    scale[e[0]] = Foam::max(0.0, scale[e[0]]-0.2);
                     nHits++;
                 }
                 if (isPointOnHitEdge.set(e[1]))
@@ -342,7 +342,7 @@ label detectIntersectionPoints
                         << pt
                         << endl;
 
-                    scale[e[1]] = max(0.0, scale[e[1]]-0.2);
+                    scale[e[1]] = Foam::max(0.0, scale[e[1]]-0.2);
                     nHits++;
                 }
             }
@@ -418,7 +418,7 @@ void minSmooth
         const edge& e = edges[edgeI];
         scalar w = mag(points[mp[e[0]]]-points[mp[e[1]]]);
 
-        edgeWeights[edgeI] = 1.0/(max(w, SMALL));
+        edgeWeights[edgeI] = 1.0/(Foam::max(w, SMALL));
     }
 
     tmp<scalarField> tavgFld = avg(s, fld, edgeWeights);
@@ -429,7 +429,7 @@ void minSmooth
     {
         if (isAffectedPoint.test(pointI))
         {
-            newFld[pointI] = min
+            newFld[pointI] = Foam::min
             (
                 fld[pointI],
                 0.5*fld[pointI] + 0.5*avgFld[pointI]
diff --git a/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C b/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C
index 6f276914579..fcd551ab61e 100644
--- a/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C
+++ b/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C
@@ -109,7 +109,7 @@ void writeOBJ
     const auto& constraints = ppp.constraints();
     forAll(constraints, i)
     {
-        maxConstraint = max(maxConstraint, constraints[i].first());
+        maxConstraint = Foam::max(maxConstraint, constraints[i].first());
     }
     reduce(maxConstraint, maxOp<label>());
 
diff --git a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C
index 220a0da6ddb..7345394f9c2 100644
--- a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C
+++ b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C
@@ -180,8 +180,8 @@ int main(int argc, char *argv[])
 
         scalar o2 = (1.0/equiv)*stoicO2;
         scalar n2 = (0.79/0.21)*o2;
-        scalar fres = max(1.0 - 1.0/equiv, 0.0);
-        scalar ores = max(1.0/equiv - 1.0, 0.0);
+        scalar fres = Foam::max(1.0 - 1.0/equiv, 0.0);
+        scalar ores = Foam::max(1.0/equiv - 1.0, 0.0);
         scalar fburnt = 1.0 - fres;
 
         thermo reactants
diff --git a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C
index a6f2e4fb63f..89798b21521 100644
--- a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C
+++ b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C
@@ -196,12 +196,12 @@ int main(int argc, char *argv[])
         // Number of moles of species for one mole of fuel
         scalar o2 = (1.0/equiv)*stoicO2;
         scalar n2 = (0.79/0.21)*o2;
-        scalar fres = max(1.0 - 1.0/equiv, 0.0);
+        scalar fres = Foam::max(1.0 - 1.0/equiv, 0.0);
         scalar fburnt = 1.0 - fres;
 
         // Initial guess for number of moles of product species
         // ignoring product dissociation
-        scalar oresInit = max(1.0/equiv - 1.0, 0.0)*stoicO2;
+        scalar oresInit = Foam::max(1.0/equiv - 1.0, 0.0)*stoicO2;
         scalar co2Init = fburnt*stoicCO2;
         scalar h2oInit = fburnt*stoicH2O;
 
@@ -231,18 +231,18 @@ int main(int argc, char *argv[])
             if (j > 0)
             {
                 co = co2*
-                    min
+                    Foam::min
                     (
                         CO2BreakUp.Kn(P, equilibriumFlameTemperature, N)
-                       /::sqrt(max(ores, 0.001)),
+                       /::sqrt(Foam::max(ores, 0.001)),
                         1.0
                     );
 
                 h2 = h2o*
-                    min
+                    Foam::min
                     (
                         H2OBreakUp.Kn(P, equilibriumFlameTemperature, N)
-                       /::sqrt(max(ores, 0.001)),
+                       /::sqrt(Foam::max(ores, 0.001)),
                         1.0
                     );
 
diff --git a/src/parallel/decompose/faDecompose/faMeshDecomposition.C b/src/parallel/decompose/faDecompose/faMeshDecomposition.C
index 63806592796..ff97ec03fda 100644
--- a/src/parallel/decompose/faDecompose/faMeshDecomposition.C
+++ b/src/parallel/decompose/faDecompose/faMeshDecomposition.C
@@ -85,7 +85,8 @@ void Foam::faMeshDecomposition::distributeFaces()
         ioAddr.rename("faceProcAddressing");
         labelIOList fvFaceProcAddressing(ioAddr);
 
-        labelHashSet faceProcAddressingHash(2*fvFaceProcAddressing.size());
+        labelHashSet faceProcAddressingHash;
+        faceProcAddressingHash.reserve(fvFaceProcAddressing.size());
 
         // If faMesh's fvPatch is a part of the global face zones, faces of that
         // patch will be present on all processors. Because of that, looping
@@ -941,10 +942,8 @@ void Foam::faMeshDecomposition::decomposeMesh()
 
         // Globally shared points are the ones used by more than 2 processors
         // Size the list approximately and gather the points
-        labelHashSet gSharedPoints
-        (
-            min(100, nPoints()/1000)
-        );
+        labelHashSet gSharedPoints;
+        gSharedPoints.reserve(Foam::min(128, nPoints()/1000));
 
         // Loop through all the processors and mark up points used by
         // processor boundaries.  When a point is used twice, it is a
diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C
index 7559047023f..dd9ca6401bd 100644
--- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C
+++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C
@@ -163,7 +163,8 @@ scalar pyrolysisModelCollection::maxDiff() const
     scalar maxDiff = 0.0;
     forAll(*this, i)
     {
-        maxDiff = max(maxDiff, this->operator[](i).maxDiff());
+        maxDiff =
+            Foam::max(maxDiff, this->operator[](i).maxDiff());
     }
 
     return maxDiff;
@@ -175,7 +176,8 @@ scalar pyrolysisModelCollection::solidRegionDiffNo() const
     scalar totalDiNum = GREAT;
     forAll(*this, i)
     {
-        totalDiNum = min(totalDiNum, this->operator[](i).solidRegionDiffNo());
+        totalDiNum =
+            Foam::min(totalDiNum, this->operator[](i).solidRegionDiffNo());
     }
 
     return totalDiNum;
-- 
GitLab


From 59f3c55871f2514e7133c802f299aa43a9e4e783 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Tue, 8 Apr 2025 11:00:11 +0200
Subject: [PATCH 5/5] STYLE: avoid implicit cast of UList to List

---
 .../adjointShapeOptimizationFoam.C            |  7 +---
 .../createFields.H                            |  4 +-
 .../pimpleFoam/overPimpleDyMFoam/correctPhi.H |  2 +-
 .../VoFPatchTransfer/VoFPatchTransfer.C       |  2 +-
 .../interFoam/overInterDyMFoam/correctPhi.H   |  2 +-
 .../fluentMeshToFoam/fluentMeshToFoam.L       |  5 +--
 .../foamMeshToFluent/fluentFvMesh.C           |  3 +-
 .../mesh/conversion/gmshToFoam/gmshToFoam.C   |  2 +-
 .../DelaunayMesh/DistributedDelaunayMesh.C    |  4 +-
 .../DelaunayMesh/DistributedDelaunayMesh.H    |  4 +-
 .../backgroundMeshDecomposition.C             |  2 +-
 .../backgroundMeshDecomposition.H             |  2 +-
 .../conformalVoronoiMeshCalcDualMesh.C        |  2 +-
 .../pointPairs/pointPairs.C                   |  2 +-
 .../pointPairs/pointPairs.H                   |  2 +-
 .../generation/foamyMesh/foamyQuadMesh/CV2D.H |  8 ++--
 .../insertSurfaceNearestPointPairs.C          |  8 ++--
 .../foamyQuadMesh/shortEdgeFilter2D.C         |  8 ++--
 .../mesh/manipulation/checkMesh/checkTools.C  |  4 +-
 .../manipulation/polyDualMesh/meshDualiser.C  | 19 ++++------
 .../manipulation/polyDualMesh/meshDualiser.H  |  9 ++---
 .../miscellaneous/patchSummary/patchSummary.C |  4 +-
 .../foamDataToFluent/writeFluentScalarField.C |  2 +-
 .../viewFactor2AI/viewFactor2AI.C             |  8 ++--
 .../viewFactor2AI/viewFactor2AI.H             |  8 ++--
 .../viewFactor2LI/viewFactor2LI.C             |  8 ++--
 .../viewFactor2LI/viewFactor2LI.H             |  8 ++--
 .../viewFactorHottel/viewFactorHottel.C       |  8 ++--
 .../viewFactorHottel/viewFactorHottel.H       |  8 ++--
 .../viewFactorModel/viewFactorModel.H         |  8 ++--
 .../setAlphaField/setAlphaField.C             | 10 ++---
 src/OpenFOAM/containers/Lists/List/UList.H    | 10 ++++-
 src/OpenFOAM/containers/Lists/List/UListI.H   |  7 ----
 .../lduMatrix/lduAddressing/lduAddressing.C   |  8 ++--
 .../lduCalculatedProcessorField.C             |  2 +-
 .../cyclicGAMGInterfaceField.C                |  4 +-
 src/OpenFOAM/meshes/lduMesh/lduMesh.C         |  4 +-
 .../parallel/commSchedule/commSchedule.C      |  2 +-
 .../atmNutWallFunctionFvPatchScalarField.C    |  2 +-
 .../atmNutkWallFunctionFvPatchScalarField.C   |  2 +-
 .../freeSurfacePointDisplacement.C            |  2 +-
 .../interfaceTrackingFvMesh.C                 | 37 ++++++++++---------
 .../attachDetach/attachInterface.C            |  4 +-
 src/dynamicMesh/polyMeshAdder/polyMeshAdder.C | 12 +++---
 src/dynamicMesh/polyMeshAdder/polyMeshAdder.H |  6 +--
 .../hexRef8/refinementHistory.C               |  2 +-
 .../hexRef8/refinementHistory.H               |  2 +-
 .../enrichedPatch/enrichedPatch.H             |  6 +--
 .../faMesh/faMeshMapper/faPatchMapper.C       |  2 +-
 .../faPatches/basic/coupled/coupledFaPatch.H  |  2 +-
 .../expressions/patch/patchExprDriverFields.C |  2 +-
 .../calculatedProcessorFvPatchField.C         |  4 +-
 .../constraint/cyclic/cyclicFvPatchField.C    |  2 +-
 .../activeBaffleVelocityFvPatchVectorField.C  |  4 +-
 ...ureForceBaffleVelocityFvPatchVectorField.C |  4 +-
 .../fvPatchFields/fvPatchField/fvPatchField.C |  2 +-
 .../faceCorrectedSnGrad/faceCorrectedSnGrad.C |  4 +-
 .../solvers/MULES/CMULESTemplates.C           |  8 ++--
 .../fvMatrices/solvers/MULES/MULESTemplates.C |  6 +--
 .../interpolationPointMVC/pointMVCWeight.C    |  2 +-
 .../interpolationPointMVC/pointMVCWeight.H    |  2 +-
 .../schemes/linearUpwind/linearUpwind.C       |  8 ++--
 .../schemes/linearUpwind/linearUpwindV.C      |  4 +-
 .../outletStabilised/outletStabilised.H       | 30 ++++++---------
 .../schemes/pointLinear/pointLinear.C         |  4 +-
 .../field/fieldMinMax/fieldMinMaxTemplates.C  |  2 +-
 src/fvOptions/cellSetOption/cellSetOption.C   |  2 +-
 .../PairCollision/PairCollision.C             |  4 +-
 .../PairCollision/PairCollision.H             |  4 +-
 .../clouds/Templates/SprayCloud/SprayCloudI.H |  2 +-
 .../blockMesh/blockMesh/blockMeshCreate.C     |  2 +-
 .../meshRefinement/meshRefinement.C           |  6 +--
 .../meshRefinement/meshRefinement.H           |  6 +--
 .../snappyHexMeshDriver/snappyLayerDriver.C   |  8 ++--
 .../snappyHexMeshDriver/snappySnapDriver.H    |  8 ++--
 .../snappySnapDriverFeature.C                 |  8 ++--
 .../advancingFrontAMI/advancingFrontAMI.C     |  2 +-
 .../advancingFrontAMI/advancingFrontAMI.H     |  2 +-
 .../faceAreaWeightAMI/faceAreaWeightAMI.C     |  6 +--
 .../faceAreaWeightAMI/faceAreaWeightAMI.H     |  2 +-
 .../cyclicACMIGAMGInterfaceField.C            |  4 +-
 .../cyclicAMIGAMGInterfaceField.C             |  4 +-
 .../faceAreaIntersect/faceAreaIntersect.H     | 10 ++++-
 .../faceAreaIntersect/faceAreaIntersectI.H    | 13 -------
 .../adjointBoundaryCondition.C                |  2 +-
 ...ointOutletVelocityFluxFvPatchVectorField.C |  2 +-
 .../linearUpwindNormal/linearUpwindNormal.C   |  4 +-
 .../topODesignVariables/topODesignVariables.C |  6 +--
 .../adjointSpalartAllmaras.C                  |  2 +-
 .../adjointkOmegaSST/adjointkOmegaSST.C       | 12 +++---
 .../kaqRWallFunctionFvPatchScalarField.C      |  2 +-
 .../waWallFunctionFvPatchScalarField.C        |  2 +-
 .../cellCellStencil/cellCellStencil.C         |  2 +-
 .../cellCellStencilTemplates.C                |  2 +-
 .../cellVolumeWeightCellCellStencil.C         | 13 +++----
 .../inverseDistanceCellCellStencil.C          | 11 +++---
 .../trackingInverseDistanceCellCellStencil.C  |  4 +-
 src/overset/include/setCellMask.H             |  2 +-
 src/overset/include/setInterpolatedCells.H    |  2 +-
 .../oversetAdjustPhi/oversetAdjustPhi.C       |  4 +-
 src/overset/oversetFvMesh/oversetFvMeshBase.C |  4 +-
 src/overset/oversetFvMesh/oversetFvMeshBase.H |  4 +-
 .../oversetPolyPatch/oversetFvPatchField.C    | 12 +++---
 .../wallBoiling/wallBoiling.C                 |  2 +-
 .../IATEsources/wallBoiling/wallBoiling.C     |  2 +-
 .../singleLayerRegion/singleLayerRegion.C     |  2 +-
 .../curvatureSeparation/curvatureSeparation.C |  4 +-
 .../patchInjection/patchInjection.C           |  3 +-
 .../cellVolumeWeight/cellVolumeWeightMethod.C |  2 +-
 .../cellVolumeWeight/cellVolumeWeightMethod.H |  2 +-
 .../meshToMeshMethod/meshToMeshMethod.C       |  2 +-
 .../meshToMeshMethod/meshToMeshMethod.H       |  2 +-
 .../surface/isoSurface/isoSurfaceCell.H       |  6 +--
 .../isoSurface/isoSurfaceCellTemplates.C      |  6 +--
 .../surface/isoSurface/isoSurfacePoint.H      |  6 +--
 .../isoSurface/isoSurfacePointTemplates.C     |  6 +--
 .../radiationModels/solarLoad/solarLoad.C     |  6 +--
 .../isoAdvection/isoAdvection.C               | 16 +++-----
 .../isoAdvection/isoAdvection.H               |  5 +--
 119 files changed, 298 insertions(+), 336 deletions(-)

diff --git a/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C b/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C
index be66f4cc539..79a06161d1b 100644
--- a/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C
+++ b/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C
@@ -60,13 +60,10 @@ template<class Type>
 void zeroCells
 (
     GeometricField<Type, fvPatchField, volMesh>& vf,
-    const labelList& cells
+    const labelUList& cells
 )
 {
-    forAll(cells, i)
-    {
-        vf[cells[i]] = Zero;
-    }
+    UIndirectList<Type>(vf.primitiveField(), cells) = Zero;
 }
 
 
diff --git a/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H b/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H
index 4d7b9d88110..3d19017f9de 100644
--- a/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H
+++ b/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H
@@ -103,8 +103,8 @@ dimensionedScalar alphaMax
     laminarTransport
 );
 
-const labelList& inletCells = mesh.boundary()["inlet"].faceCells();
-//const labelList& outletCells = mesh.boundary()["outlet"].faceCells();
+const labelUList& inletCells = mesh.boundary()["inlet"].faceCells();
+//const labelUList& outletCells = mesh.boundary()["outlet"].faceCells();
 
 volScalarField alpha
 (
diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H
index 8c692c1378b..f5304eea588 100644
--- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H
+++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H
@@ -55,7 +55,7 @@ if (mesh.changing())
     dimensionedScalar rAUf("rAUf", dimTime, 1.0);
 
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
+    const labelUList& cellTypes = overlap.cellTypes();
     const labelIOList& zoneIDs = overlap.zoneID();
 
     while (pimple.correctNonOrthogonal())
diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C
index b0c52f0f621..e3e2d7ee5f6 100644
--- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C
+++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C
@@ -210,7 +210,7 @@ void VoFPatchTransfer::correct
             film().toRegion(patchi, Vp);
 
             const polyPatch& pp = pbm[patchi];
-            const labelList& faceCells = pp.faceCells();
+            const labelUList& faceCells = pp.faceCells();
 
             // Accumulate the total mass removed from patch
             scalar dMassPatch = 0;
diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/correctPhi.H
index 7df3631b040..9af4e28691c 100644
--- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/correctPhi.H
+++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/correctPhi.H
@@ -65,7 +65,7 @@
     dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
 
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
+    const labelUList& cellTypes = overlap.cellTypes();
     const labelIOList& zoneIDs = overlap.zoneID();
 
     while (pimple.correctNonOrthogonal())
diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
index d74f4ab01ca..200a45becd3 100644
--- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
+++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
@@ -1674,10 +1674,9 @@ int main(int argc, char *argv[])
             // Add cell zones to patch zone list
             forAll(bPatches, pI)
             {
-                const labelList& faceCells = bPatches[pI].faceCells();
-                forAll(faceCells, fcI)
+                for (const label celli : bPatches[pI].faceCells())
                 {
-                    if (zoneCell.test(faceCells[fcI]))
+                    if (zoneCell.test(celli))
                     {
                         boundaryZones[pI].append(name);
                         break;
diff --git a/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C b/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C
index f212aee72a2..75ee48cccfa 100644
--- a/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C
+++ b/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C
@@ -161,8 +161,7 @@ void Foam::fluentFvMesh::writeFluentMesh() const
     {
         const faceUList& patchFaces = boundaryMesh()[patchi];
 
-        const labelList& patchFaceCells =
-            boundaryMesh()[patchi].faceCells();
+        const labelUList& patchFaceCells = boundaryMesh()[patchi].faceCells();
 
         // The face group will be offset by 10 from the patch label
 
diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C
index 8e95e454a99..c91d9023bde 100644
--- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C
+++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C
@@ -1506,7 +1506,7 @@ int main(int argc, char *argv[])
     // Go through all the patchFaces and find corresponding face in pp.
     forAll(patchFaces, patchi)
     {
-        const DynamicList<face>& pFaces = patchFaces[patchi];
+        const auto& pFaces = patchFaces[patchi];
 
         Info<< "Finding faces of patch " << patchi << endl;
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
index 2c50d6c462b..d0acdef622d 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
@@ -42,7 +42,7 @@ template<class Triangulation>
 Foam::autoPtr<Foam::mapDistribute>
 Foam::DistributedDelaunayMesh<Triangulation>::buildMap
 (
-    const List<label>& toProc
+    const labelUList& toProc
 )
 {
     // Determine send map
@@ -431,7 +431,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::markVerticesToRefer
 template<class Triangulation>
 Foam::label Foam::DistributedDelaunayMesh<Triangulation>::referVertices
 (
-    const DynamicList<label>& targetProcessor,
+    const labelUList& targetProcessor,
     DynamicList<Vb>& parallelVertices,
     PtrList<labelPairHashSet>& referralVertices,
     labelPairHashSet& receivedVertices
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.H
index 8a8c75cd97d..1af5cba7572 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.H
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.H
@@ -115,7 +115,7 @@ private:
 
         label referVertices
         (
-            const DynamicList<label>& targetProcessor,
+            const labelUList& targetProcessor,
             DynamicList<Vb>& parallelVertices,
             PtrList<labelPairHashSet>& referralVertices,
             labelPairHashSet& receivedVertices
@@ -160,7 +160,7 @@ public:
     // Member Functions
 
         //- Build a mapDistribute for the supplied destination processor data
-        static autoPtr<mapDistribute> buildMap(const List<label>& toProc);
+        static autoPtr<mapDistribute> buildMap(const labelUList& toProc);
 
         //-
         bool distribute(const boundBox& bb);
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
index 48c0a68a63c..4a93e7117b3 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
@@ -47,7 +47,7 @@ namespace Foam
 
 Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::buildMap
 (
-    const List<label>& toProc
+    const labelUList& toProc
 )
 {
     // Determine send map
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H
index a0dd1bd11d5..64ad37a169f 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H
@@ -213,7 +213,7 @@ public:
     // Member Functions
 
         //- Build a mapDistribute for the supplied destination processor data
-        static autoPtr<mapDistribute> buildMap(const List<label>& toProc);
+        static autoPtr<mapDistribute> buildMap(const labelUList& toProc);
 
         //- Redistribute the background mesh based on a supplied weight field,
         //  returning a map to use to redistribute vertices.
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
index a90fa8ac514..8107aee818e 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
@@ -945,7 +945,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findOffsetPatchFaces
         const faceList& localFaces = patch.localFaces();
         const pointField& localPoints = patch.localPoints();
 
-        const labelList& fCell = patch.faceCells();
+        const labelUList& fCell = patch.faceCells();
 
         forAll(localFaces, pLFI)
         {
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C
index b4f3e88b169..cfeb5885cfd 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C
@@ -117,7 +117,7 @@ template<class Triangulation>
 inline bool Foam::pointPairs<Triangulation>::addPointPair
 (
     const labelPair& master,
-    const DynamicList<labelPair>& slaves
+    const UList<labelPair>& slaves
 )
 {
     for (const labelPair& slave : slaves)
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.H
index 11feda75d47..3b16e5a044d 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.H
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.H
@@ -130,7 +130,7 @@ public:
             inline bool addPointPair
             (
                 const labelPair& master,
-                const DynamicList<labelPair>& slaves
+                const UList<labelPair>& slaves
             );
 
             inline bool addPointPair
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.H b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.H
index 2efc703e5eb..0f3735423f9 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.H
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.H
@@ -262,10 +262,10 @@ private:
         //  and write the inserted point locations to the given file.
         void insertPointPairs
         (
-            const DynamicList<point2D>& nearSurfacePoints,
-            const DynamicList<point2D>& surfacePoints,
-            const DynamicList<label>& surfaceTris,
-            const DynamicList<label>& surfaceHits,
+            const UList<point2D>& nearSurfacePoints,
+            const UList<point2D>& surfacePoints,
+            const labelUList& surfaceTris,
+            const labelUList& surfaceHits,
             const fileName fName
         );
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C
index d9b88edbdcd..694ff9efea6 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C
@@ -75,10 +75,10 @@ bool Foam::CV2D::dualCellSurfaceIntersection
 
 void Foam::CV2D::insertPointPairs
 (
-    const DynamicList<point2D>& nearSurfacePoints,
-    const DynamicList<point2D>& surfacePoints,
-    const DynamicList<label>& surfaceTris,
-    const DynamicList<label>& surfaceHits,
+    const UList<point2D>& nearSurfacePoints,
+    const UList<point2D>& surfacePoints,
+    const labelUList& surfaceTris,
+    const labelUList& surfaceHits,
     const fileName fName
 )
 {
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C
index 3141e0a4b33..92ec92926b7 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C
@@ -80,10 +80,10 @@ void Foam::shortEdgeFilter2D::updateEdgeRegionMap
 
         label region = -1;
 
-        const DynamicList<label>& startPtRegions =
+        const labelUList& startPtRegions =
             boundaryPtRegions[surfPtToBoundaryPt[meshPoints[e.first()]]];
 
-        const DynamicList<label>& endPtRegions =
+        const labelUList& endPtRegions =
             boundaryPtRegions[surfPtToBoundaryPt[meshPoints[e.second()]]];
 
         if (startPtRegions.size() > 1 && endPtRegions.size() > 1)
@@ -363,9 +363,9 @@ void Foam::shortEdgeFilter2D::filter()
              && !flagDegenerateFace
             )
             {
-                const DynamicList<label>& startVertexRegions =
+                const labelUList& startVertexRegions =
                     boundaryPointRegions[meshPoints[startVertex]];
-                const DynamicList<label>& endVertexRegions =
+                const labelUList& endVertexRegions =
                     boundaryPointRegions[meshPoints[endVertex]];
 
                 if (startVertexRegions.size() && endVertexRegions.size())
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
index 8b6b0d3195d..36d1b4755d0 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
@@ -294,7 +294,7 @@ void Foam::mergeAndWrite
     forAll(pbm, patchi)
     {
         const polyPatch& pp = pbm[patchi];
-        const labelList& fc = pp.faceCells();
+        const labelUList& fc = pp.faceCells();
         forAll(fc, i)
         {
             bndInSet[pp.start()+i-mesh.nInternalFaces()] = isInSet[fc[i]];
@@ -319,7 +319,7 @@ void Foam::mergeAndWrite
     forAll(pbm, patchi)
     {
         const polyPatch& pp = pbm[patchi];
-        const labelList& fc = pp.faceCells();
+        const labelUList& fc = pp.faceCells();
         if (pp.coupled())
         {
             forAll(fc, i)
diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C
index c5cdb173707..a3d8b6e510c 100644
--- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C
+++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C
@@ -33,6 +33,7 @@ License
 #include "mapPolyMesh.H"
 #include "edgeFaceCirculator.H"
 #include "mergePoints.H"
+#include "DynamicList.H"
 #include "OFstream.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -98,20 +99,14 @@ void Foam::meshDualiser::dumpPolyTopoChange
     Info<< "Dumping current polyTopoChange. Faces to " << str1.name()
         << " , points and edges to " << str2.name() << endl;
 
-    const DynamicList<point>& points = meshMod.points();
-
-    forAll(points, pointi)
+    for (const auto& p : meshMod.points())
     {
-        meshTools::writeOBJ(str1, points[pointi]);
-        meshTools::writeOBJ(str2, points[pointi]);
+        meshTools::writeOBJ(str1, p);
+        meshTools::writeOBJ(str2, p);
     }
 
-    const DynamicList<face>& faces = meshMod.faces();
-
-    forAll(faces, facei)
+    for (const face& f : meshMod.faces())
     {
-        const face& f = faces[facei];
-
         str1<< 'f';
         forAll(f, fp)
         {
@@ -210,7 +205,7 @@ Foam::label Foam::meshDualiser::addInternalFace
     const bool edgeOrder,
     const label dualCell0,
     const label dualCell1,
-    const DynamicList<label>& verts,
+    const labelUList& verts,
     polyTopoChange& meshMod
 ) const
 {
@@ -326,7 +321,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace
 
     const label dualCelli,
     const label patchi,
-    const DynamicList<label>& verts,
+    const labelUList& verts,
     polyTopoChange& meshMod
 ) const
 {
diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H
index d65d796d085..e10b8c9a982 100644
--- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H
+++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H
@@ -46,10 +46,9 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef meshDualiser_H
-#define meshDualiser_H
+#ifndef Foam_meshDualiser_H
+#define Foam_meshDualiser_H
 
-#include "DynamicList.H"
 #include "bitSet.H"
 #include "boolList.H"
 #include "typeInfo.H"
@@ -124,7 +123,7 @@ class meshDualiser
             const bool edgeOrder,
             const label dualCell0,
             const label dualCell1,
-            const DynamicList<label>& verts,
+            const labelUList& verts,
             polyTopoChange& meshMod
         ) const;
 
@@ -137,7 +136,7 @@ class meshDualiser
 
             const label dualCelli,
             const label patchi,
-            const DynamicList<label>& verts,
+            const labelUList& verts,
             polyTopoChange& meshMod
         ) const;
 
diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummary.C b/applications/utilities/miscellaneous/patchSummary/patchSummary.C
index 14d9e3f9ea6..a451b1134a9 100644
--- a/applications/utilities/miscellaneous/patchSummary/patchSummary.C
+++ b/applications/utilities/miscellaneous/patchSummary/patchSummary.C
@@ -191,10 +191,8 @@ int main(int argc, char *argv[])
             }
 
 
-            forAll(groupToPatches, groupI)
+            for (const auto& patchIDs : groupToPatches)
             {
-                const DynamicList<label>& patchIDs = groupToPatches[groupI];
-
                 if (patchIDs.size() > 1)
                 {
                     // Check if part of a group
diff --git a/applications/utilities/postProcessing/dataConversion/foamDataToFluent/writeFluentScalarField.C b/applications/utilities/postProcessing/dataConversion/foamDataToFluent/writeFluentScalarField.C
index 56dd1c626dd..9a00f738bda 100644
--- a/applications/utilities/postProcessing/dataConversion/foamDataToFluent/writeFluentScalarField.C
+++ b/applications/utilities/postProcessing/dataConversion/foamDataToFluent/writeFluentScalarField.C
@@ -76,7 +76,7 @@ void Foam::writeFluentField
             const scalarField& phiInternal = phi;
 
             // Get reference to internal cells
-            const labelList emptyFaceCells =
+            const auto& emptyFaceCells =
                 phi.boundaryField()[patchi].patch().patch().faceCells();
 
             // Writing cells for empty patch
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.C b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.C
index 2b7afe34bff..ff333a20e09 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.C
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.C
@@ -78,10 +78,10 @@ Foam::scalarListList Foam::VF::viewFactor2AI::calculate
     const labelListList& visibleFaceFaces,
     const pointField& compactCf,
     const vectorField& compactSf,
-    const List<List<vector>>& compactFineSf,
-    const List<List<point>>& compactFineCf,
-    const DynamicList<List<point>>& compactPoints,
-    const DynamicList<label>& compactPatchId
+    const UList<List<vector>>& compactFineSf,
+    const UList<List<point>>& compactFineCf,
+    const UList<List<point>>& compactPoints,
+    const UList<label>& compactPatchId
 ) const
 {
     // Fill local view factor matrix
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.H b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.H
index 9ba377435b4..3610dc9239a 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.H
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2AI/viewFactor2AI.H
@@ -85,10 +85,10 @@ protected:
             const labelListList& visibleFaceFaces,
             const pointField& compactCf,
             const vectorField& compactSf,
-            const List<List<vector>>& compactFineSf,
-            const List<List<point>>& compactFineCf,
-            const DynamicList<List<point>>& compactPoints,
-            const DynamicList<label>& compactPatchId
+            const UList<List<vector>>& compactFineSf,
+            const UList<List<point>>& compactFineCf,
+            const UList<List<point>>& compactPoints,
+            const UList<label>& compactPatchId
         ) const;
 
 
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.C b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.C
index 273b5c2ac5e..d81598e6850 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.C
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.C
@@ -84,10 +84,10 @@ Foam::scalarListList Foam::VF::viewFactor2LI::calculate
     const labelListList& visibleFaceFaces,
     const pointField& compactCf,
     const vectorField& compactSf,
-    const List<List<vector>>& compactFineSf,
-    const List<List<point>>& compactFineCf,
-    const DynamicList<List<point>>& compactPoints,
-    const DynamicList<label>& compactPatchId
+    const UList<List<vector>>& compactFineSf,
+    const UList<List<point>>& compactFineCf,
+    const UList<List<point>>& compactPoints,
+    const UList<label>& compactPatchId
 ) const
 {
     // Fill local view factor matrix
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.H b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.H
index 0d2c0d273d3..94625f654a1 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.H
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactor2LI/viewFactor2LI.H
@@ -98,10 +98,10 @@ protected:
             const labelListList& visibleFaceFaces,
             const pointField& compactCf,
             const vectorField& compactSf,
-            const List<List<vector>>& compactFineSf,
-            const List<List<point>>& compactFineCf,
-            const DynamicList<List<point>>& compactPoints,
-            const DynamicList<label>& compactPatchId
+            const UList<List<vector>>& compactFineSf,
+            const UList<List<point>>& compactFineCf,
+            const UList<List<point>>& compactPoints,
+            const UList<label>& compactPatchId
         ) const;
 
 
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.C b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.C
index 3b352ab69f8..85ae0b75df5 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.C
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.C
@@ -63,10 +63,10 @@ Foam::scalarListList Foam::VF::viewFactorHottel::calculate
     const labelListList& visibleFaceFaces,
     const pointField& compactCf,
     const vectorField& compactSf,
-    const List<List<vector>>& compactFineSf,
-    const List<List<point>>& compactFineCf,
-    const DynamicList<List<point>>& compactPoints,
-    const DynamicList<label>& compactPatchId
+    const UList<List<vector>>& compactFineSf,
+    const UList<List<point>>& compactFineCf,
+    const UList<List<point>>& compactPoints,
+    const UList<label>& compactPatchId
 ) const
 {
     // Fill local view factor matrix
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.H b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.H
index da7bade587b..0b11f75b3cf 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.H
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorHottel/viewFactorHottel.H
@@ -103,10 +103,10 @@ protected:
             const labelListList& visibleFaceFaces,
             const pointField& compactCf,
             const vectorField& compactSf,
-            const List<List<vector>>& compactFineSf,
-            const List<List<point>>& compactFineCf,
-            const DynamicList<List<point>>& compactPoints,
-            const DynamicList<label>& compactPatchId
+            const UList<List<vector>>& compactFineSf,
+            const UList<List<point>>& compactFineCf,
+            const UList<List<point>>& compactPoints,
+            const UList<label>& compactPatchId
         ) const;
 
 
diff --git a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorModel/viewFactorModel.H b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorModel/viewFactorModel.H
index 549c50978da..a2ed02d9347 100644
--- a/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorModel/viewFactorModel.H
+++ b/applications/utilities/preProcessing/createViewFactors/viewFactorModels/viewFactorModel/viewFactorModel/viewFactorModel.H
@@ -117,10 +117,10 @@ protected:
             const labelListList& visibleFaceFaces,
             const pointField& compactCoarseCf,
             const vectorField& compactCoarseSf,
-            const List<List<vector>>& compactFineSf,
-            const List<List<point>>& compactFineCf,
-            const DynamicList<List<point>>& compactPoints,
-            const DynamicList<label>& compactPatchId
+            const UList<List<vector>>& compactFineSf,
+            const UList<List<point>>& compactFineCf,
+            const UList<List<point>>& compactPoints,
+            const labelUList& compactPatchId
         ) const = 0;
 
 
diff --git a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C
index 867e8762b79..d6f754d286b 100644
--- a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C
+++ b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C
@@ -55,7 +55,7 @@ Description
 
 void isoFacesToFile
 (
-    const DynamicList<List<point>>& faces,
+    const UList<List<point>>& faces,
     const word& fileName
 )
 {
@@ -65,7 +65,7 @@ void isoFacesToFile
     if (Pstream::parRun())
     {
         // Collect points from all the processors
-        List<DynamicList<List<point>>> allProcFaces(Pstream::nProcs());
+        List<List<List<point>>> allProcFaces(Pstream::nProcs());
         allProcFaces[Pstream::myProcNo()] = faces;
         Pstream::gatherList(allProcFaces);
 
@@ -73,9 +73,9 @@ void isoFacesToFile
         {
             Info<< "Writing file: " << fileName << endl;
 
-            for (const DynamicList<List<point>>& procFaces : allProcFaces)
+            for (const auto& procFaces : allProcFaces)
             {
-                for (const List<point>& facePts : procFaces)
+                for (const auto& facePts : procFaces)
                 {
                     os.writeFace(facePts);
                 }
@@ -86,7 +86,7 @@ void isoFacesToFile
     {
         Info<< "Writing file: " << fileName << endl;
 
-        for (const List<point>& facePts : faces)
+        for (const auto& facePts : faces)
         {
             os.writeFace(facePts);
         }
diff --git a/src/OpenFOAM/containers/Lists/List/UList.H b/src/OpenFOAM/containers/Lists/List/UList.H
index ede6083323d..2af60648ff3 100644
--- a/src/OpenFOAM/containers/Lists/List/UList.H
+++ b/src/OpenFOAM/containers/Lists/List/UList.H
@@ -424,8 +424,14 @@ public:
         //       out-of-range element returns false without ill-effects
         inline const T& operator[](const label i) const;
 
-        //- Allow cast to a const List<T>&
-        inline operator const Foam::List<T>&() const;
+        //- Allow cast to a const List<T>&.
+        //  \note Marked as "strictly" deprecated.
+        //  Currently (2025-04) code still depends on this cast.
+        FOAM_DEPRECATED_STRICTER(2025-04, "dereference as UList, not List")
+        operator const Foam::List<T>&() const
+        {
+            return *reinterpret_cast<const List<T>*>(this);
+        }
 
         //- Assignment of all entries to the given value
         inline void operator=(const T& val);
diff --git a/src/OpenFOAM/containers/Lists/List/UListI.H b/src/OpenFOAM/containers/Lists/List/UListI.H
index de385d61161..9e544cbfcf0 100644
--- a/src/OpenFOAM/containers/Lists/List/UListI.H
+++ b/src/OpenFOAM/containers/Lists/List/UListI.H
@@ -385,13 +385,6 @@ inline const T& Foam::UList<T>::operator[](const label i) const
 }
 
 
-template<class T>
-inline Foam::UList<T>::operator const Foam::List<T>&() const
-{
-    return *reinterpret_cast<const List<T>*>(this);
-}
-
-
 // * * * * * * * * * * * * * * STL Member Functions  * * * * * * * * * * * * //
 
 template<class T>
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C
index 81b80f0efb5..d90d1b98213 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C
@@ -80,7 +80,7 @@ void Foam::lduAddressing::calcLosort() const
 
     forAll(cellNbrFaces, celli)
     {
-        const labelList& curNbr = cellNbrFaces[celli];
+        const labelUList& curNbr = cellNbrFaces[celli];
 
         forAll(curNbr, curNbrI)
         {
@@ -100,7 +100,7 @@ void Foam::lduAddressing::calcOwnerStart() const
             << abort(FatalError);
     }
 
-    const labelList& own = lowerAddr();
+    const labelUList& own = lowerAddr();
 
     ownerStartPtr_ = std::make_unique<labelList>(size() + 1, own.size());
     auto& ownStart = *ownerStartPtr_;
@@ -139,9 +139,9 @@ void Foam::lduAddressing::calcLosortStart() const
     losortStartPtr_ = std::make_unique<labelList>(size() + 1, Foam::zero{});
     auto& lsrtStart = *losortStartPtr_;
 
-    const labelList& nbr = upperAddr();
+    const labelUList& nbr = upperAddr();
 
-    const labelList& lsrt = losortAddr();
+    const labelUList& lsrt = losortAddr();
 
     // Set up first lookup by hand
     lsrtStart[0] = 0;
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C
index 075a79f4460..2eba61fb8f8 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C
@@ -99,7 +99,7 @@ void Foam::lduCalculatedProcessorField<Type>::initInterfaceMatrixUpdate
     }
 
     // Bypass patchInternalField since uses fvPatch addressing
-    const labelList& fc = lduAddr.patchAddr(patchId);
+    const labelUList& fc = lduAddr.patchAddr(patchId);
 
     scalarSendBuf_.resize_nocopy(fc.size());
     forAll(fc, i)
diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C
index 439a3f936f8..a6c358984ca 100644
--- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C
+++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C
@@ -162,7 +162,7 @@ void Foam::cyclicGAMGInterfaceField::updateInterfaceMatrix
 {
     // Get neighbouring field
 
-    const labelList& nbrFaceCells =
+    const auto& nbrFaceCells =
         lduAddr.patchAddr
         (
             cyclicInterface_.neighbPatchID()
@@ -172,7 +172,7 @@ void Foam::cyclicGAMGInterfaceField::updateInterfaceMatrix
 
     transformCoupleField(pnf, cmpt);
 
-    const labelList& faceCells = lduAddr.patchAddr(patchId);
+    const auto& faceCells = lduAddr.patchAddr(patchId);
 
     this->addToInternalField(result, !add, faceCells, coeffs, pnf);
 }
diff --git a/src/OpenFOAM/meshes/lduMesh/lduMesh.C b/src/OpenFOAM/meshes/lduMesh/lduMesh.C
index a6c62c3811b..e7dbad5f2a5 100644
--- a/src/OpenFOAM/meshes/lduMesh/lduMesh.C
+++ b/src/OpenFOAM/meshes/lduMesh/lduMesh.C
@@ -105,8 +105,8 @@ Foam::Ostream& Foam::operator<<
     // Print actual contents
     if (lduMesh::debug)
     {
-        const labelList& l = addr.lowerAddr();
-        const labelList& u = addr.upperAddr();
+        const labelUList& l = addr.lowerAddr();
+        const labelUList& u = addr.upperAddr();
         forAll(l, facei)
         {
             os  << "        face:" << facei << " l:" << l[facei]
diff --git a/src/OpenFOAM/parallel/commSchedule/commSchedule.C b/src/OpenFOAM/parallel/commSchedule/commSchedule.C
index ae5817627cd..5386ea857eb 100644
--- a/src/OpenFOAM/parallel/commSchedule/commSchedule.C
+++ b/src/OpenFOAM/parallel/commSchedule/commSchedule.C
@@ -49,7 +49,7 @@ namespace Foam
 static label outstandingComms
 (
     const labelUList& commToSchedule,
-    const DynamicList<label>& procComms
+    const labelUList& procComms
 )
 {
     label nOutstanding = 0;
diff --git a/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutWallFunction/atmNutWallFunctionFvPatchScalarField.C b/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutWallFunction/atmNutWallFunctionFvPatchScalarField.C
index da1a3fd09a5..c6a727b0f3c 100644
--- a/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutWallFunction/atmNutWallFunctionFvPatchScalarField.C
+++ b/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutWallFunction/atmNutWallFunctionFvPatchScalarField.C
@@ -86,7 +86,7 @@ tmp<scalarField> atmNutWallFunctionFvPatchScalarField::calcNut() const
     }
     #endif
 
-    const labelList& faceCells = patch().faceCells();
+    const labelUList& faceCells = patch().faceCells();
 
     forAll(nutw, facei)
     {
diff --git a/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutkWallFunction/atmNutkWallFunctionFvPatchScalarField.C b/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutkWallFunction/atmNutkWallFunctionFvPatchScalarField.C
index deaae7c9dc7..a1f0b7ec39e 100644
--- a/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutkWallFunction/atmNutkWallFunctionFvPatchScalarField.C
+++ b/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmNutkWallFunction/atmNutkWallFunctionFvPatchScalarField.C
@@ -84,7 +84,7 @@ tmp<scalarField> atmNutkWallFunctionFvPatchScalarField::calcNut() const
     }
     #endif
 
-    const labelList& faceCells = patch().faceCells();
+    const labelUList& faceCells = patch().faceCells();
 
     // (HW:Eq. 5)
     forAll(nutw, facei)
diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/freeSurfacePointDisplacement.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/freeSurfacePointDisplacement.C
index 8661837cf23..6382d9a5f0e 100644
--- a/src/dynamicFaMesh/interfaceTrackingFvMesh/freeSurfacePointDisplacement.C
+++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/freeSurfacePointDisplacement.C
@@ -113,7 +113,7 @@ Foam::interfaceTrackingFvMesh::pointDisplacement()
             aMesh().boundary()[patchI].ngbPolyPatchFaceNormals()
         );
 
-        const labelList& eFaces =
+        const labelUList& eFaces =
             aMesh().boundary()[patchI].edgeFaces();
 
         // Correct N according to specified contact angle
diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C
index d74fe5b006b..e0644c2f243 100644
--- a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C
+++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C
@@ -733,12 +733,13 @@ void Foam::interfaceTrackingFvMesh::initializeControlPointsPosition()
                     << abort(FatalError);
             }
 
-            const labelList& eFaces =
-                aMesh().boundary()[fixedPatchID].edgeFaces();
-
-            forAll(eFaces, edgeI)
+            for
+            (
+                const label facei
+              : aMesh().boundary()[fixedPatchID].edgeFaces()
+            )
             {
-                deltaH[eFaces[edgeI]] *= 2.0;
+                deltaH[facei] *= 2.0;
             }
         }
 
@@ -789,12 +790,13 @@ void Foam::interfaceTrackingFvMesh::smoothFreeSurfaceMesh()
                 << abort(FatalError);
         }
 
-        const labelList& eFaces =
-            aMesh().boundary()[fixedPatchID].edgeFaces();
-
-        forAll(eFaces, edgeI)
+        for
+        (
+            const label facei
+          : aMesh().boundary()[fixedPatchID].edgeFaces()
+        )
         {
-            deltaHf[eFaces[edgeI]] *= 2.0;
+            deltaHf[facei] *= 2.0;
         }
     }
 
@@ -1060,7 +1062,7 @@ void Foam::interfaceTrackingFvMesh::correctPointDisplacement
         const labelList& pLabels =
             aMesh().boundary()[fixedPatchID].pointLabels();
 
-        const labelList& eFaces =
+        const labelUList& eFaces =
             aMesh().boundary()[fixedPatchID].edgeFaces();
 
         labelHashSet pointSet;
@@ -1147,7 +1149,7 @@ void Foam::interfaceTrackingFvMesh::correctPointDisplacement
         const labelList& pLabels =
             aMesh().boundary()[nonReflectingPatchID].pointLabels();
 
-        const labelList& eFaces =
+        const labelUList& eFaces =
             aMesh().boundary()[nonReflectingPatchID].edgeFaces();
 
         labelList corrPoints = pLabels;
@@ -2123,12 +2125,13 @@ bool Foam::interfaceTrackingFvMesh::update()
                     << abort(FatalError);
             }
 
-            const labelList& eFaces =
-                aMesh().boundary()[fixedPatchID].edgeFaces();
-
-            forAll(eFaces, edgeI)
+            for
+            (
+                const label facei
+              : aMesh().boundary()[fixedPatchID].edgeFaces()
+            )
             {
-                deltaHf[eFaces[edgeI]] *= 2.0;
+                deltaHf[facei] *= 2.0;
             }
         }
 
diff --git a/src/dynamicMesh/attachDetach/attachInterface.C b/src/dynamicMesh/attachDetach/attachInterface.C
index 70e996d297e..4a420a21d8a 100644
--- a/src/dynamicMesh/attachDetach/attachInterface.C
+++ b/src/dynamicMesh/attachDetach/attachInterface.C
@@ -110,8 +110,8 @@ void Foam::attachDetach::attachInterface
     }
 
     // Modify the faces from the master patch
-    const labelList& masterFaceCells = masterPatch.faceCells();
-    const labelList& slaveFaceCells = slavePatch.faceCells();
+    const labelUList& masterFaceCells = masterPatch.faceCells();
+    const labelUList& slaveFaceCells = slavePatch.faceCells();
 
     const boolList& mfFlip = mesh.faceZones()[faceZoneID_.index()].flipMap();
 
diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C
index a2ff8326812..8d586f8bdb5 100644
--- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C
+++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C
@@ -1339,14 +1339,14 @@ void Foam::polyMeshAdder::mergeZones
 
 void Foam::polyMeshAdder::addZones
 (
-    const DynamicList<word>& pointZoneNames,
+    const UList<word>& pointZoneNames,
     const List<DynamicList<label>>& pzPoints,
 
-    const DynamicList<word>& faceZoneNames,
+    const UList<word>& faceZoneNames,
     const List<DynamicList<label>>& fzFaces,
     const List<DynamicList<bool>>& fzFlips,
 
-    const DynamicList<word>& cellZoneNames,
+    const UList<word>& cellZoneNames,
     const List<DynamicList<label>>& czCells,
 
     polyMesh& mesh
@@ -2423,9 +2423,9 @@ void Foam::polyMeshAdder::patchFacePairs
     {
         const auto& mesh = meshes[meshi];
         const polyBoundaryMesh& pbm = mesh.boundaryMesh();
-        const DynamicList<label>& procPatches = localPatch[meshi];
-        const DynamicList<label>& procNbrs = remoteMesh[meshi];
-        const DynamicList<label>& procNbrPatches = remotePatch[meshi];
+        const labelUList& procPatches = localPatch[meshi];
+        const labelUList& procNbrs = remoteMesh[meshi];
+        const labelUList& procNbrPatches = remotePatch[meshi];
 
 
         // Count number of processor faces
diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H
index cad076ca049..6af9c4e1cd8 100644
--- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H
+++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H
@@ -226,14 +226,14 @@ class polyMeshAdder
         //- Create new zones and add to new mesh.
         static void addZones
         (
-            const DynamicList<word>& pointZoneNames,
+            const UList<word>& pointZoneNames,
             const List<DynamicList<label>>& pzPoints,
 
-            const DynamicList<word>& faceZoneNames,
+            const UList<word>& faceZoneNames,
             const List<DynamicList<label>>& fzFaces,
             const List<DynamicList<bool>>& fzFlips,
 
-            const DynamicList<word>& cellZoneNames,
+            const UList<word>& cellZoneNames,
             const List<DynamicList<label>>& czCells,
 
             polyMesh& mesh
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
index c842c2a6960..6f2ee3caf31 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
@@ -983,7 +983,7 @@ Foam::autoPtr<Foam::refinementHistory> Foam::refinementHistory::clone
 Foam::autoPtr<Foam::refinementHistory> Foam::refinementHistory::clone
 (
     const IOobject& io,
-    const labelList& cellMap
+    const labelUList& cellMap
 ) const
 {
     if (active_)
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H
index 6f40cf11dd6..9f50fb348c1 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H
@@ -341,7 +341,7 @@ public:
         autoPtr<refinementHistory> clone
         (
             const IOobject& io,
-            const labelList& cellMap
+            const labelUList& cellMap
         ) const;
 
         //- Update numbering for mesh changes
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H
index 2689d449f83..9dd3f615695 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H
@@ -86,13 +86,13 @@ class enrichedPatch
         mutable Map<label> pointMergeMap_;
 
         //- Slave point point hits
-        const labelList& slavePointPointHits_;
+        const labelUList& slavePointPointHits_;
 
         //- Slave point edge hits
-        const labelList& slavePointEdgeHits_;
+        const labelUList& slavePointEdgeHits_;
 
         //- Slave point face hits
-        const List<objectHit>& slavePointFaceHits_;
+        const UList<objectHit>& slavePointFaceHits_;
 
 
     // Demand-driven private data
diff --git a/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C b/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C
index 88f8393b54a..42a2227f99f 100644
--- a/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C
+++ b/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C
@@ -63,7 +63,7 @@ void Foam::faPatchMapper::calcAddressing() const
     }
 
     // Go through new edgeFaces and for each edge try to locate old index
-    const labelList& ef = patch_.edgeFaces();
+    const labelUList& ef = patch_.edgeFaces();
 
     forAll(ef, efI)
     {
diff --git a/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H b/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H
index d7e0dc74ceb..504355122dd 100644
--- a/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H
+++ b/src/finiteArea/faMesh/faPatches/basic/coupled/coupledFaPatch.H
@@ -119,7 +119,7 @@ public:
         coupledFaPatch
         (
             const word& name,
-            const labelList& edgeLabels,
+            const labelUList& edgeLabels,
             const label index,
             const faBoundaryMesh& bm,
             const label nbrPolyPatchIndex,
diff --git a/src/finiteVolume/expressions/patch/patchExprDriverFields.C b/src/finiteVolume/expressions/patch/patchExprDriverFields.C
index 2b1326b9fc9..32f1b47a32f 100644
--- a/src/finiteVolume/expressions/patch/patchExprDriverFields.C
+++ b/src/finiteVolume/expressions/patch/patchExprDriverFields.C
@@ -84,7 +84,7 @@ Foam::expressions::patchExpr::parseDriver::field_cellSelection
     // Not particularly efficient...
     labelHashSet inSelection(tselected());
 
-    const labelList& faceCells = patch_.faceCells();
+    const labelUList& faceCells = patch_.faceCells();
     auto tresult = tmp<boolField>::New(this->size(), false);
     auto& result = tresult.ref();
 
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C
index 682a4481fb3..d89655e902e 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C
@@ -129,7 +129,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
         // Bypass patchInternalField since uses fvPatch addressing
         {
             const Field<Type>& iF = this->internalField();
-            const labelList& fc = procInterface_.faceCells();
+            const labelUList& fc = procInterface_.faceCells();
             sendBuf_.resize_nocopy(fc.size());
             forAll(fc, i)
             {
@@ -202,7 +202,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
     }
 
     // Bypass patchInternalField since uses fvPatch addressing
-    const labelList& fc = lduAddr.patchAddr(patchId);
+    const labelUList& fc = lduAddr.patchAddr(patchId);
 
     scalarSendBuf_.resize_nocopy(fc.size());
     forAll(fc, i)
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C
index 380b6e4999a..548ae95d907 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C
@@ -222,7 +222,7 @@ void Foam::cyclicFvPatchField<Type>::updateInterfaceMatrix
     const Pstream::commsTypes
 ) const
 {
-    const labelList& nbrFaceCells =
+    const labelUList& nbrFaceCells =
         lduAddr.patchAddr
         (
             this->cyclicPatch().neighbPatchID()
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
index 8722e4b16ec..f4ba5c41371 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
@@ -227,12 +227,12 @@ void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs()
         );
 
         const fvPatch& cyclicPatch = patch().boundaryMesh()[cyclicPatchLabel_];
-        const labelList& cyclicFaceCells = cyclicPatch.patch().faceCells();
+        const labelUList& cyclicFaceCells = cyclicPatch.patch().faceCells();
         const fvPatch& nbrPatch = refCast<const cyclicFvPatch>
         (
             cyclicPatch
         ).neighbFvPatch();
-        const labelList& nbrFaceCells = nbrPatch.patch().faceCells();
+        const labelUList& nbrFaceCells = nbrPatch.patch().faceCells();
 
         scalar forceDiff = 0;
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C
index f2b719f5454..845899c3547 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C
@@ -253,11 +253,11 @@ void Foam::activePressureForceBaffleVelocityFvPatchVectorField::updateCoeffs()
             db().lookupObject<volScalarField>(pName_);
 
         const fvPatch& cyclicPatch = patch().boundaryMesh()[cyclicPatchLabel_];
-        const labelList& cyclicFaceCells = cyclicPatch.patch().faceCells();
+        const labelUList& cyclicFaceCells = cyclicPatch.patch().faceCells();
         const fvPatch& nbrPatch =
             refCast<const cyclicFvPatch>(cyclicPatch).neighbFvPatch();
 
-        const labelList& nbrFaceCells = nbrPatch.patch().faceCells();
+        const labelUList& nbrFaceCells = nbrPatch.patch().faceCells();
 
         scalar valueDiff = 0;
         scalar area = 0;
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
index ada91e0d510..0fb4255c422 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
@@ -272,7 +272,7 @@ void Foam::fvPatchField<Type>::autoMap
              && mapper.directAddressing().size()
             )
             {
-                const labelList& mapAddressing = mapper.directAddressing();
+                const labelUList& mapAddressing = mapper.directAddressing();
 
                 forAll(mapAddressing, i)
                 {
diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C
index 46982ebda83..3e970fbfa34 100644
--- a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C
+++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C
@@ -71,8 +71,8 @@ Foam::fv::faceCorrectedSnGrad<Type>::fullGradCorrection
     const vectorField& Sf = mesh.Sf();
     const vectorField& C = mesh.C();
     const scalarField& magSf = mesh.magSf();
-    const labelList& owner = mesh.owner();
-    const labelList& neighbour = mesh.neighbour();
+    const auto& owner = mesh.owner();
+    const auto& neighbour = mesh.neighbour();
 
     forAll(sfCorr, facei)
     {
diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C
index 070e9b557ba..80e686e64b6 100644
--- a/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C
+++ b/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C
@@ -322,7 +322,7 @@ void Foam::MULES::limiterCorr
         const fvPatchScalarField& psiPf = psiBf[patchi];
         const scalarField& phiCorrPf = phiCorrBf[patchi];
 
-        const labelList& pFaceCells = mesh.boundary()[patchi].faceCells();
+        const labelUList& pFaceCells = mesh.boundary()[patchi].faceCells();
 
         if (psiPf.coupled())
         {
@@ -441,7 +441,7 @@ void Foam::MULES::limiterCorr
             scalarField& lambdaPf = lambdaBf[patchi];
             const scalarField& phiCorrfPf = phiCorrBf[patchi];
 
-            const labelList& pFaceCells = mesh.boundary()[patchi].faceCells();
+            const labelUList& pFaceCells = mesh.boundary()[patchi].faceCells();
 
             forAll(lambdaPf, pFacei)
             {
@@ -515,7 +515,7 @@ void Foam::MULES::limiterCorr
             }
             else if (psiPf.coupled())
             {
-                const labelList& pFaceCells =
+                const labelUList& pFaceCells =
                     mesh.boundary()[patchi].faceCells();
 
                 forAll(lambdaPf, pFacei)
@@ -536,7 +536,7 @@ void Foam::MULES::limiterCorr
             }
             else
             {
-                const labelList& pFaceCells =
+                const labelUList& pFaceCells =
                     mesh.boundary()[patchi].faceCells();
                 const scalarField& phiPf = phiBf[patchi];
 
diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C
index 30ad56a9d38..cd59c831e6f 100644
--- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C
+++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C
@@ -321,7 +321,7 @@ void Foam::MULES::limiter
         const scalarField& phiBDPf = phiBDBf[patchi];
         const scalarField& phiCorrPf = phiCorrBf[patchi];
 
-        const labelList& pFaceCells = mesh.boundary()[patchi].faceCells();
+        const labelUList& pFaceCells = mesh.boundary()[patchi].faceCells();
 
         if (psiPf.coupled())
         {
@@ -469,7 +469,7 @@ void Foam::MULES::limiter
             scalarField& lambdaPf = lambdaBf[patchi];
             const scalarField& phiCorrfPf = phiCorrBf[patchi];
 
-            const labelList& pFaceCells = mesh.boundary()[patchi].faceCells();
+            const labelUList& pFaceCells = mesh.boundary()[patchi].faceCells();
 
             forAll(lambdaPf, pFacei)
             {
@@ -542,7 +542,7 @@ void Foam::MULES::limiter
             }
             else if (psiPf.coupled())
             {
-                const labelList& pFaceCells =
+                const labelUList& pFaceCells =
                     mesh.boundary()[patchi].faceCells();
 
                 forAll(lambdaPf, pFacei)
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C
index e26f61466b7..e6871a0bb37 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C
@@ -44,7 +44,7 @@ void Foam::pointMVCWeight::calcWeights
 (
     const Map<label>& toLocal,
     const face& f,
-    const DynamicList<point>& u,
+    const UList<point>& u,
     const scalarField& dist,
     scalarField& weights
 ) const
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H
index f2abe5a2107..220e6baa398 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H
@@ -86,7 +86,7 @@ protected:
         (
             const Map<label>& toLocal,
             const face& f,
-            const DynamicList<point>& u,
+            const UList<point>& u,
             const scalarField& dist,
             scalarField& weights
         ) const;
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwind.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwind.C
index 7848088c173..ac5e0b67e1f 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwind.C
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwind.C
@@ -61,8 +61,8 @@ Foam::linearUpwind<Type>::correction
 
     const surfaceScalarField& faceFlux = this->faceFlux_;
 
-    const labelList& owner = mesh.owner();
-    const labelList& neighbour = mesh.neighbour();
+    const auto& owner = mesh.owner();
+    const auto& neighbour = mesh.neighbour();
 
     const volVectorField& C = mesh.C();
     const surfaceVectorField& Cf = mesh.Cf();
@@ -172,8 +172,8 @@ Foam::linearUpwind<Foam::vector>::correction
 
     const surfaceScalarField& faceFlux = this->faceFlux_;
 
-    const labelList& owner = mesh.owner();
-    const labelList& neighbour = mesh.neighbour();
+    const auto& owner = mesh.owner();
+    const auto& neighbour = mesh.neighbour();
 
     const volVectorField& C = mesh.C();
     const surfaceVectorField& Cf = mesh.Cf();
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C
index 48439fe7407..f53be64e1bf 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C
@@ -64,8 +64,8 @@ Foam::linearUpwindV<Type>::correction
     const surfaceScalarField& faceFlux = this->faceFlux_;
     const surfaceScalarField& w = mesh.weights();
 
-    const labelList& own = mesh.owner();
-    const labelList& nei = mesh.neighbour();
+    const auto& own = mesh.owner();
+    const auto& nei = mesh.neighbour();
 
     const volVectorField& C = mesh.C();
     const surfaceVectorField& Cf = mesh.Cf();
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/outletStabilised/outletStabilised.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/outletStabilised/outletStabilised.H
index 381ab0cc03e..65f7a49cb15 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/outletStabilised/outletStabilised.H
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/outletStabilised/outletStabilised.H
@@ -154,17 +154,14 @@ public:
                     (vf.boundaryField()[patchi])
                 )
                 {
-                    const labelList& pFaceCells =
-                        mesh_.boundary()[patchi].faceCells();
-
-                    forAll(pFaceCells, pFacei)
+                    for
+                    (
+                        const label celli
+                      : mesh_.boundary()[patchi].faceCells()
+                    )
                     {
-                        const cell& pFaceCell = cells[pFaceCells[pFacei]];
-
-                        forAll(pFaceCell, fi)
+                        for (const label facei : cells[celli])
                         {
-                            label facei = pFaceCell[fi];
-
                             if (mesh_.isInternalFace(facei))
                             {
                                 // Apply upwind differencing
@@ -213,17 +210,14 @@ public:
                             (vf.boundaryField()[patchi])
                     )
                     {
-                        const labelList& pFaceCells =
-                            mesh_.boundary()[patchi].faceCells();
-
-                        forAll(pFaceCells, pFacei)
+                        for
+                        (
+                            const label celli
+                          : mesh_.boundary()[patchi].faceCells()
+                        )
                         {
-                            const cell& pFaceCell = cells[pFaceCells[pFacei]];
-
-                            forAll(pFaceCell, fi)
+                            for (const label facei : cells[celli])
                             {
-                                label facei = pFaceCell[fi];
-
                                 if (mesh_.isInternalFace(facei))
                                 {
                                     // Remove correction
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/pointLinear/pointLinear.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/pointLinear/pointLinear.C
index 6d8cad97f71..40b8b70111f 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/pointLinear/pointLinear.C
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/pointLinear/pointLinear.C
@@ -56,8 +56,8 @@ correction
     const pointField& C = mesh.C();
     const faceList& faces = mesh.faces();
     const scalarField& w = mesh.weights();
-    const labelList& owner = mesh.owner();
-    const labelList& neighbour = mesh.neighbour();
+    const auto& owner = mesh.owner();
+    const auto& neighbour = mesh.neighbour();
 
     forAll(sfCorr, facei)
     {
diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
index 092969850fd..65ff24101fc 100644
--- a/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
+++ b/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
@@ -162,7 +162,7 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
         {
             const vectorField& Cfp = CfBoundary[patchi];
 
-            const labelList& faceCells =
+            const labelUList& faceCells =
                 fieldBoundary[patchi].patch().faceCells();
 
             minMaxIds = findMinMax(fp);
diff --git a/src/fvOptions/cellSetOption/cellSetOption.C b/src/fvOptions/cellSetOption/cellSetOption.C
index b5117ada94d..8b484a77753 100644
--- a/src/fvOptions/cellSetOption/cellSetOption.C
+++ b/src/fvOptions/cellSetOption/cellSetOption.C
@@ -314,7 +314,7 @@ void Foam::fv::cellSetOption::setCellSelection()
         {
             labelHashSet selectedCells;
             const cellCellStencilObject& overlap = Stencil::New(mesh_);
-            const labelList& cellTypes = overlap.cellTypes();
+            const labelUList& cellTypes = overlap.cellTypes();
             forAll(cellTypes, celli)
             {
                 if (cellTypes[celli] == cellCellStencil::POROUS)
diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C
index 2dbed1a87b9..4d631f7efc1 100644
--- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C
+++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C
@@ -436,7 +436,7 @@ void Foam::PairCollision<CloudType>::wallInteraction()
 template<class CloudType>
 bool Foam::PairCollision<CloudType>::duplicatePointInList
 (
-    const DynamicList<point>& existingPoints,
+    const UList<point>& existingPoints,
     const point& pointToTest,
     scalar duplicateRangeSqr
 ) const
@@ -456,7 +456,7 @@ bool Foam::PairCollision<CloudType>::duplicatePointInList
 template<class CloudType>
 bool Foam::PairCollision<CloudType>::duplicatePointInList
 (
-    const DynamicList<point>& existingPoints,
+    const UList<point>& existingPoints,
     const point& pointToTest,
     const scalarList& duplicateRangeSqr
 ) const
diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H
index a5c2af2de37..acb9e05754f 100644
--- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H
+++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H
@@ -111,14 +111,14 @@ class PairCollision
 
         bool duplicatePointInList
         (
-            const DynamicList<point>& existingPoints,
+            const UList<point>& existingPoints,
             const point& pointToTest,
             scalar duplicateRangeSqr
         ) const;
 
         bool duplicatePointInList
         (
-            const DynamicList<point>& existingPoints,
+            const UList<point>& existingPoints,
             const point& pointToTest,
             const scalarList& duplicateRangeSqr
         ) const;
diff --git a/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H b/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H
index 8e2a817dab0..279bf2e807d 100644
--- a/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H
+++ b/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H
@@ -136,7 +136,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
             const SortList<scalar> sortedDist(dist);
 
             const scalar mLimit = fraction*mTotal;
-            const labelList& indices = sortedDist.indices();
+            const labelUList& indices = sortedDist.indices();
 
             if (mLimit > (mTotal - mass[indices.last()]))
             {
diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C
index baa9e9ecad6..199fe05b86c 100644
--- a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C
+++ b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C
@@ -163,7 +163,7 @@ Foam::faceList Foam::blockMesh::createPatchFaces
 {
     const blockList& blocks = *this;
 
-    labelList blockLabels = patchTopologyFaces.polyPatch::faceCells();
+    const labelUList& blockLabels = patchTopologyFaces.polyPatch::faceCells();
 
     label nFaces = 0;
 
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
index 5e3bafccad8..a0f40a2158b 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
@@ -288,8 +288,8 @@ void Foam::meshRefinement::calcNeighbourData
 void Foam::meshRefinement::calcCellCellRays
 (
     const pointField& neiCc,
-    const labelList& neiLevel,
-    const labelList& testFaces,
+    const labelUList& neiLevel,
+    const labelUList& testFaces,
     pointField& start,
     pointField& end,
     labelList& minLevel
@@ -358,7 +358,7 @@ void Foam::meshRefinement::calcCellCellRays
 }
 
 
-void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
+void Foam::meshRefinement::updateIntersections(const labelUList& changedFaces)
 {
     // Stats on edges to test. Count proc faces only once.
     bitSet isMasterFace(syncTools::getMasterFaces(mesh_));
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H
index cc87edc7623..26bd899f033 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H
@@ -259,8 +259,8 @@ private:
         void calcCellCellRays
         (
             const pointField& neiCc,
-            const labelList& neiLevel,
-            const labelList& testFaces,
+            const labelUList& neiLevel,
+            const labelUList& testFaces,
             pointField& start,
             pointField& end,
             labelList& minLevel
@@ -1589,7 +1589,7 @@ public:
             void selectSeparatedCoupledFaces(boolList&) const;
 
             //- Find any intersection of surface. Store in surfaceIndex_.
-            void updateIntersections(const labelList& changedFaces);
+            void updateIntersections(const labelUList& changedFaces);
 
             //- Calculate nearest intersection for selected mesh faces
             void nearestIntersection
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
index 181a588f871..48ddfd48cfb 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
@@ -3097,7 +3097,7 @@ void Foam::snappyLayerDriver::printLayerData
         label sumSize = pp.size();
 
         // Number of layers
-        const labelList& faceCells = pp.faceCells();
+        const labelUList& faceCells = pp.faceCells();
         label sumNLayers = 0;
         forAll(faceCells, i)
         {
@@ -3265,7 +3265,7 @@ bool Foam::snappyLayerDriver::writeLayerData
             {
                 label patchi = patchIDs[i];
                 const polyPatch& pp = pbm[patchi];
-                const labelList& faceCells = pp.faceCells();
+                const labelUList& faceCells = pp.faceCells();
                 scalarField pfld(faceCells.size());
                 forAll(faceCells, i)
                 {
@@ -5536,9 +5536,9 @@ void Foam::snappyLayerDriver::doLayers
                 if (numLayers[patchi] > 0)
                 {
                     const polyPatch& pp = mesh.boundaryMesh()[patchi];
-                    forAll(pp.faceCells(), i)
+                    for (const label celli : pp.faceCells())
                     {
-                        cellWeights[pp.faceCells()[i]] += numLayers[patchi];
+                        cellWeights[celli] += numLayers[patchi];
                     }
                 }
             }
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H
index 0ed56c89a30..eec7f933a88 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H
@@ -327,8 +327,8 @@ class snappySnapDriver
                 ) const;
                 void correctAttraction
                 (
-                    const DynamicList<point>& surfacePoints,
-                    const DynamicList<label>& surfaceCounts,
+                    const UList<point>& surfacePoints,
+                    const UList<label>& surfaceCounts,
                     const point& edgePt,
                     const vector& edgeNormal,   // normalised normal
                     const point& pt,
@@ -504,7 +504,7 @@ class snappySnapDriver
                 (
                     const point& pt,
                     const labelList& pfPatchID,
-                    const DynamicList<vector>& surfaceNormals,
+                    const UList<vector>& surfaceNormals,
                     const labelList& faceToNormalBin
                 ) const;
 
@@ -513,7 +513,7 @@ class snappySnapDriver
                 (
                     const scalar featureCos,
                     const vector& faceSurfaceNormal,
-                    const DynamicList<vector>& surfaceNormals
+                    const UList<vector>& surfaceNormals
                 ) const;
 
                 //- Determine attraction and constraints for single point
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C
index b4aaa38fa32..6f2174af828 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C
@@ -757,8 +757,8 @@ void Foam::snappySnapDriver::calcNearestFacePointProperties
 // and if so attracts the point to that non-dominant plane.
 void Foam::snappySnapDriver::correctAttraction
 (
-    const DynamicList<point>& surfacePoints,
-    const DynamicList<label>& surfaceCounts,
+    const UList<point>& surfacePoints,
+    const UList<label>& surfaceCounts,
     const point& edgePt,
     const vector& edgeNormal,       // normalised normal
     const point& pt,
@@ -820,7 +820,7 @@ Foam::label Foam::snappySnapDriver::findNormal
 (
     const scalar featureCos,
     const vector& n,
-    const DynamicList<vector>& surfaceNormals
+    const UList<vector>& surfaceNormals
 ) const
 {
     label index = -1;
@@ -853,7 +853,7 @@ Foam::pointIndexHit Foam::snappySnapDriver::findMultiPatchPoint
 (
     const point& pt,
     const labelList& patchIDs,
-    const DynamicList<vector>& surfaceNormals,
+    const UList<vector>& surfaceNormals,
     const labelList& faceToNormalBin
 ) const
 {
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C
index 9cfb1c30c6f..ae54edff67c 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C
@@ -364,7 +364,7 @@ void Foam::advancingFrontAMI::appendNbrFaces
 (
     const label facei,
     const primitivePatch& patch,
-    const DynamicList<label>& visitedFaces,
+    const labelUList& visitedFaces,
     DynamicList<label>& faceIDs
 ) const
 {
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H
index 368d61fe2a0..768ec7758f0 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H
@@ -211,7 +211,7 @@ protected:
             (
                 const label facei,
                 const primitivePatch& patch,
-                const DynamicList<label>& visitedFaces,
+                const labelUList& visitedFaces,
                 DynamicList<label>& faceIDs
             ) const;
 
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C
index c985cdc589e..c62cc19c57b 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C
@@ -63,7 +63,7 @@ namespace Foam
         // Write out triangulated surfaces as OBJ files
         OBJstream srcTriObj("srcTris_" + Foam::name(nAMI) + ".obj");
         const pointField& srcPts = src.points();
-        for (const DynamicList<face>& faces : srcTris_)
+        for (const auto& faces : srcTris_)
         {
             for (const face& f : faces)
             {
@@ -76,7 +76,7 @@ namespace Foam
 
         OBJstream tgtTriObj("tgtTris_" + Foam::name(nAMI) + ".obj");
         const pointField& tgtPts = tgt.points();
-        for (const DynamicList<face>& faces : tgtTris_)
+        for (const auto& faces : tgtTris_)
         {
             for (const face& f : faces)
             {
@@ -258,7 +258,7 @@ bool Foam::faceAreaWeightAMI::setNextFaces
     label& tgtFacei,
     const bitSet& mapFlag,
     labelList& seedFaces,
-    const DynamicList<label>& visitedFaces,
+    const labelUList& visitedFaces,
     const bool errorOnNotFound
 ) const
 {
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.H
index 5c3d61dbd84..6eac3e4133f 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.H
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.H
@@ -118,7 +118,7 @@ protected:
                 label& tgtFacei,
                 const bitSet& mapFlag,
                 labelList& seedFaces,
-                const DynamicList<label>& visitedFaces,
+                const labelUList& visitedFaces,
                 const bool errorOnNotFound = true
             ) const;
 
diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C
index 6a68693944d..0d1cc1f1d79 100644
--- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C
+++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C
@@ -202,7 +202,7 @@ void Foam::cyclicACMIGAMGInterfaceField::initInterfaceMatrixUpdate
         }
 
         // Get neighbouring field
-        const labelList& nbrFaceCells =
+        const labelUList& nbrFaceCells =
             lduAddr.patchAddr(cyclicACMIInterface_.neighbPatchID());
 
         solveScalarField pnf(psiInternal, nbrFaceCells);
@@ -315,7 +315,7 @@ void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix
     else
     {
         // Get neighbouring field
-        const labelList& nbrFaceCells =
+        const labelUList& nbrFaceCells =
             lduAddr.patchAddr(cyclicACMIInterface_.neighbPatchID());
 
         solveScalarField pnf(psiInternal, nbrFaceCells);
diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C
index da63d6a0e94..ee07f274410 100644
--- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C
+++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C
@@ -203,7 +203,7 @@ void Foam::cyclicAMIGAMGInterfaceField::initInterfaceMatrixUpdate
         }
 
         // Get neighbouring field
-        const labelList& nbrFaceCells =
+        const labelUList& nbrFaceCells =
             lduAddr.patchAddr(cyclicAMIInterface_.neighbPatchID());
 
         solveScalarField pnf(psiInternal, nbrFaceCells);
@@ -329,7 +329,7 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
     else
     {
         // Get neighbouring field
-        const labelList& nbrFaceCells =
+        const labelUList& nbrFaceCells =
             lduAddr.patchAddr(cyclicAMIInterface_.neighbPatchID());
 
         solveScalarField work(psiInternal, nbrFaceCells);
diff --git a/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.H b/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.H
index 7a45177352e..8c2cba41489 100644
--- a/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.H
+++ b/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.H
@@ -188,10 +188,16 @@ public:
         inline bool cacheTriangulation() const;
 
         //- Const access to the triangulation
-        inline const DynamicList<triPoints> triangles() const;
+        const DynamicList<triPoints>& triangles() const noexcept
+        {
+            return triangles_;
+        }
 
         //- Non-const access to the triangulation
-        inline DynamicList<triPoints>& triangles();
+        DynamicList<triPoints>& triangles() noexcept
+        {
+            return triangles_;
+        }
 
         //- Decompose face into triangle fan
         static inline void triangleFan
diff --git a/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersectI.H b/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersectI.H
index 7541b14141c..e78cf0281ff 100644
--- a/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersectI.H
+++ b/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersectI.H
@@ -121,17 +121,4 @@ bool Foam::faceAreaIntersect::cacheTriangulation() const
 }
 
 
-const Foam::DynamicList<Foam::triPoints>
-Foam::faceAreaIntersect::triangles() const
-{
-    return triangles_;
-}
-
-
-Foam::DynamicList<Foam::triPoints>& Foam::faceAreaIntersect::triangles()
-{
-    return triangles_;
-}
-
-
 // ************************************************************************* //
diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C
index d7f399de4fc..9b100aaa45d 100644
--- a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C
+++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C
@@ -54,7 +54,7 @@ adjointBoundaryCondition<Type>::computePatchGrad(word name)
     auto tresGrad = tmp<Field<GradType>>::New(patch_.size(), Zero);
     auto& resGrad = tresGrad.ref();
 
-    const labelList& faceCells = patch_.faceCells();
+    const labelUList& faceCells = patch_.faceCells();
     const fvMesh& mesh = patch_.boundaryMesh().mesh();
     const cellList& cells = mesh.cells();
 
diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointOutletVelocityFlux/adjointOutletVelocityFluxFvPatchVectorField.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointOutletVelocityFlux/adjointOutletVelocityFluxFvPatchVectorField.C
index 597cc61d62c..8c37685b960 100644
--- a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointOutletVelocityFlux/adjointOutletVelocityFluxFvPatchVectorField.C
+++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointOutletVelocityFlux/adjointOutletVelocityFluxFvPatchVectorField.C
@@ -101,7 +101,7 @@ void Foam::adjointOutletVelocityFluxFvPatchVectorField::manipulateMatrix
     );
     vectorField& source = matrix.source();
     const vectorField& Sf = patch().Sf();
-    const labelList& faceCells = patch().faceCells();
+    const labelUList& faceCells = patch().faceCells();
     const scalarField& magSf = patch().magSf();
     tmp<vectorField> tvelocitySource(boundaryContrPtr_->velocitySource());
     const vectorField& velocitySource = tvelocitySource();
diff --git a/src/optimisation/adjointOptimisation/adjoint/finiteVolume/interpolation/surfaceInterpolation/schemes/limitedSchemes/linearUpwindNormal/linearUpwindNormal.C b/src/optimisation/adjointOptimisation/adjoint/finiteVolume/interpolation/surfaceInterpolation/schemes/limitedSchemes/linearUpwindNormal/linearUpwindNormal.C
index 86f201430fe..51f7f27f5fb 100644
--- a/src/optimisation/adjointOptimisation/adjoint/finiteVolume/interpolation/surfaceInterpolation/schemes/limitedSchemes/linearUpwindNormal/linearUpwindNormal.C
+++ b/src/optimisation/adjointOptimisation/adjoint/finiteVolume/interpolation/surfaceInterpolation/schemes/limitedSchemes/linearUpwindNormal/linearUpwindNormal.C
@@ -63,8 +63,8 @@ Foam::linearUpwindNormal<Type>::correction
 
     const surfaceScalarField& faceFlux = this->faceFlux_;
 
-    const labelList& owner = mesh.owner();
-    const labelList& neighbour = mesh.neighbour();
+    const auto& owner = mesh.owner();
+    const auto& neighbour = mesh.neighbour();
 
     const volVectorField& C = mesh.C();
     const surfaceVectorField& Cf = mesh.Cf();
diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/topODesignVariables.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/topODesignVariables.C
index 6af1794f14e..f4263cdbfa7 100644
--- a/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/topODesignVariables.C
+++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/designVariables/topODesignVariables/topODesignVariables.C
@@ -268,11 +268,7 @@ void Foam::topODesignVariables::initialize()
         {
             if (isA<wallFvPatch>(patch))
             {
-                const labelList& faceCells = patch.faceCells();
-                forAll(faceCells, cI)
-                {
-                    alpha[faceCells[cI]] = 1.;
-                }
+                UIndirectList<scalar>(alpha, patch.faceCells()) = 1;
             }
         }
     }
diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointSpalartAllmaras/adjointSpalartAllmaras.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointSpalartAllmaras/adjointSpalartAllmaras.C
index 72bf06a4887..3ca8d35f8f5 100644
--- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointSpalartAllmaras/adjointSpalartAllmaras.C
+++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointSpalartAllmaras/adjointSpalartAllmaras.C
@@ -907,7 +907,7 @@ tmp<volScalarField> adjointSpalartAllmaras::distanceSensitivities()
             const scalarField rt(tsource() & tf);
             const scalarField Uap_t(Uap & tf);
 
-            const labelList& faceCells = patch.faceCells();
+            const labelUList& faceCells = patch.faceCells();
             forAll(faceCells, faceI)
             {
                 label cellI = faceCells[faceI];
diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointkOmegaSST/adjointkOmegaSST.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointkOmegaSST/adjointkOmegaSST.C
index e04e2237059..8ec6ae59d77 100644
--- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointkOmegaSST/adjointkOmegaSST.C
+++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointkOmegaSST/adjointkOmegaSST.C
@@ -142,7 +142,7 @@ tmp<volScalarField> adjointkOmegaSST::zeroFirstCell()
         if (isA<omegaWallFunctionFvPatchScalarField>(omegab))
         {
             const label patchi = patch.index();
-            const labelList& faceCells = patch.faceCells();
+            const labelUList& faceCells = patch.faceCells();
             fvPatchScalarField& bf = zeroFirstCell.boundaryFieldRef()[patchi];
             forAll(faceCells, faceI)
             {
@@ -180,7 +180,7 @@ tmp<volScalarField> adjointkOmegaSST::dR_dnut()
     {
         const fvPatch& patch = mesh_.boundary()[pI];
         const fvPatchScalarField& nutb = nutRef().boundaryField()[pI];
-        const labelList& faceCells = patch.faceCells();
+        const labelUList& faceCells = patch.faceCells();
         if (isA<nutkWallFunctionFvPatchScalarField>(nutb))
         {
             fvPatchScalarField& bf = dRdnut.boundaryFieldRef()[pI];
@@ -716,7 +716,7 @@ tmp<volScalarField> adjointkOmegaSST::dNutdbMult
                 dev2(gradU_.boundaryField()[pI].patchInternalField())
             );
             const vectorField& Sfb = Sf.boundaryField()[pI];
-            const labelList& faceCells = mesh_.boundary()[pI].faceCells();
+            const labelUList& faceCells = mesh_.boundary()[pI].faceCells();
             forAll(faceCells, fI)
             {
                 const label celli = faceCells[fI];
@@ -969,7 +969,7 @@ void adjointkOmegaSST::addWallFunctionTerms
 
             const scalar Cmu25 = pow025(Cmu);
 
-            const labelList& faceCells = patch.faceCells();
+            const labelUList& faceCells = patch.faceCells();
             const fvPatchScalarField& dR_dnutw =
                 dR_dnut.boundaryField()[patchi];
             const fvPatchScalarField& omegaw = omega.boundaryField()[patchi];
@@ -1845,7 +1845,7 @@ tmp<fvVectorMatrix> adjointkOmegaSST::divDevReff(volVectorField& Ua) const
             const fvPatchScalarField& nuEffb = nuEff.boundaryField()[pI];
             const vectorField nf = mesh_.boundary()[pI].nf();
             const vectorField Uai = Ua.boundaryField()[pI].patchInternalField();
-            const labelList& faceCells = mesh_.boundary()[pI].faceCells();
+            const labelUList& faceCells = mesh_.boundary()[pI].faceCells();
             const vectorField& Sfb = Sf.boundaryField()[pI];
 
             forAll(faceCells, fI)
@@ -1989,7 +1989,7 @@ tmp<volVectorField> adjointkOmegaSST::adjointMeanFlowSource()
             const scalar kappa = wallCoeffs.kappa();
             const scalar Cmu25 = pow025(Cmu);
 
-            const labelList& faceCells = patch.faceCells();
+            const labelUList& faceCells = patch.faceCells();
 
             const fvPatchVectorField& Uw =
                 primalVars_.U().boundaryField()[patchi];
diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/kaqRWallFunction/kaqRWallFunctionFvPatchScalarField.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/kaqRWallFunction/kaqRWallFunctionFvPatchScalarField.C
index 0057310ad04..8a9cd5eb44c 100644
--- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/kaqRWallFunction/kaqRWallFunctionFvPatchScalarField.C
+++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/kaqRWallFunction/kaqRWallFunctionFvPatchScalarField.C
@@ -124,7 +124,7 @@ void Foam::kaqRWallFunctionFvPatchScalarField::manipulateMatrix
 
         const scalar Cmu25 = pow025(Cmu);
 
-        const labelList& faceCells = patch().faceCells();
+        const labelUList& faceCells = patch().faceCells();
         const fvPatchVectorField& Uw = boundaryContrPtr_->Ub();
         const scalarField magGradUw(mag(Uw.snGrad()));
 
diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/waWallFunction/waWallFunctionFvPatchScalarField.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/waWallFunction/waWallFunctionFvPatchScalarField.C
index a3dc8d51c87..6203105c77d 100644
--- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/waWallFunction/waWallFunctionFvPatchScalarField.C
+++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/waWallFunction/waWallFunctionFvPatchScalarField.C
@@ -136,7 +136,7 @@ void waWallFunctionFvPatchScalarField::manipulateMatrix
     FieldField<Field, scalar>& internalCoeffs = matrix.internalCoeffs();
     FieldField<Field, scalar>& boundaryCoeffs = matrix.boundaryCoeffs();
     const fvMesh& mesh = patch().boundaryMesh().mesh();
-    const labelList& faceCells = patch().faceCells();
+    const labelUList& faceCells = patch().faceCells();
 
     // Add diag term from the omega expression next to the wall
     for (const label celli : faceCells)
diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C
index f5f3522932d..a19f48171af 100644
--- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C
+++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C
@@ -423,7 +423,7 @@ void Foam::cellCellStencil::setUpFrontOnOversetPatch
     {
         if (isA<oversetFvPatch>(fvm[patchi]))
         {
-            const labelList& fc = fvm[patchi].faceCells();
+            const labelUList& fc = fvm[patchi].faceCells();
             forAll(fc, i)
             {
                 const label celli = fc[i];
diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C
index f110df64632..a93838a4629 100644
--- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C
+++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C
@@ -46,7 +46,7 @@ void Foam::cellCellStencil::interpolate
     }
 
     const mapDistribute& map = overlap.cellInterpolationMap();
-    const labelList& cellIDs = overlap.interpolationCells();
+    const labelUList& cellIDs = overlap.interpolationCells();
     const scalarList& factor = overlap.cellInterpolationWeight();
 
     Field<T> work(psi);
diff --git a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C
index 602d31b0752..892e2f652fc 100644
--- a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C
+++ b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C
@@ -197,16 +197,15 @@ void Foam::cellCellStencils::cellVolumeWeight::findHoles
             //Pout<< "Proper patch " << fvp.name() << " of type " << fvp.type()
             //    << endl;
 
-            const labelList& fc = fvp.faceCells();
-            forAll(fc, i)
+            for (const label celli : fvp.faceCells())
             {
-                label regionI = cellRegion[fc[i]];
+                label regionI = cellRegion[celli];
 
-                if (cellTypes[fc[i]] != HOLE && regionType[regionI] != 2)
+                if (cellTypes[celli] != HOLE && regionType[regionI] != 2)
                 {
                     //Pout<< "reachable region : " << regionI
-                    //    << " at cell " << mesh.cellCentres()[fc[i]]
-                    //    << " on zone " << zoneID[fc[i]] << endl;
+                    //    << " at cell " << mesh.cellCentres()[celli]
+                    //    << " on zone " << zoneID[celli] << endl;
                     regionType[regionI] = 2;
                 }
             }
@@ -301,7 +300,7 @@ void Foam::cellCellStencils::cellVolumeWeight::markPatchCells
     forAll(pbm, patchI)
     {
         const fvPatch& fvp = pbm[patchI];
-        const labelList& fc = fvp.faceCells();
+        const labelUList& fc = fvp.faceCells();
 
         if (isA<oversetFvPatch>(fvp))
         {
diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C
index c09703ec547..c416d825d61 100644
--- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C
+++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C
@@ -181,7 +181,7 @@ void Foam::cellCellStencils::inverseDistance::markBoundaries
     forAll(pbm, patchI)
     {
         const fvPatch& fvp = pbm[patchI];
-        const labelList& fc = fvp.faceCells();
+        const labelUList& fc = fvp.faceCells();
 
         if (!fvPatch::constraintType(fvp.type()))
         {
@@ -209,7 +209,7 @@ void Foam::cellCellStencils::inverseDistance::markBoundaries
     forAll(pbm, patchI)
     {
         const fvPatch& fvp = pbm[patchI];
-        const labelList& fc = fvp.faceCells();
+        const labelUList& fc = fvp.faceCells();
 
         if (isA<oversetFvPatch>(fvp))
         {
@@ -1074,12 +1074,11 @@ void Foam::cellCellStencils::inverseDistance::findHoles
         {}
         else if (!fvPatch::constraintType(fvp.type()))
         {
-            const labelList& fc = fvp.faceCells();
-            forAll(fc, i)
+            for (const label celli : fvp.faceCells())
             {
-                label regionI = cellRegion[fc[i]];
+                label regionI = cellRegion[celli];
 
-                if (cellTypes[fc[i]] != HOLE && regionType[regionI] != 2)
+                if (cellTypes[celli] != HOLE && regionType[regionI] != 2)
                 {
                     regionType[regionI] = 2;
                 }
diff --git a/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C
index 07f3c254362..815d7d701e8 100644
--- a/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C
+++ b/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C
@@ -77,7 +77,7 @@ bool Foam::cellCellStencils::trackingInverseDistance::markBoundaries
     forAll(pbm, patchi)
     {
         const fvPatch& fvp = pbm[patchi];
-        const labelList& fc = fvp.faceCells();
+        const labelUList& fc = fvp.faceCells();
 
         if (!fvPatch::constraintType(fvp.type()))
         {
@@ -112,7 +112,7 @@ bool Foam::cellCellStencils::trackingInverseDistance::markBoundaries
     forAll(pbm, patchi)
     {
         const fvPatch& fvp = pbm[patchi];
-        const labelList& fc = fvp.faceCells();
+        const labelUList& fc = fvp.faceCells();
 
         if (isA<oversetFvPatch>(fvp))
         {
diff --git a/src/overset/include/setCellMask.H b/src/overset/include/setCellMask.H
index 0e65bd585ab..850e87267a5 100644
--- a/src/overset/include/setCellMask.H
+++ b/src/overset/include/setCellMask.H
@@ -30,7 +30,7 @@ Description
 
 {
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
+    const labelUList& cellTypes = overlap.cellTypes();
 
     cellMask.primitiveFieldRef() = 1.0;
     forAll(cellMask, cellI)
diff --git a/src/overset/include/setInterpolatedCells.H b/src/overset/include/setInterpolatedCells.H
index 6e42e2c795a..d45585ec8e9 100644
--- a/src/overset/include/setInterpolatedCells.H
+++ b/src/overset/include/setInterpolatedCells.H
@@ -30,7 +30,7 @@ Description
 
 {
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
+    const labelUList& cellTypes = overlap.cellTypes();
 
     interpolatedCells.primitiveFieldRef() = 1.0;
     forAll(cellMask, cellI)
diff --git a/src/overset/oversetAdjustPhi/oversetAdjustPhi.C b/src/overset/oversetAdjustPhi/oversetAdjustPhi.C
index 4b858ab40c6..f98de6d741a 100644
--- a/src/overset/oversetAdjustPhi/oversetAdjustPhi.C
+++ b/src/overset/oversetAdjustPhi/oversetAdjustPhi.C
@@ -43,8 +43,8 @@ bool Foam::oversetAdjustPhi
 {
     const fvMesh& mesh = U.mesh();
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
-    const labelList& zoneID = overlap.zoneID();
+    const labelUList& cellTypes = overlap.cellTypes();
+    const labelUList& zoneID = overlap.zoneID();
 
     // Pass1: accumulate all fluxes, calculate correction factor
 
diff --git a/src/overset/oversetFvMesh/oversetFvMeshBase.C b/src/overset/oversetFvMesh/oversetFvMeshBase.C
index 9d8571dc437..08883c1617c 100644
--- a/src/overset/oversetFvMesh/oversetFvMeshBase.C
+++ b/src/overset/oversetFvMesh/oversetFvMeshBase.C
@@ -359,8 +359,8 @@ bool Foam::oversetFvMeshBase::updateAddressing() const
 
 Foam::scalar Foam::oversetFvMeshBase::cellAverage
 (
-    const labelList& types,
-    const labelList& nbrTypes,
+    const labelUList& types,
+    const labelUList& nbrTypes,
     const scalarField& norm,
     const scalarField& nbrNorm,
     const label celli,
diff --git a/src/overset/oversetFvMesh/oversetFvMeshBase.H b/src/overset/oversetFvMesh/oversetFvMeshBase.H
index 04530c4da50..9f0c2aa2275 100644
--- a/src/overset/oversetFvMesh/oversetFvMeshBase.H
+++ b/src/overset/oversetFvMesh/oversetFvMeshBase.H
@@ -142,8 +142,8 @@ protected:
         //- Average norm of valid neighbours
         scalar cellAverage
         (
-            const labelList& types,
-            const labelList& nbrTypes,
+            const labelUList& types,
+            const labelUList& nbrTypes,
             const scalarField& norm,
             const scalarField& nbrNorm,
             const label celli,
diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.C b/src/overset/oversetPolyPatch/oversetFvPatchField.C
index 1ab511b730d..1d23d779c4d 100644
--- a/src/overset/oversetPolyPatch/oversetFvPatchField.C
+++ b/src/overset/oversetPolyPatch/oversetFvPatchField.C
@@ -168,8 +168,8 @@ void Foam::oversetFvPatchField<Type>::storeFringeCoefficients
     const fvMesh& mesh = this->internalField().mesh();
 
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
-    const labelList& zoneID = overlap.zoneID();
+    const labelUList& cellTypes = overlap.cellTypes();
+    const labelUList& zoneID = overlap.zoneID();
     const labelUList& own = mesh.owner();
     const labelUList& nei = mesh.neighbour();
 
@@ -345,8 +345,8 @@ void Foam::oversetFvPatchField<Type>::fringeFlux
     {
         const fvMesh& mesh = this->internalField().mesh();
         const cellCellStencilObject& overlap = Stencil::New(mesh);
-        const labelList& cellTypes = overlap.cellTypes();
-        const labelList& zoneID = overlap.zoneID();
+        const labelUList& cellTypes = overlap.cellTypes();
+        const labelUList& zoneID = overlap.zoneID();
 
         // Check all faces on the outside of interpolated cells
         const labelUList& own = mesh.owner();
@@ -421,8 +421,8 @@ void Foam::oversetFvPatchField<Type>::adjustPsi
     const fvMesh& mesh = this->internalField().mesh();
 
     const cellCellStencilObject& overlap = Stencil::New(mesh);
-    const labelList& cellTypes = overlap.cellTypes();
-    const labelList& zoneID = overlap.zoneID();
+    const labelUList& cellTypes = overlap.cellTypes();
+    const labelUList& zoneID = overlap.zoneID();
 
     // Pass-1: accumulate all fluxes, calculate correction factor
 
diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C
index 445162fcb62..d5cdaa204d9 100644
--- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C
+++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C
@@ -175,7 +175,7 @@ Foam::diameterModels::nucleationModels::wallBoiling::addToNucleationRate
             const scalarField& dmdt = alphatw.dmdt();
             const scalarField& dDep = alphatw.dDeparture();
 
-            const labelList& faceCells = alphatw.patch().faceCells();
+            const labelUList& faceCells = alphatw.patch().faceCells();
 
             dimensionedScalar unitLength("unitLength", dimLength, 1.0);
 
diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/wallBoiling/wallBoiling.C b/src/phaseSystemModels/reactingEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/wallBoiling/wallBoiling.C
index e0b87ac0a9c..1969cb88a14 100644
--- a/src/phaseSystemModels/reactingEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/wallBoiling/wallBoiling.C
+++ b/src/phaseSystemModels/reactingEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/wallBoiling/wallBoiling.C
@@ -122,7 +122,7 @@ Foam::diameterModels::IATEsources::wallBoiling::R
             const scalarField& dmdt = alphatw.dmdt();
             const scalarField& dDep = alphatw.dDeparture();
 
-            const labelList& faceCells = alphatw.patch().faceCells();
+            const labelUList& faceCells = alphatw.patch().faceCells();
 
             forAll(alphatw, facei)
             {
diff --git a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C
index 207d1c0a486..28812ae78b8 100644
--- a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C
+++ b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C
@@ -102,7 +102,7 @@ void Foam::regionModels::singleLayerRegion::initialise()
     {
         const label patchi = intCoupledPatchIDs_[i];
         const polyPatch& pp = rbm[patchi];
-        const labelList& fCells = pp.faceCells();
+        const labelUList& fCells = pp.faceCells();
 
         nBoundaryFaces += fCells.size();
 
diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C
index da3827b43a5..ace7e58f91e 100644
--- a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C
+++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C
@@ -144,7 +144,7 @@ tmp<scalarField> curvatureSeparation::calcCosAngle
     {
         const fvsPatchScalarField& phip = phi.boundaryField()[patchi];
         const fvPatch& pp = phip.patch();
-        const labelList& faceCells = pp.faceCells();
+        const labelUList& faceCells = pp.faceCells();
         const vectorField nf(pp.nf());
         forAll(phip, i)
         {
@@ -166,7 +166,7 @@ tmp<scalarField> curvatureSeparation::calcCosAngle
         {
             const scalarField& phip = phi.boundaryField()[patchi];
             const vectorField nf(pbm[patchi].nf());
-            const labelList& faceCells = pbm[patchi].faceCells();
+            const labelUList& faceCells = pbm[patchi].faceCells();
             const label sizeBy2 = pbm[patchi].size()/2;
 
             for (label face0=0; face0<sizeBy2; face0++)
diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/patchInjection/patchInjection.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/patchInjection/patchInjection.C
index 24acdaf03b4..3eb24a5ff3a 100644
--- a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/patchInjection/patchInjection.C
+++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/patchInjection/patchInjection.C
@@ -115,12 +115,11 @@ void patchInjection::correct
     {
         label patchi = patchIDs_[pidi];
         const polyPatch& pp = pbm[patchi];
-        const labelList& faceCells = pp.faceCells();
 
         // Accumulate the total mass removed from patch
         scalar dMassPatch = 0;
 
-        for (const label celli : faceCells)
+        for (const label celli : pp.faceCells())
         {
             scalar ddelta = max(0.0, delta[celli] - deltaStable_);
             scalar dMass = ddelta*rho[celli]*magSf[celli];
diff --git a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C
index 4e4a426491f..474ef3f3df2 100644
--- a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C
+++ b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C
@@ -236,7 +236,7 @@ void Foam::cellVolumeWeightMethod::setNextCells
     label& tgtCelli,
     const labelList& srcCellIDs,
     const boolList& mapFlag,
-    const DynamicList<label>& visitedCells,
+    const labelUList& visitedCells,
     labelList& seedCells
 ) const
 {
diff --git a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H
index 44176deefdf..957015b15c2 100644
--- a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H
+++ b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H
@@ -91,7 +91,7 @@ protected:
             label& tgtCelli,
             const labelList& srcCellIDs,
             const boolList& mapFlag,
-            const DynamicList<label>& visitedCells,
+            const labelUList& visitedCells,
             labelList& seedCells
         ) const;
 
diff --git a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C
index f1cd0e78e52..c62d1496657 100644
--- a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C
+++ b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C
@@ -157,7 +157,7 @@ void Foam::meshToMeshMethod::appendNbrCells
 (
     const label celli,
     const polyMesh& mesh,
-    const DynamicList<label>& visitedCells,
+    const labelUList& visitedCells,
     DynamicList<label>& nbrCellIDs
 ) const
 {
diff --git a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H
index 28f82d0f279..d90d9e538cf 100644
--- a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H
+++ b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H
@@ -100,7 +100,7 @@ protected:
         (
             const label tgtCelli,
             const polyMesh& mesh,
-            const DynamicList<label>& visitedTgtCells,
+            const labelUList& visitedTgtCells,
             DynamicList<label>& nbrTgtCellIDs
         ) const;
 
diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.H b/src/sampling/surface/isoSurface/isoSurfaceCell.H
index 56ef23d34bf..2e4f37bd76e 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceCell.H
+++ b/src/sampling/surface/isoSurface/isoSurfaceCell.H
@@ -163,7 +163,7 @@ class isoSurfaceCell
         template<class Type>
         Type generatePoint
         (
-            const DynamicList<Type>& snappedPoints,
+            const UList<Type>& snappedPoints,
             const scalar s0,
             const Type& p0,
             const label p0Index,
@@ -175,7 +175,7 @@ class isoSurfaceCell
         template<class Type>
         void generateTriPoints
         (
-            const DynamicList<Type>& snapped,
+            const UList<Type>& snapped,
             const scalar s0,
             const Type& p0,
             const label p0Index,
@@ -200,7 +200,7 @@ class isoSurfaceCell
             const Field<Type>& cCoords,
             const Field<Type>& pCoords,
 
-            const DynamicList<Type>& snappedPoints,
+            const UList<Type>& snappedPoints,
             const labelList& snappedCc,
             const labelList& snappedPoint,
 
diff --git a/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C b/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C
index af1e5d5924c..9082399494a 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C
+++ b/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C
@@ -36,7 +36,7 @@ License
 template<class Type>
 Type Foam::isoSurfaceCell::generatePoint
 (
-    const DynamicList<Type>& snappedPoints,
+    const UList<Type>& snappedPoints,
 
     const scalar s0,
     const Type& p0,
@@ -78,7 +78,7 @@ Type Foam::isoSurfaceCell::generatePoint
 template<class Type>
 void Foam::isoSurfaceCell::generateTriPoints
 (
-    const DynamicList<Type>& snapped,
+    const UList<Type>& snapped,
 
     const scalar s0,
     const Type& p0,
@@ -273,7 +273,7 @@ void Foam::isoSurfaceCell::generateTriPoints
     const Field<Type>& cCoords,
     const Field<Type>& pCoords,
 
-    const DynamicList<Type>& snappedPoints,
+    const UList<Type>& snappedPoints,
     const labelList& snappedCc,
     const labelList& snappedPoint,
 
diff --git a/src/sampling/surface/isoSurface/isoSurfacePoint.H b/src/sampling/surface/isoSurface/isoSurfacePoint.H
index c11241d2284..7421843ca75 100644
--- a/src/sampling/surface/isoSurface/isoSurfacePoint.H
+++ b/src/sampling/surface/isoSurface/isoSurfacePoint.H
@@ -259,7 +259,7 @@ class isoSurfacePoint
             const VolumeField<Type>& cCoords,
             const Field<Type>& pCoords,
 
-            const DynamicList<Type>& snappedPoints,
+            const UList<Type>& snappedPoints,
             const labelList& snappedCc,
             const labelList& snappedPoint,
             const label facei,
@@ -282,7 +282,7 @@ class isoSurfacePoint
             const VolumeField<Type>& cCoords,
             const Field<Type>& pCoords,
 
-            const DynamicList<Type>& snappedPoints,
+            const UList<Type>& snappedPoints,
             const labelList& snappedCc,
             const labelList& snappedPoint,
 
@@ -298,7 +298,7 @@ class isoSurfacePoint
             const labelList& interpolatedPoints,
             const List<FixedList<label, 3>>& interpolatedOldPoints,
             const List<FixedList<scalar, 3>>& interpolationWeights,
-            const DynamicList<Type>& unmergedValues
+            const UList<Type>& unmergedValues
         );
 
         triSurface stitchTriPoints
diff --git a/src/sampling/surface/isoSurface/isoSurfacePointTemplates.C b/src/sampling/surface/isoSurface/isoSurfacePointTemplates.C
index 06d90de29e0..37054e35665 100644
--- a/src/sampling/surface/isoSurface/isoSurfacePointTemplates.C
+++ b/src/sampling/surface/isoSurface/isoSurfacePointTemplates.C
@@ -438,7 +438,7 @@ Foam::label Foam::isoSurfacePoint::generateFaceTriPoints
     const VolumeField<Type>& cCoords,
     const Field<Type>& pCoords,
 
-    const DynamicList<Type>& snappedPoints,
+    const UList<Type>& snappedPoints,
     const labelList& snappedCc,
     const labelList& snappedPoint,
     const label facei,
@@ -521,7 +521,7 @@ void Foam::isoSurfacePoint::generateTriPoints
     const VolumeField<Type>& cCoords,
     const Field<Type>& pCoords,
 
-    const DynamicList<Type>& snappedPoints,
+    const UList<Type>& snappedPoints,
     const labelList& snappedCc,
     const labelList& snappedPoint,
 
@@ -738,7 +738,7 @@ Foam::isoSurfacePoint::interpolate
     const labelList& interpolatedPoints,
     const List<FixedList<label, 3>>& interpolatedOldPoints,
     const List<FixedList<scalar, 3>>& interpolationWeights,
-    const DynamicList<Type>& unmergedValues
+    const UList<Type>& unmergedValues
 )
 {
     // One value per point
diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C
index 503a7489ce9..15f2c414f8a 100644
--- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C
+++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C
@@ -281,7 +281,7 @@ void Foam::radiation::solarLoad::updateSkyDiffusiveRadiation
                 const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
 
                 const vectorField n = pp.faceNormals();
-                const labelList& cellids = pp.faceCells();
+                const labelUList& cellids = pp.faceCells();
 
                 // Calculate diffusive radiance
                 // contribution from sky and ground
@@ -326,7 +326,7 @@ void Foam::radiation::solarLoad::updateSkyDiffusiveRadiation
                 const polyPatch& pp = patches[patchID];
                 const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
 
-                const labelList& cellids = pp.faceCells();
+                const labelUList& cellids = pp.faceCells();
                 forAll(pp, facei)
                 {
                     const label celli = cellids[facei];
@@ -697,7 +697,7 @@ void Foam::radiation::solarLoad::calculateQdiff
         else
         {
             const polyPatch& pp = patches[patchID];
-            const labelList& cellids = pp.faceCells();
+            const labelUList& cellids = pp.faceCells();
             const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
             forAll(pp, facei)
             {
diff --git a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C
index d34604b2566..110f3127ba1 100644
--- a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C
+++ b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C
@@ -266,7 +266,7 @@ void Foam::isoAdvection::timeIntegratedFlux()
 
     // Storage for isoFace points. Only used if writeIsoFacesToFile_
     DynamicList<List<point>> isoFacePts;
-    const DynamicField<label>& interfaceLabels = surf_->interfaceLabels();
+    const labelUList& interfaceLabels = surf_->interfaceLabels();
 
     // Calculating isoface normal velocity
     scalarField Un0(interfaceLabels.size());
@@ -678,7 +678,7 @@ void Foam::isoAdvection::writeSurfaceCells() const
 
 void Foam::isoAdvection::writeIsoFaces
 (
-    const DynamicList<List<point>>& faces
+    const UList<List<point>>& faces
 ) const
 {
     if (!writeIsoFacesToFile_ || !mesh_.time().writeTime()) return;
@@ -694,7 +694,7 @@ void Foam::isoAdvection::writeIsoFaces
     if (Pstream::parRun())
     {
         // Collect points from all the processors
-        List<DynamicList<List<point>>> allProcFaces(Pstream::nProcs());
+        List<List<List<point>>> allProcFaces(Pstream::nProcs());
         allProcFaces[Pstream::myProcNo()] = faces;
         Pstream::gatherList(allProcFaces);
 
@@ -705,13 +705,9 @@ void Foam::isoAdvection::writeIsoFaces
             Info<< nl << "isoAdvection: writing iso faces to file: "
                 << os.name() << nl << endl;
 
-            for
-            (
-                const DynamicList<List<point>>& procFacePts
-              : allProcFaces
-            )
+            for (const auto& procFacePts : allProcFaces)
             {
-                for (const List<point>& facePts : procFacePts)
+                for (const auto& facePts : procFacePts)
                 {
                     os.writeFace(facePts, false);
                 }
@@ -725,7 +721,7 @@ void Foam::isoAdvection::writeIsoFaces
         Info<< nl << "isoAdvection: writing iso faces to file: "
             << os.name() << nl << endl;
 
-        for (const List<point>& facePts : faces)
+        for (const auto& facePts : faces)
         {
             os.writeFace(facePts, false);
         }
diff --git a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H
index f741963733d..e74589d9d27 100644
--- a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H
+++ b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H
@@ -400,10 +400,7 @@ public:
             }
 
             //- Write isoface points to .obj file
-            void writeIsoFaces
-            (
-                const DynamicList<List<point>>& isoFacePts
-            ) const;
+            void writeIsoFaces(const UList<List<point>>& isoFacePts) const;
 };
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-- 
GitLab