From 1ebb116def75592ec7d1be2adc88fef01e222f19 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Tue, 23 Jan 2024 09:50:54 +0100
Subject: [PATCH] ENH: use tmp field factory methods [3] (#2723)

- src/faOptions, src/fvOptions
---
 .../faOption/faOptionListTemplates.C          | 12 ++--
 .../jouleHeatingSource/jouleHeatingSource.C   | 20 +++---
 .../jouleHeatingSourceTemplates.C             | 17 +++--
 .../mapFieldConstraint/MapFieldConstraint.C   | 21 ++----
 .../limitTurbulenceViscosity.C                | 20 ++----
 .../acousticDampingSource.C                   | 51 ++++++++------
 ...irectionalPressureGradientExplicitSource.C | 27 +++-----
 .../jouleHeatingSource/jouleHeatingSource.C   | 24 +++----
 .../jouleHeatingSource/jouleHeatingSource.H   |  5 +-
 .../jouleHeatingSourceTemplates.C             | 17 +++--
 .../meanVelocityForce/meanVelocityForce.C     | 29 +++-----
 .../derived/rotorDiskSource/rotorDiskSource.C | 44 +++++--------
 .../rotorDiskSourceTemplates.C                | 35 ++++------
 .../solidificationMeltingSource.C             | 18 ++---
 .../viscousDissipation/viscousDissipation.C   | 24 ++-----
 .../semiImplicitSource/SemiImplicitSource.C   |  4 ++
 .../interRegionExplicitPorositySource.C       | 66 +++++++------------
 17 files changed, 178 insertions(+), 256 deletions(-)

diff --git a/src/faOptions/faOption/faOptionListTemplates.C b/src/faOptions/faOption/faOptionListTemplates.C
index b71f4958800..7445acae929 100644
--- a/src/faOptions/faOption/faOptionListTemplates.C
+++ b/src/faOptions/faOption/faOptionListTemplates.C
@@ -41,8 +41,8 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source
 {
     checkApplied();
 
-    tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds));
-    faMatrix<Type>& mtx = tmtx.ref();
+    auto tmtx = tmp<faMatrix<Type>>::New(field, ds);
+    auto& mtx = tmtx.ref();
 
     for (fa::option& source : *this)
     {
@@ -132,8 +132,8 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
         rho.dimensions()*field.dimensions()/dimTime*dimArea
     );
 
-    tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds));
-    faMatrix<Type>& mtx = tmtx.ref();
+    auto tmtx = tmp<faMatrix<Type>>::New(field, ds);
+    auto& mtx = tmtx.ref();
 
     for (fa::option& source : *this)
     {
@@ -184,8 +184,8 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
 
     const dimensionSet dsMat(ds*dimArea);
 
-    tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, dsMat));
-    faMatrix<Type>& mtx = tmtx.ref();
+    auto tmtx = tmp<faMatrix<Type>>::New(field, dsMat);
+    auto& mtx = tmtx.ref();
 
     for (fa::option& source : *this)
     {
diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C
index 051cd3d7b89..5921e788fcf 100644
--- a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C
+++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C
@@ -58,11 +58,12 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
     (
         IOobject
         (
-            typeName + ":V_" + regionName_,
+            IOobject::scopedName(typeName, "V_" + regionName_),
             regionMesh().thisDb().time().timeName(),
             regionMesh().thisDb(),
             IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
+            IOobject::AUTO_WRITE,
+            IOobject::REGISTER
         ),
         regionMesh()
     ),
@@ -141,6 +142,11 @@ void Foam::fa::jouleHeatingSource::addSup
         }
 
         // Add the Joule heating contribution
+        const word sigmaName
+        (
+            IOobject::scopedName(typeName, "sigma_" + regionName_)
+        );
+
         areaVectorField gradV("gradV", fac::grad(V_));
 
         if (debug > 1 && mesh().time().writeTime())
@@ -156,20 +162,14 @@ void Foam::fa::jouleHeatingSource::addSup
         if (anisotropicElectricalConductivity_)
         {
             const auto& sigma =
-                obr.lookupObject<areaTensorField>
-                (
-                    typeName + ":sigma_" + regionName_
-                );
+                obr.lookupObject<areaTensorField>(sigmaName);
 
             tsource = (h*sigma & gradV) & gradV;
         }
         else
         {
             const auto& sigma =
-                obr.lookupObject<areaScalarField>
-                (
-                    typeName + ":sigma_" + regionName_
-                );
+                obr.lookupObject<areaScalarField>(sigmaName);
 
             tsource = (h*sigma*gradV) & gradV;
         }
diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C
index 43763b7238c..351b5146544 100644
--- a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C
+++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C
@@ -36,13 +36,13 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
     autoPtr<Function1<Type>>& sigmaVsTPtr
 )
 {
-    typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType;
+    typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
 
     auto& obr = regionMesh().thisDb();
 
     IOobject io
     (
-        typeName + ":sigma_" + regionName_,
+        IOobject::scopedName(typeName, "sigma_" + regionName_),
         obr.time().timeName(),
         obr,
         IOobject::NO_READ,
@@ -50,7 +50,7 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
         IOobject::REGISTER
     );
 
-    tmp<AreaFieldType> tsigma;
+    autoPtr<FieldType> tsigma;
 
     if (dict.found("sigma"))
     {
@@ -59,7 +59,7 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
 
         tsigma.reset
         (
-            new AreaFieldType
+            new FieldType
             (
                 io,
                 regionMesh(),
@@ -76,7 +76,7 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
         // Sigma to be defined by user input
         io.readOpt(IOobject::MUST_READ);
 
-        tsigma.reset(new AreaFieldType(io, regionMesh()));
+        tsigma.reset(new FieldType(io, regionMesh()));
 
         Info<< "    Conductivity 'sigma' read from file" << nl << endl;
     }
@@ -92,12 +92,15 @@ Foam::fa::jouleHeatingSource::updateSigma
     const autoPtr<Function1<Type>>& sigmaVsTPtr
 ) const
 {
-    typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType;
+    typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
 
     const auto& obr = regionMesh().thisDb();
 
     auto& sigma =
-        obr.lookupObjectRef<AreaFieldType>(typeName + ":sigma_" + regionName_);
+        obr.lookupObjectRef<FieldType>
+        (
+            IOobject::scopedName(typeName, "sigma_" + regionName_)
+        );
 
     if (!sigmaVsTPtr)
     {
diff --git a/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C b/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C
index 5425dadb0ab..6aeb9d82ed2 100644
--- a/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C
+++ b/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C
@@ -34,30 +34,23 @@ License
 
 namespace Foam
 {
-namespace fv
-{
+
 static inline tmp<volScalarField> createField
 (
     const fvMesh& mesh,
     const scalar val
 )
 {
-    return tmp<volScalarField>::New
+    return volScalarField::New
     (
-        IOobject
-        (
-            polyMesh::defaultRegion,
-            mesh.time().timeName(),
-            mesh,
-            IOobjectOption::NO_READ,
-            IOobject::NO_WRITE,
-            IOobject::NO_REGISTER
-        ),
+        polyMesh::defaultRegion,
+        IOobject::NO_REGISTER,
         mesh,
-        dimensionedScalar(dimless, val)
+        val,
+        dimless
     );
 }
-}  // End namespace fv
+
 }  // End namespace Foam
 
 
diff --git a/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C b/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C
index 6c039accceb..836a23bf87c 100644
--- a/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C
+++ b/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C
@@ -87,19 +87,13 @@ Foam::tmp<Foam::volScalarField> Foam::fv::limitTurbulenceViscosity::nu() const
     const auto* dictPtr = mesh_.cfindObject<dictionary>("transportProperties");
     if (dictPtr)
     {
-        return
-            tmp<volScalarField>::New
-            (
-                IOobject
-                (
-                    "nu",
-                    mesh_.time().timeName(),
-                    mesh_,
-                    IOobject::NO_READ
-                ),
-                mesh_,
-                dimensionedScalar("nu", dimViscosity, *dictPtr)
-            );
+        return volScalarField::New
+        (
+            "nu",
+            IOobject::NO_REGISTER,
+            mesh_,
+            dimensionedScalar("nu", dimViscosity, *dictPtr)
+        );
     }
 
     FatalErrorInFunction
diff --git a/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C b/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C
index 898926ef188..3be2df145e8 100644
--- a/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C
+++ b/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2016-2021 OpenCFD Ltd.
+    Copyright (C) 2016-2023 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -87,23 +87,13 @@ Foam::fv::acousticDampingSource::acousticDampingSource
     fv::cellSetOption(name, modelType, dict, mesh),
     blendFactor_
     (
-        volScalarField
-        (
-            IOobject
-            (
-                name_ + ":blend",
-                mesh_.time().timeName(),
-                mesh_,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE
-            ),
-            mesh_,
-            scalar(1),
-            dimless,
-            fvPatchFieldBase::zeroGradientType()
-        )
+        mesh_.newIOobject(IOobject::scopedName(name_, "blend")),
+        mesh_,
+        scalar(1),
+        dimless,
+        fvPatchFieldBase::zeroGradientType()
     ),
-    frequency_("frequency", dimless/dimTime, 0),
+    frequency_("frequency", dimless/dimTime, Zero),
     x0_(Zero),
     r1_(0),
     r2_(0),
@@ -122,8 +112,15 @@ void Foam::fv::acousticDampingSource::addSup
     const label fieldI
 )
 {
+    auto tcoeff = volScalarField::New
+    (
+        IOobject::scopedName(name_, "coeff"),
+        IOobject::NO_REGISTER,
+        w_*frequency_*blendFactor_
+    );
+    const auto& coeff = tcoeff();
+
     const volVectorField& U = eqn.psi();
-    const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_);
     const auto& URef = mesh().lookupObject<volVectorField>(URefName_);
 
     fvMatrix<vector> dampingEqn
@@ -141,8 +138,15 @@ void Foam::fv::acousticDampingSource::addSup
     const label fieldI
 )
 {
+    auto tcoeff = volScalarField::New
+    (
+        IOobject::scopedName(name_, "coeff"),
+        IOobject::NO_REGISTER,
+        w_*frequency_*blendFactor_
+    );
+    const auto& coeff = tcoeff();
+
     const volVectorField& U = eqn.psi();
-    const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_);
     const auto& URef = mesh().lookupObject<volVectorField>(URefName_);
 
     fvMatrix<vector> dampingEqn
@@ -161,8 +165,15 @@ void Foam::fv::acousticDampingSource::addSup
     const label fieldI
 )
 {
+    auto tcoeff = volScalarField::New
+    (
+        IOobject::scopedName(name_, "coeff"),
+        IOobject::NO_REGISTER,
+        w_*frequency_*blendFactor_
+    );
+    const auto& coeff = tcoeff();
+
     const volVectorField& U = eqn.psi();
-    const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_);
     const auto& URef = mesh().lookupObject<volVectorField>(URefName_);
 
     fvMatrix<vector> dampingEqn
diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C
index d436078a18f..c2d6ea05c16 100644
--- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C
+++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C
@@ -148,7 +148,8 @@ void Foam::fv::directionalPressureGradientExplicitSource::writeProps
                 "uniform",
                 mesh_,
                 IOobject::NO_READ,
-                IOobject::NO_WRITE
+                IOobject::NO_WRITE,
+                IOobject::NO_REGISTER
             )
         );
         propsDict.add("gradient", gradP);
