From 018124e3bf3812238d4d0deb4842a2a8fb257073 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 21 Mar 2018 09:31:09 +0100
Subject: [PATCH] STYLE: use 'return nullptr' for empty autoPtr/tmp returns

- both autoPtr and tmp are defined with an implicit construct from
  nullptr (but with explicit construct from a pointer to null).
  Thus is it safe to use 'nullptr' when returning an empty autoPtr or tmp.
---
 .../phaseModel/phaseModel.C                      |  2 +-
 .../twoPhaseMixtureEThermo.C                     | 12 ++++++------
 .../multiphaseSystem/phaseModel/phaseModel.C     |  2 +-
 .../multiphaseMixture/phase/phase.C              |  2 +-
 .../IsothermalPhaseModel/IsothermalPhaseModel.C  |  2 +-
 .../MultiComponentPhaseModel.C                   |  2 +-
 .../phaseModel/PurePhaseModel/PurePhaseModel.C   |  3 +--
 .../phaseModel/phaseModel/phaseModel.C           |  2 +-
 .../IATE/IATEsources/IATEsource/IATEsource.H     |  2 +-
 .../IATE/IATEsources/IATEsource/IATEsource.H     |  2 +-
 .../DelaunayMesh/DistributedDelaunayMesh.C       |  6 ++----
 .../searchableSurfaceFeatures.H                  |  4 ++--
 .../createBaffles/faceSelection/faceSelection.H  |  2 +-
 .../faceSelection/faceZoneSelection.H            |  2 +-
 .../faceSelection/searchableSurfaceSelection.H   |  2 +-
 .../reconstructParMesh/reconstructParMesh.C      |  2 +-
 .../lumped/lumpedPointForces/lumpedPointForces.C |  2 +-
 .../searchableSurfaceModifier/autoPatch.H        |  2 +-
 .../surfacePatch/searchableSurfaceModifier/cut.H |  2 +-
 .../searchableSurfaceModifier.H                  |  2 +-
 .../functionObject/functionObject.H              |  2 +-
 .../matrices/LUscalarMatrix/procLduInterface.H   |  2 +-
 .../LduMatrix/LduMatrixPreconditioner.C          |  2 +-
 .../LduMatrix/LduMatrix/LduMatrixSmoother.C      |  2 +-
 .../LduMatrix/LduMatrix/LduMatrixSolver.C        |  2 +-
 .../lduMatrix/lduMatrixPreconditioner.C          |  2 +-
 .../lduMatrix/lduMatrix/lduMatrixSmoother.C      |  2 +-
 .../lduMatrix/lduMatrix/lduMatrixSolver.C        |  2 +-
 .../lduMatrix/lduMatrix/lduMatrixTemplates.C     |  2 +-
 src/OpenFOAM/meshes/polyMesh/polyMesh.C          |  2 +-
 .../functions/Function1/Function1/Function1.C    |  4 ++--
 .../schemes/DEShybrid/DEShybrid.H                |  4 ++--
 src/conversion/ccm/reader/ccmReaderMesh.C        |  2 +-
 .../fvMeshDistribute/fvMeshDistribute.C          |  2 +-
 src/dynamicMesh/meshCut/cellLooper/cellLooper.H  |  2 +-
 .../motionSolvers/motionSolver/motionSolver.C    |  2 +-
 .../polyTopoChanger/polyTopoChanger.C            |  8 +++-----
 .../lnGradSchemes/lnGradScheme/lnGradScheme.H    |  2 +-
 .../edgeInterpolationScheme.H                    |  2 +-
 src/finiteVolume/cfdTools/general/MRF/MRFZone.H  |  2 +-
 .../cfdTools/general/fvOptions/fvOption.H        |  2 +-
 .../CoEulerDdtScheme/CoEulerDdtScheme.C          |  2 +-
 .../ReynoldsAnalogy/ReynoldsAnalogy.C            |  4 ++--
 .../solvers/energyTransport/energyTransport.C    |  3 ++-
 .../solidificationMeltingSource.C                |  8 +++-----
 .../viscousDissipation/viscousDissipation.C      |  8 ++++----
 .../MPPIC/ParticleStressModels/Lun/Lun.C         |  2 +-
 .../DispersionRASModel/DispersionRASModel.C      |  4 ++--
 .../BrownianMotion/BrownianMotionForce.C         |  2 +-
 src/lumpedPointMotion/lumpedPointTools.C         |  2 +-
 .../blockMesh/blockEdges/blockEdge/blockEdge.C   |  2 +-
 .../blockMesh/blockFaces/blockFace/blockFace.C   |  2 +-
 .../blockVertices/blockVertex/blockVertex.C      |  4 ++--
 src/mesh/blockMesh/blocks/block/block.H          |  2 +-
 .../coordinateRotation/EulerCoordinateRotation.C | 10 +++++-----
 .../STARCDCoordinateRotation.C                   | 10 +++++-----
 .../coordinateRotation/axesRotation.C            |  4 ++--
 .../searchableSurface/searchableSurface.H        |  2 +-
 src/meshTools/sets/topoSetSource/topoSetSource.H |  2 +-
 src/meshTools/sets/topoSets/topoSet.H            |  2 +-
 .../pyrolysisModel/pyrolysisModel.H              |  2 +-
 src/sampling/sampledSet/sampledSet/sampledSet.H  |  2 +-
 .../sampledSurface/sampledSurface.C              | 10 +++++-----
 .../sampledSurface/sampledSurface.H              |  2 +-
 .../sampledTriSurfaceMeshNormal.H                | 16 ++++++++--------
 .../surfMeshSampler/surfMeshSampler.H            |  2 +-
 .../triSurfaceMesh/discreteSurfaceTemplates.C    |  6 ++----
 src/surfMesh/surfZone/surfZone/surfZone.H        |  2 +-
 68 files changed, 109 insertions(+), 117 deletions(-)

diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/phaseModel/phaseModel.C b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/phaseModel/phaseModel.C
index ac37bac4aef..a59534e603b 100644
--- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/phaseModel/phaseModel.C
+++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/phaseModel/phaseModel.C
@@ -81,7 +81,7 @@ Foam::phaseModel::phaseModel
 Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::clone() const
 {
     NotImplemented;
-    return autoPtr<phaseModel>();
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C
index 751df5fcb78..3cfbfe89ed3 100644
--- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C
+++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C
@@ -259,7 +259,7 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::THE
 ) const
 {
     NotImplemented;
-    return tmp<Foam::scalarField>();
+    return nullptr;
 }
 
 
@@ -272,7 +272,7 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::THE
 ) const
 {
     NotImplemented;
-    return tmp<Foam::scalarField>();
+    return nullptr;
 }
 
 
@@ -436,8 +436,8 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cpv
 
 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::CpByCpv() const
 {
-     NotImplemented;
-     return tmp<Foam::volScalarField>();
+    NotImplemented;
+    return nullptr;
 }
 
 
@@ -448,8 +448,8 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::CpByCpv
     const label patchi
 ) const
 {
-     NotImplemented;
-     return tmp<Foam::scalarField>();
+    NotImplemented;
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C
index cc6790499f0..9b66605cf8b 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C
@@ -205,7 +205,7 @@ Foam::phaseModel::~phaseModel()
 Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::clone() const
 {
     NotImplemented;
-    return autoPtr<phaseModel>();
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/phase/phase.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/phase/phase.C
index e14906619b4..e7a5603c9f9 100644
--- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/phase/phase.C
+++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/phase/phase.C
@@ -68,7 +68,7 @@ Foam::phase::phase
 Foam::autoPtr<Foam::phase> Foam::phase::clone() const
 {
     NotImplemented;
-    return autoPtr<phase>();
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C
index 95a9f0c38bb..8677e02a475 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C
@@ -65,7 +65,7 @@ template<class BasePhaseModel>
 Foam::tmp<Foam::fvScalarMatrix>
 Foam::IsothermalPhaseModel<BasePhaseModel>::heEqn()
 {
-    return tmp<fvScalarMatrix>();
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C
index 171f2f38786..7547954fd56 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C
@@ -152,7 +152,7 @@ Foam::MultiComponentPhaseModel<BasePhaseModel>::YiEqn
         )
     )
     {
-        return tmp<fvScalarMatrix>();
+        return nullptr;
     }
 
     const volScalarField& alpha = *this;
diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/PurePhaseModel/PurePhaseModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/PurePhaseModel/PurePhaseModel.C
index 9d94f7627e5..db8556d47d1 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/PurePhaseModel/PurePhaseModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/PurePhaseModel/PurePhaseModel.C
@@ -57,8 +57,7 @@ Foam::PurePhaseModel<BasePhaseModel>::YiEqn
 )
 {
     NotImplemented;
-
-    return tmp<fvScalarMatrix>();
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/phaseModel/phaseModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/phaseModel/phaseModel.C
index 4d183cd0a29..68e85badefd 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/phaseModel/phaseModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/phaseModel/phaseModel.C
@@ -77,7 +77,7 @@ Foam::phaseModel::phaseModel
 Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::clone() const
 {
     NotImplemented;
-    return autoPtr<phaseModel>();
+    return nullptr;
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H
index db917c48659..1e3b3f1f4ce 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H
@@ -115,7 +115,7 @@ public:
         autoPtr<IATEsource> clone() const
         {
             NotImplemented;
-            return autoPtr<IATEsource>();
+            return nullptr;
         }
 
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H
index 29c150ce741..964df057ce7 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.H
@@ -114,7 +114,7 @@ public:
         autoPtr<IATEsource> clone() const
         {
             NotImplemented;
-            return autoPtr<IATEsource>();
+            return nullptr;
         }
 
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
index 620bd04decf..f6e6c75aba4 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
@@ -794,14 +794,12 @@ Foam::DistributedDelaunayMesh<Triangulation>::distribute
 {
     if (!Pstream::parRun())
     {
-        return autoPtr<mapDistribute>();
+        return nullptr;
     }
 
     distributeBoundBoxes(decomposition.procBounds());
 
-    autoPtr<mapDistribute> mapDist = decomposition.distributePoints(points);
-
-    return mapDist;
+    return decomposition.distributePoints(points);
 }
 
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.H
index fe1c509207a..f42e974f0a0 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.H
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.H
@@ -101,7 +101,7 @@ public:
         virtual autoPtr<searchableSurfaceFeatures> clone() const
         {
             NotImplemented;
-            return autoPtr<searchableSurfaceFeatures>();
+            return nullptr;
         }
 
 
@@ -139,7 +139,7 @@ public:
         //- Return an extendedFeatureEdgeMesh containing the features
         virtual autoPtr<extendedFeatureEdgeMesh> features() const
         {
-            return autoPtr<extendedFeatureEdgeMesh>();
+            return nullptr;
         }
 };
 
diff --git a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.H b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.H
index b17f016212c..04a95cf0cec 100644
--- a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.H
+++ b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.H
@@ -109,7 +109,7 @@ public:
         autoPtr<faceSelection> clone() const
         {
             NotImplemented;
-            return autoPtr<faceSelection>();
+            return nullptr;
         }
 
 
diff --git a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceZoneSelection.H b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceZoneSelection.H
index 20e7f66fe5d..ac19cf0ed74 100644
--- a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceZoneSelection.H
+++ b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceZoneSelection.H
@@ -86,7 +86,7 @@ public:
         autoPtr<faceSelection> clone() const
         {
             NotImplemented;
-            return autoPtr<faceSelection>();
+            return nullptr;
         }
 
 
diff --git a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.H b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.H
index 8f934ae3c3f..fb76b1c486a 100644
--- a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.H
+++ b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.H
@@ -79,7 +79,7 @@ public:
         autoPtr<faceSelection> clone() const
         {
             NotImplemented;
-            return autoPtr<faceSelection>();
+            return nullptr;
         }
 
 
diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
index a61b5829807..6c0c7b96cf0 100644
--- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
+++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
@@ -251,7 +251,7 @@ autoPtr<mapPolyMesh> mergeSharedPoints
 
     if (returnReduce(pointToMaster.size(), sumOp<label>()) == 0)
     {
-        return autoPtr<mapPolyMesh>();
+        return nullptr;
     }
 
     polyTopoChange meshMod(mesh);
diff --git a/applications/utilities/postProcessing/lumped/lumpedPointForces/lumpedPointForces.C b/applications/utilities/postProcessing/lumped/lumpedPointForces/lumpedPointForces.C
index c45dce76aec..ac36be2058a 100644
--- a/applications/utilities/postProcessing/lumped/lumpedPointForces/lumpedPointForces.C
+++ b/applications/utilities/postProcessing/lumped/lumpedPointForces/lumpedPointForces.C
@@ -71,7 +71,7 @@ autoPtr<GeoFieldType> loadField
         );
     }
 
