diff --git a/src/faOptions/faOption/faOptionListTemplates.C b/src/faOptions/faOption/faOptionListTemplates.C index b71f49588007f30fb80ab31f06db1faafeffb6d6..7445acae929b8686856e69d8cc73474191c8fb9f 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 051cd3d7b89c85c7de20ddf80d3785949b1e06cb..5921e788fcfe3c8265946a6edd7972ec0a84b726 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 43763b7238c350e6f1398d748b1b0e17300378d4..351b5146544ceac2c0fc689e140f1154f356d315 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 5425dadb0ab54032a284faab99a82fa9070e2048..6aeb9d82ed2b7acc679743cfae986388ef21df7e 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 6c039accceb0fccb2c8260d422fdf1b4f14ff057..836a23bf87c92766fd96fa4b802188456511d4df 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 898926ef1888aaa14d98623e340494bed9ae1c02..3be2df145e87ae841111233b40ac7e911e43d4de 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 d436078a18fbad4150882ce8ed99e6d9345f6e8c..c2d6ea05c16901adaa23bedc25cf9381ea2c7e77 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 0fc3317c274e1b9da2b0a1f9207deda7bef8dcdb..6053fb1ca4019963ebacb5c9235a201bc2adea23 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 d748dcdab84dec42084d8e866dc58ba50a7793ce..76cd3ea4c1cba467549ff1d7c58770051811b781 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 4eb7391caf096056405963b985d960bd427aa311..2b7fbb0ed1dae06bc073aa431eedc3f90fbd81e1 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 909d57f395b2455289d21a4f9c1a39f6bfad55f1..6d0523632646cfc45dc965f3df1928f846a12b84 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 a638b55ae71b69d9c609d47ba14880b22ac04d81..f4f9085591becfb7e1534718b5c9cccf2f7acc0f 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 5a050a7053ba3c7e4a981732f00eadcaeaaabc1d..db93871990fc7a9b39fb214a97c659209dbcb9f4 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 6f891187c9ad4e6d351f4aecf6ceefecd9a7f8da..f7d853c8174837627ee8cc4c803b315542b5ae08 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 ac2d5b980b3e0f4e6f1e00461b26c99f26728583..4d8491fed2ca7366be38087dbdaec7f58a2b46bb 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 c8830ae3d7e1ba484bb2a53978e6ef24097816ec..6e3585e68a902657cd4141a17df798fed5e581b4 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 4e00e9b2251340d6c53ed795c07b298a87bd8395..65da636ee897356b4a73bf740a54e3efbcf3439b 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);