From ee39e3d2761ecabd02d49e03d698f5bf5811bfa6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 24 Apr 2023 12:05:55 +0200 Subject: [PATCH] STYLE: use explicit REGISTER option when storing fields --- .../parLagrangianDistributorTemplates.C | 5 +-- .../db/dynamicLibrary/codedBase/codedBase.C | 4 +-- src/OpenFOAM/fields/cloud/cloudTemplates.C | 22 ++++++------ .../schemes/DEShybrid/DEShybrid.H | 9 +++-- .../ObukhovLength/ObukhovLength.C | 3 ++ .../atmPlantCanopyTurbSource.C | 3 +- .../atmPlantCanopyUSource.C | 3 +- .../polyMeshFilter/polyMeshFilterTemplates.C | 18 ++++------ .../columnAverage/columnAverageTemplates.C | 5 +-- .../histogramModel/histogramModel.C | 3 +- .../field/mapFields/mapFieldsTemplates.C | 34 +++++++++---------- .../proudmanAcousticPower.C | 9 ++--- .../field/readFields/readFields.C | 3 +- .../resolutionIndexModel.C | 5 +-- .../resolutionIndexModelTemplates.C | 3 +- .../stabilityBlendingFactor.C | 12 ++++--- .../turbulenceFieldsTemplates.C | 24 ++++++------- .../forces/forceCoeffs/forceCoeffs.C | 6 ++-- src/functionObjects/forces/forces/forces.C | 6 ++-- .../utilities/solverInfo/solverInfo.C | 3 +- .../HeatTransferCoeff/HeatTransferCoeff.C | 29 +++++++++------- .../KinematicReynoldsNumber.C | 29 +++++++++------- .../NusseltNumber/NusseltNumber.C | 29 +++++++++------- .../ParticleDose/ParticleDose.C | 28 ++++++++------- .../ThermoReynoldsNumber.C | 29 +++++++++------- .../WeberNumber/WeberNumberReacting.C | 29 +++++++++------- .../triSurfaceMesh/triSurfaceMesh.C | 3 +- .../cellCellStencil/cellCellStencil.C | 19 +++++++---- .../functionObjects/filmFlux/filmFlux.C | 3 +- ...emperatureCoupledMixedFvPatchScalarField.C | 3 +- .../basic/basicThermo/basicThermo.C | 3 +- .../speciesSorptionFvPatchScalarField.C | 5 +-- .../isoAdvection/isoAdvection.C | 6 ++-- .../angledDuct/implicit/system/sampling | 21 +++++++----- .../setups.orig/common/system/controlDict | 3 +- .../setups.orig/common/system/controlDict | 3 +- .../setups.orig/common/system/controlDict | 3 +- 37 files changed, 239 insertions(+), 186 deletions(-) diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C index 6bfb38094c..8cb5119bed 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C @@ -302,8 +302,9 @@ Foam::label Foam::parLagrangianDistributor::readFields objectName, cloud.time().timeName(), cloud, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::LAZY_READ, + IOobject::NO_WRITE, + IOobject::REGISTER ), label(0) ); diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C index bdf64d0597..c2e25c8b19 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C @@ -103,7 +103,7 @@ Foam::codedBase::codeDict const word& dictName ) { - IOdictionary* dictptr = obr.getObjectPtr(dictName); + auto* dictptr = obr.getObjectPtr(dictName); if (!dictptr) { @@ -114,7 +114,7 @@ Foam::codedBase::codeDict dictName, obr.time().system(), obr, - IOobject::MUST_READ_IF_MODIFIED, + IOobject::READ_MODIFIED, IOobject::NO_WRITE, IOobject::REGISTER ) diff --git a/src/OpenFOAM/fields/cloud/cloudTemplates.C b/src/OpenFOAM/fields/cloud/cloudTemplates.C index 3bdd332fbb..0bbe00f3b5 100644 --- a/src/OpenFOAM/fields/cloud/cloudTemplates.C +++ b/src/OpenFOAM/fields/cloud/cloudTemplates.C @@ -37,20 +37,18 @@ Foam::IOField& Foam::cloud::createIOField objectRegistry& obr ) { - IOField* fieldPtr + IOField* fieldPtr = new IOField ( - new IOField + IOobject ( - IOobject - ( - fieldName, - obr.time().timeName(), - obr, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - nParticle - ) + fieldName, + obr.time().timeName(), + obr, + IOobject::NO_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER + ), + nParticle ); fieldPtr->store(); diff --git a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H index ff82ef379b..62618f3260 100644 --- a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H +++ b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H @@ -297,13 +297,14 @@ class DEShybrid const word factorName(IOobject::scopedName(typeName, "Factor")); const fvMesh& mesh = this->mesh(); - const IOobject factorIO + IOobject factorIO ( factorName, mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ); if (blendedSchemeBaseName::debug) @@ -335,7 +336,9 @@ class DEShybrid } else { - const volScalarField factor + factorIO.registerObject(IOobjectOption::NO_REGISTER); + + volScalarField factor ( factorIO, max(sigmaMax_*tanh(pow(A, CH1_)), sigmaMin_) diff --git a/src/atmosphericModels/functionObjects/ObukhovLength/ObukhovLength.C b/src/atmosphericModels/functionObjects/ObukhovLength/ObukhovLength.C index 399e940477..68e8d0eef7 100644 --- a/src/atmosphericModels/functionObjects/ObukhovLength/ObukhovLength.C +++ b/src/atmosphericModels/functionObjects/ObukhovLength/ObukhovLength.C @@ -80,7 +80,10 @@ bool Foam::functionObjects::ObukhovLength::calcOL() ); result1->store(); + } + if (!result2) + { result2 = new volScalarField ( IOobject diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C index 9ced80a9a1..ed01512dbd 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C @@ -60,7 +60,8 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyTurbSource::getOrReadField mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ); diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C index 158ac96647..89beb35193 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C @@ -61,7 +61,8 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyUSource::getOrReadField mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ); diff --git a/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C b/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C index 1583757852..4d13814c23 100644 --- a/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C +++ b/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C @@ -83,24 +83,20 @@ void Foam::polyMeshFilter::copySets { const SetType& set = *iter(); - SetType* origSet = + auto* setPtr = newMesh.objectRegistry::getObjectPtr(set.name()); - if (origSet) + if (setPtr) { - (*origSet) = set; - (*origSet).sync(newMesh); + (*setPtr) = set; } else { - SetType* newSet - ( - new SetType(newMesh, set.name(), set, set.writeOpt()) - ); - - newSet->store(); - newSet->sync(newMesh); + setPtr = new SetType(newMesh, set.name(), set, set.writeOpt()); + setPtr->store(); } + + setPtr->sync(newMesh); } } diff --git a/src/functionObjects/field/columnAverage/columnAverageTemplates.C b/src/functionObjects/field/columnAverage/columnAverageTemplates.C index ab95a2b48f..6a6b537500 100644 --- a/src/functionObjects/field/columnAverage/columnAverageTemplates.C +++ b/src/functionObjects/field/columnAverage/columnAverageTemplates.C @@ -47,7 +47,7 @@ bool Foam::functionObjects::columnAverage::columnAverageField const word resultName(averageName(fieldName)); - fieldType* resPtr = obr_.getObjectPtr(resultName); + auto* resPtr = obr_.getObjectPtr(resultName); if (!resPtr) { @@ -59,7 +59,8 @@ bool Foam::functionObjects::columnAverage::columnAverageField fld.mesh().time().timeName(), fld.mesh(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), fld ); diff --git a/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C b/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C index 8bfb64ce1d..4e57b40e34 100644 --- a/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C +++ b/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C @@ -68,7 +68,8 @@ Foam::volScalarField& Foam::histogramModel::getOrReadField mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ); diff --git a/src/functionObjects/field/mapFields/mapFieldsTemplates.C b/src/functionObjects/field/mapFields/mapFieldsTemplates.C index 6de7cb7be0..aa35e00716 100644 --- a/src/functionObjects/field/mapFields/mapFieldsTemplates.C +++ b/src/functionObjects/field/mapFields/mapFieldsTemplates.C @@ -129,28 +129,28 @@ bool Foam::functionObjects::mapFields::mapFieldType() const const VolFieldType& field = lookupObject(fieldName); - if (!mapRegion.foundObject(fieldName)) + auto* mapFieldPtr = mapRegion.getObjectPtr(fieldName); + + if (!mapFieldPtr) { - VolFieldType* tmappedField = - new VolFieldType + mapFieldPtr = new VolFieldType + ( + IOobject ( - IOobject - ( - fieldName, - time_.timeName(), - mapRegion, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + fieldName, + time_.timeName(), mapRegion, - dimensioned(field.dimensions(), Zero) - ); + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ), + mapRegion, + dimensioned(field.dimensions(), Zero) + ); - tmappedField->store(); + mapFieldPtr->store(); } - - VolFieldType& mappedField = - mapRegion.template lookupObjectRef(fieldName); + auto& mappedField = *mapFieldPtr; mappedField = interpPtr_->mapTgtToSrc(field); diff --git a/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C b/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C index dd11e31367..0718ae315f 100644 --- a/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C +++ b/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C @@ -94,8 +94,7 @@ Foam::functionObjects::proudmanAcousticPower::a() const ( scopedName("a"), mesh_.time().timeName(), - mesh_, - IOobject::NO_READ + mesh_ ), mesh_, aRef_ @@ -170,7 +169,8 @@ Foam::functionObjects::proudmanAcousticPower::proudmanAcousticPower mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimPower/dimVolume, Zero) @@ -189,7 +189,8 @@ Foam::functionObjects::proudmanAcousticPower::proudmanAcousticPower mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimless, Zero) diff --git a/src/functionObjects/field/readFields/readFields.C b/src/functionObjects/field/readFields/readFields.C index bd670217d3..ccd549b180 100644 --- a/src/functionObjects/field/readFields/readFields.C +++ b/src/functionObjects/field/readFields/readFields.C @@ -111,7 +111,8 @@ bool Foam::functionObjects::readFields::execute() mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ); const bool ok = diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C index 44baba6b55..bf21e27a23 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C @@ -99,8 +99,9 @@ bool Foam::resolutionIndexModel::read(const dictionary& dict) resultName_, mesh_.time().timeName(), mesh_, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::LAZY_READ, + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimless, Zero), diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C index 61e494e74a..cdbe29b3d6 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C @@ -48,7 +48,8 @@ GeoFieldType& Foam::resolutionIndexModel::getOrReadField mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ); diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index 871367501b..63c976e07e 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -67,7 +67,8 @@ Foam::functionObjects::stabilityBlendingFactor::indicator() time_.timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimless, Zero), @@ -558,7 +559,8 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor mesh_.time().constant(), mesh_, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ); if (fieldHeader.typeHeaderOk(true, true, false)) @@ -587,7 +589,8 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor mesh_.time().constant(), mesh_, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ); if (fieldHeader.typeHeaderOk(true, true, false)) @@ -614,7 +617,8 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor mesh_.time().constant(), mesh_, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ); if (fieldHeader.typeHeaderOk(true, true, false)) diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index 6d4cc90658..e30d45d522 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -49,21 +49,21 @@ void Foam::functionObjects::turbulenceFields::processField } else { - obr_.store + fldPtr = new FieldType ( - new FieldType + IOobject ( - IOobject - ( - localName, - obr_.time().timeName(), - obr_, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), - tvalue - ) + localName, + obr_.time().timeName(), + obr_, + IOobject::LAZY_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ), + tvalue ); + + obr_.store(fldPtr); } } diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index 3c08879e90..39234240fa 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -76,7 +76,8 @@ Foam::volVectorField& Foam::functionObjects::forceCoeffs::forceCoeff() time_.timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimless, Zero) @@ -104,7 +105,8 @@ Foam::volVectorField& Foam::functionObjects::forceCoeffs::momentCoeff() time_.timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimless, Zero) diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 2fe3e42352..7b420685da 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -101,7 +101,8 @@ Foam::volVectorField& Foam::functionObjects::forces::force() time_.timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimForce, Zero) @@ -128,7 +129,8 @@ Foam::volVectorField& Foam::functionObjects::forces::moment() time_.timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimForce*dimLength, Zero) diff --git a/src/functionObjects/utilities/solverInfo/solverInfo.C b/src/functionObjects/utilities/solverInfo/solverInfo.C index 51942e72eb..361c8998e6 100644 --- a/src/functionObjects/utilities/solverInfo/solverInfo.C +++ b/src/functionObjects/utilities/solverInfo/solverInfo.C @@ -102,7 +102,8 @@ void Foam::functionObjects::solverInfo::createResidualField mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), Field(mesh_.nCells(), Zero) ); diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/HeatTransferCoeff/HeatTransferCoeff.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/HeatTransferCoeff/HeatTransferCoeff.C index 423b21dc97..63ba5bc3e0 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/HeatTransferCoeff/HeatTransferCoeff.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/HeatTransferCoeff/HeatTransferCoeff.C @@ -64,25 +64,28 @@ void Foam::HeatTransferCoeff::postEvolve const auto& tc = static_cast>>&>(c); - if (!c.template foundObject>("htc")) + auto* htcPtr = c.template getObjectPtr>("htc"); + + if (!htcPtr) { - auto* htcPtr = - new IOField + htcPtr = new IOField + ( + IOobject ( - IOobject - ( - "htc", - c.time().timeName(), - c, - IOobject::NO_READ - ) - ); + "htc", + c.time().timeName(), + c, + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ) + ); htcPtr->store(); } + auto& htc = *htcPtr; - auto& htc = c.template lookupObjectRef>("htc"); - htc.setSize(c.size()); + htc.resize(c.size()); const auto& heatTransfer = tc.heatTransfer(); typename parcelType::trackingData& nctd = diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/KinematicReynoldsNumber/KinematicReynoldsNumber.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/KinematicReynoldsNumber/KinematicReynoldsNumber.C index ac2ca5a27a..9a8e5f0c4e 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/KinematicReynoldsNumber/KinematicReynoldsNumber.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/KinematicReynoldsNumber/KinematicReynoldsNumber.C @@ -61,25 +61,28 @@ void Foam::KinematicReynoldsNumber::postEvolve { auto& c = this->owner(); - if (!c.template foundObject>("Re")) + auto* RePtr = c.template getObjectPtr>("Re"); + + if (!RePtr) { - auto* RePtr = - new IOField + RePtr = new IOField + ( + IOobject ( - IOobject - ( - "Re", - c.time().timeName(), - c, - IOobject::NO_READ - ) - ); + "Re", + c.time().timeName(), + c, + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ) + ); RePtr->store(); } + auto& Re = *RePtr; - auto& Re = c.template lookupObjectRef>("Re"); - Re.setSize(c.size()); + Re.resize(c.size()); label parceli = 0; forAllConstIters(c, parcelIter) diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/NusseltNumber/NusseltNumber.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/NusseltNumber/NusseltNumber.C index ee8a3eba0e..573aaf7081 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/NusseltNumber/NusseltNumber.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/NusseltNumber/NusseltNumber.C @@ -64,25 +64,28 @@ void Foam::NusseltNumber::postEvolve const auto& tc = static_cast>>&>(c); - if (!c.template foundObject>("Nu")) + auto* NuPtr = c.template getObjectPtr>("Nu"); + + if (!NuPtr) { - auto* NuPtr = - new IOField + NuPtr = new IOField + ( + IOobject ( - IOobject - ( - "Nu", - c.time().timeName(), - c, - IOobject::NO_READ - ) - ); + "Nu", + c.time().timeName(), + c, + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ) + ); NuPtr->store(); } + auto& Nu = *NuPtr; - auto& Nu = c.template lookupObjectRef>("Nu"); - Nu.setSize(c.size()); + Nu.resize(c.size()); const auto& heatTransfer = tc.heatTransfer(); typename parcelType::trackingData& nctd = diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleDose/ParticleDose.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleDose/ParticleDose.C index 31f60743dd..89339f87c1 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleDose/ParticleDose.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleDose/ParticleDose.C @@ -64,24 +64,26 @@ void Foam::ParticleDose::postEvolve { auto& c = this->owner(); - if (!c.template foundObject>("D")) + auto* DPtr = c.template getObjectPtr>("D"); + + if (!DPtr) { - auto* DPtr = - new IOField + DPtr = new IOField + ( + IOobject ( - IOobject - ( - "D", - c.time().timeName(), - c, - IOobject::NO_READ - ) - ); + "D", + c.time().timeName(), + c, + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ) + ); DPtr->store(); } - - auto& D = c.template lookupObjectRef>("D"); + auto& D = *DPtr; D.resize(c.size(), Zero); diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ThermoReynoldsNumber/ThermoReynoldsNumber.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ThermoReynoldsNumber/ThermoReynoldsNumber.C index 45457d7706..6f06c372d8 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ThermoReynoldsNumber/ThermoReynoldsNumber.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ThermoReynoldsNumber/ThermoReynoldsNumber.C @@ -62,25 +62,28 @@ void Foam::ThermoReynoldsNumber::postEvolve { auto& c = this->owner(); - if (!c.template foundObject>("Re")) + auto* RePtr = c.template getObjectPtr>("Re"); + + if (!RePtr) { - auto* RePtr = - new IOField + RePtr = new IOField + ( + IOobject ( - IOobject - ( - "Re", - c.time().timeName(), - c, - IOobject::NO_READ - ) - ); + "Re", + c.time().timeName(), + c, + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ) + ); RePtr->store(); } + auto& Re = *RePtr; - auto& Re = c.template lookupObjectRef>("Re"); - Re.setSize(c.size()); + Re.resize(c.size()); typename parcelType::trackingData& nctd = const_cast(td); diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/WeberNumber/WeberNumberReacting.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/WeberNumber/WeberNumberReacting.C index f596c0c330..307db42ec0 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/WeberNumber/WeberNumberReacting.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/WeberNumber/WeberNumberReacting.C @@ -62,25 +62,28 @@ void Foam::WeberNumberReacting::postEvolve { const auto& c = this->owner(); - if (!c.template foundObject>("We")) + auto* WePtr = c.template getObjectPtr>("We"); + + if (!WePtr) { - IOField* WePtr = - new IOField + WePtr = new IOField + ( + IOobject ( - IOobject - ( - "We", - c.time().timeName(), - c, - IOobject::NO_READ - ) - ); + "We", + c.time().timeName(), + c, + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER + ) + ); WePtr->store(); } + auto& We = *WePtr; - auto& We = c.template lookupObjectRef>("We"); - We.setSize(c.size()); + We.resize(c.size()); const auto& thermo = c.db().template lookupObject("SLGThermo"); const auto& liquids = thermo.liquids(); diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index dd5b041590..0cc6121635 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -1158,7 +1158,8 @@ void Foam::triSurfaceMesh::setField(const labelList& values) meshSubDir, // local *this, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), *this, dimless, diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C index b41f93a8e6..5a05dd3332 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C @@ -112,9 +112,11 @@ Foam::word Foam::cellCellStencil::baseName(const word& name) const Foam::labelIOList& Foam::cellCellStencil::zoneID(const fvMesh& mesh) { - if (!mesh.foundObject("zoneID")) + labelIOList* zoneIDPtr = mesh.getObjectPtr("zoneID"); + + if (!zoneIDPtr) { - labelIOList* zoneIDPtr = new labelIOList + zoneIDPtr = new labelIOList ( IOobject ( @@ -123,11 +125,15 @@ const Foam::labelIOList& Foam::cellCellStencil::zoneID(const fvMesh& mesh) polyMesh::meshSubDir, mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh.nCells() ); - labelIOList& zoneID = *zoneIDPtr; + + zoneIDPtr->store(); + + auto& zoneID = *zoneIDPtr; volScalarField volZoneID ( @@ -146,10 +152,9 @@ const Foam::labelIOList& Foam::cellCellStencil::zoneID(const fvMesh& mesh) { zoneID[celli] = label(volZoneID[celli]); } - - zoneIDPtr->store(); } - return mesh.lookupObject("zoneID"); + + return *zoneIDPtr; } diff --git a/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C b/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C index aad394213e..305c579bf8 100644 --- a/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C +++ b/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C @@ -101,7 +101,8 @@ bool Foam::functionObjects::filmFlux::execute() time_.timeName(), filmMesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), filmMesh, dimensionedScalar(dimMass/dimTime, Zero) diff --git a/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index ab879eda9b..d59610e575 100644 --- a/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -108,7 +108,8 @@ Foam::humidityTemperatureCoupledMixedFvPatchScalarField::thicknessField mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimless, Zero) diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index 0c19e0b837..d994878872 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -256,7 +256,8 @@ Foam::volScalarField& Foam::basicThermo::lookupOrConstruct mesh.time().timeName(), mesh, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh ); diff --git a/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C b/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C index f1275de1bc..26a4a27fd6 100644 --- a/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C +++ b/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C @@ -121,9 +121,10 @@ Foam::speciesSorptionFvPatchScalarField::field ( fieldName, mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dim, Zero) diff --git a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C index fc9e8746a3..27b94e3db3 100644 --- a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C +++ b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.C @@ -156,10 +156,10 @@ Foam::isoAdvection::isoAdvection if (porosityEnabled_) { - if (mesh_.foundObject("porosity")) - { - porosityPtr_ = mesh_.getObjectPtr("porosity"); + porosityPtr_ = mesh_.getObjectPtr("porosity"); + if (porosityPtr_) + { if ( gMin(porosityPtr_->primitiveField()) <= 0 diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling index 63b567b833..5aa11fe99a 100644 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling @@ -25,8 +25,7 @@ cellZoneID // but is fairly low overhead anyhow volScalarField* getZoneField(const fvMesh& mesh) { - volScalarField* volZonePtr = - mesh.getObjectPtr(fieldName); + auto* volZonePtr = mesh.getObjectPtr(fieldName); const cellZoneMesh& zones = mesh.cellZones(); @@ -34,16 +33,22 @@ cellZoneID { if (!volZonePtr) { - volZonePtr = ®IOobject::store + volZonePtr = new volScalarField ( - volScalarField::New + IOobject ( fieldName, - mesh, - dimless, - fvPatchScalarField::zeroGradientType() - ) + mesh.time().timeName(), + mesh.thisDb(), + IOobject::NO_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER + ), + mesh, + dimless, + fvPatchFieldBase::zeroGradientType() ); + regIOobject::store(volZonePtr); Info<< "Creating " << fieldName << " field for postProcessing" << nl; diff --git a/tutorials/incompressible/pimpleFoam/LES/planeChannel/setups.orig/common/system/controlDict b/tutorials/incompressible/pimpleFoam/LES/planeChannel/setups.orig/common/system/controlDict index 504020affd..929b6b6e83 100644 --- a/tutorials/incompressible/pimpleFoam/LES/planeChannel/setups.orig/common/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/LES/planeChannel/setups.orig/common/system/controlDict @@ -89,7 +89,8 @@ functions mesh().time().timeName(), mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh(), dimless diff --git a/tutorials/verificationAndValidation/schemes/nonOrthogonalChannel/setups.orig/common/system/controlDict b/tutorials/verificationAndValidation/schemes/nonOrthogonalChannel/setups.orig/common/system/controlDict index 46abec5c2c..98f9267e3a 100644 --- a/tutorials/verificationAndValidation/schemes/nonOrthogonalChannel/setups.orig/common/system/controlDict +++ b/tutorials/verificationAndValidation/schemes/nonOrthogonalChannel/setups.orig/common/system/controlDict @@ -114,7 +114,8 @@ functions mesh().time().timeName(), mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh(), sqr(dimLength)/pow3(dimTime) diff --git a/tutorials/verificationAndValidation/turbulenceModels/planeChannel/setups.orig/common/system/controlDict b/tutorials/verificationAndValidation/turbulenceModels/planeChannel/setups.orig/common/system/controlDict index 922e76edd1..3411cc17b7 100644 --- a/tutorials/verificationAndValidation/turbulenceModels/planeChannel/setups.orig/common/system/controlDict +++ b/tutorials/verificationAndValidation/turbulenceModels/planeChannel/setups.orig/common/system/controlDict @@ -114,7 +114,8 @@ functions mesh().time().timeName(), mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh(), sqr(dimLength)/pow3(dimTime)