@@ -463,23 +464,18 @@ void Foam::fv::directionalPressureGradientExplicitSource::addSup
     const label fieldI
 )
 {
-    DimensionedField<vector, volMesh> Su
+    auto tSu = DimensionedField<vector, volMesh>::New
     (
-        IOobject
-        (
-            name_ + fieldNames_[fieldI] + "Sup",
-            mesh_.time().timeName(),
-            mesh_,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        name_ + fieldNames_[fieldI] + "Sup",
+        IOobject::NO_REGISTER,
         mesh_,
         dimensionedVector(eqn.dimensions()/dimVolume, Zero)
     );
+    auto& Su = tSu.ref();
 
     UIndirectList<vector>(Su, cells_) = gradP0_ + dGradP_ + gradPporous_;
 
-    eqn += Su;
+    eqn += tSu;
 }
 
 
@@ -506,14 +502,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::constrain
         (
             new volScalarField
             (
-                IOobject
-                (
-                    name_ + ":invA",
-                    mesh_.time().timeName(),
-                    mesh_,
-                    IOobject::NO_READ,
-                    IOobject::NO_WRITE
-                ),
+                mesh_.newIOobject(IOobject::scopedName(name_, "invA")),
                 1.0/eqn.A()
             )
         );
diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C
index 0fc3317c274..6053fb1ca40 100644
--- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C
+++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C
@@ -44,8 +44,6 @@ namespace fv
 }
 }
 