-    return autoPtr<GeoFieldType>();
+    return nullptr;
 }
 
 
diff --git a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.H b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.H
index 40d23bbb963..e0457837f2a 100644
--- a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.H
+++ b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.H
@@ -76,7 +76,7 @@ public:
         autoPtr<searchableSurfaceModifier> clone() const
         {
             NotImplemented;
-            return autoPtr<searchableSurfaceModifier>();
+            return nullptr;
         }
 
 
diff --git a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.H b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.H
index 1024e5e44b0..33620b8ecfd 100644
--- a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.H
+++ b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.H
@@ -100,7 +100,7 @@ public:
         autoPtr<searchableSurfaceModifier> clone() const
         {
             NotImplemented;
-            return autoPtr<searchableSurfaceModifier>();
+            return nullptr;
         }
 
 
diff --git a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.H b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.H
index 897bad68a0f..a1877ebf9c8 100644
--- a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.H
+++ b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.H
@@ -96,7 +96,7 @@ public:
         autoPtr<searchableSurfaceModifier> clone() const
         {
             NotImplemented;
-            return autoPtr<searchableSurfaceModifier>();
+            return nullptr;
         }
 
 
diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H
index 825b562af75..7150594c3db 100644
--- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H
+++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H
@@ -197,7 +197,7 @@ public:
         autoPtr<functionObject> clone() const
         {
             NotImplemented;
-            return autoPtr<functionObject>();
+            return nullptr;
         }
 
 
diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/procLduInterface.H b/src/OpenFOAM/matrices/LUscalarMatrix/procLduInterface.H
index 56de4eb76a6..cad2a869541 100644
--- a/src/OpenFOAM/matrices/LUscalarMatrix/procLduInterface.H
+++ b/src/OpenFOAM/matrices/LUscalarMatrix/procLduInterface.H
@@ -93,7 +93,7 @@ public:
         autoPtr<procLduInterface> clone()
         {
             NotImplemented;
-            return autoPtr<procLduInterface>();
+            return nullptr;
         }
 
         static autoPtr<procLduInterface> New(Istream& is)
diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C
index 468297c2a5f..a0f4b9241f4 100644
--- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C
+++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C
@@ -97,7 +97,7 @@ Foam::LduMatrix<Type, DType, LUType>::preconditioner::New
            "no diagonal or off-diagonal coefficient"
         << exit(FatalIOError);
 
-    return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C
index dd27fc51c2b..a362e5f1604 100644
--- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C
+++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C
@@ -89,7 +89,7 @@ Foam::LduMatrix<Type, DType, LUType>::smoother::New
         << "cannot solve incomplete matrix, no off-diagonal coefficients"
         << exit(FatalIOError);
 
-    return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C
index 626301066e6..5324acef626 100644
--- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C
+++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C
@@ -105,7 +105,7 @@ Foam::LduMatrix<Type, DType, LUType>::solver::New
            "no diagonal or off-diagonal coefficient"
         << exit(FatalIOError);
 
-    return autoPtr<typename LduMatrix<Type, DType, LUType>::solver>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C
index 27f8c3687d2..059721926da 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C
@@ -138,7 +138,7 @@ Foam::lduMatrix::preconditioner::New
            "no diagonal or off-diagonal coefficient"
         << exit(FatalIOError);
 
-    return autoPtr<lduMatrix::preconditioner>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C
index 731d4c89b30..03f62412c05 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C
@@ -142,7 +142,7 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
         "no diagonal or off-diagonal coefficient"
         << exit(FatalIOError);
 
-    return autoPtr<lduMatrix::smoother>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C
index 4b0a2092ec7..8629b76654a 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C
@@ -122,7 +122,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
         "no diagonal or off-diagonal coefficient"
         << exit(FatalIOError);
 
-    return autoPtr<lduMatrix::solver>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C
index 9f28ad17cda..0a132a2f230 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C
@@ -104,7 +104,7 @@ Foam::lduMatrix::faceH(const Field<Type>& psi) const
            " the matrix does not have any off-diagonal coefficients."
         << exit(FatalError);
 
-    return tmp<Field<Type>>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
index 78d3ff5cddb..f66b48555f3 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
@@ -152,7 +152,7 @@ Foam::autoPtr<Foam::labelIOList> Foam::polyMesh::readTetBasePtIs() const
         return autoPtr<labelIOList>::New(io);
     }
 
-    return autoPtr<labelIOList>();
+    return nullptr;
 }
 
 
diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C
index 6d46ce921db..d03e6e84259 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C
@@ -79,7 +79,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
 ) const
 {
     NotImplemented;
-    return tmp<Field<Type>>();
+    return nullptr;
 }
 
 
@@ -100,7 +100,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
 ) const
 {
     NotImplemented;
-    return tmp<Field<Type>>();
+    return nullptr;
 }
 
 
diff --git a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H
index f1c8dfd5992..645670e9bda 100644
--- a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H
+++ b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H
@@ -423,7 +423,7 @@ public:
                 << "Unable to retrieve turbulence model from the mesh "
                 << "database" << exit(FatalError);
 
-            return tmp<surfaceScalarField>();
+            return nullptr;
         }
 
 
@@ -500,7 +500,7 @@ public:
                 return (bf*tScheme2_().correction(vf));
             }
 
-            return tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>();
+            return nullptr;
         }
 };
 
