diff --git a/src/faOptions/faOption/faOptionListTemplates.C b/src/faOptions/faOption/faOptionListTemplates.C index b71f495880..7445acae92 100644 --- a/src/faOptions/faOption/faOptionListTemplates.C +++ b/src/faOptions/faOption/faOptionListTemplates.C @@ -41,8 +41,8 @@ Foam::tmp> Foam::fa::optionList::source { checkApplied(); - tmp> tmtx(new faMatrix(field, ds)); - faMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fa::option& source : *this) { @@ -132,8 +132,8 @@ Foam::tmp> Foam::fa::optionList::operator() rho.dimensions()*field.dimensions()/dimTime*dimArea ); - tmp> tmtx(new faMatrix(field, ds)); - faMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fa::option& source : *this) { @@ -184,8 +184,8 @@ Foam::tmp> Foam::fa::optionList::operator() const dimensionSet dsMat(ds*dimArea); - tmp> tmtx(new faMatrix(field, dsMat)); - faMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::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 051cd3d7b8..5921e788fc 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 - ( - typeName + ":sigma_" + regionName_ - ); + obr.lookupObject(sigmaName); tsource = (h*sigma & gradV) & gradV; } else { const auto& sigma = - obr.lookupObject - ( - typeName + ":sigma_" + regionName_ - ); + obr.lookupObject(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 43763b7238..351b514654 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>& sigmaVsTPtr ) { - typedef GeometricField AreaFieldType; + typedef GeometricField 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 tsigma; + autoPtr 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>& sigmaVsTPtr ) const { - typedef GeometricField AreaFieldType; + typedef GeometricField FieldType; const auto& obr = regionMesh().thisDb(); auto& sigma = - obr.lookupObjectRef(typeName + ":sigma_" + regionName_); + obr.lookupObjectRef + ( + 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 5425dadb0a..6aeb9d82ed 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 createField ( const fvMesh& mesh, const scalar val ) { - return tmp::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 6c039accce..836a23bf87 100644 --- a/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C +++ b/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C @@ -87,19 +87,13 @@ Foam::tmp Foam::fv::limitTurbulenceViscosity::nu() const const auto* dictPtr = mesh_.cfindObject("transportProperties"); if (dictPtr) { - return - tmp::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 898926ef18..3be2df145e 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(URefName_); fvMatrix 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(URefName_); fvMatrix 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(URefName_); fvMatrix dampingEqn diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index d436078a18..c2d6ea05c1 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 Su + auto tSu = DimensionedField::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(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 0fc3317c27..6053fb1ca4 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::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 d748dcdab8..76cd3ea4c1 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 4eb7391caf..2b7fbb0ed1 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>& sigmaVsTPtr ) { - typedef GeometricField VolFieldType; + typedef GeometricField 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 tsigma; + autoPtr 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>& sigmaVsTPtr ) const { - typedef GeometricField VolFieldType; + typedef GeometricField FieldType; - auto& sigma = mesh_.lookupObjectRef(typeName + ":sigma"); + auto& sigma = mesh_.lookupObjectRef + ( + 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 909d57f395..6d05236326 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(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 a638b55ae7..f4f9085591 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(area.primitiveField(), cells_) = area_; + auto& area = tarea.ref(); - Info<< type() << ": " << name_ << " writing field " << area.name() - << endl; + UIndirectList(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 5a050a7053..db93871990 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 FieldType; - if (mesh_.time().writeTime() || writeNow) { - auto tfield = tmp::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::New ( - IOobject - ( - name, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + name, + IOobject::NO_REGISTER, mesh_, dimensioned(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(field, cells_) = values; tfield().write(); } diff --git a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C index 6f891187c9..f7d853c817 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("CpRef"); - return tmp::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 ac2d5b980b..4d8491fed2 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::fv::viscousDissipation::rho() const { - auto trho = tmp::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::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 c8830ae3d7..6e3585e68a 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::addSup tsu = DimensionedField::New ( name_ + fieldName + "Su", + IOobject::NO_REGISTER, mesh_, dimensioned(SuDims, Zero) ); @@ -375,6 +376,7 @@ void Foam::fv::SemiImplicitSource::addSup tsu = DimensionedField::New ( name_ + fieldName + "Su", + IOobject::NO_REGISTER, mesh_, dimensioned(SuDims, Zero) ); @@ -462,6 +464,7 @@ void Foam::fv::SemiImplicitSource::addSup tsp = DimensionedField::New ( name_ + fieldName + "Sp", + IOobject::NO_REGISTER, mesh_, dimensioned(SpDims, Zero) ); @@ -501,6 +504,7 @@ void Foam::fv::SemiImplicitSource::addSup tsp = DimensionedField::New ( name_ + fieldName + "Sp", + IOobject::NO_REGISTER, mesh_, dimensioned(SpDims, Zero) ); diff --git a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C index 4e00e9b225..65da636ee8 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(), 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 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(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(), Udiag);