-const Foam::word Foam::fv::jouleHeatingSource::sigmaName(typeName + ":sigma");
-
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
@@ -55,17 +53,10 @@ Foam::fv::jouleHeatingSource::transformSigma
     const volVectorField& sigmaLocal
 ) const
 {
-    auto tsigma = tmp<volSymmTensorField>::New
+    auto tsigma = volSymmTensorField::New
     (
-        IOobject
-        (
-            sigmaName,
-            mesh_.time().timeName(),
-            mesh_.thisDb(),
-            IOobject::NO_READ,
-            IOobject::NO_WRITE,
-            IOobject::NO_REGISTER
-        ),
+        IOobject::scopedName(typeName, "sigma"),
+        IOobject::NO_REGISTER,
         mesh_,
         dimensionedSymmTensor(sigmaLocal.dimensions(), Zero),
         fvPatchFieldBase::zeroGradientType()
@@ -115,11 +106,12 @@ Foam::fv::jouleHeatingSource::jouleHeatingSource
     (
         IOobject
         (
-            typeName + ":V",
+            IOobject::scopedName(typeName, "V"),
             mesh.time().timeName(),
             mesh,
             IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
+            IOobject::AUTO_WRITE,
+            IOobject::REGISTER
         ),
         mesh
     ),
@@ -182,6 +174,10 @@ void Foam::fv::jouleHeatingSource::addSup
     }
 
     // Add the Joule heating contribution
+    const word sigmaName
+    (
+        IOobject::scopedName(typeName, "sigma")
+    );
 
     const volVectorField gradV(fvc::grad(V_));
     if (anisotropicElectricalConductivity_)
diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H
index d748dcdab84..76cd3ea4c1c 100644
--- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H
+++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2016-2020 OpenCFD Ltd.
+    Copyright (C) 2016-2023 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -179,9 +179,6 @@ class jouleHeatingSource
 {
     // Private Data
 
-        //- Name of electrical conductivity field
-        static const word sigmaName;
-
         //- Name of temperature field
         word TName_;
 
diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C
index 4eb7391caf0..2b7fbb0ed1d 100644
--- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C
+++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C
@@ -34,11 +34,11 @@ void Foam::fv::jouleHeatingSource::initialiseSigma
     autoPtr<Function1<Type>>& sigmaVsTPtr
 )
 {
-    typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
+    typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
 
     IOobject io
     (
-        typeName + ":sigma",
+        IOobject::scopedName(typeName, "sigma"),
         mesh_.time().timeName(),
         mesh_.thisDb(),
         IOobject::NO_READ,
@@ -46,7 +46,7 @@ void Foam::fv::jouleHeatingSource::initialiseSigma
         IOobject::REGISTER
     );
 
-    tmp<VolFieldType> tsigma;
+    autoPtr<FieldType> tsigma;
 
     if (dict.found("sigma"))
     {
@@ -55,7 +55,7 @@ void Foam::fv::jouleHeatingSource::initialiseSigma
 
         tsigma.reset
         (
-            new VolFieldType
+            new FieldType
             (
                 io,
                 mesh_,
@@ -72,7 +72,7 @@ void Foam::fv::jouleHeatingSource::initialiseSigma
         // Sigma to be defined by user input
         io.readOpt(IOobject::MUST_READ);
 
-        tsigma.reset(new VolFieldType(io, mesh_));
+        tsigma.reset(new FieldType(io, mesh_));
 
         Info<< "    Conductivity 'sigma' read from file" << nl << endl;
     }
@@ -88,9 +88,12 @@ Foam::fv::jouleHeatingSource::updateSigma
     const autoPtr<Function1<Type>>& sigmaVsTPtr
 ) const
 {
-    typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
+    typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
 
-    auto& sigma = mesh_.lookupObjectRef<VolFieldType>(typeName + ":sigma");
+    auto& sigma = mesh_.lookupObjectRef<FieldType>
+    (
+        IOobject::scopedName(typeName, "sigma")
+    );
 
     if (!sigmaVsTPtr)
     {
diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C
index 909d57f395b..6d052363264 100644
--- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C
+++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2018-2021 OpenCFD Ltd.
+    Copyright (C) 2018-2023 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -63,7 +63,8 @@ void Foam::fv::meanVelocityForce::writeProps
                 "uniform",
                 mesh_,
                 IOobject::NO_READ,
-                IOobject::NO_WRITE
+                IOobject::NO_WRITE,
+                IOobject::NO_REGISTER
             )
         );
         propsDict.add("gradient", gradP);
@@ -192,25 +193,20 @@ void Foam::fv::meanVelocityForce::addSup
     const label fieldi
 )
 {
-    volVectorField::Internal Su
+    auto tSu = volVectorField::Internal::New
     (
-        IOobject
-        (
-            name_ + fieldNames_[fieldi] + "Sup",
-            mesh_.time().timeName(),
-            mesh_,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        name_ + fieldNames_[fieldi] + "Sup",
+        IOobject::NO_REGISTER,
         mesh_,
         dimensionedVector(eqn.dimensions()/dimVolume, Zero)
     );
+    auto& Su = tSu.ref();
 
     scalar gradP = gradP0_ + dGradP_;
 
     UIndirectList<vector>(Su, cells_) = flowDir_*gradP;
 
-    eqn += Su;
+    eqn += tSu;
 }
 
 
@@ -237,14 +233,7 @@ void Foam::fv::meanVelocityForce::constrain
         (
             new volScalarField
             (
-                IOobject
-                (
-                    name_ + ":rA",
-                    mesh_.time().timeName(),
-                    mesh_,
-                    IOobject::NO_READ,
-                    IOobject::NO_WRITE
-                ),
+                mesh_.newIOobject(IOobject::scopedName(name_, "rA")),
                 1.0/eqn.A()
             )
         );
diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C
index a638b55ae71..f4f9085591b 100644
--- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C
+++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2018-2022 OpenCFD Ltd.
+    Copyright (C) 2018-2023 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -238,23 +238,19 @@ void Foam::fv::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
 
     if (debug)
     {
-        volScalarField area
+        auto tarea = volScalarField::New
         (
-            IOobject
-            (
-                name_ + ":area",
-                mesh_.time().timeName(),
-                mesh_,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE
-            ),
+            IOobject::scopedName(name_, "area"),
+            IOobject::NO_REGISTER,
             mesh_,
             dimensionedScalar(dimArea, Zero)
         );
-        UIndirectList<scalar>(area.primitiveField(), cells_) = area_;
+        auto& area = tarea.ref();
 
-        Info<< type() << ": " << name_ << " writing field " << area.name()
-            << endl;
+        UIndirectList<scalar>(area.primitiveFieldRef(), cells_) = area_;
+
+        Info<< type() << ": " << name_
+            << " writing field " << area.name() << endl;
 
         area.write();
     }
@@ -480,17 +476,14 @@ void Foam::fv::rotorDiskSource::addSup
     const label fieldi
 )
 {
-    volVectorField force
+    auto tforce = volVectorField::New
     (
-        IOobject
-        (
-            name_ + ":rotorForce",
-            mesh_.time().timeName(),
-            mesh_
-        ),
+        IOobject::scopedName(name_, "rotorForce"),
+        IOobject::NO_REGISTER,
         mesh_,
         dimensionedVector(eqn.dimensions()/dimVolume, Zero)
     );
+    auto& force = tforce.ref();
 
     // Read the reference density for incompressible flow
     coeffs_.readEntry("rhoRef", rhoRef_);
@@ -516,17 +509,14 @@ void Foam::fv::rotorDiskSource::addSup
     const label fieldi
 )
 {
-    volVectorField force
+    auto tforce = volVectorField::New
     (
-        IOobject
-        (
-            name_ + ":rotorForce",
-            mesh_.time().timeName(),
-            mesh_
-        ),
+        IOobject::scopedName(name_, "rotorForce"),
+        IOobject::NO_REGISTER,
         mesh_,
         dimensionedVector(eqn.dimensions()/dimVolume, Zero)
     );
+    auto& force = tforce.ref();
 
     const vectorField Uin(inflowVelocity(eqn.psi()));
     trim_->correct(rho, Uin, force);
diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C
index 5a050a7053b..db93871990f 100644
--- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C
+++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C
@@ -178,37 +178,28 @@ void Foam::fv::rotorDiskSource::writeField
     const bool writeNow
 ) const
 {
-    typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
-
     if (mesh_.time().writeTime() || writeNow)
     {
-        auto tfield = tmp<FieldType>::New
+        if (cells_.size() != values.size())
+        {
+            FatalErrorInFunction
+                << "Size mismatch. Number of cells "
+                << cells_.size() << " != number of values "
+                << values.size() << nl
+                << abort(FatalError);
+        }
+
+        auto tfield = GeometricField<Type, fvPatchField, volMesh>::New
         (
-            IOobject
-            (
-                name,
-                mesh_.time().timeName(),
-                mesh_,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE
-            ),
+            name,
+            IOobject::NO_REGISTER,
             mesh_,
             dimensioned<Type>(dimless, Zero)
         );
 
         auto& field = tfield.ref().primitiveFieldRef();
 
-        if (cells_.size() != values.size())
-        {
-            FatalErrorInFunction
-                << abort(FatalError);
-        }
-
-        forAll(cells_, i)
-        {
-            const label celli = cells_[i];
-            field[celli] = values[i];
-        }
+        UIndirectList<Type>(field, cells_) = values;
 
         tfield().write();
     }
diff --git a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C
index 6f891187c9a..f7d853c8174 100644
--- a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C
+++ b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2014-2017 OpenFOAM Foundation
-    Copyright (C) 2018-2021 OpenCFD Ltd.
+    Copyright (C) 2018-2023 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -78,16 +78,9 @@ Foam::fv::solidificationMeltingSource::Cp() const
             {
                 const scalar CpRef = coeffs_.get<scalar>("CpRef");
 
-                return tmp<volScalarField>::New
+                return volScalarField::New
                 (
-                    IOobject
-                    (
-                        name_ + ":Cp",
-                        mesh_.time().timeName(),
-                        mesh_,
-                        IOobject::NO_READ,
-                        IOobject::NO_WRITE
-                    ),
+                    IOobject::scopedName(name_, "Cp"),
                     mesh_,
                     dimensionedScalar
                     (
@@ -184,11 +177,12 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource
     (
         IOobject
         (
-            name_ + ":alpha1",
+            IOobject::scopedName(name_, "alpha1"),
             mesh.time().timeName(),
             mesh,
             IOobject::READ_IF_PRESENT,
-            IOobject::AUTO_WRITE
+            IOobject::AUTO_WRITE,
+            IOobject::REGISTER
         ),
         mesh,
         dimensionedScalar(dimless, Zero),
diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
index ac2d5b980b3..4d8491fed2c 100644
--- a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
+++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
@@ -47,16 +47,10 @@ namespace fv
 
 Foam::tmp<Foam::volScalarField> Foam::fv::viscousDissipation::rho() const
 {
-    auto trho = tmp<volScalarField>::New
+    auto trho = volScalarField::New
     (
-        IOobject
-        (
-            "trho",
-            mesh_.time().timeName(),
-            mesh_,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        "trho",
+        IOobject::NO_REGISTER,
         mesh_,
         rho_
     );
@@ -177,16 +171,10 @@ void Foam::fv::viscousDissipation::addSup
 
     const word gradUName("grad(" + UName_ + ')');
 
-    auto tgradU = tmp<GradFieldType>::New
+    auto tgradU = GradFieldType::New
     (
-        IOobject
-        (
-            "gradU",
-            mesh_.time().timeName(),
-            mesh_.time(),
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        "gradU",
+        IOobject::NO_REGISTER,
         mesh_,
         dimensionedTensor(inv(dimTime), Zero)
     );
diff --git a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C
index c8830ae3d7e..6e3585e68a9 100644
--- a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C
+++ b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C
@@ -336,6 +336,7 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
             tsu = DimensionedField<Type, volMesh>::New
             (
                 name_ + fieldName + "Su",
+                IOobject::NO_REGISTER,
                 mesh_,
                 dimensioned<Type>(SuDims, Zero)
             );
@@ -375,6 +376,7 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
                 tsu = DimensionedField<Type, volMesh>::New
                 (
                     name_ + fieldName + "Su",
+                    IOobject::NO_REGISTER,
                     mesh_,
                     dimensioned<Type>(SuDims, Zero)
                 );
@@ -462,6 +464,7 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
             tsp = DimensionedField<scalar, volMesh>::New
             (
                 name_ + fieldName + "Sp",
+                IOobject::NO_REGISTER,
                 mesh_,
                 dimensioned<scalar>(SpDims, Zero)
             );
@@ -501,6 +504,7 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
                 tsp = DimensionedField<scalar, volMesh>::New
                 (
                     name_ + fieldName + "Sp",
+                    IOobject::NO_REGISTER,
                     mesh_,
                     dimensioned<scalar>(SpDims, Zero)
                 );
diff --git a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
index 4e00e9b2251..65da636ee89 100644
--- a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
+++ b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2012-2016 OpenFOAM Foundation
-    Copyright (C) 2020 OpenCFD Ltd.
+    Copyright (C) 2020-2023 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -93,16 +93,16 @@ void Foam::fv::interRegionExplicitPorositySource::initialise()
             << abort(FatalError);
     }
 
-    porosityPtr_.reset
-    (
+    porosityPtr_.reset(nullptr);
+
+    porosityPtr_ =
         porosityModel::New
         (
             name_,
             nbrMesh,
             coeffs_,
             zoneName
-        ).ptr()
-    ),
+        );
 
     firstIter_ = false;
 }
@@ -146,19 +146,14 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
 
     const volVectorField& U = eqn.psi();
 
-    volVectorField UNbr
+    auto tUNbr = volVectorField::New
     (
-        IOobject
-        (
-            name_ + ":UNbr",
-            nbrMesh.time().timeName(),
-            nbrMesh,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        IOobject::scopedName(name_, "UNbr"),
+        IOobject::NO_REGISTER,
         nbrMesh,
         dimensionedVector(U.dimensions(), Zero)
     );
+    auto& UNbr = tUNbr.ref();
 
     // Map local velocity onto neighbour region
     meshInterp().mapSrcToTgt
@@ -177,7 +172,7 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
     scalarField& Udiag = porosityEqn.diag();
     vectorField& Usource = porosityEqn.source();
 
-    Udiag.setSize(eqn.diag().size(), 0.0);
+    Udiag.setSize(eqn.diag().size(), Zero);
     Usource.setSize(eqn.source().size(), Zero);
 
     meshInterp().mapTgtToSrc(nbrEqn.diag(), plusEqOp<scalar>(), Udiag);
@@ -200,19 +195,14 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
 
     const volVectorField& U = eqn.psi();
 
-    volVectorField UNbr
+    auto tUNbr = volVectorField::New
     (
-        IOobject
-        (
-            name_ + ":UNbr",
-            nbrMesh.time().timeName(),
-            nbrMesh,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        IOobject::scopedName(name_, "UNbr"),
+        IOobject::NO_REGISTER,
         nbrMesh,
         dimensionedVector(U.dimensions(), Zero)
     );
+    auto& UNbr = tUNbr.ref();
 
     // Map local velocity onto neighbour region
     meshInterp().mapSrcToTgt
@@ -224,33 +214,23 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
 
     fvMatrix<vector> nbrEqn(UNbr, eqn.dimensions());
 
-    volScalarField rhoNbr
+    auto trhoNbr = volScalarField::New
     (
-        IOobject
-        (
-            "rho:UNbr",
-            nbrMesh.time().timeName(),
-            nbrMesh,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        IOobject::scopedName("rho", "UNbr"),
+        IOobject::NO_REGISTER,
         nbrMesh,
         dimensionedScalar(dimDensity, Zero)
     );
+    auto& rhoNbr = trhoNbr.ref();
 
-    volScalarField muNbr
+    auto tmuNbr = volScalarField::New
     (
-        IOobject
-        (
-            "mu:UNbr",
-            nbrMesh.time().timeName(),
-            nbrMesh,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
+        IOobject::scopedName("mu", "UNbr"),
+        IOobject::NO_REGISTER,
         nbrMesh,
         dimensionedScalar(dimViscosity, Zero)
     );
+    auto& muNbr = tmuNbr.ref();
 
     const auto& mu = mesh_.lookupObject<volScalarField>(muName_);
 
@@ -277,7 +257,7 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
     scalarField& Udiag = porosityEqn.diag();
     vectorField& Usource = porosityEqn.source();
 
-    Udiag.setSize(eqn.diag().size(), 0.0);
+    Udiag.setSize(eqn.diag().size(), Zero);
     Usource.setSize(eqn.source().size(), Zero);
 
     meshInterp().mapTgtToSrc(nbrEqn.diag(), plusEqOp<scalar>(), Udiag);
-- 
GitLab