diff --git a/src/conversion/ccm/reader/ccmReaderMesh.C b/src/conversion/ccm/reader/ccmReaderMesh.C
index f7ea2947b54..3412fbc906c 100644
--- a/src/conversion/ccm/reader/ccmReaderMesh.C
+++ b/src/conversion/ccm/reader/ccmReaderMesh.C
@@ -2591,7 +2591,7 @@ Foam::autoPtr<Foam::polyMesh> Foam::ccm::reader::mesh
 {
     if (!readGeometry())
     {
-        return autoPtr<polyMesh>();
+        return nullptr;
     }
 
     // merge cellTable and rename boundaryRegion
diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
index a2b245ebeb3..cf502e92add 100644
--- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
+++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
@@ -704,7 +704,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::mergeSharedPoints
 
     if (returnReduce(pointToMaster.size(), sumOp<label>()) == 0)
     {
-        return autoPtr<mapPolyMesh>();
+        return nullptr;
     }
 
     polyTopoChange meshMod(mesh_);
diff --git a/src/dynamicMesh/meshCut/cellLooper/cellLooper.H b/src/dynamicMesh/meshCut/cellLooper/cellLooper.H
index 02ade8a4383..c7f10685c41 100644
--- a/src/dynamicMesh/meshCut/cellLooper/cellLooper.H
+++ b/src/dynamicMesh/meshCut/cellLooper/cellLooper.H
@@ -145,7 +145,7 @@ public:
         autoPtr<cellLooper> clone() const
         {
             NotImplemented;
-            return autoPtr<cellLooper>();
+            return nullptr;
         }
 
 
diff --git a/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C b/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C
index 7efaf9cd5b8..884736f7291 100644
--- a/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C
+++ b/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C
@@ -92,7 +92,7 @@ Foam::motionSolver::motionSolver
 Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::clone() const
 {
     NotImplemented;
-    return autoPtr<motionSolver>();
+    return nullptr;
 }
 
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
index 2d9f9ecf557..b12cae508ca 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
@@ -283,11 +283,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChanger::changeMesh
         mesh_.updateMesh(topoChangeMap());
         return topoChangeMap;
     }
-    else
-    {
-        mesh_.topoChanging(false);
-        return autoPtr<mapPolyMesh>();
-    }
+
+    mesh_.topoChanging(false);
+    return nullptr;
 }
 
 
diff --git a/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.H b/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.H
index be8e5b7e195..e0099127285 100644
--- a/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.H
+++ b/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.H
@@ -148,7 +148,7 @@ public:
         virtual tmp<GeometricField<Type, faePatchField, edgeMesh>>
         correction(const GeometricField<Type, faPatchField, areaMesh>&) const
         {
-            return tmp<GeometricField<Type, faePatchField, edgeMesh>>();
+            return nullptr;
         }
 
         //- Return the lnGrad of the given cell field
diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.H b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.H
index fd2e8b8ff7d..575bfb83f58 100644
--- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.H
+++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.H
@@ -189,7 +189,7 @@ public:
         virtual tmp<GeometricField<Type, faePatchField, edgeMesh>>
         correction(const GeometricField<Type, faPatchField, areaMesh>&) const
         {
-            return tmp<GeometricField<Type, faePatchField, edgeMesh>>();
+            return nullptr;
         }
 
         //- Return the face-interpolate of the given cell field
diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H
index 236bef78370..141c2efd5d8 100644
--- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H
+++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H
@@ -174,7 +174,7 @@ public:
         autoPtr<MRFZone> clone() const
         {
             NotImplemented;
-            return autoPtr<MRFZone>();
+            return nullptr;
         }
 
 
diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H
index 45be00daa8d..ac56c7d2283 100644
--- a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H
+++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H
@@ -133,7 +133,7 @@ public:
         autoPtr<option> clone() const
         {
             NotImplemented;
-            return autoPtr<option>();
+            return nullptr;
         }
 
         //- Return pointer to new fvOption object created
diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C
index 3b8d31be2d9..1e8ce859f64 100644
--- a/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C
+++ b/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C
@@ -140,7 +140,7 @@ tmp<surfaceScalarField> CoEulerDdtScheme<Type>::CofrDeltaT() const
         << "Incorrect dimensions of phi: " << phi.dimensions()
         << abort(FatalError);
 
-    return tmp<surfaceScalarField>();
+    return nullptr;
 }
 
 
diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C
index b6fcdc31378..b01313428b6 100644
--- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C
+++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C
@@ -67,7 +67,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::rho(const label patchi) const
         << "Unable to set rho for patch " << patchi
         << exit(FatalError);
 
-    return tmp<Field<scalar>>();
+    return nullptr;
 }
 
 
@@ -94,7 +94,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cp(const label patchi) const
         << "Unable to set Cp for patch " << patchi
         << exit(FatalError);
 
-    return tmp<Field<scalar>>();
+    return nullptr;
 }
 
 
diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C
index 6562338cab9..f5f5280301d 100644
--- a/src/functionObjects/solvers/energyTransport/energyTransport.C
+++ b/src/functionObjects/solvers/energyTransport/energyTransport.C
@@ -105,7 +105,8 @@ Foam::functionObjects::energyTransport::kappaEff() const
 
     FatalErrorInFunction
         << "Turbulence model not found" << exit(FatalError);
-    return tmp<volScalarField>();
+
+    return nullptr;
 }
 
 
diff --git a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C
index 6272af6db95..09d2fec8d14 100644
--- a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C
+++ b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C
@@ -116,7 +116,7 @@ Foam::fv::solidificationMeltingSource::Cp() const
         }
     }
 
-    return tmp<volScalarField>();
+    return nullptr;
 }
 
 
@@ -128,10 +128,8 @@ Foam::vector Foam::fv::solidificationMeltingSource::g() const
             mesh_.lookupObject<uniformDimensionedVectorField>("g");
         return value.value();
     }
-    else
-    {
-        return coeffs_.lookup("g");
-    }
+
+    return coeffs_.lookup("g");
 }
 
 
diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
index 7ac99f96f75..3a78957d9da 100644
--- a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
+++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
@@ -82,7 +82,7 @@ Foam::tmp<Foam::volScalarField> Foam::fv::viscousDissipation::rho() const
         << "Neither rhoName nor rho are specified."
         << exit(FatalError);
 
-    return tmp<volScalarField>();
+    return nullptr;
 }
 
 
@@ -133,8 +133,8 @@ Foam::fv::viscousDissipation::viscousDissipation
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-Foam::tmp<Foam::volSymmTensorField> Foam::fv::viscousDissipation::
-devRhoReff() const
+Foam::tmp<Foam::volSymmTensorField>
+Foam::fv::viscousDissipation::devRhoReff() const
 {
     // Incompressible
     {
@@ -166,7 +166,7 @@ devRhoReff() const
         << " The turbulence model is not found in the database."
         << exit(FatalError);
 
-    return tmp<volSymmTensorField>();
+    return nullptr;
 }
 
 
diff --git a/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/Lun/Lun.C b/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/Lun/Lun.C
index 47ba7192888..e4aba79ab96 100644
--- a/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/Lun/Lun.C
+++ b/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/Lun/Lun.C
@@ -109,7 +109,7 @@ Foam::ParticleStressModels::Lun::dTaudTheta
 ) const
 {
     NotImplemented;
-    return tmp<Field<scalar>>();
+    return nullptr;
 }
 
 
diff --git a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C
index 35f869c5861..b1116d76ce5 100644
--- a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C
+++ b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C
@@ -53,7 +53,7 @@ Foam::DispersionRASModel<CloudType>::kModel() const
         << "Database objects include: " << obr.sortedToc()
         << abort(FatalError);
 
-    return tmp<volScalarField>();
+    return nullptr;
 }
 
 
@@ -81,7 +81,7 @@ Foam::DispersionRASModel<CloudType>::epsilonModel() const
         << "Database objects include: " << obr.sortedToc()
         << abort(FatalError);
 
-    return tmp<volScalarField>();
+    return nullptr;
 }
 
 
diff --git a/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C b/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C
index 4b0be43e65e..ac4eb95f7f5 100644
--- a/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C
+++ b/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C
@@ -76,7 +76,7 @@ Foam::BrownianMotionForce<CloudType>::kModel() const
         << "Database objects include: " << obr.sortedToc()
         << abort(FatalError);
 
-    return tmp<volScalarField>();
+    return nullptr;
 }
 
 
diff --git a/src/lumpedPointMotion/lumpedPointTools.C b/src/lumpedPointMotion/lumpedPointTools.C
index e842aa8c50f..3f3b330edf3 100644
--- a/src/lumpedPointMotion/lumpedPointTools.C
+++ b/src/lumpedPointMotion/lumpedPointTools.C
@@ -62,7 +62,7 @@ namespace Foam
             );
         }
 
-        return autoPtr<GeoFieldType>();
+        return nullptr;
     }
 }
 
diff --git a/src/mesh/blockMesh/blockEdges/blockEdge/blockEdge.C b/src/mesh/blockMesh/blockEdges/blockEdge/blockEdge.C
index 1d48424208a..ca4b4cd6fea 100644
--- a/src/mesh/blockMesh/blockEdges/blockEdge/blockEdge.C
+++ b/src/mesh/blockMesh/blockEdges/blockEdge/blockEdge.C
@@ -67,7 +67,7 @@ Foam::blockEdge::blockEdge
 Foam::autoPtr<Foam::blockEdge> Foam::blockEdge::clone() const
 {
     NotImplemented;
-    return autoPtr<blockEdge>();
+    return nullptr;
 }
 
 
diff --git a/src/mesh/blockMesh/blockFaces/blockFace/blockFace.C b/src/mesh/blockMesh/blockFaces/blockFace/blockFace.C
index 812fb52fb31..d60886a694a 100644
--- a/src/mesh/blockMesh/blockFaces/blockFace/blockFace.C
+++ b/src/mesh/blockMesh/blockFaces/blockFace/blockFace.C
@@ -65,7 +65,7 @@ Foam::blockFace::blockFace
 Foam::autoPtr<Foam::blockFace> Foam::blockFace::clone() const
 {
     NotImplemented;
-    return autoPtr<blockFace>();
+    return nullptr;
 }
 
 
diff --git a/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C b/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C
index 902295182e4..bf601607232 100644
--- a/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C
+++ b/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C
@@ -45,7 +45,7 @@ Foam::blockVertex::blockVertex()
 Foam::autoPtr<Foam::blockVertex> Foam::blockVertex::clone() const
 {
     NotImplemented;
-    return autoPtr<blockVertex>();
+    return nullptr;
 }
 
 
@@ -98,7 +98,7 @@ Foam::autoPtr<Foam::blockVertex> Foam::blockVertex::New
         << firstToken.info()
         << exit(FatalIOError);
 
-    return autoPtr<blockVertex>();
+    return nullptr;
 }
 
 
diff --git a/src/mesh/blockMesh/blocks/block/block.H b/src/mesh/blockMesh/blocks/block/block.H
index b0941d3462e..9f3e0f6e7e8 100644
--- a/src/mesh/blockMesh/blocks/block/block.H
+++ b/src/mesh/blockMesh/blocks/block/block.H
@@ -134,7 +134,7 @@ public:
         autoPtr<block> clone() const
         {
             NotImplemented;
-            return autoPtr<block>();
+            return nullptr;
         }
 
         //- New function which constructs and returns pointer to a block
diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C
index cbc61246246..5a7d86e8289 100644
--- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C
+++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C
@@ -70,7 +70,7 @@ Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::transform
 ) const
 {
     NotImplemented;
-    return tmp<vectorField>();
+    return nullptr;
 }
 
 
@@ -80,7 +80,7 @@ Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::invTransform
 ) const
 {
     NotImplemented;
-    return tmp<vectorField>();
+    return nullptr;
 }
 
 
@@ -96,8 +96,8 @@ Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
     const tensorField& st
 ) const
 {
-     NotImplemented;
-    return tmp<tensorField>();
+    NotImplemented;
+    return nullptr;
 }
 
 
@@ -117,7 +117,7 @@ Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
 ) const
 {
     NotImplemented;
-    return tmp<tensorField>();
+    return nullptr;
 }
 
 
diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C
index fcaa3ed0992..2cb61d9d1df 100644
--- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C
+++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C
@@ -71,7 +71,7 @@ Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::transform
 ) const
 {
     NotImplemented;
-    return tmp<vectorField>();
+    return nullptr;
 }
 
 
@@ -81,7 +81,7 @@ Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::invTransform
 ) const
 {
     NotImplemented;
-    return tmp<vectorField>();
+    return nullptr;
 }
 
 
@@ -97,8 +97,8 @@ Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
     const tensorField& st
 ) const
 {
-     NotImplemented;
-    return tmp<tensorField>();
+    NotImplemented;
+    return nullptr;
 }
 
 
@@ -118,7 +118,7 @@ Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
 ) const
 {
     NotImplemented;
-    return tmp<tensorField>();
+    return nullptr;
 }
 
 
diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C
index 162bab5cb8a..95ec8f0e763 100644
--- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C
+++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C
@@ -245,7 +245,7 @@ Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor
 ) const
 {
     NotImplemented;
-    return tmp<tensorField>();
+    return nullptr;
 }
 
 
@@ -265,7 +265,7 @@ Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor
 ) const
 {
     NotImplemented;
-    return tmp<tensorField>();
+    return nullptr;
 }
 
 
diff --git a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H
index 9f67882eb8f..38f9d0226bc 100644
--- a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H
+++ b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H
@@ -139,7 +139,7 @@ public:
         virtual autoPtr<searchableSurface> clone() const
         {
             NotImplemented;
-            return autoPtr<searchableSurface>();
+            return nullptr;
         }
 
 
diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.H b/src/meshTools/sets/topoSetSource/topoSetSource.H
index 293474c1ccb..5ec70414111 100644
--- a/src/meshTools/sets/topoSetSource/topoSetSource.H
+++ b/src/meshTools/sets/topoSetSource/topoSetSource.H
@@ -243,7 +243,7 @@ public:
         autoPtr<topoSetSource> clone() const
         {
             NotImplemented;
-            return autoPtr<topoSetSource>();
+            return nullptr;
         }
 
 
diff --git a/src/meshTools/sets/topoSets/topoSet.H b/src/meshTools/sets/topoSets/topoSet.H
index 2fde875cece..03498942981 100644
--- a/src/meshTools/sets/topoSets/topoSet.H
+++ b/src/meshTools/sets/topoSets/topoSet.H
@@ -254,7 +254,7 @@ public:
         autoPtr<topoSet> clone() const
         {
             NotImplemented;
-            return autoPtr<topoSet>();
+            return nullptr;
         }
 
 
diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H
index daa2938e722..79af2752cd0 100644
--- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H
+++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H
@@ -156,7 +156,7 @@ public:
         autoPtr<pyrolysisModel> clone() const
         {
             NotImplemented;
-            return autoPtr<pyrolysisModel>();
+            return nullptr;
         }
 
 
diff --git a/src/sampling/sampledSet/sampledSet/sampledSet.H b/src/sampling/sampledSet/sampledSet/sampledSet.H
index 7de1433443d..1a7a253d976 100644
--- a/src/sampling/sampledSet/sampledSet/sampledSet.H
+++ b/src/sampling/sampledSet/sampledSet/sampledSet.H
@@ -217,7 +217,7 @@ public:
         autoPtr<sampledSet> clone() const
         {
             NotImplemented;
-            return autoPtr<sampledSet>();
+            return nullptr;
         }
 
 
diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C
index 8f3ea1ad50c..9265cd389f9 100644
--- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C
+++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C
@@ -137,7 +137,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledSurface::sample
 ) const
 {
     NotImplemented;
-    return tmp<scalarField>();
+    return nullptr;
 }
 
 
@@ -147,7 +147,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledSurface::sample
 ) const
 {
     NotImplemented;
-    return tmp<vectorField>();
+    return nullptr;
 }
 
 
@@ -157,7 +157,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledSurface::sample
 ) const
 {
     NotImplemented;
-    return tmp<sphericalTensorField>();
+    return nullptr;
 }
 
 
@@ -167,7 +167,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledSurface::sample
 ) const
 {
     NotImplemented;
-    return tmp<symmTensorField>();
+    return nullptr;
 }
 
 
@@ -177,7 +177,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledSurface::sample
 ) const
 {
     NotImplemented;
-    return tmp<tensorField>();
+    return nullptr;
 }
 
 
diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
index 1080c96d5d1..cdda4084ce8 100644
--- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
+++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
@@ -205,7 +205,7 @@ public:
         autoPtr<sampledSurface> clone() const
         {
             NotImplemented;
-            return autoPtr<sampledSurface>();
+            return nullptr;
         }
 
 
diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.H b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.H
index 13ad4b847ce..7409e3b548e 100644
--- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.H
+++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.H
@@ -103,7 +103,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<scalarField>();
+            return nullptr;
         }
 
         //- Sample field on surface
@@ -119,7 +119,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<sphericalTensorField>();
+            return nullptr;
         }
 
         //- Sample field on surface
@@ -129,7 +129,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<symmTensorField>();
+            return nullptr;
         }
 
         //- Sample field on surface
@@ -139,7 +139,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<tensorField>();
+            return nullptr;
         }
 
         //- Interpolate field on surface
@@ -149,7 +149,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<scalarField>();
+            return nullptr;
         }
 
         //- Interpolate field on surface
@@ -165,7 +165,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<sphericalTensorField>();
+            return nullptr;
         }
 
         //- Interpolate field on surface
@@ -175,7 +175,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<symmTensorField>();
+            return nullptr;
         }
 
         //- Interpolate field on surface
@@ -185,7 +185,7 @@ public:
         ) const
         {
             NotImplemented;
-            return tmp<tensorField>();
+            return nullptr;
         }
 };
 
diff --git a/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H b/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H
index a4f8d5c45fd..027d5d8c297 100644
--- a/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H
+++ b/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H
@@ -181,7 +181,7 @@ public:
         autoPtr<surfMeshSampler> clone() const
         {
             NotImplemented;
-            return autoPtr<surfMeshSampler>();
+            return nullptr;
         }
 
 
diff --git a/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C b/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C
index 2fed330e657..03523195044 100644
--- a/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C
+++ b/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C
@@ -120,10 +120,8 @@ Foam::discreteSurface::sampleType
         const VolFieldType& fld = mesh().lookupObject<VolFieldType>(fieldName);
         return sampleField(fld);
     }
-    else
-    {
-        return tmp<Field<Type>>();
-    }
+
+    return nullptr;
 }
 
 
diff --git a/src/surfMesh/surfZone/surfZone/surfZone.H b/src/surfMesh/surfZone/surfZone/surfZone.H
index 75078453973..d90fdde90ad 100644
--- a/src/surfMesh/surfZone/surfZone/surfZone.H
+++ b/src/surfMesh/surfZone/surfZone/surfZone.H
@@ -115,7 +115,7 @@ public:
         autoPtr<surfZone> clone() const
         {
             NotImplemented;
-            return autoPtr<surfZone>();
+            return nullptr;
         }
 
         static autoPtr<surfZone> New(Istream& is)
-- 
GitLab