From ac574a6ccb46bf9a0bfdc77c58e0fb670d793b6b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 4 Jan 2024 12:03:21 +0100 Subject: [PATCH 01/13] STYLE: use static call for regIOobject::store (#1507) --- .../solvers/combustion/fireFoam/phrghEqn.H | 3 +- .../createROMfields/readFields.H | 4 +- .../setExprBoundaryFields/readFields.H | 4 +- .../preProcessing/setExprFields/readFields.H | 4 +- .../regionFunctionObjectTemplates.C | 13 +++-- .../GAMGAgglomeration/GAMGAgglomeration.C | 8 +-- .../schemes/DEShybrid/DEShybrid.H | 6 +-- .../atmPlantCanopyTurbSource.C | 6 +-- .../atmPlantCanopyUSource.C | 6 +-- .../jouleHeatingSourceTemplates.C | 54 +++++++++---------- .../cfdTools/general/fvOptions/fvOptions.C | 4 +- .../LimitedScheme/LimitedScheme.C | 6 +-- .../volPointInterpolate.C | 4 +- .../field/CourantNo/CourantNo.C | 6 +-- .../columnAverage/columnAverageTemplates.C | 6 +-- .../field/expressions/fvExpressionField.C | 4 +- .../heatTransferCoeff/heatTransferCoeff.C | 7 +-- .../multiphaseInterHtcModel.C | 7 +-- .../reactingEulerHtcModel.C | 6 +-- .../histogramModel/histogramModel.C | 6 +-- src/functionObjects/field/momentum/momentum.C | 6 +-- .../field/momentumError/momentumError.C | 31 +++++------ .../field/readFields/readFieldsTemplates.C | 4 +- .../resolutionIndexModel.C | 6 +-- .../resolutionIndexModelTemplates.C | 6 +-- .../stabilityBlendingFactor.C | 18 +++---- .../field/surfaceDistance/surfaceDistance.C | 6 +-- .../field/wallHeatFlux/wallHeatFlux.C | 6 +-- .../field/wallShearStress/wallShearStress.C | 6 +-- src/functionObjects/field/yPlus/yPlus.C | 6 +-- .../forces/forceCoeffs/forceCoeffs.C | 28 +++++----- src/functionObjects/forces/forces/forces.C | 26 ++++----- .../hydrostaticPressure/hydrostaticPressure.C | 4 +- .../electricPotential/electricPotential.C | 13 ++--- .../mapFieldConstraint/MapFieldConstraint.C | 6 +-- .../jouleHeatingSource/jouleHeatingSource.C | 4 +- .../jouleHeatingSourceTemplates.C | 50 +++++++++-------- .../ParticleForces/Coulomb/CoulombForce.C | 9 ++-- ...edPointDisplacementPointPatchVectorField.C | 4 +- .../mappedPatchBaseTemplates.C | 6 +-- .../processorColour.C | 18 +++---- .../functionObjects/filmFlux/filmFlux.C | 10 ++-- ...eratureRadCoupledMixedFvPatchScalarField.C | 9 ++-- .../BilgerMixtureFraction.C | 6 +-- 44 files changed, 227 insertions(+), 225 deletions(-) diff --git a/applications/solvers/combustion/fireFoam/phrghEqn.H b/applications/solvers/combustion/fireFoam/phrghEqn.H index 482355f12a..022006494f 100644 --- a/applications/solvers/combustion/fireFoam/phrghEqn.H +++ b/applications/solvers/combustion/fireFoam/phrghEqn.H @@ -10,7 +10,8 @@ if (pimple.dict().getOrDefault("hydrostaticInitialization", false)) "0", mesh, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh ) diff --git a/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H b/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H index a1d345d1c8..084d0c16bd 100644 --- a/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H +++ b/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ class readFieldsHandler Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H b/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H index 07e0bb443e..e72ac18820 100644 --- a/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H +++ b/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ class readFieldsHandler Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/applications/utilities/preProcessing/setExprFields/readFields.H b/applications/utilities/preProcessing/setExprFields/readFields.H index 8ab2063ed9..b150c97d97 100644 --- a/applications/utilities/preProcessing/setExprFields/readFields.H +++ b/applications/utilities/preProcessing/setExprFields/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ class readFieldsHandler Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C index c1c0f740b6..0c295eca2b 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -139,7 +139,7 @@ bool Foam::functionObjects::regionFunctionObject::store } else { - obr().objectRegistry::store(tfield.ptr()); + regIOobject::store(tfield.ptr()); } } else @@ -153,7 +153,7 @@ bool Foam::functionObjects::regionFunctionObject::store fieldName = tfield().name(); } - obr().objectRegistry::store(tfield.ptr()); + regIOobject::store(tfield.ptr()); } return true; @@ -179,8 +179,11 @@ bool Foam::functionObjects::regionFunctionObject::storeInDb } else { - tfield.ref().rename(fieldName); - obr.objectRegistry::store(tfield.ptr()); + if (fieldName.size() && fieldName != tfield().name()) + { + tfield.ref().rename(fieldName); + } + regIOobject::store(tfield.ptr()); } return true; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C index b6b6291552..1ced04106f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2023 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -348,7 +348,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New { agglomPtr().printLevels(); } - return store(agglomPtr.ptr()); + return regIOobject::store(agglomPtr); } } @@ -398,7 +398,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New { agglomPtr().printLevels(); } - return store(agglomPtr.ptr()); + return regIOobject::store(agglomPtr); } } } @@ -463,7 +463,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New { agglomPtr().printLevels(); } - return store(agglomPtr.ptr()); + return regIOobject::store(agglomPtr); } } diff --git a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H index 62618f3260..7d9720679c 100644 --- a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H +++ b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. Copyright (C) 2022 Upstream CFD GmbH ------------------------------------------------------------------------------- License @@ -301,7 +301,7 @@ class DEShybrid ( factorName, mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -321,7 +321,7 @@ class DEShybrid dimensionedScalar(dimless, Zero) ); - const_cast(mesh).objectRegistry::store(factorPtr); + regIOobject::store(factorPtr); } auto& factor = *factorPtr; diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C index ed01512dbd..b5b72cc4f3 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,14 +58,14 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyTurbSource::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C index 89beb35193..683d112c95 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,14 +59,14 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyUSource::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C index a59bdc65ac..43763b7238 100644 --- a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2023 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,50 +40,48 @@ void Foam::fa::jouleHeatingSource::initialiseSigma auto& obr = regionMesh().thisDb(); + IOobject io + ( + typeName + ":sigma_" + regionName_, + obr.time().timeName(), + obr, + IOobject::NO_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER + ); + + tmp tsigma; + if (dict.found("sigma")) { // Sigma to be defined using a Function1 type sigmaVsTPtr = Function1::New("sigma", dict, &mesh_); - auto tsigma = tmp::New + tsigma.reset ( - IOobject + new AreaFieldType ( - typeName + ":sigma_" + regionName_, - obr.time().timeName(), - obr, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - regionMesh(), - dimensioned(sqr(dimCurrent)/dimPower/dimLength, Zero) + io, + regionMesh(), + Foam::zero{}, // value + sqr(dimCurrent)/dimPower/dimLength + ) ); - regIOobject::store(tsigma.ptr()); - Info<< " Conductivity 'sigma' read from dictionary as f(T)" << nl << endl; } else { // Sigma to be defined by user input - auto tsigma = tmp::New - ( - IOobject - ( - typeName + ":sigma_" + regionName_, - obr.time().timeName(), - obr, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - regionMesh() - ); + io.readOpt(IOobject::MUST_READ); - regIOobject::store(tsigma.ptr()); + tsigma.reset(new AreaFieldType(io, regionMesh())); Info<< " Conductivity 'sigma' read from file" << nl << endl; } + + regIOobject::store(tsigma); } @@ -117,11 +115,11 @@ Foam::fa::jouleHeatingSource::updateSigma // Boundary field - typename AreaFieldType::Boundary& bf = sigma.boundaryFieldRef(); + auto& bf = sigma.boundaryFieldRef(); forAll(bf, patchi) { faPatchField& pf = bf[patchi]; - if (!isA(bf[patchi])) + if (!isA(pf)) { const scalarField& Tbf = T.boundaryField()[patchi]; forAll(pf, facei) diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C index a341b20543..7b37201c35 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -102,7 +102,7 @@ Foam::fv::options::options Foam::fv::options& Foam::fv::options::New(const fvMesh& mesh) { - options* ptr = mesh.thisDb().getObjectPtr(typeName); + auto* ptr = mesh.thisDb().getObjectPtr(typeName); if (!ptr) { diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C index aed48475eb..e72725405b 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -161,7 +161,7 @@ Foam::LimitedScheme::limiter ( limiterFieldName, mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -170,7 +170,7 @@ Foam::LimitedScheme::limiter dimless ); - mesh.objectRegistry::store(fldptr); + regIOobject::store(fldptr); } auto& limiterField = *fldptr; diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index ed1476717c..798c3bf152 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -570,8 +570,8 @@ Foam::volPointInterpolation::interpolate if (!pfPtr) { solution::cachePrintMessage("Calculating and caching", name, vf); - pfPtr = interpolate(vf, name, false).ptr(); + pfPtr = interpolate(vf, name, false).ptr(); regIOobject::store(pfPtr); } else diff --git a/src/functionObjects/field/CourantNo/CourantNo.C b/src/functionObjects/field/CourantNo/CourantNo.C index 98aeb51a9c..198fbfaa24 100644 --- a/src/functionObjects/field/CourantNo/CourantNo.C +++ b/src/functionObjects/field/CourantNo/CourantNo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,7 +88,7 @@ bool Foam::functionObjects::CourantNo::calc() ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -97,7 +97,7 @@ bool Foam::functionObjects::CourantNo::calc() dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - mesh_.objectRegistry::store(resultPtr); + regIOobject::store(resultPtr); } auto& Co = *resultPtr; diff --git a/src/functionObjects/field/columnAverage/columnAverageTemplates.C b/src/functionObjects/field/columnAverage/columnAverageTemplates.C index 6a6b537500..2bba02a3dc 100644 --- a/src/functionObjects/field/columnAverage/columnAverageTemplates.C +++ b/src/functionObjects/field/columnAverage/columnAverageTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,14 +57,14 @@ bool Foam::functionObjects::columnAverage::columnAverageField ( resultName, fld.mesh().time().timeName(), - fld.mesh(), + fld.db(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER ), fld ); - obr_.objectRegistry::store(resPtr); + regIOobject::store(resPtr); } fieldType& res = *resPtr; diff --git a/src/functionObjects/field/expressions/fvExpressionField.C b/src/functionObjects/field/expressions/fvExpressionField.C index 7b3444f6f8..3ab2ae93d4 100644 --- a/src/functionObjects/field/expressions/fvExpressionField.C +++ b/src/functionObjects/field/expressions/fvExpressionField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -137,7 +137,7 @@ bool Foam::functionObjects::fvExpressionField::loadAndStore(const IOobject& io) Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C index 5c33fcdc62..9c0925c306 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,6 +71,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff { read(dict); + // scopedName? setResultName(typeName, "htc:" + htcModelPtr_->type()); auto* heatTransferCoeffPtr = @@ -80,7 +81,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -89,7 +90,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) ); - mesh_.objectRegistry::store(heatTransferCoeffPtr); + regIOobject::store(heatTransferCoeffPtr); } diff --git a/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C b/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C index 206827e72a..c1b17947c3 100644 --- a/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C +++ b/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022-2023 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -127,6 +127,7 @@ Foam::functionObjects::multiphaseInterHtcModel::multiphaseInterHtcModel { read(dict); + // scopedName? setResultName(typeName, "htc:" + htcModelPtr_->type()); auto* htcPtr = @@ -136,7 +137,7 @@ Foam::functionObjects::multiphaseInterHtcModel::multiphaseInterHtcModel ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -145,7 +146,7 @@ Foam::functionObjects::multiphaseInterHtcModel::multiphaseInterHtcModel dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) ); - mesh_.objectRegistry::store(htcPtr); + regIOobject::store(htcPtr); } diff --git a/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C b/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C index fa8108e9b3..f9d403f776 100644 --- a/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C +++ b/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -145,7 +145,7 @@ Foam::functionObjects::reactingEulerHtcModel::reactingEulerHtcModel ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -154,7 +154,7 @@ Foam::functionObjects::reactingEulerHtcModel::reactingEulerHtcModel dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) ); - mesh_.objectRegistry::store(htcPtr); + regIOobject::store(htcPtr); } diff --git a/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C b/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C index 790f5c2348..95feae0b32 100644 --- a/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C +++ b/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,14 +66,14 @@ Foam::volScalarField& Foam::histogramModel::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/functionObjects/field/momentum/momentum.C b/src/functionObjects/field/momentum/momentum.C index 04a3f131ae..ed24a5837b 100644 --- a/src/functionObjects/field/momentum/momentum.C +++ b/src/functionObjects/field/momentum/momentum.C @@ -446,14 +446,14 @@ bool Foam::functionObjects::momentum::read(const dictionary& dict) { Info<< " Momentum fields will be written" << endl; - mesh_.objectRegistry::store + regIOobject::store ( newField("momentum", dimVelocity*dimMass) ); if (hasCsys_) { - mesh_.objectRegistry::store + regIOobject::store ( newField("angularMomentum", dimVelocity*dimMass) ); @@ -466,7 +466,7 @@ bool Foam::functionObjects::momentum::read(const dictionary& dict) { Info<< " Angular velocity will be written" << endl; - mesh_.objectRegistry::store + regIOobject::store ( newField("angularVelocity", dimVelocity) ); diff --git a/src/functionObjects/field/momentumError/momentumError.C b/src/functionObjects/field/momentumError/momentumError.C index 6bbc1068fc..fa467510e3 100644 --- a/src/functionObjects/field/momentumError/momentumError.C +++ b/src/functionObjects/field/momentumError/momentumError.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -154,53 +154,54 @@ Foam::functionObjects::momentumError::momentumError phi.dimensions()*dimVelocity/dimVolume ); - - volVectorField* momentPtr = nullptr; - - word momName(scopedName("momentError")); - if (zoneSubSetPtr_) { const fvMesh& subMesh = zoneSubSetPtr_->subsetter().subMesh(); // momentErrorMap - momentPtr = new volVectorField + volVectorField* fldPtr = new volVectorField ( IOobject ( scopedName("momentErrorMap"), subMesh.time().timeName(), - subMesh, + subMesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER ), subMesh, - dimensionedVector(momDims) + dimensionedVector(momDims, Zero) ); - subMesh.objectRegistry::store(momentPtr); + regIOobject::store(fldPtr); - momName = scopedName("momentErrorZone"); } - momentPtr = new volVectorField + const word momName = + ( + zoneSubSetPtr_ + ? scopedName("momentErrorZone") + : scopedName("momentError") + ); + + volVectorField* fldPtr = new volVectorField ( IOobject ( momName, time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER ), mesh_, - dimensionedVector(momDims) + dimensionedVector(momDims, Zero) ); - mesh_.objectRegistry::store(momentPtr); + regIOobject::store(fldPtr); } diff --git a/src/functionObjects/field/readFields/readFieldsTemplates.C b/src/functionObjects/field/readFields/readFieldsTemplates.C index 2ce668755f..5cf6018bdd 100644 --- a/src/functionObjects/field/readFields/readFieldsTemplates.C +++ b/src/functionObjects/field/readFields/readFieldsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,7 @@ bool Foam::functionObjects::readFields::loadAndStore(const IOobject& io) Log << " Reading " << io.name() << " (" << io.headerClassName() << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C index fb86bca1ef..ca01a013fa 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -98,7 +98,7 @@ bool Foam::resolutionIndexModel::read(const dictionary& dict) ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::LAZY_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -108,7 +108,7 @@ bool Foam::resolutionIndexModel::read(const dictionary& dict) fvPatchFieldBase::zeroGradientType() ); - mesh_.objectRegistry::store(indexPtr); + regIOobject::store(indexPtr); } return true; diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C index cdbe29b3d6..641e9ce1ef 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,14 +46,14 @@ GeoFieldType& Foam::resolutionIndexModel::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index ef07ad51de..134427f7ba 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,7 +65,7 @@ Foam::functionObjects::stabilityBlendingFactor::indicator() ( "blendedIndicator" + fieldName_, time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -75,7 +75,7 @@ Foam::functionObjects::stabilityBlendingFactor::indicator() fvPatchFieldBase::zeroGradientType() ); - mesh_.objectRegistry::store(fldPtr); + regIOobject::store(fldPtr); } return *fldPtr; @@ -558,7 +558,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ( nonOrthogonalityName_, mesh_.time().constant(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -567,7 +567,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor if (fieldHeader.typeHeaderOk(true, true, false)) { auto* vfPtr = new volScalarField(fieldHeader, mesh_); - mesh_.objectRegistry::store(vfPtr); + regIOobject::store(vfPtr); } else { @@ -588,7 +588,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ( faceWeightName_, mesh_.time().constant(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -597,7 +597,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor if (fieldHeader.typeHeaderOk(true, true, false)) { auto* vfPtr = new volScalarField(fieldHeader, mesh_); - mesh_.objectRegistry::store(vfPtr); + regIOobject::store(vfPtr); } else { @@ -616,7 +616,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ( skewnessName_, mesh_.time().constant(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -625,7 +625,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor if (fieldHeader.typeHeaderOk(true, true, false)) { auto* vfPtr = new volScalarField(fieldHeader, mesh_); - mesh_.objectRegistry::store(vfPtr); + regIOobject::store(vfPtr); } else { diff --git a/src/functionObjects/field/surfaceDistance/surfaceDistance.C b/src/functionObjects/field/surfaceDistance/surfaceDistance.C index f7ad43ebc2..d3362a971d 100644 --- a/src/functionObjects/field/surfaceDistance/surfaceDistance.C +++ b/src/functionObjects/field/surfaceDistance/surfaceDistance.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,7 +61,7 @@ Foam::functionObjects::surfaceDistance::surfaceDistance ( "surfaceDistance", mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -71,7 +71,7 @@ Foam::functionObjects::surfaceDistance::surfaceDistance ) ); - mesh_.objectRegistry::store(distPtr); + regIOobject::store(distPtr); } diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C index a97ed64ed0..3235b4cbc5 100644 --- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C +++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -120,7 +120,7 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux ( scopedName(typeName), mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobjectOption::NO_READ, IOobjectOption::NO_WRITE, IOobjectOption::REGISTER @@ -130,7 +130,7 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux ) ); - mesh_.objectRegistry::store(wallHeatFluxPtr); + regIOobject::store(wallHeatFluxPtr); } diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C index 83ce52c202..6fd8853dcc 100644 --- a/src/functionObjects/field/wallShearStress/wallShearStress.C +++ b/src/functionObjects/field/wallShearStress/wallShearStress.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,7 +104,7 @@ Foam::functionObjects::wallShearStress::wallShearStress ( scopedName(typeName), mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobjectOption::NO_READ, IOobjectOption::NO_WRITE, IOobjectOption::REGISTER @@ -114,7 +114,7 @@ Foam::functionObjects::wallShearStress::wallShearStress ) ); - mesh_.objectRegistry::store(wallShearStressPtr); + regIOobject::store(wallShearStressPtr); } diff --git a/src/functionObjects/field/yPlus/yPlus.C b/src/functionObjects/field/yPlus/yPlus.C index b175a154bf..f9b5f3a3b5 100644 --- a/src/functionObjects/field/yPlus/yPlus.C +++ b/src/functionObjects/field/yPlus/yPlus.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,7 +86,7 @@ Foam::functionObjects::yPlus::yPlus ( scopedName(typeName), mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -96,7 +96,7 @@ Foam::functionObjects::yPlus::yPlus ) ); - mesh_.objectRegistry::store(yPlusPtr); + regIOobject::store(yPlusPtr); } diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index b749dcf81b..bbad31544f 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,18 +63,17 @@ void Foam::functionObjects::forceCoeffs::initialise() Foam::volVectorField& Foam::functionObjects::forceCoeffs::forceCoeff() { - auto* coeffPtr = - mesh_.getObjectPtr(scopedName("forceCoeff")); + auto* ptr = mesh_.getObjectPtr(scopedName("forceCoeff")); - if (!coeffPtr) + if (!ptr) { - coeffPtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("forceCoeff"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -83,27 +82,26 @@ Foam::volVectorField& Foam::functionObjects::forceCoeffs::forceCoeff() dimensionedVector(dimless, Zero) ); - mesh_.objectRegistry::store(coeffPtr); + regIOobject::store(ptr); } - return *coeffPtr; + return *ptr; } Foam::volVectorField& Foam::functionObjects::forceCoeffs::momentCoeff() { - auto* coeffPtr = - mesh_.getObjectPtr(scopedName("momentCoeff")); + auto* ptr = mesh_.getObjectPtr(scopedName("momentCoeff")); - if (!coeffPtr) + if (!ptr) { - coeffPtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("momentCoeff"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -112,10 +110,10 @@ Foam::volVectorField& Foam::functionObjects::forceCoeffs::momentCoeff() dimensionedVector(dimless, Zero) ); - mesh_.objectRegistry::store(coeffPtr); + regIOobject::store(ptr); } - return *coeffPtr; + return *ptr; } diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index b5caaf7b3c..ac66678394 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,17 +89,17 @@ void Foam::functionObjects::forces::setCoordinateSystem Foam::volVectorField& Foam::functionObjects::forces::force() { - auto* forcePtr = mesh_.getObjectPtr(scopedName("force")); + auto* ptr = mesh_.getObjectPtr(scopedName("force")); - if (!forcePtr) + if (!ptr) { - forcePtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("force"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -108,26 +108,26 @@ Foam::volVectorField& Foam::functionObjects::forces::force() dimensionedVector(dimForce, Zero) ); - mesh_.objectRegistry::store(forcePtr); + regIOobject::store(ptr); } - return *forcePtr; + return *ptr; } Foam::volVectorField& Foam::functionObjects::forces::moment() { - auto* momentPtr = mesh_.getObjectPtr(scopedName("moment")); + auto* ptr = mesh_.getObjectPtr(scopedName("moment")); - if (!momentPtr) + if (!ptr) { - momentPtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("moment"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -136,10 +136,10 @@ Foam::volVectorField& Foam::functionObjects::forces::moment() dimensionedVector(dimForce*dimLength, Zero) ); - mesh_.objectRegistry::store(momentPtr); + regIOobject::store(ptr); } - return *momentPtr; + return *ptr; } diff --git a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C index 9bc7e256f0..75c6f8509f 100644 --- a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C +++ b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -197,7 +197,7 @@ Foam::functionObjects::hydrostaticPressure::hydrostaticPressure mesh_ ); - mesh_.objectRegistry::store(ph_rghPtr); + regIOobject::store(ph_rghPtr); bool reInitialise = dict.getOrDefault("reInitialise", false); diff --git a/src/functionObjects/solvers/electricPotential/electricPotential.C b/src/functionObjects/solvers/electricPotential/electricPotential.C index 6a83baee67..4b5dd5d855 100644 --- a/src/functionObjects/solvers/electricPotential/electricPotential.C +++ b/src/functionObjects/solvers/electricPotential/electricPotential.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2023 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,14 +59,14 @@ Foam::volScalarField& Foam::functionObjects::electricPotential::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; @@ -241,13 +241,14 @@ Foam::functionObjects::electricPotential::electricPotential ( Ename_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), -fvc::grad(eV) ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } } } diff --git a/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C b/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C index 1d18b8960b..5425dadb0a 100644 --- a/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C +++ b/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -157,14 +157,14 @@ VolFieldType& Foam::fv::MapFieldConstraint::getOrReadField ( fieldName, thisMesh.time().timeName(), - thisMesh, + thisMesh.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER ), thisMesh ); - thisMesh.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index f6f41c11a0..0fc3317c27 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,7 +61,7 @@ Foam::fv::jouleHeatingSource::transformSigma ( sigmaName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C index 95cb6a05b9..4eb7391caf 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,50 +36,48 @@ void Foam::fv::jouleHeatingSource::initialiseSigma { typedef GeometricField VolFieldType; + IOobject io + ( + typeName + ":sigma", + mesh_.time().timeName(), + mesh_.thisDb(), + IOobject::NO_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER + ); + + tmp tsigma; + if (dict.found("sigma")) { // Sigma to be defined using a Function1 type sigmaVsTPtr = Function1::New("sigma", dict, &mesh_); - auto tsigma = tmp::New + tsigma.reset ( - IOobject + new VolFieldType ( - typeName + ":sigma", - mesh_.time().timeName(), + io, mesh_, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh_, - dimensioned(sqr(dimCurrent)/dimPower/dimLength, Zero) + Foam::zero{}, // value + sqr(dimCurrent)/dimPower/dimLength + ) ); - mesh_.objectRegistry::store(tsigma.ptr()); - Info<< " Conductivity 'sigma' read from dictionary as f(T)" << nl << endl; } else { // Sigma to be defined by user input - auto tsigma = tmp::New - ( - IOobject - ( - typeName + ":sigma", - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ); + io.readOpt(IOobject::MUST_READ); - mesh_.objectRegistry::store(tsigma.ptr()); + tsigma.reset(new VolFieldType(io, mesh_)); Info<< " Conductivity 'sigma' read from file" << nl << endl; } + + regIOobject::store(tsigma); } @@ -110,7 +108,7 @@ Foam::fv::jouleHeatingSource::updateSigma // Boundary field - typename VolFieldType::Boundary& bf = sigma.boundaryFieldRef(); + auto& bf = sigma.boundaryFieldRef(); forAll(bf, patchi) { fvPatchField& pf = bf[patchi]; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C index 36e4b0da60..97a9c55fc6 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,13 +46,14 @@ Foam::volVectorField& Foam::CoulombForce::getOrReadField ( fieldName, this->mesh().time().timeName(), - this->mesh(), + this->mesh().thisDb(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh() ); - this->mesh().objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C b/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C index 6a6814fc6f..b10fe98d72 100644 --- a/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C +++ b/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -191,7 +191,7 @@ Foam::lumpedPointDisplacementPointPatchVectorField::movement() const // Create and register with this patch as the owner ptr = lumpedPointIOMovement::New(obr, this->patch().index()).ptr(); - objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C index 924afa2b5a..7b6ce7e3ca 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -300,7 +300,7 @@ bool Foam::mappedPatchBase::constructIOField ), Foam::zero{} ); - objectRegistry::store(fldPtr); + regIOobject::store(fldPtr); } fldPtr->transfer @@ -340,7 +340,7 @@ void Foam::mappedPatchBase::storeField ), Foam::zero{} ); - objectRegistry::store(fldPtr); + regIOobject::store(fldPtr); } *fldPtr = values; diff --git a/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C b/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C index 92298e2091..b655785b1d 100644 --- a/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C +++ b/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C @@ -340,23 +340,21 @@ Foam::processorColour::processorColour(const lduMesh& mesh) const Foam::processorColour& Foam::processorColour::New(const lduMesh& mesh) { - const processorColour* ptr = - mesh.thisDb().objectRegistry::template cfindObject + auto* ptr = + mesh.thisDb().objectRegistry::template getObjectPtr ( processorColour::typeName ); - if (ptr) + if (!ptr) { - return *ptr; + ptr = new processorColour(mesh); + + //regIOobject::store(static_cast*>(ptr)); + regIOobject::store(ptr); } - processorColour* objectPtr = new processorColour(mesh); - - //regIOobject::store(static_cast*>(objectPtr)); - regIOobject::store(objectPtr); - - return *objectPtr; + return *ptr; } diff --git a/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C b/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C index 305c579bf8..a69a586167 100644 --- a/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C +++ b/src/regionModels/surfaceFilmModels/functionObjects/filmFlux/filmFlux.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,7 +99,7 @@ bool Foam::functionObjects::filmFlux::execute() ( resultName_, time_.timeName(), - filmMesh, + filmMesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -108,7 +108,7 @@ bool Foam::functionObjects::filmFlux::execute() dimensionedScalar(dimMass/dimTime, Zero) ); - filmMesh.objectRegistry::store(resultPtr); + regIOobject::store(resultPtr); } auto& result = *resultPtr; @@ -123,7 +123,7 @@ bool Foam::functionObjects::filmFlux::execute() ( "height", time_.timeName(), - filmMesh, + filmMesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER @@ -133,7 +133,7 @@ bool Foam::functionObjects::filmFlux::execute() fvPatchFieldBase::zeroGradientType() ); - auto& heightc = height.ref(); + auto& heightc = height.internalFieldRef(); heightc = max(dimensionedScalar("eps", dimLength, ROOTVSMALL), vol/magSf()); height.correctBoundaryConditions(); diff --git a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index 2c10c551c8..0471bdd398 100644 --- a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,14 +62,15 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField::getOrCreateField ( fieldName, mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimless, Zero) ); - mesh.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C b/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C index 3deae52445..038a33451f 100644 --- a/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C +++ b/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 Thorsten Zirwes - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,7 +68,7 @@ void Foam::functionObjects::BilgerMixtureFraction::calcBilgerMixtureFraction() ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -76,7 +76,7 @@ void Foam::functionObjects::BilgerMixtureFraction::calcBilgerMixtureFraction() mesh_, dimensionedScalar(dimless, Zero) ); - mesh_.objectRegistry::store(resultPtr); + regIOobject::store(resultPtr); } auto& f_Bilger = *resultPtr; From 21196d8c0bbe56f53e21fa03af80dc9d451f7e14 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 09:03:59 +0100 Subject: [PATCH 02/13] ENH: use tmp field factory methods [1] (#2723) - src/OpenFOAM, src/meshTools, src/mesh, src/dynamicMesh, src/sampling src/topoChanger src/overset src/fvMotionSolver --- .../GeometricField/uniformInterpolate.C | 3 +- .../LduMatrix/LduMatrix/LduMatrixOperations.C | 9 +--- .../lduMatrix/lduMatrix/lduMatrixTemplates.C | 2 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 2 +- .../polyPatches/polyPatch/polyPatch.C | 8 ++-- .../interfaceTrackingFvMesh.C | 41 +++++----------- .../layerAdditionRemoval/addCellLayer.C | 4 +- .../displacementInterpolationMotionSolver.C | 4 +- .../displacementLayeredMotionMotionSolver.C | 25 ++++------ .../pairPatchAgglomeration.C | 4 +- ...lacementComponentLaplacianFvMotionSolver.C | 4 +- ...velocityComponentLaplacianFvMotionSolver.C | 2 +- .../surfaceAlignedSBRStressFvMotionSolver.C | 47 ++++++------------- .../snappyHexMeshDriver/snappyLayerDriver.C | 4 +- .../snappyHexMeshDriver/snappySnapDriver.C | 22 ++++----- src/meshTools/cellQuality/cellQuality.C | 43 ++++------------- .../edgeMeshTools/edgeMeshFeatureProximity.C | 4 +- .../momentOfInertia/momentOfInertia.C | 5 +- .../triSurfaceTools/triSurfaceCloseness.C | 4 +- .../cellCellStencilTemplates.C | 15 ++---- .../oversetPolyPatch/oversetFvPatchField.C | 5 +- .../oversetPolyPatch/oversetFvPatchField.H | 20 ++------ .../rigidBodyMotion/rigidBodyMotion.C | 12 ++--- .../rigidBodyMeshMotion/rigidBodyMeshMotion.C | 4 +- src/sampling/meshToMesh/meshToMeshTemplates.C | 42 ++++++----------- .../sampledCuttingPlane/sampledCuttingPlane.C | 27 +++-------- .../sixDoFRigidBodyMotion.C | 4 +- .../sixDoFRigidBodyMotionSolver.C | 4 +- .../linearValveLayersFvMesh.C | 8 +--- .../movingConeTopoFvMesh.C | 4 +- 30 files changed, 128 insertions(+), 254 deletions(-) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C index 6476a59d35..559f7fe26f 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C @@ -46,7 +46,8 @@ Foam::tmp Foam::uniformInterpolate field0.time().timeName(), field0.db(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), weights[0]*(*fields[indices[0]]) ); diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C index 7fa0cd403c..7945a8cd2d 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C @@ -90,16 +90,11 @@ template Foam::tmp> Foam::LduMatrix::H(const Field& psi) const { - tmp> tHpsi - ( - new Field(lduAddr().size(), Zero) - ); + auto tHpsi = tmp>::New(lduAddr().size(), Foam::zero{}); if (lowerPtr_ || upperPtr_) { - Field & Hpsi = tHpsi(); - - Type* __restrict__ HpsiPtr = Hpsi.begin(); + Type* __restrict__ HpsiPtr = tHpsi.ref().begin(); const Type* __restrict__ psiPtr = psi.begin(); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C index cafd283abb..ed7eb4d260 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C @@ -35,7 +35,7 @@ Description template Foam::tmp> Foam::lduMatrix::H(const Field& psi) const { - auto tHpsi = tmp>::New(lduAddr().size(), Zero); + auto tHpsi = tmp>::New(lduAddr().size(), Foam::zero{}); if (lowerPtr_ || upperPtr_) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 00480e7669..5aba0e0d2f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1195,7 +1195,7 @@ void Foam::polyMesh::movePoints(const pointField& newPoints) { if (debug) { - Info<< "tmp polyMesh::movePoints(const pointField&) : " + Info<< "void polyMesh::movePoints(const pointField&) : " << " Storing current points for time " << time().value() << " index " << time().timeIndex() << endl; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index 1a5e79754c..3f2530d6da 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -333,8 +333,8 @@ const Foam::vectorField::subField Foam::polyPatch::faceAreas() const Foam::tmp Foam::polyPatch::faceCellCentres() const { - tmp tcc(new vectorField(size())); - vectorField& cc = tcc.ref(); + auto tcc = tmp::New(size()); + auto& cc = tcc.ref(); // get reference to global cell centres const vectorField& gcc = boundaryMesh_.mesh().cellCentres(); @@ -352,8 +352,8 @@ Foam::tmp Foam::polyPatch::faceCellCentres() const Foam::tmp Foam::polyPatch::areaFraction() const { - tmp tfraction(new scalarField(size())); - scalarField& fraction = tfraction.ref(); + auto tfraction = tmp::New(size()); + auto& fraction = tfraction.ref(); const vectorField::subField faceAreas = this->faceAreas(); const pointField& points = this->points(); diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C index ef431b1d9e..4197ef6bac 100644 --- a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C +++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C @@ -295,46 +295,31 @@ void Foam::interfaceTrackingFvMesh::makeControlPoints() << abort(FatalError); } - IOobject controlPointsHeader + IOobject pointsIO ( "controlPoints", mesh().time().timeName(), mesh(), - IOobject::MUST_READ + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER ); - if (controlPointsHeader.typeHeaderOk()) + if (pointsIO.typeHeaderOk()) { Info<< "Reading control points" << endl; - controlPointsPtr_ = - new vectorIOField - ( - IOobject - ( - "controlPoints", - mesh().time().timeName(), - mesh(), - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ) - ); + controlPointsPtr_ = new vectorIOField(pointsIO); } else { + pointsIO.readOpt(IOobject::NO_READ); + Info<< "Creating new control points" << endl; - controlPointsPtr_ = - new vectorIOField - ( - IOobject - ( - "controlPoints", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - aMesh().areaCentres().internalField() - ); + controlPointsPtr_ = new vectorIOField + ( + pointsIO, + aMesh().areaCentres().internalField() + ); initializeControlPointsPosition(); } diff --git a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C index 2c6eb27b36..43f12a7cd7 100644 --- a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C +++ b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C @@ -47,8 +47,8 @@ Foam::tmp Foam::layerAdditionRemoval::extrusionDir() const const pointField& points = mesh.points(); const labelList& mp = masterFaceLayer.meshPoints(); - tmp textrusionDir(new vectorField(mp.size())); - vectorField& extrusionDir = textrusionDir.ref(); + auto textrusionDir = tmp::New(mp.size()); + auto& extrusionDir = textrusionDir.ref(); if (setLayerPairing()) { diff --git a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C index dbd93a73fb..2026e4e09e 100644 --- a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C @@ -339,8 +339,8 @@ Foam::displacementInterpolationMotionSolver::curPoints() const << " points." << exit(FatalError); } - tmp tcurPoints(new pointField(points0())); - pointField& curPoints = tcurPoints.ref(); + auto tcurPoints = tmp::New(points0()); + auto& curPoints = tcurPoints.ref(); // Interpolate the displacement of the face zones. vectorField zoneDisp(displacements_.size(), Zero); diff --git a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C index 5b88d28c57..645be3cea2 100644 --- a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -338,14 +338,9 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve patchi, new pointVectorField ( - IOobject + mesh().newIOobject ( - mesh().cellZones()[cellZoneI].name() + "_" + fz.name(), - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh().cellZones()[cellZoneI].name() + "_" + fz.name() ), pointDisplacement_ // to inherit the boundary conditions ) @@ -429,20 +424,18 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve if (debug) { // Normalised distance - pointScalarField distance + auto tdistance = pointScalarField::New ( - IOobject + IOobject::scopedName ( - mesh().cellZones()[cellZoneI].name() + ":distance", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh().cellZones()[cellZoneI].name(), + "distance" ), + IOobject::NO_REGISTER, pointMesh::New(mesh()), dimensionedScalar(dimLength, Zero) ); + auto& distance = tdistance.ref(); for (const label pointi : isZonePoint) { diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C index 16314968ad..3db5770d17 100644 --- a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -664,8 +664,8 @@ Foam::tmp Foam::pairPatchAgglomeration::agglomerateOneLevel { const label nFineFaces = patch.size(); - tmp tcoarseCellMap(new labelField(nFineFaces, -1)); - labelField& coarseCellMap = tcoarseCellMap.ref(); + auto tcoarseCellMap = tmp::New(nFineFaces, -1); + auto& coarseCellMap = tcoarseCellMap.ref(); const labelListList& faceFaces = patch.faceFaces(); diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C index c0656e0516..541cc4882b 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C @@ -186,8 +186,8 @@ Foam::displacementComponentLaplacianFvMotionSolver::curPoints() const } else { - tmp tcurPoints(new pointField(fvMesh_.points())); - pointField& curPoints = tcurPoints.ref(); + auto tcurPoints = tmp::New(fvMesh_.points()); + auto& curPoints = tcurPoints.ref(); curPoints.replace ( diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C index 68d95d1f98..9fd45f1149 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C @@ -104,7 +104,7 @@ Foam::velocityComponentLaplacianFvMotionSolver::curPoints() const pointMotionU_ ); - tmp tcurPoints(new pointField(fvMesh_.points())); + auto tcurPoints = tmp::New(fvMesh_.points()); tcurPoints.ref().replace ( diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C index 0d6c19e100..f886e65d23 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C @@ -301,28 +301,18 @@ void Foam::surfaceAlignedSBRStressFvMotionSolver::solve() // Calculate rotations on surface intersection calculateCellRot(); - tmp tUd + auto tUd = volVectorField::New ( - new volVectorField + "Ud", + IOobject::NO_REGISTER, + fvMesh_, + dimensionedVector(dimLength, Zero), + cellMotionBoundaryTypes ( - IOobject - ( - "Ud", - fvMesh_.time().timeName(), - fvMesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - fvMesh_, - dimensionedVector(dimLength, Zero), - cellMotionBoundaryTypes - ( - pointDisplacement().boundaryField() - ) + pointDisplacement().boundaryField() ) ); - - volVectorField& Ud = tUd.ref(); + auto& Ud = tUd.ref(); const vectorList& C = fvMesh_.C(); forAll(Ud, i) @@ -346,23 +336,14 @@ void Foam::surfaceAlignedSBRStressFvMotionSolver::solve() const volTensorField gradD("gradD", fvc::grad(Ud)); - tmp tmu + auto tmu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "mu", - fvMesh_.time().timeName(), - fvMesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - fvMesh_, - dimensionedScalar(dimless, Zero) - ) + "mu", + IOobject::NO_REGISTER, + fvMesh_, + dimensionedScalar(dimless, Zero) ); - volScalarField& mu = tmu.ref(); + auto& mu = tmu.ref(); const scalarList& V = fvMesh_.V(); mu.primitiveFieldRef() = (1.0/V); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 2f857a3d56..072e39dfeb 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -113,8 +113,8 @@ Foam::tmp Foam::snappyLayerDriver::avgPointData const scalarField& pointFld ) { - tmp tfaceFld(new scalarField(pp.size(), Zero)); - scalarField& faceFld = tfaceFld.ref(); + auto tfaceFld = tmp::New(pp.size(), Zero); + auto& faceFld = tfaceFld.ref(); forAll(pp.localFaces(), facei) { diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C index 9667c05783..b38620a13f 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -257,8 +257,8 @@ Foam::tmp Foam::snappySnapDriver::smoothInternalDisplacement // Add coupled contributions weightedPosition::syncPoints(mesh, sumLocation); - tmp tdisplacement(new pointField(mesh.nPoints(), Zero)); - pointField& displacement = tdisplacement.ref(); + auto tdisplacement = tmp::New(mesh.nPoints(), Zero); + auto& displacement = tdisplacement.ref(); label nAdapted = 0; @@ -490,8 +490,8 @@ Foam::tmp Foam::snappySnapDriver::smoothPatchDisplacement // Displacement to calculate. - tmp tpatchDisp(new pointField(meshPoints.size(), Zero)); - pointField& patchDisp = tpatchDisp.ref(); + auto tpatchDisp = tmp::New(meshPoints.size(), Zero); + auto& patchDisp = tpatchDisp.ref(); forAll(pointFaces, i) { @@ -571,8 +571,8 @@ Foam::tmp Foam::snappySnapDriver::smoothPatchDisplacement // const labelListList& pointEdges = pp.pointEdges(); // const edgeList& edges = pp.edges(); // -// tmp tavg(new pointField(pointEdges.size(), Zero)); -// pointField& avg = tavg(); +// auto tavg = tmp::New(pointEdges.size(), Zero); +// auto& avg = tavg.ref(); // // forAll(pointEdges, verti) // { @@ -658,8 +658,8 @@ Foam::tmp Foam::snappySnapDriver::edgePatchDist ); // Copy edge values into scalarField - tmp tedgeDist(new scalarField(mesh.nEdges())); - scalarField& edgeDist = tedgeDist.ref(); + auto tedgeDist = tmp::New(mesh.nEdges()); + auto& edgeDist = tedgeDist.ref(); forAll(allEdgeInfo, edgei) { @@ -1057,7 +1057,7 @@ Foam::tmp Foam::snappySnapDriver::avgCellCentres // Add coupled contributions weightedPosition::syncPoints(mesh, pp.meshPoints(), avgBoundary); - tmp tavgBoundary(new pointField(avgBoundary.size())); + auto tavgBoundary = tmp::New(avgBoundary.size()); weightedPosition::getPoints(avgBoundary, tavgBoundary.ref()); return tavgBoundary; @@ -1073,8 +1073,8 @@ Foam::tmp Foam::snappySnapDriver::avgCellCentres // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // (Ripped from snappyLayerDriver) // -// tmp tedgeLen(new scalarField(pp.nPoints())); -// scalarField& edgeLen = tedgeLen(); +// auto tedgeLen = tmp::New(pp.nPoints()); +// auto& edgeLen = tedgeLen.ref(); // { // const fvMesh& mesh = meshRefiner_.mesh(); // const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength(); diff --git a/src/meshTools/cellQuality/cellQuality.C b/src/meshTools/cellQuality/cellQuality.C index 2ee6a6c4c3..fc5f7df520 100644 --- a/src/meshTools/cellQuality/cellQuality.C +++ b/src/meshTools/cellQuality/cellQuality.C @@ -41,15 +41,8 @@ Foam::cellQuality::cellQuality(const polyMesh& mesh) Foam::tmp Foam::cellQuality::nonOrthogonality() const { - tmp tresult - ( - new scalarField - ( - mesh_.nCells(), 0.0 - ) - ); - - scalarField& result = tresult.ref(); + auto tresult = tmp::New(mesh_.nCells(), Zero); + auto& result = tresult.ref(); scalarField sumArea(mesh_.nCells(), Zero); @@ -103,14 +96,8 @@ Foam::tmp Foam::cellQuality::nonOrthogonality() const Foam::tmp Foam::cellQuality::skewness() const { - tmp tresult - ( - new scalarField - ( - mesh_.nCells(), 0.0 - ) - ); - scalarField& result = tresult.ref(); + auto tresult = tmp::New(mesh_.nCells(), Zero); + auto& result = tresult.ref(); scalarField sumArea(mesh_.nCells(), Zero); @@ -182,15 +169,8 @@ Foam::tmp Foam::cellQuality::skewness() const Foam::tmp Foam::cellQuality::faceNonOrthogonality() const { - tmp tresult - ( - new scalarField - ( - mesh_.nFaces(), 0.0 - ) - ); - scalarField& result = tresult.ref(); - + auto tresult = tmp::New(mesh_.nFaces(), Zero); + auto& result = tresult.ref(); const vectorField& centres = mesh_.cellCentres(); const vectorField& areas = mesh_.faceAreas(); @@ -242,15 +222,8 @@ Foam::tmp Foam::cellQuality::faceNonOrthogonality() const Foam::tmp Foam::cellQuality::faceSkewness() const { - tmp tresult - ( - new scalarField - ( - mesh_.nFaces(), 0.0 - ) - ); - scalarField& result = tresult.ref(); - + auto tresult = tmp::New(mesh_.nFaces(), Zero); + auto& result = tresult.ref(); const vectorField& cellCtrs = mesh_.cellCentres(); const vectorField& faceCtrs = mesh_.faceCentres(); diff --git a/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C b/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C index fbb851e4b3..6458779c7f 100644 --- a/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C +++ b/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C @@ -143,8 +143,8 @@ Foam::tmp Foam::edgeMeshTools::featureProximity const scalar searchDistance ) { - tmp tfld(new scalarField(surf.size(), searchDistance)); - scalarField& featureProximity = tfld.ref(); + auto tfld = tmp::New(surf.size(), searchDistance); + auto& featureProximity = tfld.ref(); Info<< "Extracting proximity of close feature points and " << "edges to the surface" << endl; diff --git a/src/meshTools/momentOfInertia/momentOfInertia.C b/src/meshTools/momentOfInertia/momentOfInertia.C index 3ea48e8472..ffb296a3a0 100644 --- a/src/meshTools/momentOfInertia/momentOfInertia.C +++ b/src/meshTools/momentOfInertia/momentOfInertia.C @@ -354,9 +354,8 @@ Foam::tmp Foam::momentOfInertia::meshInertia const polyMesh& mesh ) { - tmp tTf = tmp(new tensorField(mesh.nCells())); - - tensorField& tf = tTf.ref(); + auto tTf = tmp::New(mesh.nCells()); + auto& tf = tTf.ref(); forAll(tf, cI) { diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C index c47ee9e62f..b9add2217b 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C @@ -103,8 +103,8 @@ Foam::triSurfaceTools::writeCloseness { Pair> tpair ( - tmp(new scalarField(surf.size(), GREAT)), - tmp(new scalarField(surf.size(), GREAT)) + tmp::New(surf.size(), GREAT), + tmp::New(surf.size(), GREAT) ); Info<< "Extracting internal and external closeness of surface." << endl; diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C index bb441cb79a..8023791110 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C @@ -158,22 +158,15 @@ Foam::cellCellStencil::createField const UList& psi ) { - auto tfld = tmp::New + auto tfld = volScalarField::New ( - IOobject - ( - name, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + name, + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - volScalarField& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(psi, cellI) { diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.C b/src/overset/oversetPolyPatch/oversetFvPatchField.C index 3beba4a72f..1ab511b730 100644 --- a/src/overset/oversetPolyPatch/oversetFvPatchField.C +++ b/src/overset/oversetPolyPatch/oversetFvPatchField.C @@ -585,10 +585,7 @@ template Foam::tmp> Foam::oversetFvPatchField:: patchNeighbourField() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Zero); } diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.H b/src/overset/oversetPolyPatch/oversetFvPatchField.H index cb22fb6726..ead67e8fab 100644 --- a/src/overset/oversetPolyPatch/oversetFvPatchField.H +++ b/src/overset/oversetPolyPatch/oversetFvPatchField.H @@ -195,10 +195,7 @@ public: const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } //- Return the matrix source coefficients corresponding to the @@ -208,30 +205,21 @@ public: const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } //- Return the matrix diagonal coefficients corresponding to the //- evaluation of the gradient of this patchField tmp> gradientInternalCoeffs() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } //- Return the matrix source coefficients corresponding to the //- evaluation of the gradient of this patchField tmp> gradientBoundaryCoeffs() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } //- Manipulate matrix diff --git a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C index cc03840da3..88cdd4e3af 100644 --- a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C +++ b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C @@ -238,8 +238,8 @@ Foam::tmp Foam::RBD::rigidBodyMotion::transformPoints // to the current state in the global frame spatialTransform X(X0(bodyID).inv() & X00(bodyID)); - tmp tpoints(new pointField(initialPoints.size())); - pointField& points = tpoints.ref(); + auto tpoints = tmp::New(initialPoints.size()); + auto& points = tpoints.ref(); forAll(points, i) { @@ -265,8 +265,8 @@ Foam::tmp Foam::RBD::rigidBodyMotion::transformPoints // interpolation septernion s(X); - tmp tpoints(new pointField(initialPoints)); - pointField& points = tpoints.ref(); + auto tpoints = tmp::New(initialPoints); + auto& points = tpoints.ref(); forAll(points, i) { @@ -314,8 +314,8 @@ Foam::tmp Foam::RBD::rigidBodyMotion::transformPoints ss[bi] = septernion(X); } - tmp tpoints(new pointField(initialPoints)); - pointField& points = tpoints.ref(); + auto tpoints = tmp::New(initialPoints); + auto& points = tpoints.ref(); List w(ss.size()); diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 780844e6e7..e7f4d71072 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -224,8 +224,8 @@ Foam::rigidBodyMeshMotion::curPoints() const } else { - tmp ttransformedPts(new pointField(mesh().points())); - pointField& transformedPts = ttransformedPts.ref(); + auto ttransformedPts = tmp::New(mesh().points()); + auto& transformedPts = ttransformedPts.ref(); UIndirectList(transformedPts, pointIDs()) = pointField(newPoints.ref(), pointIDs()); diff --git a/src/sampling/meshToMesh/meshToMeshTemplates.C b/src/sampling/meshToMesh/meshToMeshTemplates.C index a1f8b6f637..a1df936555 100644 --- a/src/sampling/meshToMesh/meshToMeshTemplates.C +++ b/src/sampling/meshToMesh/meshToMeshTemplates.C @@ -218,14 +218,7 @@ Foam::tmp> Foam::meshToMesh::mapSrcToTgt const CombineOp& cop ) const { - tmp> tresult - ( - new Field - ( - tgtToSrcCellAddr_.size(), - Zero - ) - ); + auto tresult = tmp>::New(tgtToSrcCellAddr_.size(), Zero); mapSrcToTgt(srcField, cop, tresult.ref()); @@ -423,14 +416,7 @@ Foam::tmp> Foam::meshToMesh::mapTgtToSrc const CombineOp& cop ) const { - tmp> tresult - ( - new Field - ( - srcToTgtCellAddr_.size(), - Zero - ) - ); + auto tresult = tmp>::New(srcToTgtCellAddr_.size(), Zero); mapTgtToSrc(tgtField, cop, tresult.ref()); @@ -645,13 +631,13 @@ Foam::meshToMesh::mapSrcToTgt auto tresult = tmp>::New ( - IOobject + tgtMesh.newIOobject ( - type() + ":interpolate(" + field.name() + ")", - tgtMesh.time().timeName(), - tgtMesh, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::scopedName + ( + type(), + "interpolate(" + field.name() + ")" + ) ), tgtMesh, field.dimensions(), @@ -876,13 +862,13 @@ Foam::meshToMesh::mapTgtToSrc auto tresult = tmp>::New ( - IOobject + srcMesh.newIOobject ( - type() + ":interpolate(" + field.name() + ")", - srcMesh.time().timeName(), - srcMesh, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::scopedName + ( + type(), + "interpolate(" + field.name() + ")" + ) ), srcMesh, field.dimensions(), diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 17cb45fb9e..2d47649cd5 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -464,20 +464,12 @@ void Foam::sampledCuttingPlane::createGeometry() ( new volScalarField ( - IOobject - ( - "cellDistance", - mesh.time().timeName(), - mesh.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + mesh.newIOobject("cellDistance"), mesh, dimensionedScalar(dimLength, Zero) ) ); - const volScalarField& cellDistance = cellDistancePtr_(); + const auto& cellDistance = *cellDistancePtr_; setDistanceFields(plane_); @@ -485,20 +477,15 @@ void Foam::sampledCuttingPlane::createGeometry() { Pout<< "Writing cell distance:" << cellDistance.objectPath() << endl; cellDistance.write(); - pointScalarField pointDist + auto tpointDist = pointScalarField::New ( - IOobject - ( - "pointDistance", - mesh.time().timeName(), - mesh.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "pointDistance", + IOobject::NO_REGISTER, pointMesh::New(mesh), dimensionedScalar(dimLength, Zero) ); + auto& pointDist = tpointDist.ref(); + pointDist.primitiveFieldRef() = pointDistance_; Pout<< "Writing point distance:" << pointDist.objectPath() << endl; diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C index 349493e096..9b0e0a592e 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C @@ -393,8 +393,8 @@ Foam::tmp Foam::sixDoFRigidBodyMotion::transform quaternion(Q().T() & initialQ()) ); - tmp tpoints(new pointField(initialPoints)); - pointField& points = tpoints.ref(); + auto tpoints = tmp::New(initialPoints); + auto& points = tpoints.ref(); forAll(points, pointi) { diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C index 267fc19643..33de436dcf 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C @@ -173,8 +173,8 @@ Foam::sixDoFRigidBodyMotionSolver::curPoints() const if (!moveAllCells()) { - tmp ttransformedPts(new pointField(mesh().points())); - pointField& transformedPts = ttransformedPts.ref(); + auto ttransformedPts = tmp::New(mesh().points()); + auto& transformedPts = ttransformedPts.ref(); UIndirectList(transformedPts, pointIDs()) = pointField(newPoints.ref(), pointIDs()); diff --git a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C index 4e56adeb3d..d4dc7990d4 100644 --- a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C +++ b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C @@ -275,12 +275,8 @@ bool Foam::linearValveLayersFvMesh::attached() const Foam::tmp Foam::linearValveLayersFvMesh::newPoints() const { - tmp tnewPoints - ( - new pointField(points()) - ); - - pointField& np = tnewPoints(); + auto tnewPoints = tmp::New(points()); + auto& np = tnewPoints(); const word layerPatchName ( diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C index 51221b8fad..0b0d1e8bef 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C @@ -70,8 +70,8 @@ Foam::tmp Foam::movingConeTopoFvMesh::vertexMarkup Info<< "Updating vertex markup. curLeft: " << curLeft << " curRight: " << curRight << endl; - tmp tvertexMarkup(new scalarField(p.size())); - scalarField& vertexMarkup = tvertexMarkup.ref(); + auto tvertexMarkup = tmp::New(p.size()); + auto& vertexMarkup = tvertexMarkup.ref(); forAll(p, pI) { From 092db087c911aa3b9e7ecbaf3a73246e3d58fedf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 09:33:54 +0100 Subject: [PATCH 03/13] ENH: use tmp field factory methods [2] (#2723) - src/finiteVolume, src/finiteArea --- src/finiteArea/faMatrices/faMatrix/faMatrix.C | 6 +- .../faMatrices/faMatrix/faMatrixSolve.C | 4 +- .../basic/fixedValue/fixedValueFaPatchField.C | 5 +- .../constraint/cyclic/cyclicFaPatchField.C | 4 +- .../constraint/wedge/wedgeFaPatchField.C | 19 +++-- .../clampedPlate/clampedPlateFaPatchField.H | 5 +- .../fixedValueOutflowFaPatchField.C | 5 +- .../faePatchField/faePatchField.H | 5 +- .../divSchemes/faDivScheme/faDivScheme.C | 13 ---- .../divSchemes/faDivScheme/faDivScheme.H | 35 ++++++--- .../gaussFaDivScheme/gaussFaDivScheme.H | 2 +- .../gradSchemes/gaussFaGrad/gaussFaGrad.H | 25 +++---- .../faLaplacianScheme/faLaplacianScheme.H | 35 ++++----- .../gaussFaLaplacianScheme.H | 6 +- .../cfdTools/general/MRF/MRFZoneList.C | 43 ++++------- .../general/SRF/SRFModel/SRFModel/SRFModel.C | 75 ++++++------------- .../general/fvOptions/fvOptionListTemplates.C | 12 +-- .../cfdTools/general/levelSet/levelSet.C | 25 +++---- .../general/levelSet/levelSetTemplates.C | 27 +++---- .../DarcyForchheimer/DarcyForchheimer.C | 20 +---- .../porosityModel/porosityModel.C | 2 +- .../basic/fixedValue/fixedValueFvPatchField.C | 5 +- .../zeroGradient/zeroGradientFvPatchField.C | 20 +---- .../constraint/cyclic/cyclicFvPatchField.C | 4 +- .../cyclicACMI/cyclicACMIFvPatchField.C | 5 +- .../symmetryPlane/symmetryPlaneFvPatchField.C | 28 +++---- .../constraint/wedge/wedgeFvPatchField.C | 19 +++-- .../mappedField/mappedPatchFieldBase.C | 8 +- .../fixedValue/fixedValueFvsPatchField.C | 5 +- .../divSchemes/divScheme/divScheme.H | 25 +++++-- .../gradSchemes/gaussGrad/gaussGrad.H | 22 +++--- .../laplacianScheme/laplacianScheme.C | 6 -- .../laplacianScheme/laplacianScheme.H | 40 +++++----- .../relaxedNonOrthoGaussLaplacianScheme.C | 2 +- .../relaxedNonOrthoGaussLaplacianSchemes.C | 2 +- .../relaxedSnGrad/relaxedSnGrad.C | 2 +- .../fvMatrices/fvMatrix/fvMatrix.C | 54 ++++++------- .../fvMatrices/fvMatrix/fvMatrixSolve.C | 4 +- .../averageNeighbourFvGeometryScheme.C | 8 +- src/finiteVolume/fvMesh/fvMeshGeometry.C | 29 ++++--- .../constraint/cyclic/cyclicFvPatch.C | 4 +- .../Poisson/PoissonPatchDistMethod.C | 21 ++---- .../LimitedScheme/LimitedScheme.C | 16 +--- .../schemes/midPoint/midPoint.H | 23 ++---- .../schemes/reverseLinear/reverseLinear.H | 23 ++---- .../surfaceInterpolation/surfaceInterpolate.C | 14 ++-- .../volPointInterpolate.C | 7 +- 47 files changed, 310 insertions(+), 459 deletions(-) diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrix.C b/src/finiteArea/faMatrices/faMatrix/faMatrix.C index 074cc0693a..4d06db262d 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrix.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrix.C @@ -1207,7 +1207,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, B, "+"); - tmp> tC(new faMatrix(A)); + auto tC = tmp>::New(A); tC.ref() += B; return tC; } @@ -1262,7 +1262,7 @@ Foam::tmp> Foam::operator- const faMatrix& A ) { - tmp> tC(new faMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); return tC; } @@ -1288,7 +1288,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, B, "-"); - tmp> tC(new faMatrix(A)); + auto tC = tmp>::New(A); tC.ref() -= B; return tC; } diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C index 87d5ef0e03..600adc3ce0 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C @@ -192,8 +192,8 @@ Foam::SolverPerformance Foam::faMatrix::solve() template Foam::tmp> Foam::faMatrix::residual() const { - tmp> tres(new Field(source_)); - Field& res = tres().ref(); + auto tres = tmp>::New(source_); + auto& res = tres().ref(); addBoundarySource(res); diff --git a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C index 728fa8e89b..f4d1e26592 100644 --- a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C @@ -108,10 +108,7 @@ Foam::fixedValueFaPatchField::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C index 8aa6296aa0..70b711375f 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C @@ -130,8 +130,8 @@ Foam::cyclicFaPatchField::patchNeighbourField() const const Field& iField = this->primitiveField(); const labelUList& faceCells = cyclicPatch_.faceCells(); - tmp> tpnf(new Field(this->size())); - Field& pnf = tpnf.ref(); + auto tpnf = tmp>::New(this->size()); + auto& pnf = tpnf.ref(); const label sizeby2 = this->size()/2; diff --git a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C index e9bd75e3ff..d3e5c31d78 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C @@ -143,19 +143,18 @@ Foam::wedgeFaPatchField::snGradTransformDiag() const const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); - return tmp> + return tmp>::New ( - new Field + this->size(), + transformMask ( - this->size(), - transformMask + pow ( - pow - ( - diagV, - pTraits::rank> - ::type>::zero - ) + diagV, + pTraits + < + typename powProduct::rank>::type + >::zero ) ) ); diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H index 828937bb6c..4cb191c158 100644 --- a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H @@ -149,10 +149,7 @@ public: //- Return gradient at boundary virtual tmp> snGrad() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } //- Evaluate the patch field diff --git a/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C b/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C index 3b04c3fbbd..b9d26257fb 100644 --- a/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C @@ -95,10 +95,7 @@ Foam::fixedValueOutflowFaPatchField::valueInternalCoeffs const tmp& weights ) const { - return tmp> - ( - new Field(Type(pTraits::one)*weights) - ); + return pTraits::one*weights; } diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H index 96428b68fd..fd1c318d8e 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H @@ -377,10 +377,7 @@ public: const DimensionedField& iF ) const { - return tmp> - ( - new faePatchField(*this, iF) - ); + return tmp>::New(*this, iF); } diff --git a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C index ee05ffe259..6d85dfafd9 100644 --- a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C +++ b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C @@ -34,9 +34,6 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fa { @@ -84,19 +81,9 @@ tmp> divScheme::New } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -divScheme::~divScheme() -{} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fa - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - } // End namespace Foam // ************************************************************************* // diff --git a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H index 56f4abc534..47414a9123 100644 --- a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H +++ b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef faDivScheme_H -#define faDivScheme_H +#ifndef Foam_faDivScheme_H +#define Foam_faDivScheme_H #include "tmp.H" #include "areaFieldsFwd.H" @@ -50,9 +50,8 @@ SourceFiles namespace Foam { -template -class faMatrix; - +// Forward Declarations +template class faMatrix; class faMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,12 +68,12 @@ class divScheme : public refCount { - protected: - // Protected data + // Protected Data const faMesh& mesh_; + tmp> tinterpScheme_; @@ -113,9 +112,23 @@ public: //- Construct from mesh and Istream divScheme(const faMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpScheme_(edgeInterpolationScheme::New(mesh, is)) - {} + mesh_(mesh) + { + if (is.eof()) + { + tinterpScheme_.reset + ( + new linearEdgeInterpolation(mesh) + ); + } + else + { + tinterpScheme_.reset + ( + edgeInterpolationScheme::New(mesh, is) + ); + } + } // Selectors @@ -129,7 +142,7 @@ public: //- Destructor - virtual ~divScheme(); + virtual ~divScheme() = default; // Member Functions diff --git a/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H b/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H index d92add74ee..98e834128f 100644 --- a/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H +++ b/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H @@ -76,7 +76,7 @@ public: // Constructors - //- Construct null + //- Construct from mesh gaussDivScheme(const faMesh& mesh) : divScheme(mesh) diff --git a/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H b/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H index f0348ffdda..59fc08d91d 100644 --- a/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H +++ b/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef gaussFaGrad_H -#define gaussFaGrad_H +#ifndef Foam_gaussFaGrad_H +#define Foam_gaussFaGrad_H #include "faGradScheme.H" #include "edgeInterpolationScheme.H" @@ -96,24 +96,21 @@ public: //- Construct from Istream gaussGrad(const faMesh& mesh, Istream& is) : - gradScheme(mesh), - tinterpScheme_(nullptr) + gradScheme(mesh) { if (is.eof()) { - tinterpScheme_ = - tmp> - ( - new linearEdgeInterpolation(mesh) - ); + tinterpScheme_.reset + ( + new linearEdgeInterpolation(mesh) + ); } else { - tinterpScheme_ = - tmp> - ( - edgeInterpolationScheme::New(mesh, is) - ); + tinterpScheme_.reset + ( + edgeInterpolationScheme::New(mesh, is) + ); } } diff --git a/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H b/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H index 01a1e34787..009d2a8001 100644 --- a/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H +++ b/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef faLaplacianScheme_H -#define faLaplacianScheme_H +#ifndef Foam_faLaplacianScheme_H +#define Foam_faLaplacianScheme_H #include "tmp.H" #include "areaFieldsFwd.H" @@ -51,9 +51,8 @@ SourceFiles namespace Foam { -template -class faMatrix; - +// Forward Declarations +template class faMatrix; class faMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,12 +69,12 @@ class laplacianScheme : public refCount { - protected: - // Protected data + // Protected Data const faMesh& mesh_; + tmp> tinterpGammaScheme_; tmp> tlnGradScheme_; @@ -116,30 +115,28 @@ public: //- Construct from mesh and Istream laplacianScheme(const faMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpGammaScheme_(nullptr), - tlnGradScheme_(nullptr) + mesh_(mesh) { if (is.eof()) { - tinterpGammaScheme_ = tmp> + tinterpGammaScheme_.reset ( new linearEdgeInterpolation(mesh) ); - tlnGradScheme_ = tmp> + tlnGradScheme_.reset ( new correctedLnGrad(mesh) ); } else { - tinterpGammaScheme_ = tmp> + tinterpGammaScheme_.reset ( edgeInterpolationScheme::New(mesh, is) ); - tlnGradScheme_ = tmp> + tlnGradScheme_.reset ( lnGradScheme::New(mesh, is) ); @@ -218,11 +215,11 @@ public: \ namespace Foam \ { \ - namespace fa \ - { \ - laplacianScheme::addIstreamConstructorToTable> \ - add##SS##Type##IstreamConstructorToTable_; \ - } \ + namespace fa \ + { \ + laplacianScheme::addIstreamConstructorToTable> \ + add##SS##Type##IstreamConstructorToTable_; \ + } \ } diff --git a/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H b/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H index fac32562cc..7da2395700 100644 --- a/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H +++ b/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef gaussFaLaplacianScheme_H -#define gaussFaLaplacianScheme_H +#ifndef Foam_gaussFaLaplacianScheme_H +#define Foam_gaussFaLaplacianScheme_H #include "faLaplacianScheme.H" @@ -76,7 +76,7 @@ public: // Constructors - //- Construct null + //- Construct from mesh gaussLaplacianScheme(const faMesh& mesh) : laplacianScheme(mesh) diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C index c3b4084131..a66957b9ec 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C @@ -188,18 +188,13 @@ Foam::tmp Foam::MRFZoneList::DDt const volVectorField& U ) const { - auto tacceleration = - tmp::New - ( - IOobject - ( - "MRFZoneList:acceleration", - U.mesh().time().timeName(), - U.mesh().thisDb() - ), - U.mesh(), - dimensionedVector(U.dimensions()/dimTime, Zero) - ); + auto tacceleration = volVectorField::New + ( + IOobject::scopedName("MRFZoneList", "acceleration"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedVector(U.dimensions()/dimTime, Zero) + ); auto& acceleration = tacceleration.ref(); for (const auto& mrf: *this) @@ -263,10 +258,8 @@ Foam::tmp Foam::MRFZoneList::relative return rphi; } - else - { - return tmp(tphi, true); - } + + return tmp(tphi, true); } @@ -289,10 +282,8 @@ Foam::MRFZoneList::relative return rphi; } - else - { - return tmp>(tphi, true); - } + + return tmp>(tphi, true); } @@ -316,10 +307,8 @@ Foam::MRFZoneList::relative return rphi; } - else - { - return tmp>(tphi, true); - } + + return tmp>(tphi, true); } @@ -378,10 +367,8 @@ Foam::tmp Foam::MRFZoneList::absolute return rphi; } - else - { - return tmp(tphi, true); - } + + return tmp(tphi, true); } diff --git a/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C b/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C index 683f2a9c66..58b002be2d 100644 --- a/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C +++ b/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C @@ -55,8 +55,9 @@ Foam::SRF::SRFModel::SRFModel "SRFProperties", Urel.time().constant(), Urel.db(), - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), Urel_(Urel), @@ -118,19 +119,12 @@ const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const Foam::tmp> Foam::SRF::SRFModel::Fcoriolis() const { - return tmp + return volVectorField::Internal::New ( - new volVectorField::Internal + "Fcoriolis", + IOobject::NO_REGISTER, ( - IOobject - ( - "Fcoriolis", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - 2.0*omega_ ^ Urel_ + 2.0*omega_ ^ Urel_.internalField() ) ); } @@ -139,18 +133,11 @@ Foam::SRF::SRFModel::Fcoriolis() const Foam::tmp> Foam::SRF::SRFModel::Fcentrifugal() const { - return tmp + return volVectorField::Internal::New ( - new volVectorField::Internal + "Fcentrifugal", + IOobject::NO_REGISTER, ( - IOobject - ( - "Fcentrifugal", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), omega_ ^ (omega_ ^ (mesh_.C().internalField() - origin_)) ) ); @@ -169,14 +156,14 @@ Foam::vectorField Foam::SRF::SRFModel::velocity const vectorField& positions ) const { - tmp tfld = + return vectorField + ( omega_.value() ^ ( (positions - origin_.value()) - axis_*(axis_ & (positions - origin_.value())) - ); - - return tfld(); + ) + ); } @@ -186,18 +173,11 @@ Foam::tmp Foam::SRF::SRFModel::U() const volVectorField::Boundary::localConsistency = 0; tmp relPos(mesh_.C() - origin_); - tmp tU + auto tU = volVectorField::New ( - new volVectorField + "Usrf", + IOobject::NO_REGISTER, ( - IOobject - ( - "Usrf", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), omega_ ^ (relPos() - axis_*(axis_ & relPos())) ) ); @@ -211,24 +191,13 @@ Foam::tmp Foam::SRF::SRFModel::Uabs() const { tmp Usrf = U(); - tmp tUabs + auto tUabs = volVectorField::New ( - new volVectorField - ( - IOobject - ( - "Uabs", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - Usrf - ) + "Uabs", + IOobject::NO_REGISTER, + Usrf ); - - volVectorField& Uabs = tUabs.ref(); + auto& Uabs = tUabs.ref(); // Add SRF contribution to internal field Uabs.primitiveFieldRef() += Urel_.primitiveField(); diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C index 8112e1c689..201ecb634d 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C @@ -42,8 +42,8 @@ Foam::tmp> Foam::fv::optionList::source { checkApplied(); - tmp> tmtx(new fvMatrix(field, ds)); - fvMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { @@ -129,8 +129,8 @@ Foam::tmp> Foam::fv::optionList::operator() rho.dimensions()*field.dimensions()/dimTime*dimVolume ); - tmp> tmtx(new fvMatrix(field, ds)); - fvMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { @@ -198,8 +198,8 @@ Foam::tmp> Foam::fv::optionList::operator() /dimTime*dimVolume ); - tmp> tmtx(new fvMatrix(field, ds)); - fvMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { diff --git a/src/finiteVolume/cfdTools/general/levelSet/levelSet.C b/src/finiteVolume/cfdTools/general/levelSet/levelSet.C index 4e800b71a0..2dcea81c81 100644 --- a/src/finiteVolume/cfdTools/general/levelSet/levelSet.C +++ b/src/finiteVolume/cfdTools/general/levelSet/levelSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,21 +42,14 @@ Foam::levelSetFraction const bool above ) { - tmp> tResult + auto tResult = DimensionedField::New ( - new DimensionedField - ( - IOobject - ( - "levelSetFraction", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar(dimless, Zero) - ) + "levelSetFraction", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimless, Zero) ); - DimensionedField& result = tResult.ref(); + auto& result = tResult.ref(); forAll(result, cI) { @@ -113,8 +106,8 @@ Foam::tmp Foam::levelSetFraction const bool above ) { - tmp tResult(new scalarField(patch.size(), Zero)); - scalarField& result = tResult.ref(); + auto tResult = tmp::New(patch.size(), Zero); + auto& result = tResult.ref(); forAll(result, fI) { diff --git a/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C b/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C index f5e154f93b..17b8e935ac 100644 --- a/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C +++ b/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,21 +45,14 @@ Foam::tmp> Foam::levelSetAverage const DimensionedField& negativeP ) { - tmp> tResult + auto tresult = DimensionedField::New ( - new DimensionedField - ( - IOobject - ( - positiveC.name() + ":levelSetAverage", - mesh.time().timeName(), - mesh - ), - mesh, - dimensioned(positiveC.dimensions(), Zero) - ) + IOobject::scopedName(positiveC.name(), "levelSetAverage"), + mesh, + Foam::zero{}, // value + positiveC.dimensions() ); - DimensionedField& result = tResult.ref(); + auto& result = tresult.ref(); forAll(result, cI) { @@ -114,7 +107,7 @@ Foam::tmp> Foam::levelSetAverage result[cI] = r/v; } - return tResult; + return tresult; } @@ -132,8 +125,8 @@ Foam::tmp> Foam::levelSetAverage { typedef typename outerProduct::type sumType; - tmp> tResult(new Field(patch.size(), Zero)); - Field& result = tResult.ref(); + auto tResult = tmp>::New(patch.size(), Zero); + auto& result = tResult.ref(); forAll(result, fI) { diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C index 2ac51692d2..5fbe22d284 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C @@ -126,32 +126,18 @@ void Foam::porosityModels::DarcyForchheimer::calcTransformModelData() { volTensorField Dout ( - IOobject - ( - typeName + ":D", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + mesh_.newIOobject(IOobject::scopedName(typeName, "D")), mesh_, dimensionedTensor(dXYZ_.dimensions(), Zero) ); + volTensorField Fout ( - IOobject - ( - typeName + ":F", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + mesh_.newIOobject(IOobject::scopedName(typeName, "F")), mesh_, dimensionedTensor(fXYZ_.dimensions(), Zero) ); - forAll(cellZoneIDs_, zonei) { const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zonei]]; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C index 283e46f9ae..eb4ea67311 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C @@ -173,7 +173,7 @@ Foam::tmp Foam::porosityModel::porosityModel::force { transformModelData(); - tmp tforce(new vectorField(U.size(), Zero)); + auto tforce = tmp::New(U.size(), Zero); if (!cellZoneIDs_.empty()) { diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C index dd3731399d..8a567b7150 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C @@ -119,10 +119,7 @@ Foam::fixedValueFvPatchField::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C index 65f532974f..e7aad92d1a 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C @@ -112,10 +112,7 @@ Foam::zeroGradientFvPatchField::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), pTraits::one) - ); + return tmp>::New(this->size(), pTraits::one); } @@ -126,10 +123,7 @@ Foam::zeroGradientFvPatchField::valueBoundaryCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } @@ -137,10 +131,7 @@ template Foam::tmp> Foam::zeroGradientFvPatchField::gradientInternalCoeffs() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } @@ -148,10 +139,7 @@ template Foam::tmp> Foam::zeroGradientFvPatchField::gradientBoundaryCoeffs() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C index 0d6dac5c15..487bdb8dff 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C @@ -134,8 +134,8 @@ Foam::cyclicFvPatchField::patchNeighbourField() const const labelUList& nbrFaceCells = cyclicPatch().cyclicPatch().neighbPatch().faceCells(); - tmp> tpnf(new Field(this->size())); - Field& pnf = tpnf.ref(); + auto tpnf = tmp>::New(this->size()); + auto& pnf = tpnf.ref(); if (doTransform()) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index 7c139b2f9f..d784d09aff 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -903,7 +903,8 @@ Foam::cyclicACMIFvPatchField::coeffs matrix.lduMeshAssembly().cellBoundMap()[mat][index].size() ); - Field mapCoeffs(nSubFaces, Zero); + auto tmapCoeffs = tmp>::New(nSubFaces, Zero); + auto& mapCoeffs = tmapCoeffs.ref(); const scalarListList& srcWeight = cyclicACMIPatch_.cyclicACMIPatch().AMI().srcWeights(); @@ -928,7 +929,7 @@ Foam::cyclicACMIFvPatchField::coeffs } } - return tmp>(new Field(mapCoeffs)); + return tmapCoeffs; } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C index 53851b7e00..b83f6c80a9 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C @@ -157,27 +157,21 @@ Foam::symmetryPlaneFvPatchField::snGradTransformDiag() const { vector nHat(symmetryPlanePatch_.n()); - const vector diag - ( - mag(nHat.component(vector::X)), - mag(nHat.component(vector::Y)), - mag(nHat.component(vector::Z)) - ); + const vector diag(mag(nHat.x()), mag(nHat.y()), mag(nHat.z())); - return tmp> + return tmp>::New ( - new Field + this->size(), + transformMask ( - this->size(), - transformMask + //pow::rank>(diag) + pow ( - //pow::rank>(diag) - pow - ( - diag, - pTraits::rank> - ::type>::zero - ) + diag, + pTraits + < + typename powProduct::rank>::type + >::zero ) ) ); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C index 8d63c8a5d8..e3fd64d58d 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C @@ -157,19 +157,18 @@ Foam::wedgeFvPatchField::snGradTransformDiag() const const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); - return tmp> + return tmp>::New ( - new Field + this->size(), + transformMask ( - this->size(), - transformMask + pow ( - pow - ( - diagV, - pTraits::rank> - ::type>::zero - ) + diagV, + pTraits + < + typename powProduct::rank>::type + >::zero ) ) ); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C index 117913ff8e..786ab2511b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C @@ -821,8 +821,8 @@ Foam::tmp> Foam::mappedPatchFieldBase::mappedInternalField() const { // Swap to obtain full local values of neighbour internal field - tmp> tnbrIntFld(new Field()); - Field& nbrIntFld = tnbrIntFld.ref(); + auto tnbrIntFld = tmp>::New(); + auto& nbrIntFld = tnbrIntFld.ref(); if (mapper_.sameWorld()) { @@ -855,8 +855,8 @@ Foam::tmp Foam::mappedPatchFieldBase::mappedWeightField() const { // Swap to obtain full local values of neighbour internal field - tmp tnbrKDelta(new scalarField()); - scalarField& nbrKDelta = tnbrKDelta.ref(); + auto tnbrKDelta = tmp::New(); + auto& nbrKDelta = tnbrKDelta.ref(); if (mapper_.sameWorld()) { diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C index e681852103..f457b1d07d 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C @@ -107,10 +107,7 @@ Foam::fixedValueFvsPatchField::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H b/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H index 3cf30c8e4d..61b4707f07 100644 --- a/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H +++ b/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef divScheme_H -#define divScheme_H +#ifndef Foam_divScheme_H +#define Foam_divScheme_H #include "tmp.H" #include "volFieldsFwd.H" @@ -71,12 +71,12 @@ class divScheme : public refCount { - protected: // Protected data const fvMesh& mesh_; + tmp> tinterpScheme_; @@ -120,8 +120,23 @@ public: divScheme(const fvMesh& mesh, Istream& is) : mesh_(mesh), - tinterpScheme_(surfaceInterpolationScheme::New(mesh, is)) - {} + tinterpScheme_(nullptr) + { + if (is.eof()) + { + tinterpScheme_.reset + ( + new linear(mesh) + ); + } + else + { + tinterpScheme_.reset + ( + surfaceInterpolationScheme::New(mesh, is) + ); + } + } // Selectors diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H index a5ceacf97a..3b4b306f61 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef gaussGrad_H -#define gaussGrad_H +#ifndef Foam_gaussGrad_H +#define Foam_gaussGrad_H #include "gradScheme.H" #include "surfaceInterpolationScheme.H" @@ -103,19 +103,17 @@ public: { if (is.eof()) { - tinterpScheme_ = - tmp> - ( - new linear(mesh) - ); + tinterpScheme_.reset + ( + new linear(mesh) + ); } else { - tinterpScheme_ = - tmp> - ( - surfaceInterpolationScheme::New(mesh, is) - ); + tinterpScheme_.reset + ( + surfaceInterpolationScheme::New(mesh, is) + ); } } diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C index 8e032da8cc..8de5e717cf 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C @@ -35,9 +35,6 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fv { @@ -112,9 +109,6 @@ laplacianScheme::fvcLaplacian // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - } // End namespace Foam // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H index fe1eba2077..ab8b82a211 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H @@ -53,9 +53,8 @@ SourceFiles namespace Foam { -template -class fvMatrix; - +// Forward Declarations +template class fvMatrix; class fvMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,19 +71,16 @@ class laplacianScheme : public refCount { - protected: - // Protected data + // Protected Data const fvMesh& mesh_; tmp> tinterpGammaScheme_; tmp> tsnGradScheme_; -private: - - // Private Member Functions + // Protected Member Functions //- No copy construct laplacianScheme(const laplacianScheme&) = delete; @@ -124,19 +120,25 @@ public: //- Construct from mesh and Istream laplacianScheme(const fvMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpGammaScheme_(nullptr), - tsnGradScheme_(nullptr) + mesh_(mesh) { - tinterpGammaScheme_ = tmp> - ( - surfaceInterpolationScheme::New(mesh, is) - ); + if (is.eof()) + { + tinterpGammaScheme_.reset(new linear(mesh)); + tsnGradScheme_.reset(new correctedSnGrad(mesh)); + } + else + { + tinterpGammaScheme_.reset + ( + surfaceInterpolationScheme::New(mesh, is) + ); - tsnGradScheme_ = tmp> - ( - snGradScheme::New(mesh, is) - ); + tsnGradScheme_.reset + ( + snGradScheme::New(mesh, is) + ); + } } //- Construct from mesh, interpolation and snGradScheme schemes diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C index d0732bf124..ef0efdb299 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C @@ -192,7 +192,7 @@ relaxedNonOrthoGaussLaplacianScheme::fvmLaplacian const word corrName(tfaceFluxCorrection().name()); - tmp trelaxedCorrection(new SType(tfaceFluxCorrection())); + auto trelaxedCorrection = tmp::New(tfaceFluxCorrection()); const word oldName(corrName + "_0"); const scalar relax(vf.mesh().equationRelaxationFactor(oldName)); diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C index 7aa0027ec9..ce32fd20fb 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C @@ -66,7 +66,7 @@ fvmLaplacian \ const word corrName(tCorr().name()); \ tmp tfaceFluxCorrection(gammaMagSf*tCorr); \ \ - tmp trelaxedCorrection(new SType(tfaceFluxCorrection())); \ + auto trelaxedCorrection = tmp::New(tfaceFluxCorrection()); \ \ const word oldName(corrName + "_0"); \ const scalar relax(vf.mesh().equationRelaxationFactor(corrName)); \ diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C index 0b01812677..0506e7dc1a 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C @@ -61,7 +61,7 @@ Foam::fv::relaxedSnGrad::correction } // Return under/over-relaxed explicit correction field - tmp trelaxedCorrection(new SurfFieldType(tcorrection())); + auto trelaxedCorrection = tmp::New(tcorrection()); SurfFieldType& oldCorrection = obr.lookupObjectRef(oldFieldName); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 716a2b1896..bf2ab42635 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -2078,7 +2078,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, su, "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += su.mesh().V()*su.field(); return tC; } @@ -2091,7 +2091,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, tsu(), "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2105,7 +2105,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, tsu(), "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2160,7 +2160,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, su, "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += A.psi().mesh().V()*su.value(); return tC; } @@ -2206,7 +2206,7 @@ Foam::tmp> Foam::operator- const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); return tC; } @@ -2231,7 +2231,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, B, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() += B; return tC; } @@ -2284,7 +2284,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.mesh().V()*su.field(); return tC; } @@ -2297,7 +2297,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2311,7 +2311,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2366,7 +2366,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.mesh().V()*su.field(); return tC; } @@ -2379,7 +2379,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2393,7 +2393,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2449,7 +2449,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, B, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() -= B; return tC; } @@ -2503,7 +2503,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += su.mesh().V()*su.field(); return tC; } @@ -2516,7 +2516,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2530,7 +2530,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2585,7 +2585,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= su.mesh().V()*su.field(); return tC; @@ -2599,7 +2599,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); @@ -2614,7 +2614,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); @@ -2673,7 +2673,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; } @@ -2699,7 +2699,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; } @@ -2725,7 +2725,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += su.value()*tC().psi().mesh().V(); return tC; } @@ -2751,7 +2751,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; @@ -2779,7 +2779,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= dsf; return tC; } @@ -2791,7 +2791,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= tdsf; return tC; } @@ -2803,7 +2803,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= tvsf; return tC; } @@ -2851,7 +2851,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= ds; return tC; } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 8fbd115003..000306e352 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -363,8 +363,8 @@ Foam::SolverPerformance Foam::fvMatrix::solve() template Foam::tmp> Foam::fvMatrix::residual() const { - tmp> tres(new Field(source_)); - Field& res = tres.ref(); + auto tres = tmp>::New(source_); + auto& res = tres.ref(); addBoundarySource(res); diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C index 8476a24df4..6cfef0e944 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C @@ -272,8 +272,8 @@ Foam::averageNeighbourFvGeometryScheme::averageNeighbourCentres const labelList& nei = mesh_.faceNeighbour(); - tmp tcc(new pointField(mesh_.nCells(), Zero)); - pointField& cc = tcc.ref(); + auto tcc = tmp::New(mesh_.nCells(), Zero); + auto& cc = tcc.ref(); Field cellWeights(mesh_.nCells(), Zero); @@ -382,8 +382,8 @@ Foam::averageNeighbourFvGeometryScheme::averageCentres const labelList& nei = mesh_.faceNeighbour(); - tmp tnewFc(new pointField(faceCentres)); - pointField& newFc = tnewFc.ref(); + auto tnewFc = tmp::New(faceCentres); + auto& newFc = tnewFc.ref(); // Internal faces for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index e7afa733b1..4b34dc5e27 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -376,25 +376,22 @@ Foam::tmp Foam::fvMesh::delta() const { DebugInFunction << "Calculating face deltas" << endl; - tmp tdelta + auto tdelta = tmp::New ( - new surfaceVectorField + IOobject ( - IOobject - ( - "delta", - pointsInstance(), - meshSubDir, - *this, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "delta", + pointsInstance(), + meshSubDir, *this, - dimLength - ) + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimLength ); - surfaceVectorField& delta = tdelta.ref(); + auto& delta = tdelta.ref(); delta.setOriented(); const volVectorField& C = this->C(); @@ -406,7 +403,7 @@ Foam::tmp Foam::fvMesh::delta() const delta[facei] = C[neighbour[facei]] - C[owner[facei]]; } - surfaceVectorField::Boundary& deltabf = delta.boundaryFieldRef(); + auto& deltabf = delta.boundaryFieldRef(); forAll(deltabf, patchi) { diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C index a8eccd2c9f..af2cb8a4ed 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C @@ -64,8 +64,8 @@ Foam::tmp Foam::cyclicFvPatch::delta() const const vectorField patchD(coupledFvPatch::delta()); const vectorField nbrPatchD(neighbFvPatch().coupledFvPatch::delta()); - tmp tpdv(new vectorField(patchD.size())); - vectorField& pdv = tpdv.ref(); + auto tpdv = tmp::New(patchD.size()); + auto& pdv = tpdv.ref(); // To the transformation if necessary if (parallel()) diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C index 5984f960c7..7141a428d3 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C @@ -81,23 +81,16 @@ bool Foam::patchDistMethods::Poisson::correct { if (!tyPsi_) { - tyPsi_ = tmp + tyPsi_ = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "yPsi", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(sqr(dimLength), Zero), - y.boundaryFieldRef().types() - ) + "yPsi", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(sqr(dimLength), Zero), + y.boundaryFieldRef().types() ); } - volScalarField& yPsi = tyPsi_.ref(); + auto& yPsi = tyPsi_.ref(); solve(fvm::laplacian(yPsi) == dimensionedScalar("1", dimless, -1.0)); diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C index e72725405b..a6beca477a 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C @@ -184,19 +184,11 @@ Foam::LimitedScheme::limiter } else { - tmp tlimiterField + auto tlimiterField = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - limiterFieldName, - mesh.time().timeName(), - mesh - ), - mesh, - dimless - ) + limiterFieldName, + mesh, + dimless ); calcLimiter(phi, tlimiterField.ref()); diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H index 8bfb0360dc..5ad8ee370c 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H @@ -103,26 +103,15 @@ public: const GeometricField& ) const { - tmp taw + auto taw = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - "midPointWeights", - this->mesh().time().timeName(), - this->mesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar("0.5", dimless, 0.5) - ) + "midPointWeights", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar("0.5", dimless, 0.5) ); - surfaceScalarField::Boundary& awBf = - taw.ref().boundaryFieldRef(); + auto& awBf = taw.ref().boundaryFieldRef(); forAll(awBf, patchi) { diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H index 6ce1aa91e8..f6964af2b4 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H @@ -113,28 +113,19 @@ public: ); const surfaceScalarField& cdWeights = tcdWeights(); - tmp treverseLinearWeights + auto treverseLinearWeights = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - "reverseLinearWeights", - mesh.time().timeName(), - mesh - ), - mesh, - dimless - ) + "reverseLinearWeights", + IOobject::NO_REGISTER, + mesh, + dimless ); - surfaceScalarField& reverseLinearWeights = - treverseLinearWeights.ref(); + auto& reverseLinearWeights = treverseLinearWeights.ref(); reverseLinearWeights.primitiveFieldRef() = 1.0 - cdWeights.primitiveField(); - surfaceScalarField::Boundary& rlwbf = - reverseLinearWeights.boundaryFieldRef(); + auto& rlwbf = reverseLinearWeights.boundaryFieldRef(); forAll(mesh.boundary(), patchi) diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C index edfdf8a992..15d99ffe65 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C @@ -278,22 +278,20 @@ Foam::fvc::interpolate const FieldField& fvpff ) { - FieldField* fvspffPtr - ( - new FieldField(fvpff.size()) - ); + auto tresult = tmp>::New(fvpff.size()); + auto& result = tresult.ref(); - forAll(*fvspffPtr, patchi) + forAll(result, patchi) { - fvspffPtr->set + result.set ( patchi, fvsPatchField::NewCalculatedType(fvpff[patchi].patch()).ptr() ); - (*fvspffPtr)[patchi] = fvpff[patchi]; + result[patchi] = fvpff[patchi]; } - return tmp>(fvspffPtr); + return tresult; } diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index 798c3bf152..fac2318f22 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -232,11 +232,8 @@ Foam::tmp> Foam::volPointInterpolation::flatBoundaryField const fvMesh& mesh = vf.mesh(); const fvBoundaryMesh& bm = mesh.boundary(); - tmp> tboundaryVals - ( - new Field(mesh.nBoundaryFaces()) - ); - Field& boundaryVals = tboundaryVals.ref(); + auto tboundaryVals = tmp>::New(mesh.nBoundaryFaces()); + auto& boundaryVals = tboundaryVals.ref(); forAll(vf.boundaryField(), patchi) { From 710eb5c142b1b5adcdece5a464e85c2e8e5bc07f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 09:50:54 +0100 Subject: [PATCH 04/13] 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 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); From 33f20edbb14a92fc34cc095362e350eb8860a5ae Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:16:59 +0100 Subject: [PATCH 05/13] ENH: use tmp field factory methods [4] (#2723) - src/regionModels src/regionFaModels --- .../KirchhoffShell/KirchhoffShell.C | 22 +--- .../liquidFilm/liquidFilmBase.C | 87 ++++---------- .../filmTurbulenceModel/filmTurbulenceModel.C | 55 ++++----- .../kinematic/force/forceList/forceList.C | 7 +- .../curvatureSeparation/curvatureSeparation.C | 6 +- .../thermalShell/thermalShell.C | 72 ++++-------- .../regionModel/regionModel1D/regionModel1D.C | 8 +- .../singleLayerRegion/singleLayerRegion.C | 6 +- .../kinematicSingleLayer.C | 78 +++--------- .../kinematicSingleLayerI.H | 60 +++------- .../surfaceFilmModels/noFilm/noFilm.C | 39 ++---- .../constantFilmThermo/constantFilmThermo.C | 106 +++++------------ .../liquidFilmThermo/liquidFilmThermo.C | 111 +++++------------- .../filmTurbulenceModel/laminar/laminar.C | 34 ++---- .../contactAngleForce/contactAngleForce.C | 36 ++---- .../distributionContactAngleForce.C | 32 ++--- ...bedTemperatureDependentContactAngleForce.C | 34 +++--- .../temperatureDependentContactAngleForce.C | 30 ++--- .../kinematic/force/forceList/forceList.C | 7 +- .../thermocapillaryForce.C | 3 +- .../curvatureSeparation/curvatureSeparation.C | 47 +++----- .../constantRadiation/constantRadiation.C | 26 ++-- .../noRadiation/noRadiation.C | 13 +- .../primaryRadiation/primaryRadiation.C | 25 ++-- .../standardRadiation/standardRadiation.C | 28 ++--- .../thixotropicViscosity.C | 6 +- .../waxSolventViscosity/waxSolventViscosity.C | 43 +++---- .../constantHeatTransfer.C | 26 ++-- .../solidification/solidification.C | 12 +- .../waxSolventEvaporation.C | 52 ++++---- .../thermoSingleLayer/thermoSingleLayer.C | 81 +++++-------- .../thermoSingleLayer/thermoSingleLayerI.H | 34 ++---- .../thermalBaffleModels/noThermo/noThermo.C | 19 +-- .../thermalBaffle/thermalBaffle.C | 23 +--- 34 files changed, 411 insertions(+), 857 deletions(-) diff --git a/src/regionFaModels/KirchhoffShell/KirchhoffShell.C b/src/regionFaModels/KirchhoffShell/KirchhoffShell.C index 1b09200a93..b3daab327e 100644 --- a/src/regionFaModels/KirchhoffShell/KirchhoffShell.C +++ b/src/regionFaModels/KirchhoffShell/KirchhoffShell.C @@ -282,23 +282,13 @@ const tmp KirchhoffShell::D() const const tmp KirchhoffShell::rho() const { - return tmp + return areaScalarField::New ( - new areaScalarField - ( - IOobject - ( - "rhos", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - regionMesh(), - dimensionedScalar("rho", dimDensity, solid().rho()), - faPatchFieldBase::zeroGradientType() - ) + "rhos", + IOobjectOption::NO_REGISTER, + regionMesh(), + dimensionedScalar("rho", dimDensity, solid().rho()), + faPatchFieldBase::zeroGradientType() ); } diff --git a/src/regionFaModels/liquidFilm/liquidFilmBase.C b/src/regionFaModels/liquidFilm/liquidFilmBase.C index afe3dc40a0..b392609c86 100644 --- a/src/regionFaModels/liquidFilm/liquidFilmBase.C +++ b/src/regionFaModels/liquidFilm/liquidFilmBase.C @@ -276,19 +276,12 @@ scalar liquidFilmBase::CourantNumber() const Foam::tmp liquidFilmBase::Uw() const { - tmp tUw + auto tUw = areaVectorField::New ( - new areaVectorField - ( - IOobject - ( - "tUw", - regionMesh().time().timeName(), - regionMesh().thisDb() - ), - regionMesh(), - dimensionedVector(dimVelocity, Zero) - ) + "tUw", + IOobjectOption::NO_REGISTER, + regionMesh(), + dimensionedVector(dimVelocity, Zero) ); auto& Uw = tUw.ref(); @@ -331,19 +324,12 @@ Foam::tmp liquidFilmBase::Uw() const Foam::tmp liquidFilmBase::Us() const { - tmp tUs + auto tUs = areaVectorField::New ( - new areaVectorField - ( - IOobject - ( - "tUs", - regionMesh().time().timeName(), - regionMesh().thisDb() - ), - regionMesh(), - dimensionedVector(dimVelocity, Zero) - ) + "tUs", + IOobjectOption::NO_REGISTER, + regionMesh(), + dimensionedVector(dimVelocity, Zero) ); // Uf quadratic profile @@ -358,21 +344,14 @@ Foam::tmp liquidFilmBase::Up() const const volVectorField& Uprimary = primaryMesh().lookupObject(UName_); - tmp tUp + auto tUp = areaVectorField::New ( - new areaVectorField - ( - IOobject - ( - "tUp", - regionMesh().time().timeName(), - regionMesh().thisDb() - ), - regionMesh(), - dimensionedVector(dimVelocity, Zero) - ) + "tUp", + IOobjectOption::NO_REGISTER, + regionMesh(), + dimensionedVector(dimVelocity, Zero) ); - areaVectorField& Up = tUp.ref(); + auto& Up = tUp.ref(); // Set up mapping values per patch @@ -406,19 +385,12 @@ Foam::tmp liquidFilmBase::Up() const tmp liquidFilmBase::pg() const { - tmp tpg + auto tpg = areaScalarField::New ( - new areaScalarField - ( - IOobject - ( - "tpg", - regionMesh().time().timeName(), - regionMesh().thisDb() - ), - regionMesh(), - dimensionedScalar(dimPressure, Zero) - ) + "tpg", + IOobjectOption::NO_REGISTER, + regionMesh(), + dimensionedScalar(dimPressure, Zero) ); auto& pfg = tpg.ref(); @@ -439,19 +411,12 @@ tmp liquidFilmBase::pg() const tmp liquidFilmBase::alpha() const { - tmp talpha + auto talpha = areaScalarField::New ( - new areaScalarField - ( - IOobject - ( - "talpha", - regionMesh().time().timeName(), - regionMesh().thisDb() - ), - regionMesh(), - dimensionedScalar(dimless, Zero) - ) + "talpha", + IOobjectOption::NO_REGISTER, + regionMesh(), + dimensionedScalar(dimless, Zero) ); auto& alpha = talpha.ref(); diff --git a/src/regionFaModels/liquidFilm/subModels/kinematic/filmTurbulenceModel/filmTurbulenceModel/filmTurbulenceModel.C b/src/regionFaModels/liquidFilm/subModels/kinematic/filmTurbulenceModel/filmTurbulenceModel/filmTurbulenceModel.C index a6c8b42f4a..93b54a3ce0 100644 --- a/src/regionFaModels/liquidFilm/subModels/kinematic/filmTurbulenceModel/filmTurbulenceModel/filmTurbulenceModel.C +++ b/src/regionFaModels/liquidFilm/subModels/kinematic/filmTurbulenceModel/filmTurbulenceModel/filmTurbulenceModel.C @@ -102,18 +102,13 @@ const liquidFilmBase& filmTurbulenceModel::film() const tmp filmTurbulenceModel::Cw() const { - auto tCw = - tmp::New - ( - IOobject - ( - "tCw", - film_.regionMesh().time().timeName(), - film_.regionMesh().thisDb() - ), - film_.regionMesh(), - dimensionedScalar(dimVelocity) - ); + auto tCw = areaScalarField::New + ( + "tCw", + IOobject::NO_REGISTER, + film_.regionMesh(), + dimensionedScalar(dimVelocity, Zero) + ); auto& Cw = tCw.ref(); @@ -195,10 +190,8 @@ tmp filmTurbulenceModel::primaryRegionFriction areaVectorField& U ) const { - tmp tshearStress - ( - new faVectorMatrix(U, sqr(U.dimensions())*sqr(dimLength)) - ); + auto tshearStress = + tmp::New(U, sqr(U.dimensions())*sqr(dimLength)); switch (shearMethod_) { @@ -267,14 +260,10 @@ tmp filmTurbulenceModel::primaryRegionFriction } } - auto taForce = tmp::New + auto taForce = areaVectorField::New ( - IOobject - ( - "taForce", - film_.regionMesh().time().timeName(), - film_.regionMesh().thisDb() - ), + "taForce", + IOobject::NO_REGISTER, film_.regionMesh(), dimensionedVector(sqr(dimVelocity), Zero) ); @@ -352,32 +341,30 @@ tmp filmTurbulenceModel::devRhoReff() const << "No valid model for viscous stress calculation" << exit(FatalError); - return volSymmTensorField::null(); + return nullptr; } } tmp filmTurbulenceModel::rho() const { - const fvMesh& m = film_.primaryMesh(); + const fvMesh& mesh = film_.primaryMesh(); + if (rhoName_ == "rhoInf") { - return tmp::New + return volScalarField::New ( - IOobject - ( - "rho", - m.time().timeName(), - m - ), - m, + "rho", + IOobject::NO_REGISTER, + mesh, dimensionedScalar(dimDensity, rhoRef_) ); } - return m.lookupObject(rhoName_); + return mesh.lookupObject(rhoName_); } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace areaSurfaceFilmModels diff --git a/src/regionFaModels/liquidFilm/subModels/kinematic/force/forceList/forceList.C b/src/regionFaModels/liquidFilm/subModels/kinematic/force/forceList/forceList.C index ea0c634fce..78e2ed4966 100644 --- a/src/regionFaModels/liquidFilm/subModels/kinematic/force/forceList/forceList.C +++ b/src/regionFaModels/liquidFilm/subModels/kinematic/force/forceList/forceList.C @@ -81,11 +81,8 @@ forceList::~forceList() tmp forceList::correct(areaVectorField& U) { - tmp tResult - ( - new faVectorMatrix(U, dimForce/dimDensity) - ); - faVectorMatrix& result = tResult.ref(); + auto tResult = tmp::New(U, dimForce/dimDensity); + auto& result = tResult.ref(); forAll(*this, i) { diff --git a/src/regionFaModels/liquidFilm/subModels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C b/src/regionFaModels/liquidFilm/subModels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C index 46599c9750..69e33a08f3 100644 --- a/src/regionFaModels/liquidFilm/subModels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C +++ b/src/regionFaModels/liquidFilm/subModels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C @@ -61,9 +61,11 @@ tmp curvatureSeparation::calcInvR1 { const dimensionedScalar smallU(dimVelocity, ROOTVSMALL); const areaVectorField UHat(U/(mag(U) + smallU)); - tmp tinvR1 + auto tinvR1 = areaScalarField::New ( - new areaScalarField("invR1", UHat & (UHat & -gradNHat_)) + "invR1", + IOobjectOption::NO_REGISTER, + (UHat & (UHat & -gradNHat_)) ); scalarField& invR1 = tinvR1.ref().primitiveFieldRef(); diff --git a/src/regionFaModels/thermalShell/thermalShell.C b/src/regionFaModels/thermalShell/thermalShell.C index 3fa2465dd9..ede4196f9a 100644 --- a/src/regionFaModels/thermalShell/thermalShell.C +++ b/src/regionFaModels/thermalShell/thermalShell.C @@ -182,73 +182,43 @@ void thermalShell::evolveRegion() const tmp thermalShell::Cp() const { - return tmp + return areaScalarField::New ( - new areaScalarField - ( - IOobject - ( - "Cps", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - regionMesh(), - dimensionedScalar(dimEnergy/dimTemperature/dimMass, thermo_.Cp()), - faPatchFieldBase::zeroGradientType() - ) + "Cps", + IOobject::NO_REGISTER, + regionMesh(), + dimensionedScalar(dimEnergy/dimTemperature/dimMass, thermo_.Cp()), + faPatchFieldBase::zeroGradientType() ); } const tmp thermalShell::rho() const { - return tmp + return areaScalarField::New ( - new areaScalarField - ( - IOobject - ( - "rhos", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - regionMesh(), - dimensionedScalar(dimDensity, thermo_.rho()), - faPatchFieldBase::zeroGradientType() - ) + "rhos", + IOobject::NO_REGISTER, + regionMesh(), + dimensionedScalar(dimDensity, thermo_.rho()), + faPatchFieldBase::zeroGradientType() ); } const tmp thermalShell::kappa() const { - return tmp + return areaScalarField::New ( - new areaScalarField + "kappas", + IOobject::NO_REGISTER, + regionMesh(), + dimensionedScalar ( - IOobject - ( - "kappas", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - regionMesh(), - dimensionedScalar - ( - dimPower/dimLength/dimTemperature, - thermo_.kappa() - ), - faPatchFieldBase::zeroGradientType() - ) + dimPower/dimLength/dimTemperature, + thermo_.kappa() + ), + faPatchFieldBase::zeroGradientType() ); } diff --git a/src/regionModels/regionModel/regionModel1D/regionModel1D.C b/src/regionModels/regionModel/regionModel1D/regionModel1D.C index 4b3e66278f..b365b5c346 100644 --- a/src/regionModels/regionModel/regionModel1D/regionModel1D.C +++ b/src/regionModels/regionModel/regionModel1D/regionModel1D.C @@ -42,7 +42,6 @@ namespace regionModels void Foam::regionModels::regionModel1D::constructMeshObjects() { - nMagSfPtr_.reset ( new surfaceScalarField @@ -53,7 +52,8 @@ void Foam::regionModels::regionModel1D::constructMeshObjects() time().timeName(), regionMesh(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ), regionMesh(), dimensionedScalar(dimArea, Zero) @@ -197,8 +197,8 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh const scalar minDelta ) { - tmp tcellMoveMap(new labelField(regionMesh().nCells(), Zero)); - labelField& cellMoveMap = tcellMoveMap.ref(); + auto tcellMoveMap = tmp::New(regionMesh().nCells(), Zero); + auto& cellMoveMap = tcellMoveMap.ref(); if (!moveMesh_) { diff --git a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C index 871fdcc199..94f6598400 100644 --- a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C +++ b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C @@ -56,7 +56,8 @@ void Foam::regionModels::singleLayerRegion::constructMeshObjects() time_.timeName(), regionMesh(), IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ), regionMesh(), dimensionedVector(dimless, Zero), @@ -75,7 +76,8 @@ void Foam::regionModels::singleLayerRegion::constructMeshObjects() time_.timeName(), regionMesh(), IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ), regionMesh(), dimensionedScalar(dimArea, Zero), diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 58a6beeb1b..a35106bc1f 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -108,14 +108,9 @@ void kinematicSingleLayer::transferPrimaryRegionSourceFields() { DebugInFunction << endl; - volScalarField::Boundary& rhoSpPrimaryBf = - rhoSpPrimary_.boundaryFieldRef(); - - volVectorField::Boundary& USpPrimaryBf = - USpPrimary_.boundaryFieldRef(); - - volScalarField::Boundary& pSpPrimaryBf = - pSpPrimary_.boundaryFieldRef(); + auto& rhoSpPrimaryBf = rhoSpPrimary_.boundaryFieldRef(); + auto& USpPrimaryBf = USpPrimary_.boundaryFieldRef(); + auto& pSpPrimaryBf = pSpPrimary_.boundaryFieldRef(); // Convert accumulated source terms into per unit area per unit time const scalar deltaT = time_.deltaTValue(); @@ -161,18 +156,11 @@ void kinematicSingleLayer::transferPrimaryRegionSourceFields() tmp kinematicSingleLayer::pu() { - return tmp + return volScalarField::New ( - new volScalarField + IOobject::scopedName(typeName, "pu"), + IOobject::NO_REGISTER, ( - IOobject - ( - typeName + ":pu", - time_.timeName(), - regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), pPrimary_ // pressure (mapped from primary region) - pSp_ // accumulated particle impingement - fvc::laplacian(sigma_, delta_) // surface tension @@ -183,18 +171,11 @@ tmp kinematicSingleLayer::pu() tmp kinematicSingleLayer::pp() { - return tmp + return volScalarField::New ( - new volScalarField + IOobject::scopedName(typeName, "pp"), + IOobject::NO_REGISTER, ( - IOobject - ( - typeName + ":pp", - time_.timeName(), - regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), -rho_*gNormClipped() // hydrostatic effect only ) ); @@ -1084,17 +1065,10 @@ void kinematicSingleLayer::info() tmp kinematicSingleLayer::Srho() const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - typeName + ":Srho", - time().timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "Srho"), + IOobject::NO_REGISTER, primaryMesh(), dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); @@ -1106,17 +1080,10 @@ tmp kinematicSingleLayer::Srho const label i ) const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - typeName + ":Srho(" + Foam::name(i) + ")", - time().timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "Srho(" + Foam::name(i) + ")"), + IOobject::NO_REGISTER, primaryMesh(), dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); @@ -1125,17 +1092,10 @@ tmp kinematicSingleLayer::Srho tmp kinematicSingleLayer::Sh() const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - typeName + ":Sh", - time().timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "Sh"), + IOobject::NO_REGISTER, primaryMesh(), dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayerI.H b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayerI.H index 5a022e964b..9cff5b9bd7 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayerI.H +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayerI.H @@ -211,45 +211,25 @@ inline tmp kinematicSingleLayer::deltaMass() const inline tmp kinematicSingleLayer::gNorm() const { - tmp tgNorm + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "gNorm", - time().timeName(), - regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - g_ & nHat() - ) + "gNorm", + IOobject::NO_REGISTER, + g_ & nHat() ); - - return tgNorm; } inline tmp kinematicSingleLayer::gNormClipped() const { - tmp tgNormClipped + auto tgNormClipped = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "gNormClipped", - time().timeName(), - regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - g_ & nHat() - ) + "gNormClipped", + IOobject::NO_REGISTER, + g_ & nHat() ); + auto& gNormClipped = tgNormClipped.ref(); - volScalarField& gNormClipped = tgNormClipped.ref(); gNormClipped.clamp_max(0); return tgNormClipped; @@ -258,25 +238,15 @@ inline tmp kinematicSingleLayer::gNormClipped() const inline tmp kinematicSingleLayer::gTan() const { - tmp tgTan + return volVectorField::New ( - new volVectorField - ( - IOobject - ( - "gTan", - time().timeName(), - regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - g_ - nHat()*gNorm() - ) + "gTan", + IOobject::NO_REGISTER, + g_ - nHat()*gNorm() ); - - return tgTan; } + inline tmp kinematicSingleLayer::gTan ( const label patchI @@ -284,7 +254,7 @@ inline tmp kinematicSingleLayer::gTan { const vectorField& nH = nHat().boundaryField()[patchI]; const vector& g = g_.value(); - tmp tgTan(new vectorField(g - nH*(g & nH))); + tmp tgTan(g - nH*(g & nH)); return tgTan; } diff --git a/src/regionModels/surfaceFilmModels/noFilm/noFilm.C b/src/regionModels/surfaceFilmModels/noFilm/noFilm.C index 7cad81cd1e..977eb4ec83 100644 --- a/src/regionModels/surfaceFilmModels/noFilm/noFilm.C +++ b/src/regionModels/surfaceFilmModels/noFilm/noFilm.C @@ -74,17 +74,10 @@ Foam::scalar noFilm::CourantNumber() const tmp noFilm::Srho() const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - "noFilm::Srho", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noFilm", "Srho"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); @@ -93,17 +86,10 @@ tmp noFilm::Srho() const tmp noFilm::Srho(const label i) const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - "noFilm::Srho(" + Foam::name(i) + ")", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noFilm", "Srho(" + Foam::name(i) + ")"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); @@ -112,17 +98,10 @@ tmp noFilm::Srho(const label i) const tmp noFilm::Sh() const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - "noFilm::Sh", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noFilm", "Sh"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/constantFilmThermo/constantFilmThermo.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/constantFilmThermo/constantFilmThermo.C index 92d35fc01f..0dd56f30e6 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/constantFilmThermo/constantFilmThermo.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/constantFilmThermo/constantFilmThermo.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -261,22 +262,13 @@ scalar constantFilmThermo::Tb(const scalar p) const tmp constantFilmThermo::rho() const { - tmp trho + auto trho = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ':' + rho0_.name_, - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimDensity, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + IOobject::scopedName(type(), rho0_.name_), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimDensity, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); trho.ref().primitiveFieldRef() = this->rho(0, 0); @@ -288,22 +280,13 @@ tmp constantFilmThermo::rho() const tmp constantFilmThermo::mu() const { - tmp tmu + auto tmu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ':' + mu0_.name_, - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimPressure*dimTime, Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), mu0_.name_), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimPressure*dimTime, Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); tmu.ref().primitiveFieldRef() = this->mu(0, 0); @@ -315,22 +298,13 @@ tmp constantFilmThermo::mu() const tmp constantFilmThermo::sigma() const { - tmp tsigma + auto tsigma = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ':' + sigma0_.name_, - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimMass/sqr(dimTime), Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), sigma0_.name_), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimMass/sqr(dimTime), Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); tsigma.ref().primitiveFieldRef() = this->sigma(0, 0); @@ -342,22 +316,13 @@ tmp constantFilmThermo::sigma() const tmp constantFilmThermo::Cp() const { - tmp tCp + auto tCp = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ':' + Cp0_.name_, - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimEnergy/dimMass/dimTemperature, Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), Cp0_.name_), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimEnergy/dimMass/dimTemperature, Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); tCp.ref().primitiveFieldRef() = this->Cp(0, 0); @@ -369,22 +334,13 @@ tmp constantFilmThermo::Cp() const tmp constantFilmThermo::kappa() const { - tmp tkappa + auto tkappa = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ':' + kappa0_.name_, - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimPower/dimLength/dimTemperature, Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), kappa0_.name_), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimPower/dimLength/dimTemperature, Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); tkappa.ref().primitiveFieldRef() = this->kappa(0, 0); diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C index bded086e11..d0a70fe702 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -244,24 +245,14 @@ scalar liquidFilmThermo::Tb(const scalar p) const tmp liquidFilmThermo::rho() const { - tmp trho + auto trho = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ":rho", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimDensity, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + IOobject::scopedName(type(), "rho"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimDensity, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); - scalarField& rho = trho.ref().primitiveFieldRef(); if (useReferenceValues_) @@ -289,24 +280,14 @@ tmp liquidFilmThermo::rho() const tmp liquidFilmThermo::mu() const { - tmp tmu + auto tmu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ":mu", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimPressure*dimTime, Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), "mu"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimPressure*dimTime, Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); - scalarField& mu = tmu.ref().primitiveFieldRef(); if (useReferenceValues_) @@ -334,24 +315,14 @@ tmp liquidFilmThermo::mu() const tmp liquidFilmThermo::sigma() const { - tmp tsigma + auto tsigma = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ":sigma", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimMass/sqr(dimTime), Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), "sigma"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimMass/sqr(dimTime), Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); - scalarField& sigma = tsigma.ref().primitiveFieldRef(); if (useReferenceValues_) @@ -379,24 +350,14 @@ tmp liquidFilmThermo::sigma() const tmp liquidFilmThermo::Cp() const { - tmp tCp + auto tCp = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ":Cp", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimEnergy/dimMass/dimTemperature, Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), "Cp"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimEnergy/dimMass/dimTemperature, Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); - scalarField& Cp = tCp.ref().primitiveFieldRef(); if (useReferenceValues_) @@ -424,24 +385,14 @@ tmp liquidFilmThermo::Cp() const tmp liquidFilmThermo::kappa() const { - tmp tkappa + auto tkappa = volScalarField::New ( - new volScalarField - ( - IOobject - ( - type() + ":kappa", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimPower/dimLength/dimTemperature, Zero), - extrapolatedCalculatedFvPatchScalarField::typeName - ) + IOobject::scopedName(type(), "kappa"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimPower/dimLength/dimTemperature, Zero), + extrapolatedCalculatedFvPatchScalarField::typeName ); - scalarField& kappa = tkappa.ref().primitiveFieldRef(); if (useReferenceValues_) diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmTurbulenceModel/laminar/laminar.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmTurbulenceModel/laminar/laminar.C index e91094ada8..28fc595be5 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmTurbulenceModel/laminar/laminar.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmTurbulenceModel/laminar/laminar.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,22 +73,13 @@ laminar::~laminar() tmp laminar::Us() const { - tmp tUs + auto tUs = volVectorField::New ( - new volVectorField - ( - IOobject - ( - typeName + ":Us", - filmModel_.regionMesh().time().timeName(), - filmModel_.regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - filmModel_.regionMesh(), - dimensionedVector(dimVelocity, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + IOobject::scopedName(typeName, "Us"), + IOobject::NO_REGISTER, + filmModel_.regionMesh(), + dimensionedVector(dimVelocity, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); // apply quadratic profile @@ -100,16 +92,10 @@ tmp laminar::Us() const tmp laminar::mut() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - typeName + ":mut", - filmModel_.regionMesh().time().timeName(), - filmModel_.regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(typeName, "mut"), + IOobject::NO_REGISTER, filmModel_.regionMesh(), dimensionedScalar(dimMass/dimLength/dimTime, Zero) ); diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/contactAngleForce/contactAngleForce.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/contactAngleForce/contactAngleForce.C index e88d983f08..0394eb3a67 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/contactAngleForce/contactAngleForce.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/contactAngleForce/contactAngleForce.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,14 +107,15 @@ contactAngleForce::contactAngleForce ( IOobject ( - typeName + ":contactForceMask", + IOobject::scopedName(typeName, "contactForceMask"), filmModel_.time().timeName(), filmModel_.regionMesh(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ), filmModel_.regionMesh(), - dimensionedScalar("mask", dimless, 1.0) + dimensionedScalar(word::null, dimless, 1.0) ) { initialise(); @@ -131,24 +132,14 @@ contactAngleForce::~contactAngleForce() tmp contactAngleForce::correct(volVectorField& U) { - tmp tForce + auto tForce = volVectorField::New ( - new volVectorField - ( - IOobject - ( - typeName + ":contactForce", - filmModel_.time().timeName(), - filmModel_.regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - filmModel_.regionMesh(), - dimensionedVector(dimForce/dimArea, Zero) - ) + IOobject::scopedName(typeName, "contactForce"), + IOobject::NO_REGISTER, + filmModel_.regionMesh(), + dimensionedVector(dimForce/dimArea, Zero) ); - - vectorField& force = tForce.ref().primitiveFieldRef(); + auto& force = tForce.ref().primitiveFieldRef(); const labelUList& own = filmModel_.regionMesh().owner(); const labelUList& nbr = filmModel_.regionMesh().neighbour(); @@ -226,10 +217,7 @@ tmp contactAngleForce::correct(volVectorField& U) tForce().write(); } - tmp tfvm - ( - new fvVectorMatrix(U, dimForce/dimArea*dimVolume) - ); + auto tfvm = tmp::New(U, dimForce/dimArea*dimVolume); tfvm.ref() += tForce; diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/distribution/distributionContactAngleForce.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/distribution/distributionContactAngleForce.C index 514fdb0ab8..6edb0ecd7a 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/distribution/distributionContactAngleForce.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/distribution/distributionContactAngleForce.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -74,34 +75,26 @@ distributionContactAngleForce::~distributionContactAngleForce() tmp distributionContactAngleForce::theta() const { - tmp ttheta + auto ttheta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - typeName + ":theta", - filmModel_.time().timeName(), - filmModel_.regionMesh() - ), - filmModel_.regionMesh(), - dimensionedScalar(dimless, Zero) - ) + IOobject::scopedName(typeName, "theta"), + IOobject::NO_REGISTER, + filmModel_.regionMesh(), + dimensionedScalar(dimless, Zero) ); + auto& thetaIf = ttheta.ref().internalFieldRef(); + auto& thetaBf = ttheta.ref().boundaryFieldRef(); - volScalarField& theta = ttheta.ref(); - volScalarField::Internal& thetai = theta.ref(); - - forAll(thetai, celli) + forAll(thetaIf, celli) { - thetai[celli] = distribution_->sample(); + thetaIf[celli] = distribution_->sample(); } - forAll(theta.boundaryField(), patchi) + forAll(thetaBf, patchi) { if (!filmModel_.isCoupledPatch(patchi)) { - fvPatchField& thetaf = theta.boundaryFieldRef()[patchi]; + fvPatchField& thetaf = thetaBf[patchi]; forAll(thetaf, facei) { @@ -113,6 +106,7 @@ tmp distributionContactAngleForce::theta() const return ttheta; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace surfaceFilmModels diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/perturbedTemperatureDependent/perturbedTemperatureDependentContactAngleForce.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/perturbedTemperatureDependent/perturbedTemperatureDependentContactAngleForce.C index f6ff1170d6..f22860ad72 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/perturbedTemperatureDependent/perturbedTemperatureDependentContactAngleForce.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/perturbedTemperatureDependent/perturbedTemperatureDependentContactAngleForce.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,40 +84,32 @@ perturbedTemperatureDependentContactAngleForce:: tmp perturbedTemperatureDependentContactAngleForce::theta() const { - tmp ttheta + auto ttheta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - typeName + ":theta", - filmModel_.time().timeName(), - filmModel_.regionMesh() - ), - filmModel_.regionMesh(), - dimensionedScalar(dimless, Zero) - ) + IOobject::scopedName(typeName, "theta"), + IOobject::NO_REGISTER, + filmModel_.regionMesh(), + dimensionedScalar(dimless, Zero) ); - - volScalarField& theta = ttheta.ref(); - volScalarField::Internal& thetai = theta.ref(); + auto& thetaIf = ttheta.ref().internalFieldRef(); + auto& thetaBf = ttheta.ref().boundaryFieldRef(); const volScalarField& T = filmModel_.T(); // Initialize with the function of temperature - thetai.field() = thetaPtr_->value(T()); + thetaIf.field() = thetaPtr_->value(T()); // Add the stochastic perturbation - forAll(thetai, celli) + forAll(thetaIf, celli) { - thetai[celli] += distribution_->sample(); + thetaIf[celli] += distribution_->sample(); } - forAll(theta.boundaryField(), patchi) + forAll(thetaBf, patchi) { if (!filmModel_.isCoupledPatch(patchi)) { - fvPatchField& thetaf = theta.boundaryFieldRef()[patchi]; + fvPatchField& thetaf = thetaBf[patchi]; // Initialize with the function of temperature thetaf = thetaPtr_->value(T.boundaryField()[patchi]); @@ -132,6 +125,7 @@ perturbedTemperatureDependentContactAngleForce::theta() const return ttheta; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace surfaceFilmModels diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/temperatureDependent/temperatureDependentContactAngleForce.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/temperatureDependent/temperatureDependentContactAngleForce.C index d78200a0a6..4b35841929 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/temperatureDependent/temperatureDependentContactAngleForce.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/contactAngleForces/temperatureDependent/temperatureDependentContactAngleForce.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,39 +72,32 @@ temperatureDependentContactAngleForce::~temperatureDependentContactAngleForce() tmp temperatureDependentContactAngleForce::theta() const { - tmp ttheta + auto ttheta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - typeName + ":theta", - filmModel_.time().timeName(), - filmModel_.regionMesh() - ), - filmModel_.regionMesh(), - dimensionedScalar(dimless, Zero) - ) + IOobject::scopedName(typeName, "theta"), + IOobject::NO_REGISTER, + filmModel_.regionMesh(), + dimensionedScalar(dimless, Zero) ); - - volScalarField& theta = ttheta.ref(); + auto& thetaIf = ttheta.ref().internalFieldRef(); + auto& thetaBf = ttheta.ref().boundaryFieldRef(); const volScalarField& T = filmModel_.T(); - theta.ref().field() = thetaPtr_->value(T()); + thetaIf.field() = thetaPtr_->value(T()); - forAll(theta.boundaryField(), patchi) + forAll(thetaBf, patchi) { if (!filmModel_.isCoupledPatch(patchi)) { - theta.boundaryFieldRef()[patchi] = - thetaPtr_->value(T.boundaryField()[patchi]); + thetaBf[patchi] = thetaPtr_->value(T.boundaryField()[patchi]); } } return ttheta; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace surfaceFilmModels diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/forceList/forceList.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/forceList/forceList.C index 6972aca86c..eb8962e471 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/forceList/forceList.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/forceList/forceList.C @@ -79,11 +79,8 @@ forceList::~forceList() tmp forceList::correct(volVectorField& U) { - tmp tResult - ( - new fvVectorMatrix(U, dimForce/dimArea*dimVolume) - ); - fvVectorMatrix& result = tResult.ref(); + auto tResult = tmp::New(U, dimForce/dimArea*dimVolume); + auto& result = tResult.ref(); forAll(*this, i) { diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/thermocapillaryForce/thermocapillaryForce.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/thermocapillaryForce/thermocapillaryForce.C index fddbee7d37..db48dc0e54 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/force/thermocapillaryForce/thermocapillaryForce.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/force/thermocapillaryForce/thermocapillaryForce.C @@ -68,8 +68,7 @@ tmp thermocapillaryForce::correct(volVectorField& U) const volScalarField& alpha = filmModel_.alpha(); const volScalarField& sigma = filmModel_.sigma(); - tmp - tfvm(new fvVectorMatrix(U, dimForce/dimArea*dimVolume)); + auto tfvm = tmp::New(U, dimForce/dimArea*dimVolume); tfvm.ref() += alpha*fvc::grad(sigma); diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C index 11c405527a..6cf20ab7bc 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/curvatureSeparation/curvatureSeparation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,20 +66,19 @@ tmp curvatureSeparation::calcInvR1 { // method 1 /* - tmp tinvR1 - ( - new volScalarField("invR1", fvc::div(film().nHat())) - ); + auto tinvR1 = volScalarField::New("invR1", fvc::div(film().nHat())); */ // method 2 dimensionedScalar smallU("smallU", dimVelocity, ROOTVSMALL); volVectorField UHat(U/(mag(U) + smallU)); - tmp tinvR1 - ( - new volScalarField("invR1", UHat & (UHat & gradNHat_)) - ); + auto tinvR1 = volScalarField::New + ( + "invR1", + IOobject::NO_REGISTER, + UHat & (UHat & gradNHat_) + ); scalarField& invR1 = tinvR1.ref().primitiveFieldRef(); @@ -197,21 +196,16 @@ tmp curvatureSeparation::calcCosAngle // checks if (debug && mesh.time().writeTime()) { - volScalarField volCosAngle + auto tvolCosAngle = volScalarField::New ( - IOobject - ( - "cosAngle", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "cosAngle", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& volCosAngle = tvolCosAngle.ref(); + volCosAngle.primitiveFieldRef() = cosAngle; volCosAngle.correctBoundaryConditions(); volCosAngle.write(); @@ -341,21 +335,16 @@ void curvatureSeparation::correct if (debug && mesh.time().writeTime()) { - volScalarField volFnet + auto tvolFnet = volScalarField::New ( - IOobject - ( - "Fnet", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "Fnet", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimForce, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& volFnet = tvolFnet.ref(); + volFnet.primitiveFieldRef() = Fnet; volFnet.correctBoundaryConditions(); volFnet.write(); diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/constantRadiation/constantRadiation.C b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/constantRadiation/constantRadiation.C index 04607ad05c..48861e4037 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/constantRadiation/constantRadiation.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/constantRadiation/constantRadiation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,7 +63,7 @@ constantRadiation::constantRadiation ( IOobject ( - typeName + ":qrConst", + IOobject::scopedName(typeName, "qrConst"), film.time().timeName(), film.regionMesh().thisDb(), IOobject::MUST_READ, @@ -74,7 +75,7 @@ constantRadiation::constantRadiation ( IOobject ( - typeName + ":mask", + IOobject::scopedName(typeName, "mask"), film.time().timeName(), film.regionMesh().thisDb(), IOobject::READ_IF_PRESENT, @@ -105,28 +106,19 @@ void constantRadiation::correct() tmp constantRadiation::Shs() { - tmp tShs + auto tShs = volScalarField::New ( - new volScalarField - ( - IOobject - ( - typeName + ":Shs", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimMass/pow3(dimTime), Zero) - ) + IOobject::scopedName(typeName, "Shs"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimMass/pow3(dimTime), Zero) ); + auto& Shs = tShs.ref().primitiveFieldRef(); const scalar time = film().time().value(); if ((time >= timeStart_) && (time <= timeStart_ + duration_)) { - scalarField& Shs = tShs.ref(); const scalarField& qr = qrConst_; const scalarField& alpha = filmModel_.alpha(); diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/noRadiation/noRadiation.C b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/noRadiation/noRadiation.C index cb934c6708..3851e8e506 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/noRadiation/noRadiation.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/noRadiation/noRadiation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,16 +76,10 @@ void noRadiation::correct() tmp noRadiation::Shs() { - return tmp::New + return volScalarField::New ( - IOobject - ( - typeName + ":Shs", - film().time().timeName(), - film().regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(typeName, "Shs"), + IOobject::NO_REGISTER, film().regionMesh(), dimensionedScalar(dimMass/pow3(dimTime), Zero) ); diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/primaryRadiation/primaryRadiation.C b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/primaryRadiation/primaryRadiation.C index 38b2b13e72..b53dfa9d5e 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/primaryRadiation/primaryRadiation.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/primaryRadiation/primaryRadiation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +67,8 @@ primaryRadiation::primaryRadiation film.time().timeName(), film.regionMesh().thisDb(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimMass/pow3(dimTime), Zero), @@ -92,24 +94,15 @@ void primaryRadiation::correct() tmp primaryRadiation::Shs() { - tmp tShs + auto tShs = volScalarField::New ( - new volScalarField - ( - IOobject - ( - typeName + ":Shs", - film().time().timeName(), - film().regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimMass/pow3(dimTime), Zero) - ) + IOobject::scopedName(typeName, "Shs"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimMass/pow3(dimTime), Zero) ); - scalarField& Shs = tShs.ref(); + const scalarField& qinP = qinPrimary_; const scalarField& alpha = filmModel_.alpha(); diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/standardRadiation/standardRadiation.C b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/standardRadiation/standardRadiation.C index fd39725570..9fabe064fb 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/standardRadiation/standardRadiation.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmRadiationModel/standardRadiation/standardRadiation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,7 +68,8 @@ standardRadiation::standardRadiation film.time().timeName(), film.regionMesh().thisDb(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimMass/pow3(dimTime), Zero), @@ -81,7 +83,8 @@ standardRadiation::standardRadiation film.time().timeName(), film.regionMesh().thisDb(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimMass/pow3(dimTime), Zero), @@ -103,24 +106,15 @@ void standardRadiation::correct() tmp standardRadiation::Shs() { - tmp tShs + auto tShs = volScalarField::New ( - new volScalarField - ( - IOobject - ( - typeName + ":Shs", - film().time().timeName(), - film().regionMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - film().regionMesh(), - dimensionedScalar(dimMass/pow3(dimTime), Zero) - ) + IOobject::scopedName(typeName, "Shs"), + IOobject::NO_REGISTER, + film().regionMesh(), + dimensionedScalar(dimMass/pow3(dimTime), Zero) ); - scalarField& Shs = tShs.ref(); + const scalarField& qinP = qinPrimary_; const scalarField& delta = filmModel_.delta(); const scalarField& alpha = filmModel_.alpha(); diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.C b/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.C index 67d8e792b8..058cb62aed 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,11 +77,12 @@ thixotropicViscosity::thixotropicViscosity ( IOobject ( - typeName + ":lambda", + IOobject::scopedName(typeName, "lambda"), film.regionMesh().time().timeName(), film.regionMesh().thisDb(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), film.regionMesh() ) diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/waxSolventViscosity/waxSolventViscosity.C b/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/waxSolventViscosity/waxSolventViscosity.C index df4c6ab9a8..6bbd2cbfc9 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/waxSolventViscosity/waxSolventViscosity.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/waxSolventViscosity/waxSolventViscosity.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,37 +58,29 @@ void waxSolventViscosity::correctMu() { const kinematicSingleLayer& film = filmType(); - const uniformDimensionedScalarField Wwax - ( + const auto& Wwax = film.regionMesh().lookupObject ( - waxSolventEvaporation::typeName + ":Wwax" - ) - ); + IOobject::scopedName(waxSolventEvaporation::typeName, "Wwax") + ); - const uniformDimensionedScalarField Wsolvent - ( + const auto& Wsolvent = film.regionMesh().lookupObject ( - waxSolventEvaporation::typeName + ":Wsolvent" - ) - ); + IOobject::scopedName(waxSolventEvaporation::typeName, "Wsolvent") + ); - const uniformDimensionedScalarField Ysolvent0 - ( + const auto& Ysolvent0 = film.regionMesh().lookupObject ( - waxSolventEvaporation::typeName + ":Ysolvent0" - ) - ); + IOobject::scopedName(waxSolventEvaporation::typeName, "Ysolvent0") + ); - const volScalarField& Ysolvent - ( + const auto& Ysolvent = film.regionMesh().lookupObject ( - waxSolventEvaporation::typeName + ":Ysolvent" - ) - ); + IOobject::scopedName(waxSolventEvaporation::typeName, "Ysolvent") + ); const volScalarField Xsolvent ( @@ -118,11 +111,12 @@ waxSolventViscosity::waxSolventViscosity ( IOobject ( - typeName + ":muWax", + IOobject::scopedName(typeName, "muWax"), film.regionMesh().time().timeName(), film.regionMesh().thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimDynamicViscosity, Zero), @@ -141,11 +135,12 @@ waxSolventViscosity::waxSolventViscosity ( IOobject ( - typeName + ":muSolvent", + IOobject::scopedName(typeName, "muSolvent"), film.regionMesh().time().timeName(), film.regionMesh().thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimDynamicViscosity, Zero), diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/heatTransferModel/constantHeatTransfer/constantHeatTransfer.C b/src/regionModels/surfaceFilmModels/submodels/thermo/heatTransferModel/constantHeatTransfer/constantHeatTransfer.C index 9bdae5059c..518e50b1e6 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/heatTransferModel/constantHeatTransfer/constantHeatTransfer.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/heatTransferModel/constantHeatTransfer/constantHeatTransfer.C @@ -76,26 +76,16 @@ void constantHeatTransfer::correct() tmp constantHeatTransfer::h() const { - return tmp + return volScalarField::New ( - new volScalarField + "htc", + IOobject::NO_REGISTER, + filmModel_.regionMesh(), + dimensionedScalar ( - IOobject - ( - "htc", - filmModel_.time().timeName(), - filmModel_.regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - filmModel_.regionMesh(), - dimensionedScalar - ( - "c0", - dimEnergy/dimTime/sqr(dimLength)/dimTemperature, - c0_ - ) + "c0", + dimEnergy/dimTime/sqr(dimLength)/dimTemperature, + c0_ ) ); } diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C index dd7ecd529a..1c36295efc 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,11 +75,12 @@ solidification::solidification ( IOobject ( - typeName + ":mass", + IOobject::scopedName(typeName, "mass"), film.regionMesh().time().timeName(), film.regionMesh().thisDb(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimMass, Zero), @@ -89,11 +90,12 @@ solidification::solidification ( IOobject ( - typeName + ":thickness", + IOobject::scopedName(typeName, "thickness"), film.regionMesh().time().timeName(), film.regionMesh().thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), film.regionMesh(), dimensionedScalar(dimLength, Zero), diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/waxSolventEvaporation/waxSolventEvaporation.C b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/waxSolventEvaporation/waxSolventEvaporation.C index 13ab7a4d15..b59786b74a 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/waxSolventEvaporation/waxSolventEvaporation.C +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/waxSolventEvaporation/waxSolventEvaporation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,9 +88,12 @@ waxSolventEvaporation::waxSolventEvaporation ( IOobject ( - typeName + ":Wwax", + IOobject::scopedName(typeName, "Wwax"), film.regionMesh().time().constant(), - film.regionMesh().thisDb() + film.regionMesh().thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER ), coeffDict_.get("Wwax") ), @@ -98,9 +101,12 @@ waxSolventEvaporation::waxSolventEvaporation ( IOobject ( - typeName + ":Wsolvent", + IOobject::scopedName(typeName, "Wsolvent"), film.regionMesh().time().constant(), - film.regionMesh().thisDb() + film.regionMesh().thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::REGISTER ), coeffDict_.get("Wsolvent") ), @@ -108,22 +114,24 @@ waxSolventEvaporation::waxSolventEvaporation ( IOobject ( - typeName + ":Ysolvent0", + IOobject::scopedName(typeName, "Ysolvent0"), film.regionMesh().time().constant(), film.regionMesh().thisDb(), IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ) ), Ysolvent_ ( IOobject ( - typeName + ":Ysolvent", + IOobject::scopedName(typeName, "Ysolvent"), film.regionMesh().time().timeName(), film.regionMesh().thisDb(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), film.regionMesh() ), @@ -187,35 +195,21 @@ void waxSolventEvaporation::correctModel const scalar Wwax = Wwax_.value(); const scalar Wsolvent = Wsolvent_.value(); - volScalarField::Internal evapRateCoeff + auto tevapRateCoeff = volScalarField::Internal::New ( - IOobject - ( - typeName + ":evapRateCoeff", - film.regionMesh().time().timeName(), - film.regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "evapRateCoeff"), film.regionMesh(), dimensionedScalar(dimDensity*dimVelocity, Zero) ); + auto& evapRateCoeff = tevapRateCoeff.ref(); - volScalarField::Internal evapRateInf + auto tevapRateInf = volScalarField::Internal::New ( - IOobject - ( - typeName + ":evapRateInf", - film.regionMesh().time().timeName(), - film.regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "evapRateInf"), film.regionMesh(), dimensionedScalar(dimDensity*dimVelocity, Zero) ); + auto& evapRateInf = tevapRateInf.ref(); bool filmPresent = false; diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C index 9202742a83..ba9bf0b0cb 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C @@ -327,7 +327,8 @@ thermoSingleLayer::thermoSingleLayer regionMesh().time().timeName(), regionMesh().thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), regionMesh(), dimensionedScalar(dimEnergy/dimMass/dimTemperature, Zero), @@ -341,7 +342,8 @@ thermoSingleLayer::thermoSingleLayer regionMesh().time().timeName(), regionMesh().thisDb(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), regionMesh(), dimensionedScalar(dimEnergy/dimTime/dimLength/dimTemperature, Zero), @@ -356,7 +358,8 @@ thermoSingleLayer::thermoSingleLayer regionMesh().time().timeName(), regionMesh().thisDb(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), regionMesh() ), @@ -705,38 +708,28 @@ void thermoSingleLayer::info() tmp thermoSingleLayer::Srho() const { - tmp tSrho + auto tSrho = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - typeName + ":Srho", - time().timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - primaryMesh(), - dimensionedScalar(dimMass/dimVolume/dimTime, Zero) - ) + IOobject::scopedName(typeName, "Srho"), + IOobject::NO_REGISTER, + primaryMesh(), + dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); - scalarField& Srho = tSrho.ref(); + const scalarField& V = primaryMesh().V(); const scalar dt = time_.deltaTValue(); forAll(intCoupledPatchIDs(), i) { const label filmPatchi = intCoupledPatchIDs()[i]; + const label primaryPatchi = primaryPatchIDs()[i]; scalarField patchMass = primaryMassTrans_.boundaryField()[filmPatchi]; toPrimary(filmPatchi, patchMass); - const label primaryPatchi = primaryPatchIDs()[i]; const labelUList& cells = primaryMesh().boundaryMesh()[primaryPatchi].faceCells(); @@ -757,40 +750,30 @@ tmp thermoSingleLayer::Srho { const label vapId = thermo_.carrierId(filmThermo_->name()); - tmp tSrho + auto tSrho = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - typeName + ":Srho(" + Foam::name(i) + ")", - time_.timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - primaryMesh(), - dimensionedScalar(dimMass/dimVolume/dimTime, Zero) - ) + IOobject::scopedName(typeName, "Srho(" + Foam::name(i) + ")"), + IOobject::NO_REGISTER, + primaryMesh(), + dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); + scalarField& Srho = tSrho.ref(); if (vapId == i) { - scalarField& Srho = tSrho.ref(); const scalarField& V = primaryMesh().V(); const scalar dt = time().deltaTValue(); forAll(intCoupledPatchIDs_, i) { const label filmPatchi = intCoupledPatchIDs_[i]; + const label primaryPatchi = primaryPatchIDs()[i]; scalarField patchMass = primaryMassTrans_.boundaryField()[filmPatchi]; toPrimary(filmPatchi, patchMass); - const label primaryPatchi = primaryPatchIDs()[i]; const labelUList& cells = primaryMesh().boundaryMesh()[primaryPatchi].faceCells(); @@ -807,38 +790,28 @@ tmp thermoSingleLayer::Srho tmp thermoSingleLayer::Sh() const { - tmp tSh + auto tSh = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - typeName + ":Sh", - time().timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - primaryMesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + IOobject::scopedName(typeName, "Sh"), + IOobject::NO_REGISTER, + primaryMesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); - scalarField& Sh = tSh.ref(); + const scalarField& V = primaryMesh().V(); const scalar dt = time_.deltaTValue(); forAll(intCoupledPatchIDs_, i) { const label filmPatchi = intCoupledPatchIDs_[i]; + const label primaryPatchi = primaryPatchIDs()[i]; scalarField patchEnergy = primaryEnergyTrans_.boundaryField()[filmPatchi]; toPrimary(filmPatchi, patchEnergy); - const label primaryPatchi = primaryPatchIDs()[i]; const labelUList& cells = primaryMesh().boundaryMesh()[primaryPatchi].faceCells(); diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H index e53bd1a16b..3c2ef6ed13 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H @@ -64,20 +64,11 @@ inline tmp thermoSingleLayer::hs const volScalarField& T ) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "hs(" + T.name() + ")", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - Cp_*(T - Tref) - ) + "hs(" + T.name() + ")", + IOobject::NO_REGISTER, + Cp_*(T - Tref) ); } @@ -87,20 +78,11 @@ inline tmp thermoSingleLayer::T const volScalarField& hs ) const { - tmp tT + auto tT = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "T(" + hs.name() + ")", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - hs/Cp_ + Tref - ) + "T(" + hs.name() + ")", + IOobject::NO_REGISTER, + hs/Cp_ + Tref ); if (limitType::CLAMP_MIN == withTbounds_) diff --git a/src/regionModels/thermalBaffleModels/noThermo/noThermo.C b/src/regionModels/thermalBaffleModels/noThermo/noThermo.C index 755c3a4e4e..40e96f6d93 100644 --- a/src/regionModels/thermalBaffleModels/noThermo/noThermo.C +++ b/src/regionModels/thermalBaffleModels/noThermo/noThermo.C @@ -92,24 +92,7 @@ const tmp noThermo::Cp() const FatalErrorInFunction << "Cp field not available for " << type() << abort(FatalError); - - return tmp - ( - new volScalarField - ( - IOobject - ( - "noThermo::Cp", - time().timeName(), - primaryMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - primaryMesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) - ); + return nullptr; } const volScalarField& noThermo::kappaRad() const diff --git a/src/regionModels/thermalBaffleModels/thermalBaffle/thermalBaffle.C b/src/regionModels/thermalBaffleModels/thermalBaffle/thermalBaffle.C index 75aa061458..a5e915dcd3 100644 --- a/src/regionModels/thermalBaffleModels/thermalBaffle/thermalBaffle.C +++ b/src/regionModels/thermalBaffleModels/thermalBaffle/thermalBaffle.C @@ -72,25 +72,14 @@ void thermalBaffle::solveEnergy() const polyBoundaryMesh& rbm = regionMesh().boundaryMesh(); - tmp tQ + auto tQ = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tQ", - regionMesh().time().timeName(), - regionMesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - regionMesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + "tQ", + IOobject::NO_REGISTER, + regionMesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); - - volScalarField& Q = tQ.ref(); + auto& Q = tQ.ref(); volScalarField rho("rho", thermo_->rho()); volScalarField alpha("alpha", thermo_->alpha()); From 995a9705e23dad02d1c23a8de1a3771b6af6a221 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:07:00 +0100 Subject: [PATCH 06/13] ENH: use tmp field factory methods [5] (#2723) - src/lagrangian --- .../clouds/Templates/DSMCCloud/DSMCCloud.C | 55 +++++--- .../coalCloudList/coalCloudListI.H | 128 ++++++------------ .../Templates/KinematicCloud/KinematicCloud.C | 19 ++- .../KinematicCloud/KinematicCloudI.H | 113 ++++------------ .../Templates/ReactingCloud/ReactingCloud.C | 27 +++- .../Templates/ReactingCloud/ReactingCloudI.H | 102 ++++---------- .../Templates/ThermoCloud/ThermoCloud.C | 37 ++--- .../Templates/ThermoCloud/ThermoCloudI.H | 66 +++------ .../KinematicParcelTrackingDataI.H | 19 +-- .../MPPICParcel/MPPICParcelTrackingDataI.H | 18 +-- .../PatchCollisionDensity.C | 72 +++++----- .../PatchInteractionFields.C | 14 +- .../LocalInteraction/LocalInteraction.C | 18 +-- .../AveragingMethod/AveragingMethod.C | 49 +++---- .../DampingModels/Relaxation/Relaxation.C | 23 ++-- .../IsotropyModels/Stochastic/Stochastic.C | 32 ++--- .../MPPIC/PackingModels/Explicit/Explicit.C | 20 +-- .../MPPIC/PackingModels/Implicit/Implicit.C | 104 ++++++-------- .../ParticleStressModel/ParticleStressModel.C | 10 +- .../cloudAbsorptionEmission.C | 61 +++------ .../scatter/cloudScatter/cloudScatter.C | 28 ++-- 21 files changed, 415 insertions(+), 600 deletions(-) diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index a02de47f9c..f64021f05d 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -473,8 +473,9 @@ Foam::DSMCCloud::DSMCCloud cloudName + "Properties", mesh_.time().constant(), mesh_, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), typeIdList_(particleProperties_.lookup("typeIdList")), @@ -488,7 +489,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -496,7 +498,7 @@ Foam::DSMCCloud::DSMCCloud ( IOobject ( - this->name() + ":collisionSelectionRemainder", + IOobject::scopedName(this->name(), "collisionSelectionRemainder"), mesh_.time().timeName(), mesh_ ), @@ -511,7 +513,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -523,7 +526,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -535,7 +539,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -547,7 +552,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -559,7 +565,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -571,7 +578,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -583,7 +591,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -595,7 +604,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -607,7 +617,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -621,7 +632,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -633,7 +645,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -698,8 +711,9 @@ Foam::DSMCCloud::DSMCCloud cloudName + "Properties", mesh_.time().constant(), mesh_, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), typeIdList_(particleProperties_.lookup("typeIdList")), @@ -713,7 +727,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimensionSet(0, 3, -1, 0, 0), Zero), @@ -723,7 +738,7 @@ Foam::DSMCCloud::DSMCCloud ( IOobject ( - this->name() + ":collisionSelectionRemainder", + IOobject::scopedName(this->name(), "collisionSelectionRemainder"), mesh_.time().timeName(), mesh_ ), diff --git a/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H b/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H index c4385d7dc2..21e4a2ad42 100644 --- a/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H +++ b/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H @@ -32,24 +32,14 @@ License Foam::tmp> Foam::coalCloudList::UTrans() const { - tmp tfld + auto tfld = volVectorField::Internal::New ( - new volVectorField::Internal - ( - IOobject - ( - "UTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedVector(dimMass*dimVelocity, Zero) - ) + "UTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedVector(dimMass*dimVelocity, Zero) ); - - volVectorField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -65,8 +55,8 @@ Foam::tmp Foam::coalCloudList::SU volVectorField& U ) const { - tmp tfvm(new fvVectorMatrix(U, dimForce)); - fvVectorMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(U, dimForce); + auto& fvm = tfvm.ref(); forAll(*this, i) { @@ -80,24 +70,14 @@ Foam::tmp Foam::coalCloudList::SU Foam::tmp> Foam::coalCloudList::hsTrans() const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "hsTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimEnergy, Zero) - ) + "hsTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimEnergy, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -113,8 +93,8 @@ Foam::tmp Foam::coalCloudList::Sh volScalarField& hs ) const { - tmp tfvm(new fvScalarMatrix(hs, dimEnergy/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(hs, dimEnergy/dimTime); + auto& fvm = tfvm.ref(); forAll(*this, i) { @@ -131,8 +111,8 @@ Foam::tmp Foam::coalCloudList::SYi volScalarField& Yi ) const { - tmp tfvm(new fvScalarMatrix(Yi, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(Yi, dimMass/dimTime); + auto& fvm = tfvm.ref(); forAll(*this, i) { @@ -146,24 +126,14 @@ Foam::tmp Foam::coalCloudList::SYi Foam::tmp> Foam::coalCloudList::rhoTrans() const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "rhoTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimMass, Zero) - ) + "rhoTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -177,29 +147,17 @@ Foam::coalCloudList::rhoTrans() const } - - Foam::tmp> Foam::coalCloudList::Srho() const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "rhoTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimDensity/dimTime, Zero) - ) + "rhoTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimDensity/dimTime, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -216,24 +174,14 @@ Foam::coalCloudList::Srho const label i ) const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "rhoTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimDensity/dimTime, Zero) - ) + "rhoTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimDensity/dimTime, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, j) { @@ -249,8 +197,8 @@ Foam::tmp Foam::coalCloudList::Srho volScalarField& rho ) const { - tmp tfvm(new fvScalarMatrix(rho, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(rho, dimMass/dimTime); + auto& fvm = tfvm.ref(); forAll(*this, i) { diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index f6b57014b4..776d3af811 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -360,8 +360,9 @@ Foam::KinematicCloud::KinematicCloud cloudName + "Properties", mesh_.time().constant(), mesh_, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), outputProperties_ @@ -373,7 +374,8 @@ Foam::KinematicCloud::KinematicCloud "uniform"/cloud::prefix/cloudName, mesh_, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ) ), solution_(mesh_, particleProperties_.subDict("solution")), @@ -438,7 +440,8 @@ Foam::KinematicCloud::KinematicCloud this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass, Zero) @@ -454,7 +457,8 @@ Foam::KinematicCloud::KinematicCloud this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimMass*dimVelocity, Zero) @@ -470,7 +474,8 @@ Foam::KinematicCloud::KinematicCloud this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass, Zero) @@ -571,7 +576,7 @@ Foam::KinematicCloud::KinematicCloud ( IOobject ( - name + ":UCoeff", + IOobject::scopedName(this->name(), "UCoeff"), this->db().time().timeName(), this->db(), IOobject::NO_READ, diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 3ade1a4de5..5651acab61 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -515,24 +515,15 @@ Foam::KinematicCloud::Srhok() const return rhokTrans()/this->db().time().deltaT()/this->mesh().V(); } - return - tmp::New + return tmp::New + ( + this->newIOobject(IOobject::scopedName(this->name(), "rhokTrans")), + this->mesh(), + dimensionedScalar ( - IOobject - ( - IOobject::scopedName(this->name(), "rhokTrans"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar - ( - rhokTrans().dimensions()/dimTime/dimVolume, Zero - ) - ); + rhokTrans().dimensions()/dimTime/dimVolume, Zero + ) + ); } @@ -571,8 +562,8 @@ const } else { - tmp tfvm(new fvVectorMatrix(U, dim)); - fvVectorMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(U, dim); + auto& fvm = tfvm.ref(); fvm.source() = -UTrans()/(this->db().time().deltaT()); @@ -588,26 +579,15 @@ template inline const Foam::tmp Foam::KinematicCloud::vDotSweep() const { - tmp tvDotSweep + auto tvDotSweep = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "vDotSweep"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimTime, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + this->newIOobject(IOobject::scopedName(this->name(), "vDotSweep")), + mesh_, + dimensionedScalar(dimless/dimTime, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); + auto& vDotSweep = tvDotSweep.ref(); - volScalarField& vDotSweep = tvDotSweep.ref(); for (const parcelType& p : *this) { const label celli = p.cell(); @@ -626,26 +606,15 @@ template inline const Foam::tmp Foam::KinematicCloud::theta() const { - tmp ttheta + auto ttheta = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "theta"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + this->newIOobject(IOobject::scopedName(this->name(), "theta")), + mesh_, + dimensionedScalar(dimless, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); + auto& theta = ttheta.ref(); - volScalarField& theta = ttheta.ref(); for (const parcelType& p : *this) { const label celli = p.cell(); @@ -664,22 +633,11 @@ template inline const Foam::tmp Foam::KinematicCloud::alpha() const { - tmp talpha + auto talpha = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "alpha"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless, Zero) - ) + this->newIOobject(IOobject::scopedName(this->name(), "alpha")), + mesh_, + dimensionedScalar(dimless, Zero) ); scalarField& alpha = talpha.ref().primitiveFieldRef(); @@ -700,22 +658,11 @@ template inline const Foam::tmp Foam::KinematicCloud::rhoEff() const { - tmp trhoEff + auto trhoEff = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "rhoEff"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimDensity, Zero) - ) + this->newIOobject(IOobject::scopedName(this->name(), "rhoEff")), + mesh_, + dimensionedScalar(dimDensity, Zero) ); scalarField& rhoEff = trhoEff.ref().primitiveFieldRef(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index 1062223379..8c85ff362b 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -120,7 +120,15 @@ Foam::ReactingCloud::ReactingCloud // Set storage for mass source fields and initialise to zero forAll(rhoTrans_, i) { - const word& specieName = thermo.carrier().species()[i]; + const word fieldName + ( + IOobject::scopedName + ( + this->name(), + "rhoTrans_" + thermo.carrier().species()[i] + ) + ); + rhoTrans_.set ( i, @@ -128,11 +136,12 @@ Foam::ReactingCloud::ReactingCloud ( IOobject ( - this->name() + ":rhoTrans_" + specieName, + fieldName, this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimMass, Zero) @@ -164,7 +173,15 @@ Foam::ReactingCloud::ReactingCloud { forAll(c.rhoTrans_, i) { - const word& specieName = this->thermo().carrier().species()[i]; + const word fieldName + ( + IOobject::scopedName + ( + this->name(), + "rhoTrans_" + this->thermo().carrier().species()[i] + ) + ); + rhoTrans_.set ( i, @@ -172,7 +189,7 @@ Foam::ReactingCloud::ReactingCloud ( IOobject ( - this->name() + ":rhoTrans_" + specieName, + fieldName, this->db().time().timeName(), this->db(), IOobject::NO_READ, diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H index 8f357987e5..91d816ee5f 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -144,25 +145,14 @@ inline Foam::tmp Foam::ReactingCloud::SYi { if (this->solution().semiImplicit("Yi")) { - tmp trhoTrans + auto trhoTrans = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimMass/dimTime/dimVolume, Zero) - ) + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimTime/dimVolume, Zero) ); - - volScalarField& sourceField = trhoTrans.ref(); + auto& sourceField = trhoTrans.ref(); sourceField.primitiveFieldRef() = rhoTrans_[i]/(this->db().time().deltaTValue()*this->mesh().V()); @@ -175,8 +165,8 @@ inline Foam::tmp Foam::ReactingCloud::SYi } else { - tmp tfvm(new fvScalarMatrix(Yi, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(Yi, dimMass/dimTime); + auto& fvm = tfvm.ref(); fvm.source() = -rhoTrans_[i]/this->db().time().deltaTValue(); @@ -192,30 +182,20 @@ template inline Foam::tmp> Foam::ReactingCloud::Srho(const label i) const { - tmp tRhoi + auto tRhoi = volScalarField::Internal::New ( - new volScalarField::Internal + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar - ( - rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero - ) + rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero ) ); + scalarField& rhoi = tRhoi.ref(); if (this->solution().coupled()) { - scalarField& rhoi = tRhoi.ref(); rhoi = rhoTrans_[i]/(this->db().time().deltaTValue()*this->mesh().V()); } @@ -227,30 +207,20 @@ template inline Foam::tmp> Foam::ReactingCloud::Srho() const { - tmp trhoTrans + auto trhoTrans = volScalarField::Internal::New ( - new volScalarField::Internal + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar - ( - rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero - ) + rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero ) ); + scalarField& sourceField = trhoTrans.ref(); if (this->solution().coupled()) { - scalarField& sourceField = trhoTrans.ref(); forAll(rhoTrans_, i) { sourceField += rhoTrans_[i]; @@ -269,29 +239,17 @@ Foam::ReactingCloud::Srho(volScalarField& rho) const { if (this->solution().coupled()) { - tmp trhoTrans + auto trhoTrans = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimMass/dimTime/dimVolume, Zero) - ) + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimTime/dimVolume, Zero) ); - scalarField& sourceField = trhoTrans.ref(); if (this->solution().semiImplicit("rho")) { - forAll(rhoTrans_, i) { sourceField += rhoTrans_[i]; @@ -302,8 +260,8 @@ Foam::ReactingCloud::Srho(volScalarField& rho) const } else { - tmp tfvm(new fvScalarMatrix(rho, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(rho, dimMass/dimTime); + auto& fvm = tfvm.ref(); forAll(rhoTrans_, i) { diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 9f232d96c2..1d7e1f1ea0 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,11 +64,12 @@ void Foam::ThermoCloud::setModels() ( IOobject ( - this->name() + ":radAreaP", + IOobject::scopedName(this->name(), "radAreaP"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimArea, Zero) @@ -81,11 +82,12 @@ void Foam::ThermoCloud::setModels() ( IOobject ( - this->name() + ":radT4", + IOobject::scopedName(this->name(), "radT4"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(pow4(dimTemperature), Zero) @@ -98,11 +100,12 @@ void Foam::ThermoCloud::setModels() ( IOobject ( - this->name() + ":radAreaPT4", + IOobject::scopedName(this->name(), "radAreaPT4"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(sqr(dimLength)*pow4(dimTemperature), Zero) @@ -164,11 +167,12 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsTrans", + IOobject::scopedName(this->name(), "hsTrans"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimEnergy, Zero) @@ -180,11 +184,12 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsCoeff", + IOobject::scopedName(this->name(), "hsCoeff"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimEnergy/dimTemperature, Zero) @@ -235,7 +240,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsTrans", + IOobject::scopedName(this->name(), "hsTrans"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -251,7 +256,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsCoeff", + IOobject::scopedName(this->name(), "hsCoeff"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -270,7 +275,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":radAreaP", + IOobject::scopedName(this->name(), "radAreaP"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -287,7 +292,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":radT4", + IOobject::scopedName(this->name(), "radT4"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -304,7 +309,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":radAreaPT4", + IOobject::scopedName(this->name(), "radAreaPT4"), this->db().time().timeName(), this->db(), IOobject::NO_READ, diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H index 9899a5f0c5..55b8d00234 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -260,8 +260,8 @@ Foam::ThermoCloud::Sh(volScalarField& hs) const } else { - tmp tfvm(new fvScalarMatrix(hs, dimEnergy/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(hs, dimEnergy/dimTime); + auto& fvm = tfvm.ref(); fvm.source() = -hsTrans()/(this->db().time().deltaT()); @@ -276,22 +276,14 @@ Foam::ThermoCloud::Sh(volScalarField& hs) const template inline Foam::tmp Foam::ThermoCloud::Ep() const { - tmp tEp + auto tEp = tmp::New ( - new volScalarField + this->newIOobject ( - IOobject - ( - this->name() + ":radiation:Ep", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + IOobject::scopedName(this->name(), "radiation", "Ep") + ), + this->mesh(), + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); if (radiation_) @@ -312,22 +304,14 @@ inline Foam::tmp Foam::ThermoCloud::Ep() const template inline Foam::tmp Foam::ThermoCloud::ap() const { - tmp tap + auto tap = tmp::New ( - new volScalarField + this->newIOobject ( - IOobject - ( - this->name() + ":radiation:ap", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimless/dimLength, Zero) - ) + IOobject::scopedName(this->name(), "radiation", "ap") + ), + this->mesh(), + dimensionedScalar(dimless/dimLength, Zero) ); if (radiation_) @@ -349,22 +333,14 @@ template inline Foam::tmp Foam::ThermoCloud::sigmap() const { - tmp tsigmap + auto tsigmap = tmp::New ( - new volScalarField + this->newIOobject ( - IOobject - ( - this->name() + ":radiation:sigmap", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimless/dimLength, Zero) - ) + IOobject::scopedName(this->name(), "radiation", "sigmap") + ), + this->mesh(), + dimensionedScalar(dimless/dimLength, Zero) ); if (radiation_) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H index 6587b5ecb3..fab7a36e2a 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,7 +73,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":volumeAverage", + IOobject::scopedName(cloud.name(), "volumeAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -87,7 +87,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":radiusAverage", + IOobject::scopedName(cloud.name(), "radiusAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -101,7 +101,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":rhoAverage", + IOobject::scopedName(cloud.name(), "rhoAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -115,7 +115,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uAverage", + IOobject::scopedName(cloud.name(), "uAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -129,7 +129,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uSqrAverage", + IOobject::scopedName(cloud.name(), "uSqrAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -143,7 +143,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":frequencyAverage", + IOobject::scopedName(cloud.name(), "frequencyAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -157,7 +157,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":massAverage", + IOobject::scopedName(cloud.name(), "massAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -287,7 +287,7 @@ updateAverages ( IOobject ( - cloud.name() + ":weightAverage", + IOobject::scopedName(cloud.name(), "weightAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -366,4 +366,5 @@ updateAverages frequencyAverage_->average(weightAverage); } + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H index 3b96e305fa..e9721f1a50 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":volumeAverage", + IOobject::scopedName(cloud.name(), "volumeAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -59,7 +59,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":radiusAverage", + IOobject::scopedName(cloud.name(), "radiusAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -73,7 +73,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":rhoAverage", + IOobject::scopedName(cloud.name(), "rhoAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -87,7 +87,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uAverage", + IOobject::scopedName(cloud.name(), "uAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -101,7 +101,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uSqrAverage", + IOobject::scopedName(cloud.name(), "uSqrAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -115,7 +115,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":frequencyAverage", + IOobject::scopedName(cloud.name(), "frequencyAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -129,7 +129,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":massAverage", + IOobject::scopedName(cloud.name(), "massAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -164,7 +164,7 @@ inline void Foam::MPPICParcel::trackingData::updateAverages ( IOobject ( - cloud.name() + ":weightAverage", + IOobject::scopedName(cloud.name(), "weightAverage"), cloud.db().time().timeName(), cloud.mesh() ), diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C index e98f9adc3f..170fd968c2 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,36 +39,42 @@ void Foam::PatchCollisionDensity::write() { const scalarField z(this->owner().mesh().nCells(), Zero); - volScalarField - ( - IOobject + { + volScalarField ( - this->owner().name() + ":collisionDensity", - this->owner().mesh().time().timeName(), - this->owner().mesh() - ), - this->owner().mesh(), - dimless/dimArea, - z, - collisionDensity_ - ) - .write(); + this->owner().mesh().newIOobject + ( + IOobject::scopedName + ( + this->owner().name(), + "collisionDensity" + ) + ), + this->owner().mesh(), + dimless/dimArea, + z, + collisionDensity_ + ).write(); + } - volScalarField - ( - IOobject + { + volScalarField ( - this->owner().name() + ":collisionDensityRate", - this->owner().mesh().time().timeName(), - this->owner().mesh() - ), - this->owner().mesh(), - dimless/dimArea/dimTime, - z, - (collisionDensity_ - collisionDensity0_) - /(this->owner().mesh().time().value() - time0_) - ) - .write(); + this->owner().mesh().newIOobject + ( + IOobject::scopedName + ( + this->owner().name(), + "collisionDensityRate" + ) + ), + this->owner().mesh(), + dimless/dimArea/dimTime, + z, + (collisionDensity_ - collisionDensity0_) + /(this->owner().mesh().time().value() - time0_) + ).write(); + } collisionDensity0_ == collisionDensity_; time0_ = this->owner().mesh().time().value(); @@ -106,11 +112,11 @@ Foam::PatchCollisionDensity::PatchCollisionDensity IOobject io ( - this->owner().name() + ":collisionDensity", - this->owner().mesh().time().timeName(), - this->owner().mesh(), - IOobject::MUST_READ, - IOobject::NO_WRITE + this->owner().mesh().newIOobject + ( + IOobject::scopedName(this->owner().name(), "collisionDensity"), + IOobject::MUST_READ + ) ); if (io.typeHeaderOk()) diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C index 83ed949ad7..687a6662bb 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,7 +50,7 @@ void Foam::PatchInteractionFields::clearOrReset { if (fieldPtr) { - fieldPtr->primitiveFieldRef() = 0.0; + fieldPtr->primitiveFieldRef() = scalar(0); } else { @@ -62,11 +62,17 @@ void Foam::PatchInteractionFields::clearOrReset ( IOobject ( - this->owner().name() + ":" + this->modelName() + ":" + fieldName, + IOobject::scopedName + ( + this->owner().name(), + this->modelName(), + fieldName + ), mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ), mesh, dimensionedScalar(dims, Zero) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index 6bf4fd64df..440103171a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -75,9 +75,9 @@ Foam::LocalInteraction::LocalInteraction if (writeFields_) { Info<< " Interaction fields will be written to " - << this->owner().name() << ":massEscape" + << IOobject::scopedName(this->owner().name(), "massEscape") << " and " - << this->owner().name() << ":massStick" << endl; + << IOobject::scopedName(this->owner().name(), "massStick") << endl; (void)massEscape(); (void)massStick(); @@ -164,11 +164,12 @@ Foam::volScalarField& Foam::LocalInteraction::massEscape() ( IOobject ( - this->owner().name() + ":massEscape", + IOobject::scopedName(this->owner().name(), "massEscape"), mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimMass, Zero) @@ -193,11 +194,12 @@ Foam::volScalarField& Foam::LocalInteraction::massStick() ( IOobject ( - this->owner().name() + ":massStick", + IOobject::scopedName(this->owner().name(), "massStick"), mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimMass, Zero) diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C index 08f575bdce..6b4f324d42 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -146,50 +146,41 @@ bool Foam::AveragingMethod::write(const bool writeOnProc) const Field pointVolume(mesh_.nPoints(), Zero); // output fields - GeometricField cellValue + auto tcellValue = GeometricField::New ( - IOobject - ( - this->name() + ":cellValue", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "cellValue"), + IOobject::NO_REGISTER, mesh_, dimensioned(dimless, Zero) ); - GeometricField cellGrad + auto& cellValue = tcellValue.ref(); + + auto tcellGrad = GeometricField::New ( - IOobject - ( - this->name() + ":cellGrad", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "cellGrad"), + IOobject::NO_REGISTER, mesh_, dimensioned(dimless, Zero) ); - GeometricField pointValue + auto& cellGrad = tcellGrad.ref(); + + auto tpointValue = GeometricField::New ( - IOobject - ( - this->name() + ":pointValue", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "pointValue"), + IOobject::NO_REGISTER, pointMesh_, dimensioned(dimless, Zero) ); - GeometricField pointGrad + auto& pointValue = tpointValue.ref(); + + auto tpointGrad = GeometricField::New ( - IOobject - ( - this->name() + ":pointGrad", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "pointGrad"), + IOobject::NO_REGISTER, pointMesh_, dimensioned(dimless, Zero) ); + auto& pointGrad = tpointGrad.ref(); // Barycentric coordinates of the tet vertices const FixedList diff --git a/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C b/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C index c70614da6e..a44015eed7 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,30 +73,30 @@ void Foam::DampingModels::Relaxation::cacheFields(const bool store) const fvMesh& mesh = this->owner().mesh(); const word& cloudName = this->owner().name(); - const AveragingMethod& volumeAverage = + const auto& volumeAverage = mesh.lookupObject> ( - cloudName + ":volumeAverage" + IOobject::scopedName(cloudName, "volumeAverage") ); - const AveragingMethod& radiusAverage = + const auto& radiusAverage = mesh.lookupObject> ( - cloudName + ":radiusAverage" + IOobject::scopedName(cloudName, "radiusAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - cloudName + ":uAverage" + IOobject::scopedName(cloudName, "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - cloudName + ":uSqrAverage" + IOobject::scopedName(cloudName, "uSqrAverage") ); - const AveragingMethod& frequencyAverage = + const auto& frequencyAverage = mesh.lookupObject> ( - cloudName + ":frequencyAverage" + IOobject::scopedName(cloudName, "frequencyAverage") ); uAverage_ = &uAverage; @@ -106,7 +107,7 @@ void Foam::DampingModels::Relaxation::cacheFields(const bool store) ( IOobject ( - cloudName + ":oneByTimeScaleAverage", + IOobject::scopedName(cloudName, "oneByTimeScaleAverage"), this->owner().db().time().timeName(), mesh ), diff --git a/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C b/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C index 593fa3057a..545ab63f48 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -105,35 +105,35 @@ void Foam::IsotropyModels::Stochastic::calculate() const scalar oneBySqrtThree = sqrt(1.0/3.0); - const AveragingMethod& volumeAverage = + const auto& volumeAverage = mesh.lookupObject> ( - this->owner().name() + ":volumeAverage" + IOobject::scopedName(this->owner().name(), "volumeAverage") ); - const AveragingMethod& radiusAverage = + const auto& radiusAverage = mesh.lookupObject> ( - this->owner().name() + ":radiusAverage" + IOobject::scopedName(this->owner().name(), "radiusAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - this->owner().name() + ":uAverage" + IOobject::scopedName(this->owner().name(), "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - this->owner().name() + ":uSqrAverage" + IOobject::scopedName(this->owner().name(), "uSqrAverage") ); - const AveragingMethod& frequencyAverage = + const auto& frequencyAverage = mesh.lookupObject> ( - this->owner().name() + ":frequencyAverage" + IOobject::scopedName(this->owner().name(), "frequencyAverage") ); - const AveragingMethod& massAverage = + const auto& massAverage = mesh.lookupObject> ( - this->owner().name() + ":massAverage" + IOobject::scopedName(this->owner().name(), "massAverage") ); // calculate time scales and pdf exponent @@ -143,7 +143,7 @@ void Foam::IsotropyModels::Stochastic::calculate() ( IOobject ( - this->owner().name() + ":exponentAverage", + IOobject::scopedName(this->owner().name(), "exponentAverage"), this->owner().db().time().timeName(), mesh ), @@ -191,7 +191,7 @@ void Foam::IsotropyModels::Stochastic::calculate() ( IOobject ( - this->owner().name() + ":uTildeAverage", + IOobject::scopedName(this->owner().name(), "uTildeAverage"), this->owner().db().time().timeName(), mesh ), @@ -213,7 +213,7 @@ void Foam::IsotropyModels::Stochastic::calculate() ( IOobject ( - this->owner().name() + ":uTildeSqrAverage", + IOobject::scopedName(this->owner().name(), "uTildeSqrAverage"), this->owner().db().time().timeName(), mesh ), diff --git a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C index 49ea02277d..7170622fa8 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,25 +83,25 @@ void Foam::PackingModels::Explicit::cacheFields(const bool store) const fvMesh& mesh = this->owner().mesh(); const word& cloudName = this->owner().name(); - const AveragingMethod& volumeAverage = + const auto& volumeAverage = mesh.lookupObject> ( - cloudName + ":volumeAverage" + IOobject::scopedName(cloudName, "volumeAverage") ); - const AveragingMethod& rhoAverage = + const auto& rhoAverage = mesh.lookupObject> ( - cloudName + ":rhoAverage" + IOobject::scopedName(cloudName, "rhoAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - cloudName + ":uAverage" + IOobject::scopedName(cloudName, "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - cloudName + ":uSqrAverage" + IOobject::scopedName(cloudName, "uSqrAverage") ); volumeAverage_ = &volumeAverage; @@ -113,7 +113,7 @@ void Foam::PackingModels::Explicit::cacheFields(const bool store) ( IOobject ( - cloudName + ":stressAverage", + IOobject::scopedName(cloudName, "stressAverage"), this->owner().db().time().timeName(), mesh ), diff --git a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C index c811306bc4..822fb7fc06 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +49,7 @@ Foam::PackingModels::Implicit::Implicit ( IOobject ( - this->owner().name() + ":alpha", + IOobject::scopedName(this->owner().name(), "alpha"), this->owner().db().time().timeName(), this->owner().mesh(), IOobject::NO_READ, @@ -112,20 +113,20 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) const dimensionedVector& g = this->owner().g(); const volScalarField& rhoc = this->owner().rho(); - const AveragingMethod& rhoAverage = + const auto& rhoAverage = mesh.lookupObject> ( - cloudName + ":rhoAverage" + IOobject::scopedName(cloudName, "rhoAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - cloudName + ":uAverage" + IOobject::scopedName(cloudName, "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - cloudName + ":uSqrAverage" + IOobject::scopedName(cloudName, "uSqrAverage") ); mesh.setFluxRequired(alpha_.name()); @@ -138,20 +139,15 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) alpha_.correctBoundaryConditions(); // average density - volScalarField rho + auto trho = volScalarField::New ( - IOobject - ( - cloudName + ":rho", - this->owner().db().time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(cloudName, "rho"), mesh, dimensionedScalar(dimDensity, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& rho = trho.ref(); + rho.primitiveFieldRef() = max(rhoAverage.primitiveField(), rhoMin_); rho.correctBoundaryConditions(); @@ -159,20 +155,14 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) // ~~~~~~~~~~~~ // stress derivative wrt volume fraction - volScalarField tauPrime + auto ttauPrime = volScalarField::New ( - IOobject - ( - cloudName + ":tauPrime", - this->owner().db().time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(cloudName, "tauPrime"), mesh, dimensionedScalar(dimPressure, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& tauPrime = ttauPrime.ref(); tauPrime.primitiveFieldRef() = this->particleStressModel_->dTaudTheta @@ -191,27 +181,24 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) tmp phiGByA; if (applyGravity_) - ( - phiGByA = tmp + { + phiGByA = surfaceScalarField::New ( - new surfaceScalarField - ( - "phiGByA", - deltaT*(g & mesh.Sf())*fvc::interpolate(1.0 - rhoc/rho) - ) - ) - ); + "phiGByA", + IOobject::NO_REGISTER, + deltaT*(g & mesh.Sf())*fvc::interpolate(1.0 - rhoc/rho) + ); + } // Implicit solution for the volume fraction // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - surfaceScalarField - tauPrimeByRhoAf - ( - "tauPrimeByRhoAf", - fvc::interpolate(deltaT*tauPrime/rho) - ); + surfaceScalarField tauPrimeByRhoAf + ( + "tauPrimeByRhoAf", + fvc::interpolate(deltaT*tauPrime/rho) + ); fvScalarMatrix alphaEqn ( @@ -232,38 +219,32 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) // ~~~~~~~~~~~~~~~~~ // correction volumetric flux - phiCorrect_ = tmp + phiCorrect_ = surfaceScalarField::New ( - new surfaceScalarField - ( - cloudName + ":phiCorrect", - alphaEqn.flux()/fvc::interpolate(alpha_) - ) + IOobject::scopedName(cloudName, "phiCorrect"), + IOobject::NO_REGISTER, + alphaEqn.flux()/fvc::interpolate(alpha_) ); // limit the correction flux if (applyLimiting_) { - volVectorField U + auto tU = volVectorField::New ( - IOobject - ( - cloudName + ":U", - this->owner().db().time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(cloudName, "U"), + IOobject::NO_REGISTER, mesh, dimensionedVector(dimVelocity, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& U = tU.ref(); + U.primitiveFieldRef() = uAverage.primitiveField(); U.correctBoundaryConditions(); surfaceScalarField phi ( - cloudName + ":phi", + IOobject::scopedName(cloudName, "phi"), linearInterpolate(U) & mesh.Sf() ); @@ -303,14 +284,11 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) } // correction velocity - uCorrect_ = tmp + uCorrect_ = volVectorField::New ( - new volVectorField - ( - cloudName + ":uCorrect", - fvc::reconstruct(phiCorrect_()) - ) - + IOobject::scopedName(cloudName, "uCorrect"), + IOobject::NO_REGISTER, + fvc::reconstruct(phiCorrect_()) ); uCorrect_->correctBoundaryConditions(); diff --git a/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C b/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C index 77db614098..8170bc9c82 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C @@ -107,17 +107,15 @@ Foam::ParticleStressModel::tau const FieldField& uRms ) const { - tmp> value - ( - new FieldField(alpha.size()) - ); + auto tvalue = tmp>::New(alpha.size()); + auto& value = tvalue.ref(); forAll(alpha, i) { - value->set(i, tau(alpha[i], rho[i], uRms[i])); + value.set(i, tau(alpha[i], rho[i], uRms[i])); } - return value; + return tvalue; } diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C index 4dc91ac10e..5b25c69154 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C @@ -72,29 +72,19 @@ Foam::radiation::cloudAbsorptionEmission::~cloudAbsorptionEmission() Foam::tmp Foam::radiation::cloudAbsorptionEmission::aDisp(const label) const { - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "a", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); - forAll(cloudNames_, i) + for (const word& cldName : cloudNames_) { const thermoCloud& tc ( - mesh_.objectRegistry::lookupObject(cloudNames_[i]) + mesh_.objectRegistry::lookupObject(cldName) ); ta.ref() += tc.ap(); @@ -107,17 +97,10 @@ Foam::radiation::cloudAbsorptionEmission::aDisp(const label) const Foam::tmp Foam::radiation::cloudAbsorptionEmission::eDisp(const label bandI) const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "e", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "e", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless/dimLength, Zero) ); @@ -127,29 +110,19 @@ Foam::radiation::cloudAbsorptionEmission::eDisp(const label bandI) const Foam::tmp Foam::radiation::cloudAbsorptionEmission::EDisp(const label bandI) const { - tmp tE + auto tE = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "E", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); - forAll(cloudNames_, i) + for (const word& cldName : cloudNames_) { const thermoCloud& tc ( - mesh_.objectRegistry::lookupObject(cloudNames_[i]) + mesh_.objectRegistry::lookupObject(cldName) ); tE.ref() += tc.Ep(); diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C index 1a530c91fd..8696d74e95 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C @@ -72,30 +72,18 @@ Foam::radiation::cloudScatter::~cloudScatter() Foam::tmp Foam::radiation::cloudScatter::sigmaEff() const { - tmp tsigma + auto tsigma = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "sigma", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "sigma", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); - forAll(cloudNames_, i) + for (const word& cloudName : cloudNames_) { - const thermoCloud& tc - ( - mesh_.objectRegistry::lookupObject(cloudNames_[i]) - ); + const auto& tc = + mesh_.objectRegistry::lookupObject(cloudName); tsigma.ref() += tc.sigmap(); } From 71d4a23ec09b8d5a3a2afd18815e26cd5171ae50 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:08:35 +0100 Subject: [PATCH 07/13] ENH: use tmp field factory methods [6] (#2723) - src/functionObjects --- src/functionObjects/field/PecletNo/PecletNo.C | 12 +--- .../extractEulerianParticles.C | 11 ++-- .../field/limitFields/limitFieldsTemplates.C | 24 ++++++-- src/functionObjects/field/pressure/pressure.C | 59 +++++++------------ .../proudmanAcousticPower.C | 19 +++--- .../reactionsSensitivityAnalysis.C | 14 ++--- .../regionSizeDistribution.C | 14 ++--- .../resolutionIndexModel.C | 13 +--- src/functionObjects/field/setFlow/setFlow.C | 8 +-- .../stabilityBlendingFactor.C | 52 +++++----------- .../turbulenceFieldsTemplates.C | 9 ++- src/functionObjects/forces/forces/forces.C | 10 +--- .../hydrostaticPressure/hydrostaticPressure.C | 4 +- .../sizeDistribution/sizeDistribution.C | 2 +- .../electricPotential/electricPotential.C | 40 +++---------- .../solvers/energyTransport/energyTransport.C | 57 +++++------------- .../solvers/scalarTransport/scalarTransport.C | 30 ++++------ 17 files changed, 130 insertions(+), 248 deletions(-) diff --git a/src/functionObjects/field/PecletNo/PecletNo.C b/src/functionObjects/field/PecletNo/PecletNo.C index 4550954207..8ef656db1d 100644 --- a/src/functionObjects/field/PecletNo/PecletNo.C +++ b/src/functionObjects/field/PecletNo/PecletNo.C @@ -79,16 +79,10 @@ bool Foam::functionObjects::PecletNo::calc() const dictionary& model = mesh_.lookupObject("transportProperties"); - nuEff = tmp::New + nuEff = volScalarField::New ( - IOobject - ( - "nuEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "nuEff", + IOobject::NO_REGISTER, mesh_, dimensionedScalar("nu", dimViscosity, model) ); diff --git a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C index 3829d78322..c8e2c76cb5 100644 --- a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C +++ b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -531,9 +531,10 @@ bool Foam::functionObjects::extractEulerianParticles::execute() const volScalarField& alpha = mesh_.lookupObject(alphaName_); - const surfaceScalarField alphaf + auto talphaf = surfaceScalarField::New ( - typeName + ":alphaf", + IOobject::scopedName(typeName, "alphaf"), + IOobject::NO_REGISTER, fvc::interpolate(alpha) ); @@ -546,7 +547,7 @@ bool Foam::functionObjects::extractEulerianParticles::execute() // Set the blocked faces, i.e. where alpha > alpha threshold value boolList blockedFaces(fz.size(), false); - setBlockedFaces(alphaf, fz, blockedFaces); + setBlockedFaces(talphaf(), fz, blockedFaces); // Split the faceZone according to the blockedFaces // - Returns a list of (disconnected) region index per face zone face @@ -567,7 +568,7 @@ bool Foam::functionObjects::extractEulerianParticles::execute() // Process latest region information tmp tphi = phiU(); - accumulateParticleInfo(alphaf, tphi(), regionFaceIDs, fz); + accumulateParticleInfo(talphaf(), tphi(), regionFaceIDs, fz); Log << " Collected particles : " << nCollectedParticles_ << nl << " Collected volume : " << collectedVolume_ << nl diff --git a/src/functionObjects/field/limitFields/limitFieldsTemplates.C b/src/functionObjects/field/limitFields/limitFieldsTemplates.C index 0b20a6cbe2..25ab497be0 100644 --- a/src/functionObjects/field/limitFields/limitFieldsTemplates.C +++ b/src/functionObjects/field/limitFields/limitFieldsTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,22 +49,36 @@ bool Foam::functionObjects::limitFields::limitField(const word& fieldName) if (withBounds_ & limitType::CLAMP_MIN) { - volScalarField mField(typeName + ":mag" + field.name(), mag(field)); + auto tmField = volScalarField::New + ( + IOobject::scopedName(typeName, "mag" + field.name()), + IOobject::NO_REGISTER, + mag(field) + ); + auto& mField = tmField.ref(); + Log << " min(|" << gMin(mField) << "|)"; //field.normalise(); field /= mag(field) + eps; mField.clamp_min(min_); - field *= mField; + field *= tmField; } if (withBounds_ & limitType::CLAMP_MAX) { - volScalarField mField(typeName + ":mag" + field.name(), mag(field)); + auto tmField = volScalarField::New + ( + IOobject::scopedName(typeName, "mag" + field.name()), + IOobject::NO_REGISTER, + mag(field) + ); + auto& mField = tmField.ref(); + Log << " max(|" << gMax(mField) << "|)"; //field.normalise(); field /= mag(field) + eps; mField.clamp_max(max_); - field *= mField; + field *= tmField; } return true; diff --git a/src/functionObjects/field/pressure/pressure.C b/src/functionObjects/field/pressure/pressure.C index be7d849a2f..712557669c 100644 --- a/src/functionObjects/field/pressure/pressure.C +++ b/src/functionObjects/field/pressure/pressure.C @@ -131,17 +131,10 @@ Foam::tmp Foam::functionObjects::pressure::rhoScale { if (p.dimensions() == dimPressure) { - return tmp::New + return volScalarField::New ( - IOobject - ( - "rhoScale", - p.mesh().time().timeName(), - p.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "rhoScale", + IOobject::NO_REGISTER, p, fvPatchFieldBase::calculatedType() ); @@ -236,21 +229,14 @@ Foam::tmp Foam::functionObjects::pressure::calcPressure ) const { // Initialise to the pressure reference level - auto tresult = - tmp::New - ( - IOobject - ( - scopedName("p"), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ - ), - mesh_, - dimensionedScalar("p", dimPressure, pRef_) - ); - - volScalarField& result = tresult.ref(); + auto tresult = volScalarField::New + ( + scopedName("p"), + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar("p", dimPressure, pRef_) + ); + auto& result = tresult.ref(); addHydrostaticContribution(p, result); @@ -304,7 +290,7 @@ Foam::tmp Foam::functionObjects::pressure::coeff if (mode_ & COEFF) { tmp tpCoeff(tp.ptr()); - volScalarField& pCoeff = tpCoeff.ref(); + auto& pCoeff = tpCoeff.ref(); pCoeff -= dimensionedScalar("pInf", dimPressure, pInf_); @@ -325,21 +311,16 @@ Foam::tmp Foam::functionObjects::pressure::coeff bool Foam::functionObjects::pressure::calc() { - if (foundObject(fieldName_)) - { - const volScalarField& p = lookupObject(fieldName_); + const auto* pptr = cfindObject(fieldName_); - auto tp = tmp::New + if (pptr) + { + const auto& p = *pptr; + + auto tp = volScalarField::New ( - IOobject - ( - resultName_, - p.mesh().time().timeName(), - p.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::REGISTER - ), + resultName_, + IOobject::REGISTER, coeff(calcPressure(p, rhoScale(p))) ); diff --git a/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C b/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C index 0718ae315f..4a002caeb2 100644 --- a/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C +++ b/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C @@ -87,18 +87,13 @@ Foam::functionObjects::proudmanAcousticPower::a() const return sqrt(thermo.gamma()*thermo.p()/thermo.rho()); } - return - tmp::New - ( - IOobject - ( - scopedName("a"), - mesh_.time().timeName(), - mesh_ - ), - mesh_, - aRef_ - ); + return volScalarField::New + ( + scopedName("a"), + IOobject::NO_REGISTER, + mesh_, + aRef_ + ); } diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index a0bc517f95..4429bb803b 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -80,20 +80,14 @@ calculateSpeciesRR const basicChemistryModel& basicChemistry ) { - auto RRt = tmp>::New + auto tRR = volScalarField::Internal::New ( - IOobject - ( - "RR", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "RR", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); - auto& RR = RRt.ref(); + auto& RR = tRR.ref(); scalar dt = time_.deltaTValue(); diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index a15639fe34..c5e86068c6 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -449,7 +449,8 @@ bool Foam::functionObjects::regionSizeDistribution::write() mesh_.time().timeName(), mesh_, IOobjectOption::MUST_READ, - IOobjectOption::NO_WRITE + IOobjectOption::NO_WRITE, + IOobjectOption::NO_REGISTER ), mesh_ ) @@ -535,18 +536,11 @@ bool Foam::functionObjects::regionSizeDistribution::write() { volScalarField region ( - IOobject - ( - "region", - mesh_.time().timeName(), - mesh_, - IOobjectOption::NO_READ, - IOobjectOption::NO_WRITE, - IOobjectOption::NO_REGISTER - ), + mesh_.newIOobject("region"), mesh_, dimensionedScalar(dimless, Zero) ); + Info<< " Dumping region as volScalarField to " << region.name() << endl; diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C index ca01a013fa..947545c828 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C @@ -45,17 +45,10 @@ namespace Foam Foam::tmp Foam::resolutionIndexModel::V() const { - auto tV = tmp::New + auto tV = volScalarField::New ( - IOobject - ( - "V", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "V", + IOobject::NO_REGISTER, mesh_, dimVolume, fvPatchFieldBase::zeroGradientType() diff --git a/src/functionObjects/field/setFlow/setFlow.C b/src/functionObjects/field/setFlow/setFlow.C index e2e165e7df..dd26dccb60 100644 --- a/src/functionObjects/field/setFlow/setFlow.C +++ b/src/functionObjects/field/setFlow/setFlow.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -240,7 +240,7 @@ bool Foam::functionObjects::setFlow::execute() const volVectorField& C = mesh_.C(); const volVectorField d ( - typeName + ":d", + IOobject::scopedName(typeName, "d"), C - dimensionedVector("origin", dimLength, origin_) ); const scalarField x(d.component(vector::X)); @@ -286,7 +286,7 @@ bool Foam::functionObjects::setFlow::execute() const volVectorField d ( - typeName + ":d", + IOobject::scopedName(typeName, "d"), C - dimensionedVector("origin", dimLength, origin_) ); const scalarField x(d.component(vector::X)); @@ -350,7 +350,7 @@ bool Foam::functionObjects::setFlow::execute() const volVectorField d ( - typeName + ":d", + IOobject::scopedName(typeName, "d"), C - dimensionedVector("origin", dimLength, origin_) ); const scalarField x(d.component(vector::X)); diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index 134427f7ba..27a2371d19 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -321,16 +321,10 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) << exit(FatalError); } - auto tmagGradCC = tmp::New + auto tmagGradCC = volScalarField::New ( - IOobject - ( - "magGradCC", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "magGradCC", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() @@ -340,20 +334,16 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) for (direction i=0; i::New + auto CoPtr = volScalarField::New ( - IOobject - ( - "Co", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Co", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - auto& Co = CoPtr.ref(); Co.primitiveFieldRef() = @@ -533,17 +516,10 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor read(dict); setResultName(typeName, ""); - auto faceBlendedPtr = tmp::New + auto faceBlendedPtr = surfaceScalarField::New ( - IOobject - ( - resultName_, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::REGISTER - ), + resultName_, + IOobject::REGISTER, mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index e30d45d522..a2a8ba5efc 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -77,9 +77,10 @@ Foam::functionObjects::turbulenceFields::nuTilda { const dimensionedScalar omega0(dimless/dimTime, SMALL); - return tmp::New + return volScalarField::New ( "nuTilda.tmp", + IOobject::NO_REGISTER, model.k()/(model.omega() + omega0) ); } @@ -96,9 +97,10 @@ Foam::functionObjects::turbulenceFields::L const scalar Cmu = 0.09; const dimensionedScalar eps0(sqr(dimVelocity)/dimTime, SMALL); - return tmp::New + return volScalarField::New ( "L.tmp", + IOobject::NO_REGISTER, pow(Cmu, 0.75)*pow(model.k(), 1.5)/(model.epsilon() + eps0) ); } @@ -116,9 +118,10 @@ Foam::functionObjects::turbulenceFields::I const volScalarField uPrime(sqrt((2.0/3.0)*model.k())); const dimensionedScalar U0(dimVelocity, SMALL); - return tmp::New + return volScalarField::New ( "I.tmp", + IOobject::NO_REGISTER, uPrime/max(max(uPrime, mag(model.U())), U0) ); } diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index ac66678394..fd7ab2f876 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -311,14 +311,10 @@ Foam::tmp Foam::functionObjects::forces::rho() const { if (rhoName_ == "rhoInf") { - return tmp::New + return volScalarField::New ( - IOobject - ( - "rho", - mesh_.time().timeName(), - mesh_ - ), + "rho", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimDensity, rhoRef_) ); diff --git a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C index 75c6f8509f..1a98fad13c 100644 --- a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C +++ b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C @@ -182,7 +182,7 @@ Foam::functionObjects::hydrostaticPressure::hydrostaticPressure if (read(dict)) { // Read and store the initial ph_rgh field - volScalarField* ph_rghPtr = + volScalarField* ptr = new volScalarField ( IOobject @@ -197,7 +197,7 @@ Foam::functionObjects::hydrostaticPressure::hydrostaticPressure mesh_ ); - regIOobject::store(ph_rghPtr); + regIOobject::store(ptr); bool reInitialise = dict.getOrDefault("reInitialise", false); diff --git a/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C b/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C index a3d4588ec7..c6038cec9b 100644 --- a/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C +++ b/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C @@ -243,7 +243,7 @@ Foam::functionObjects::sizeDistribution::filterField const scalarField& field ) const { - return tmp(new scalarField(field, cellId_)); + return tmp::New(field, cellId_); } diff --git a/src/functionObjects/solvers/electricPotential/electricPotential.C b/src/functionObjects/solvers/electricPotential/electricPotential.C index 4b5dd5d855..ff931d8583 100644 --- a/src/functionObjects/solvers/electricPotential/electricPotential.C +++ b/src/functionObjects/solvers/electricPotential/electricPotential.C @@ -78,12 +78,7 @@ Foam::functionObjects::electricPotential::sigma() const { const IOobject sigmaIO ( - IOobject::scopedName(typeName, "sigma"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh_.thisDb().newIOobject(IOobject::scopedName(typeName, "sigma")) ); if (phases_.size()) @@ -125,12 +120,7 @@ Foam::functionObjects::electricPotential::epsilonm() const const IOobject epsilonrIO ( - IOobject::scopedName(typeName, "epsilonr"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh_.thisDb().newIOobject(IOobject::scopedName(typeName, "epsilonr")) ); if (phases_.size()) @@ -409,17 +399,10 @@ bool Foam::functionObjects::electricPotential::write() // Write the current density field tmp tsigma = this->sigma(); - auto eJ = tmp::New + auto eJ = volVectorField::New ( - IOobject - ( - IOobject::scopedName(typeName, "J"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "J"), + IOobject::NO_REGISTER, -tsigma*fvc::grad(eV), fvPatchFieldBase::calculatedType() ); @@ -432,17 +415,10 @@ bool Foam::functionObjects::electricPotential::write() // Write the free-charge density field tmp tepsilonm = this->epsilonm(); - auto erho = tmp::New + auto erho = volScalarField::New ( - IOobject - ( - IOobject::scopedName(typeName, "rho"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "rho"), + IOobject::NO_REGISTER, fvc::div(tepsilonm*(-fvc::grad(eV))), fvPatchFieldBase::calculatedType() ); diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C index ea5b022f11..2a0ac81eba 100644 --- a/src/functionObjects/solvers/energyTransport/energyTransport.C +++ b/src/functionObjects/solvers/energyTransport/energyTransport.C @@ -93,9 +93,10 @@ Foam::functionObjects::energyTransport::kappaEff() const if (turbPtr) { - return tmp + return volScalarField::New ( - new volScalarField + "kappaEff", + IOobject::NO_REGISTER, ( kappa() + Cp()*turbPtr->nut()*rho()/Prt_ ) @@ -113,17 +114,10 @@ Foam::functionObjects::energyTransport::kappaEff() const Foam::tmp Foam::functionObjects::energyTransport::rho() const { - auto trho = tmp::New + auto trho = volScalarField::New ( - IOobject - ( - "trho", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "trho", + IOobject::NO_REGISTER, mesh_, rho_ ); @@ -150,17 +144,10 @@ Foam::functionObjects::energyTransport::Cp() const return tCp; } - return tmp::New + return volScalarField::New ( - IOobject - ( - "tCp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "tCp", + IOobject::NO_REGISTER, mesh_, Cp_ ); @@ -181,22 +168,16 @@ Foam::functionObjects::energyTransport::kappa() const return tkappa; } - return tmp::New + return volScalarField::New ( - IOobject - ( - "tkappa", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "tkappa", + IOobject::NO_REGISTER, mesh_, kappa_ ); } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::energyTransport::energyTransport @@ -404,16 +385,10 @@ bool Foam::functionObjects::energyTransport::execute() const surfaceScalarField CpPhi(rhoCp*phi); - auto trhoCp = tmp::New + auto trhoCp = volScalarField::New ( - IOobject - ( - "trhoCp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "trhoCp", + IOobject::NO_REGISTER, mesh_, rhoCp ); diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index ec36978276..f418519024 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -96,16 +96,10 @@ Foam::tmp Foam::functionObjects::scalarTransport::D if (constantD_) { - return tmp::New + return volScalarField::New ( - IOobject - ( - Dname, - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + Dname, + IOobject::NO_REGISTER, mesh_, dimensionedScalar(Dname, phi.dimensions()/dimLength, D_) ); @@ -129,9 +123,10 @@ Foam::tmp Foam::functionObjects::scalarTransport::D if (turb) { - return tmp::New + return volScalarField::New ( Dname, + IOobject::NO_REGISTER, alphaD_ * turb->nu() + alphaDt_ * turb->nut() ); } @@ -147,25 +142,20 @@ Foam::tmp Foam::functionObjects::scalarTransport::D if (turb) { - return tmp::New + return volScalarField::New ( Dname, + IOobject::NO_REGISTER, alphaD_ * turb->mu() + alphaDt_ * turb->mut() ); } } - return tmp::New + return volScalarField::New ( - IOobject - ( - Dname, - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + Dname, + IOobject::NO_REGISTER, mesh_, dimensionedScalar(phi.dimensions()/dimLength, Zero) ); From 51f150d84c2d1dea591b6d6becc69946a12fcedc Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:30:43 +0100 Subject: [PATCH 08/13] ENH: use tmp field factory methods [7] (#2723) - thermophysicalModels, transportModels --- .../thermalBaffle1DFvPatchScalarField.C | 13 +- ...tureCoupledBaffleMixedFvPatchScalarField.C | 14 +- ...eratureRadCoupledMixedFvPatchScalarField.C | 2 +- .../basic/basicThermo/basicThermo.C | 30 ++- .../basic/heThermo/heThermo.C | 220 ++++++------------ .../basic/psiThermo/psiThermo.C | 22 +- .../basic/rhoThermo/rhoThermo.C | 47 ++-- .../StandardChemistryModel.C | 67 ++---- .../laminarFlameSpeed/Gulders/Gulders.C | 46 +--- .../laminarFlameSpeed/GuldersEGR/GuldersEGR.C | 46 +--- .../RaviPetersen/RaviPetersen.C | 33 +-- .../laminarFlameSpeed/constant/constant.C | 20 +- ...veViewFactorFixedValueFvPatchScalarField.C | 2 +- .../radiation/radiationModels/P1/P1.C | 31 +-- .../blackBodyEmission/blackBodyEmission.C | 36 +-- .../radiationModels/fvDOM/fvDOM/fvDOM.C | 70 +++--- .../radiationModels/noRadiation/noRadiation.C | 24 +- .../radiationModels/opaqueSolid/opaqueSolid.C | 25 +- .../solarLoad/faceReflecting/faceReflecting.C | 16 +- .../solarLoad/faceShading/faceShading.C | 15 +- .../radiationModels/solarLoad/solarLoad.C | 13 +- .../radiationModels/viewFactor/viewFactor.C | 26 +-- .../absorptionEmissionModel.C | 120 +++------- .../constantAbsorptionEmission.C | 66 ++---- .../greyMeanAbsorptionEmission.C | 43 +--- .../greyMeanSolidAbsorptionEmission.C | 33 +-- .../multiBandAbsorptionEmission.C | 63 ++--- .../multiBandZoneAbsorptionEmission.C | 61 ++--- .../wideBandAbsorptionEmission.C | 41 +--- .../boundaryRadiationProperties.C | 30 +-- .../constantScatter/constantScatter.C | 20 +- .../scatterModel/noScatter/noScatter.C | 20 +- .../constantAbsorption/constantAbsorption.C | 4 +- .../multiBandAbsorption/multiBandAbsorption.C | 4 +- .../basicMultiComponentMixture.C | 3 +- .../psiuReactionThermo/heheuPsiThermo.C | 122 +++------- .../pyrolysisChemistryModel.C | 25 +- .../pyrolysisChemistryModelI.H | 22 +- .../solidChemistryModel/solidChemistryModel.C | 24 +- .../solidChemistryModelI.H | 45 ++-- .../solidThermo/solidThermo/heSolidThermo.C | 27 +-- .../isoAdvection/isoAdvection.H | 22 +- .../incompressibleTwoPhaseMixture.C | 9 +- .../constant/constantSurfaceTension.C | 13 +- .../temperatureDependentSurfaceTension.C | 13 +- 45 files changed, 508 insertions(+), 1140 deletions(-) diff --git a/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 6687c4a772..bb3532b43d 100644 --- a/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -253,11 +253,9 @@ baffleThickness() const nbrPatch.template lookupPatchField(TName_) ); - tmp tthickness - ( - new scalarField(nbrField.baffleThickness()) - ); - scalarField& thickness = tthickness.ref(); + auto tthickness = tmp::New(nbrField.baffleThickness()); + auto& thickness = tthickness.ref(); + mapDist.distribute(thickness); return tthickness; } @@ -284,8 +282,9 @@ tmp thermalBaffle1DFvPatchScalarField::qs() const nbrPatch.template lookupPatchField(TName_) ); - tmp tqs(new scalarField(nbrField.qs())); - scalarField& qs = tqs.ref(); + auto tqs = tmp::New(nbrField.qs()); + auto& qs = tqs.ref(); + mapDist.distribute(qs); return tqs; } diff --git a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index 0c782f824c..d2066bec6d 100644 --- a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -433,20 +433,8 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::coeffs << "which has more functionalities and it can handle " << "the assemble coupled option for energy. " << abort(FatalError); - /* - const label index(this->patch().index()); - const label nSubFaces(matrix.lduMesh().cellBoundMap()[mat][index].size()); - - Field mapCoeffs(nSubFaces, Zero); - - label subFaceI = 0; - forAll(*this, faceI) - { - - } - */ - return tmp>(new Field()); + return nullptr; } diff --git a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index 0471bdd398..81b6f09f68 100644 --- a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -804,7 +804,7 @@ tmp> turbulentTemperatureRadCoupledMixedFvPatchScalarField::coeffs << "the assemble coupled option for energy. " << abort(FatalError); - return tmp>(new Field()); + return nullptr; } diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index e4bcf751c7..f012c7a914 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -285,8 +285,9 @@ Foam::basicThermo::basicThermo phasePropertyName(dictName, phaseName), mesh.time().constant(), mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), @@ -303,11 +304,12 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("thermo:alpha"), + phaseScopedName("thermo", "alpha"), mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero) @@ -332,7 +334,8 @@ Foam::basicThermo::basicThermo mesh.time().constant(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), dict ), @@ -350,11 +353,12 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("thermo:alpha"), + phaseScopedName("thermo", "alpha"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero) @@ -378,8 +382,9 @@ Foam::basicThermo::basicThermo dictionaryName, mesh.time().constant(), mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), @@ -396,11 +401,12 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("thermo:alpha"), + phaseScopedName("thermo", "alpha"), mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero) diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.C b/src/thermophysicalModels/basic/heThermo/heThermo.C index 78600ba69c..40eb9b0705 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.C +++ b/src/thermophysicalModels/basic/heThermo/heThermo.C @@ -218,25 +218,15 @@ Foam::tmp Foam::heThermo::he { const fvMesh& mesh = this->T_.mesh(); - tmp the + auto the = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "he", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - he_.dimensions() - ) + "he", + IOobject::NO_REGISTER, + mesh, + he_.dimensions() ); + auto& he = the.ref(); - volScalarField& he = the.ref(); scalarField& heCells = he.primitiveFieldRef(); const scalarField& pCells = p; const scalarField& TCells = T; @@ -274,8 +264,8 @@ Foam::tmp Foam::heThermo::he const labelList& cells ) const { - tmp the(new scalarField(T.size())); - scalarField& he = the.ref(); + auto the = tmp::New(T.size()); + auto& he = the.ref(); forAll(T, celli) { @@ -294,8 +284,8 @@ Foam::tmp Foam::heThermo::he const label patchi ) const { - tmp the(new scalarField(T.size())); - scalarField& he = the.ref(); + auto the = tmp::New(T.size()); + auto& he = the.ref(); forAll(T, facei) { @@ -313,25 +303,15 @@ Foam::heThermo::hc() const { const fvMesh& mesh = this->T_.mesh(); - tmp thc + auto thc = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "hc", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - he_.dimensions() - ) + "hc", + IOobject::NO_REGISTER, + mesh, + he_.dimensions() ); + auto& hcf = thc.ref(); - volScalarField& hcf = thc.ref(); scalarField& hcCells = hcf.primitiveFieldRef(); forAll(hcCells, celli) @@ -363,8 +343,8 @@ Foam::tmp Foam::heThermo::Cp const label patchi ) const { - tmp tCp(new scalarField(T.size())); - scalarField& cp = tCp.ref(); + auto tCp = tmp::New(T.size()); + auto& cp = tCp.ref(); forAll(T, facei) { @@ -404,25 +384,14 @@ Foam::heThermo::Cp() const { const fvMesh& mesh = this->T_.mesh(); - tmp tCp + auto tCp = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Cp", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimEnergy/dimMass/dimTemperature - ) + "Cp", + IOobject::NO_REGISTER, + mesh, + dimEnergy/dimMass/dimTemperature ); - - volScalarField& cp = tCp.ref(); + auto& cp = tCp.ref(); forAll(this->T_, celli) { @@ -458,8 +427,8 @@ Foam::heThermo::Cv const label patchi ) const { - tmp tCv(new scalarField(T.size())); - scalarField& cv = tCv.ref(); + auto tCv = tmp::New(T.size()); + auto& cv = tCv.ref(); forAll(T, facei) { @@ -499,25 +468,14 @@ Foam::heThermo::Cv() const { const fvMesh& mesh = this->T_.mesh(); - tmp tCv + auto tCv = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Cv", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimEnergy/dimMass/dimTemperature - ) + "Cv", + IOobject::NO_REGISTER, + mesh, + dimEnergy/dimMass/dimTemperature ); - - volScalarField& cv = tCv.ref(); + auto& cv = tCv.ref(); forAll(this->T_, celli) { @@ -549,8 +507,8 @@ Foam::tmp Foam::heThermo::gamma const label patchi ) const { - tmp tgamma(new scalarField(T.size())); - scalarField& gamma = tgamma.ref(); + auto tgamma = tmp::New(T.size()); + auto& gamma = tgamma.ref(); forAll(T, facei) { @@ -568,25 +526,14 @@ Foam::heThermo::gamma() const { const fvMesh& mesh = this->T_.mesh(); - tmp tgamma + auto tgamma = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "gamma", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimless - ) + "gamma", + IOobject::NO_REGISTER, + mesh, + dimless ); - - volScalarField& gamma = tgamma.ref(); + auto& gamma = tgamma.ref(); forAll(this->T_, celli) { @@ -624,8 +571,8 @@ Foam::tmp Foam::heThermo::Cpv const label patchi ) const { - tmp tCpv(new scalarField(T.size())); - scalarField& Cpv = tCpv.ref(); + auto tCpv = tmp::New(T.size()); + auto& Cpv = tCpv.ref(); forAll(T, facei) { @@ -643,25 +590,14 @@ Foam::heThermo::Cpv() const { const fvMesh& mesh = this->T_.mesh(); - tmp tCpv + auto tCpv = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Cpv", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimEnergy/dimMass/dimTemperature - ) + "Cpv", + IOobject::NO_REGISTER, + mesh, + dimEnergy/dimMass/dimTemperature ); - - volScalarField& Cpv = tCpv.ref(); + auto& Cpv = tCpv.ref(); forAll(this->T_, celli) { @@ -696,8 +632,8 @@ Foam::tmp Foam::heThermo::CpByCpv const label patchi ) const { - tmp tCpByCpv(new scalarField(T.size())); - scalarField& CpByCpv = tCpByCpv.ref(); + auto tCpByCpv = tmp::New(T.size()); + auto& CpByCpv = tCpByCpv.ref(); forAll(T, facei) { @@ -715,25 +651,14 @@ Foam::heThermo::CpByCpv() const { const fvMesh& mesh = this->T_.mesh(); - tmp tCpByCpv + auto tCpByCpv = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "CpByCpv", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimless - ) + "CpByCpv", + IOobject::NO_REGISTER, + mesh, + dimless ); - - volScalarField& CpByCpv = tCpByCpv.ref(); + auto& CpByCpv = tCpByCpv.ref(); forAll(this->T_, celli) { @@ -776,8 +701,8 @@ Foam::tmp Foam::heThermo::THE const labelList& cells ) const { - tmp tT(new scalarField(h.size())); - scalarField& T = tT.ref(); + auto tT = tmp::New(h.size()); + auto& T = tT.ref(); forAll(h, celli) { @@ -799,8 +724,9 @@ Foam::tmp Foam::heThermo::THE ) const { - tmp tT(new scalarField(h.size())); - scalarField& T = tT.ref(); + auto tT = tmp::New(h.size()); + auto& T = tT.ref(); + forAll(h, facei) { T[facei] = this->patchFaceMixture @@ -821,25 +747,15 @@ Foam::tmp Foam::heThermo::W { const fvMesh& mesh = this->T_.mesh(); - tmp tW + auto tW = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "W", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimMass/dimMoles - ) + "W", + IOobject::NO_REGISTER, + mesh, + dimMass/dimMoles ); + auto& W = tW.ref(); - volScalarField& W = tW.ref(); scalarField& WCells = W.primitiveFieldRef(); forAll(WCells, celli) @@ -847,7 +763,7 @@ Foam::tmp Foam::heThermo::W WCells[celli] = this->cellMixture(celli).W(); } - volScalarField::Boundary& WBf = W.boundaryFieldRef(); + auto& WBf = W.boundaryFieldRef(); forAll(WBf, patchi) { diff --git a/src/thermophysicalModels/basic/psiThermo/psiThermo.C b/src/thermophysicalModels/basic/psiThermo/psiThermo.C index 82e14feb19..871a795d68 100644 --- a/src/thermophysicalModels/basic/psiThermo/psiThermo.C +++ b/src/thermophysicalModels/basic/psiThermo/psiThermo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,11 +48,12 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("thermo:psi"), + phaseScopedName("thermo", "psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(0, -2, 2, 0, 0) @@ -62,11 +63,12 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("thermo:mu"), + phaseScopedName("thermo", "mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(1, -1, -1, 0, 0) @@ -87,11 +89,12 @@ Foam::psiThermo::psiThermo ( IOobject ( - phasePropertyName("thermo:psi"), + phaseScopedName("thermo", "psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(0, -2, 2, 0, 0) @@ -101,11 +104,12 @@ Foam::psiThermo::psiThermo ( IOobject ( - phasePropertyName("thermo:mu"), + phaseScopedName("thermo", "mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(1, -1, -1, 0, 0) diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C index 9ce5a2bd59..074cccfde8 100644 --- a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C +++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,11 +47,12 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("thermo:rho"), + phaseScopedName("thermo", "rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimDensity @@ -61,11 +62,12 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("thermo:psi"), + phaseScopedName("thermo", "psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(0, -2, 2, 0, 0) @@ -75,11 +77,12 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("thermo:mu"), + phaseScopedName("thermo", "mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(1, -1, -1, 0, 0) @@ -99,11 +102,12 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("thermo:rho"), + phaseScopedName("thermo", "rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimDensity @@ -113,11 +117,12 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("thermo:psi"), + phaseScopedName("thermo", "psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(0, -2, 2, 0, 0) @@ -127,11 +132,12 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("thermo:mu"), + phaseScopedName("thermo", "mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(1, -1, -1, 0, 0) @@ -151,11 +157,12 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("thermo:rho"), + phaseScopedName("thermo", "rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimDensity @@ -165,11 +172,12 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("thermo:psi"), + phaseScopedName("thermo", "psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(0, -2, 2, 0, 0) @@ -179,11 +187,12 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("thermo:mu"), + phaseScopedName("thermo", "mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh, dimensionSet(1, -1, -1, 0, 0) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C index a306b2dadd..03e1160b6c 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020-2021,2023 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -470,25 +470,14 @@ template Foam::tmp Foam::StandardChemistryModel::tc() const { - tmp ttc + auto ttc = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tc", - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(word::null, dimTime, SMALL), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + "tc", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(word::null, dimTime, SMALL), + fvPatchFieldBase::extrapolatedCalculatedType() ); - scalarField& tc = ttc.ref(); tmp trho(this->thermo().rho()); @@ -544,22 +533,12 @@ template Foam::tmp Foam::StandardChemistryModel::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Qdot", - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh_, - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + "Qdot", + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); if (this->chemistry_) @@ -592,24 +571,14 @@ Foam::StandardChemistryModel::calculateRR scalar pf, cf, pr, cr; label lRef, rRef; - tmp tRR + auto tRR = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "RR", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar(dimMass/dimVolume/dimTime, Zero) - ) + "RR", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); - - volScalarField::Internal& RR = tRR.ref(); + auto& RR = tRR.ref(); tmp trho(this->thermo().rho()); const scalarField& rho = trho(); diff --git a/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C b/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C index d17d028d9f..ddf47fb7f6 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C +++ b/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C @@ -112,25 +112,14 @@ Foam::tmp Foam::laminarFlameSpeedModels::Gulders::Su0pTphi scalar phi ) const { - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { @@ -165,25 +154,14 @@ Foam::tmp Foam::laminarFlameSpeedModels::Gulders::Su0pTphi const volScalarField& phi ) const { - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { diff --git a/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C b/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C index f3478e80b3..be2d86de45 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C +++ b/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C @@ -112,25 +112,14 @@ Foam::laminarFlameSpeedModels::GuldersEGR::Su0pTphi scalar phi ) const { - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { @@ -167,25 +156,14 @@ Foam::laminarFlameSpeedModels::GuldersEGR::Su0pTphi const volScalarField& egr ) const { - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { diff --git a/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C b/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C index ac4df02529..3f248fe4cc 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C +++ b/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C @@ -295,15 +295,7 @@ Foam::laminarFlameSpeedModels::RaviPetersen::operator()() const volScalarField EqR ( - IOobject - ( - "EqR", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + p.db().newIOobject("EqR"), p.mesh(), dimensionedScalar(dimless, Zero) ); @@ -323,25 +315,14 @@ Foam::laminarFlameSpeedModels::RaviPetersen::operator()() const EqR = equivalenceRatio_; } - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { diff --git a/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C b/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C index 2f09891022..351a7b9c32 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C +++ b/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C @@ -71,22 +71,12 @@ Foam::laminarFlameSpeedModels::constant::~constant() Foam::tmp Foam::laminarFlameSpeedModels::constant::operator()() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - psiuReactionThermo_.T().time().timeName(), - psiuReactionThermo_.T().db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - psiuReactionThermo_.T().mesh(), - Su_ - ) + "Su0", + IOobject::NO_REGISTER, + psiuReactionThermo_.T().mesh(), + Su_ ); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C index 16ec788656..c5d3d5ff61 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C @@ -158,7 +158,7 @@ updateCoeffs() Foam::tmp Foam::radiation:: greyDiffusiveViewFactorFixedValueFvPatchScalarField::qro(label bandI) const { - tmp tqrt(new scalarField(qro_)); + auto tqrt = tmp::New(qro_); const viewFactor& radiation = db().lookupObject("radiationProperties"); diff --git a/src/thermophysicalModels/radiation/radiationModels/P1/P1.C b/src/thermophysicalModels/radiation/radiationModels/P1/P1.C index 4df1c317a5..fa7214960d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/P1/P1.C +++ b/src/thermophysicalModels/radiation/radiationModels/P1/P1.C @@ -215,18 +215,13 @@ void Foam::radiation::P1::calculate() const dimensionedScalar a0("a0", a_.dimensions(), ROOTVSMALL); // Construct diffusion - const volScalarField gamma + const auto tgamma = volScalarField::New ( - IOobject - ( - "gammaRad", - G_.mesh().time().timeName(), - G_.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "gammaRad", + IOobject::REGISTER, // used by boundary conditions 1.0/(3.0*a_ + sigmaEff + a0) ); + const auto& gamma = tgamma(); // Solve G transport equation solve @@ -254,21 +249,11 @@ void Foam::radiation::P1::calculate() Foam::tmp Foam::radiation::P1::Rp() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Rp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - 4.0*absorptionEmission_->eCont()*physicoChemical::sigma - ) + "Rp", + IOobject::NO_REGISTER, + 4.0*absorptionEmission_->eCont()*physicoChemical::sigma ); } diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C index 0195a01d69..753b7fc0cf 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C @@ -201,21 +201,12 @@ Foam::radiation::blackBodyEmission::deltaLambdaT const Vector2D& band ) const { - tmp deltaLambdaT + auto deltaLambdaT = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "deltaLambdaT", - T.mesh().time().timeName(), - T.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - T.mesh(), - dimensionedScalar("deltaLambdaT", dimless, 1.0) - ) + "deltaLambdaT", + IOobject::NO_REGISTER, + T.mesh(), + dimensionedScalar("deltaLambdaT", dimless, 1.0) ); if (band != Vector2D::one) @@ -239,20 +230,11 @@ Foam::radiation::blackBodyEmission::EbDeltaLambdaT const Vector2D& band ) const { - tmp Eb + auto Eb = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Eb", - T.mesh().time().timeName(), - T.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - physicoChemical::sigma*pow4(T) - ) + "Eb", + IOobject::NO_REGISTER, + physicoChemical::sigma*pow4(T) ); if (band != Vector2D::one) diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C index e7aabf242a..234489340e 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -356,7 +356,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -369,7 +370,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) mesh_.time().timeName(), mesh_, IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -395,7 +397,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) mesh_.time().timeName(), mesh_, IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -462,7 +465,8 @@ Foam::radiation::fvDOM::fvDOM mesh_.time().timeName(), mesh_, IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -475,7 +479,8 @@ Foam::radiation::fvDOM::fvDOM mesh_.time().timeName(), mesh_, IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -501,7 +506,8 @@ Foam::radiation::fvDOM::fvDOM mesh_.time().timeName(), mesh_, IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -645,29 +651,18 @@ void Foam::radiation::fvDOM::calculate() Foam::tmp Foam::radiation::fvDOM::Rp() const { // Construct using contribution from first frequency band - tmp tRp + auto tRp = volScalarField::New ( - new volScalarField + "Rp", + IOobject::NO_REGISTER, ( - IOobject - ( - "Rp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - ( - 4 - *physicoChemical::sigma - *(aLambda_[0] - absorptionEmission_->aDisp(0)()) - *blackBody_.deltaLambdaT(T_, absorptionEmission_->bands(0)) - ) + 4 + * physicoChemical::sigma + * (aLambda_[0] - absorptionEmission_->aDisp(0)()) + * blackBody_.deltaLambdaT(T_, absorptionEmission_->bands(0)) ) ); - - volScalarField& Rp=tRp.ref(); + auto& Rp = tRp.ref(); // Add contributions over remaining frequency bands for (label j=1; j < nLambda_; j++) @@ -688,25 +683,14 @@ Foam::tmp Foam::radiation::fvDOM::Rp() const Foam::tmp> Foam::radiation::fvDOM::Ru() const { - tmp> tRu + auto tRu = DimensionedField::New ( - new DimensionedField - ( - IOobject - ( - "Ru", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimensionSet(1, -1, -3, 0, 0), Zero) - ) + "Ru", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimensionSet(1, -1, -3, 0, 0), Zero) ); - - DimensionedField& Ru=tRu.ref(); + auto& Ru = tRu.ref(); // Sum contributions over all frequency bands for (label j=0; j < nLambda_; j++) diff --git a/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.C b/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.C index ec998448ed..ae93e29668 100644 --- a/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.C +++ b/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.C @@ -82,16 +82,10 @@ void Foam::radiation::noRadiation::calculate() Foam::tmp Foam::radiation::noRadiation::Rp() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "Rp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Rp", + IOobject::NO_REGISTER, mesh_, dimensionedScalar ( @@ -104,16 +98,10 @@ Foam::tmp Foam::radiation::noRadiation::Rp() const Foam::tmp> Foam::radiation::noRadiation::Ru() const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - "Ru", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Ru", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); diff --git a/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C b/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C index 4fd40720a2..b99907d232 100644 --- a/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C +++ b/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C @@ -83,16 +83,10 @@ void Foam::radiation::opaqueSolid::calculate() Foam::tmp Foam::radiation::opaqueSolid::Rp() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "Rp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Rp", + IOobject::NO_REGISTER, mesh_, dimensionedScalar ( @@ -105,16 +99,10 @@ Foam::tmp Foam::radiation::opaqueSolid::Rp() const Foam::tmp> Foam::radiation::opaqueSolid::Ru() const { - return tmp::New + return volScalarField::Internal::New ( - IOobject - ( - "Ru", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Ru", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); @@ -126,4 +114,5 @@ Foam::label Foam::radiation::opaqueSolid::nBands() const return absorptionEmission_->nBands(); } + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C index 0980bc0b72..32fa503e54 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C @@ -58,7 +58,8 @@ void Foam::faceReflecting::initialise(const dictionary& coeffs) mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass/pow3(dimTime), Zero) @@ -393,17 +394,8 @@ void Foam::faceReflecting::calculate() PtrList> patcha(patches.size()); forAll(patchr, patchi) { - patchr.set - ( - patchi, - new List(nBands) - ); - - patcha.set - ( - patchi, - new List(nBands) - ); + patchr.emplace_set(patchi, nBands); + patcha.emplace_set(patchi, nBands); } // Fill patchr diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C index d415b9c030..7310b71551 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C @@ -214,22 +214,15 @@ void Foam::faceShading::calculate() if (debug) { - auto thitFaces = tmp::New + auto thitFaces = surfaceScalarField::New ( - IOobject - ( - "hitFaces", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "hitFaces", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero) ); + auto& hitFaces = thitFaces.ref(); - surfaceScalarField& hitFaces = thitFaces.ref(); surfaceScalarField::Boundary& hitFacesBf = hitFaces.boundaryFieldRef(); hitFacesBf = 0.0; diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index ef13824206..503a7489ce 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -911,17 +911,10 @@ void Foam::radiation::solarLoad::calculate() Foam::tmp Foam::radiation::solarLoad::Rp() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "Rp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "Rp", + IOobject::NO_REGISTER, mesh_, dimensionedScalar ( diff --git a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C index 63c0aa70af..9a1e62068d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C +++ b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C @@ -1133,17 +1133,10 @@ void Foam::radiation::viewFactor::calculate() Foam::tmp Foam::radiation::viewFactor::Rp() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "Rp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "Rp", + IOobject::NO_REGISTER, mesh_, dimensionedScalar ( @@ -1156,17 +1149,10 @@ Foam::tmp Foam::radiation::viewFactor::Rp() const Foam::tmp> Foam::radiation::viewFactor::Ru() const { - return tmp>::New + return DimensionedField::New ( - IOobject - ( - "Ru", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "Ru", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.C index f9f78d2d2d..10870b6660 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.C @@ -69,22 +69,12 @@ Foam::radiation::absorptionEmissionModel::a(const label bandI) const Foam::tmp Foam::radiation::absorptionEmissionModel::aCont(const label bandI) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "aCont", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "aCont", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); } @@ -92,22 +82,12 @@ Foam::radiation::absorptionEmissionModel::aCont(const label bandI) const Foam::tmp Foam::radiation::absorptionEmissionModel::aDisp(const label bandI) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "aDisp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "aDisp", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); } @@ -122,22 +102,12 @@ Foam::radiation::absorptionEmissionModel::e(const label bandI) const Foam::tmp Foam::radiation::absorptionEmissionModel::eCont(const label bandI) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "eCont", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "eCont", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); } @@ -145,22 +115,12 @@ Foam::radiation::absorptionEmissionModel::eCont(const label bandI) const Foam::tmp Foam::radiation::absorptionEmissionModel::eDisp(const label bandI) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "eDisp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "eDisp", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); } @@ -175,22 +135,12 @@ Foam::radiation::absorptionEmissionModel::E(const label bandI) const Foam::tmp Foam::radiation::absorptionEmissionModel::ECont(const label bandI) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "ECont", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "ECont", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); } @@ -198,22 +148,12 @@ Foam::radiation::absorptionEmissionModel::ECont(const label bandI) const Foam::tmp Foam::radiation::absorptionEmissionModel::EDisp(const label bandI) const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "EDisp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "EDisp", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C index c3f0af471a..5d3642c10e 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C @@ -67,75 +67,39 @@ Foam::radiation::constantAbsorptionEmission::constantAbsorptionEmission Foam::tmp Foam::radiation::constantAbsorptionEmission::aCont(const label bandI) const { - tmp ta + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - a_ - ) + "a", + IOobject::NO_REGISTER, + mesh_, + a_ ); - - return ta; } Foam::tmp Foam::radiation::constantAbsorptionEmission::eCont(const label bandI) const { - tmp te + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "e", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - e_ - ) + "e", + IOobject::NO_REGISTER, + mesh_, + e_ ); - - return te; } Foam::tmp Foam::radiation::constantAbsorptionEmission::ECont(const label bandI) const { - tmp tE + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - E_ - ) + "E", + IOobject::NO_REGISTER, + mesh_, + E_ ); - - return tE; } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C index 7aca57b922..b226234969 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C @@ -194,25 +194,15 @@ Foam::radiation::greyMeanAbsorptionEmission::aCont(const label bandI) const const volScalarField& p = thermo_.p(); - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "aCont" + name(bandI), - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar(dimless/dimLength, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + "aCont" + name(bandI), + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar(dimless/dimLength, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); - - scalarField& a = ta.ref().primitiveFieldRef(); + auto& a = ta.ref().primitiveFieldRef(); forAll(a, celli) { @@ -275,21 +265,12 @@ Foam::radiation::greyMeanAbsorptionEmission::eCont(const label bandI) const Foam::tmp Foam::radiation::greyMeanAbsorptionEmission::ECont(const label bandI) const { - tmp E + auto E = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "ECont" + name(bandI), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "ECont" + name(bandI), + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); const volScalarField* QdotPtr = mesh_.findObject("Qdot"); diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanSolidAbsorptionEmission/greyMeanSolidAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanSolidAbsorptionEmission/greyMeanSolidAbsorptionEmission.C index b4fc2fc425..310ea6f2f2 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanSolidAbsorptionEmission/greyMeanSolidAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanSolidAbsorptionEmission/greyMeanSolidAbsorptionEmission.C @@ -56,11 +56,11 @@ greyMeanSolidAbsorptionEmission::X(const word specie) const const volScalarField& T = thermo_.T(); const volScalarField& p = thermo_.p(); - tmp tXj(new scalarField(T.primitiveField().size(), Zero)); - scalarField& Xj = tXj.ref(); + auto tXj = tmp::New(T.primitiveField().size(), Zero); + auto& Xj = tXj.ref(); - tmp tRhoInv(new scalarField(T.primitiveField().size(), Zero)); - scalarField& rhoInv = tRhoInv.ref(); + auto tRhoInv = tmp::New(T.primitiveField().size(), Zero); + auto& rhoInv = tRhoInv.ref(); forAll(mixture_.Y(), specieI) { @@ -142,25 +142,15 @@ Foam::tmp Foam::radiation::greyMeanSolidAbsorptionEmission:: calc(const label propertyId) const { - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar(dimless/dimLength, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + "a", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar(dimless/dimLength, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); - - scalarField& a = ta.ref().primitiveFieldRef(); + auto& a = ta.ref().primitiveFieldRef(); forAllConstIters(speciesNames_, iter) { @@ -194,4 +184,5 @@ Foam::radiation::greyMeanSolidAbsorptionEmission::aCont return calc(absorptivity); } + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandAbsorptionEmission/multiBandAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandAbsorptionEmission/multiBandAbsorptionEmission.C index c7c3199f47..deb4da3b47 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandAbsorptionEmission/multiBandAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandAbsorptionEmission/multiBandAbsorptionEmission.C @@ -81,24 +81,13 @@ Foam::radiation::multiBandAbsorptionEmission::aCont const label bandI ) const { - tmp ta + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar("a", dimless/dimLength, absCoeffs_[bandI]) - ) + "a", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar("a", dimless/dimLength, absCoeffs_[bandI]) ); - - return ta; } @@ -108,24 +97,13 @@ Foam::radiation::multiBandAbsorptionEmission::eCont const label bandI ) const { - tmp te + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "e", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar("e", dimless/dimLength, emiCoeffs_[bandI]) - ) + "e", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar("e", dimless/dimLength, emiCoeffs_[bandI]) ); - - return te; } @@ -135,24 +113,13 @@ Foam::radiation::multiBandAbsorptionEmission::ECont const label bandI ) const { - tmp E + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "E", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); - - return E; } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C index 8c02bb90bc..44a7171bb3 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C @@ -108,23 +108,13 @@ Foam::radiation::multiBandZoneAbsorptionEmission::aCont const label bandI ) const { - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar("a", dimless/dimLength, absCoeffs_[bandI]) - ) + "a", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar("a", dimless/dimLength, absCoeffs_[bandI]) ); - scalarField& a = ta.ref().primitiveFieldRef(); for (const label zonei : zoneIds_) @@ -150,23 +140,13 @@ Foam::radiation::multiBandZoneAbsorptionEmission::eCont const label bandI ) const { - tmp te + auto te = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "e", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar("e", dimless/dimLength, emiCoeffs_[bandI]) - ) + "e", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar("e", dimless/dimLength, emiCoeffs_[bandI]) ); - scalarField& e = te.ref().primitiveFieldRef(); for (const label zonei : zoneIds_) @@ -192,24 +172,13 @@ Foam::radiation::multiBandZoneAbsorptionEmission::ECont const label bandI ) const { - tmp E + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "E", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); - - return E; } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C index 084cd0284f..3eb8adc9e5 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -206,23 +206,13 @@ Foam::radiation::wideBandAbsorptionEmission::aCont(const label bandi) const const volScalarField& T = thermo_.T(); const volScalarField& p = thermo_.p(); - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar(dimless/dimLength, Zero) - ) + "a", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar(dimless/dimLength, Zero) ); - scalarField& a = ta.ref().primitiveFieldRef(); forAll(a, celli) @@ -290,21 +280,12 @@ Foam::radiation::wideBandAbsorptionEmission::eCont(const label bandi) const Foam::tmp Foam::radiation::wideBandAbsorptionEmission::ECont(const label bandi) const { - tmp E + auto E = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh(), - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "E", + IOobject::NO_REGISTER, + mesh(), + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); const volScalarField* QdotPtr = mesh().findObject("Qdot"); diff --git a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C index e6201ee327..7092f15b49 100644 --- a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C +++ b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationProperties.C @@ -209,7 +209,7 @@ Foam::radiation::boundaryRadiationProperties::emissivity << "Please add it" << exit(FatalError); - return tmp::New(); + return nullptr; } @@ -262,13 +262,13 @@ Foam::radiation::boundaryRadiationProperties::absorptivity ); } - FatalErrorInFunction - << "Patch : " << mesh().boundaryMesh()[patchi].name() - << " is not found in the boundaryRadiationProperties. " - << "Please add it" - << exit(FatalError); + FatalErrorInFunction + << "Patch : " << mesh().boundaryMesh()[patchi].name() + << " is not found in the boundaryRadiationProperties. " + << "Please add it" + << exit(FatalError); - return tmp::New(); + return nullptr; } @@ -327,7 +327,7 @@ Foam::radiation::boundaryRadiationProperties::transmissivity << "Please add it" << exit(FatalError); - return tmp::New(); + return nullptr; } @@ -389,12 +389,12 @@ Foam::radiation::boundaryRadiationProperties::zoneTransmissivity } FatalErrorInFunction - << "Zone : " << mesh().faceZones()[zonei].name() - << " is not found in the boundaryRadiationProperties. " - << "Please add it" - << exit(FatalError); + << "Zone : " << mesh().faceZones()[zonei].name() + << " is not found in the boundaryRadiationProperties. " + << "Please add it" + << exit(FatalError); - return tmp::New(); + return nullptr; } @@ -423,7 +423,7 @@ Foam::radiation::boundaryRadiationProperties::diffReflectivity << "Please add it" << exit(FatalError); - return tmp::New(); + return nullptr; } @@ -482,7 +482,7 @@ Foam::radiation::boundaryRadiationProperties::specReflectivity << "Please add it" << exit(FatalError); - return tmp::New(); + return nullptr; } diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C index 666af9dc28..c14bdc79dc 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C @@ -66,22 +66,12 @@ Foam::radiation::constantScatter::constantScatter Foam::tmp Foam::radiation::constantScatter::sigmaEff() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "sigma", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - sigma_*(3.0 - C_) - ) + "sigma", + IOobject::NO_REGISTER, + mesh_, + sigma_*(3.0 - C_) ); } diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C index cc7f40c745..8d9d1f09b6 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C @@ -56,22 +56,12 @@ Foam::radiation::noScatter::noScatter Foam::tmp Foam::radiation::noScatter::sigmaEff() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "sigma", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "sigma", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); } diff --git a/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.C b/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.C index 5b9d6ab769..188d7ee652 100644 --- a/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.C +++ b/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.C @@ -70,7 +70,7 @@ Foam::tmp Foam::radiation::constantAbsorption::a scalarField* T ) const { - return tmp(new scalarField(pp_.size(), a_)); + return tmp::New(pp_.size(), a_); } @@ -93,7 +93,7 @@ Foam::tmp Foam::radiation::constantAbsorption::e scalarField* T ) const { - return tmp(new scalarField(pp_.size(), e_)); + return tmp::New(pp_.size(), e_); } diff --git a/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.C b/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.C index 82f8f824e7..6971d9b423 100644 --- a/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.C +++ b/src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.C @@ -82,7 +82,7 @@ Foam::radiation::multiBandAbsorption::a scalarField* T ) const { - return tmp(new scalarField(pp_.size(), aCoeffs_[bandI])); + return tmp::New(pp_.size(), aCoeffs_[bandI]); } Foam::scalar Foam::radiation::multiBandAbsorption::a @@ -104,7 +104,7 @@ Foam::tmp Foam::radiation::multiBandAbsorption::e scalarField* T ) const { - return tmp(new scalarField(pp_.size(), eCoeffs_[bandI])); + return tmp::New(pp_.size(), eCoeffs_[bandI]); } diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C index 7a33d69695..f9f8bef58c 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C @@ -98,7 +98,8 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture mesh.time().timeName(), mesh, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ); IOobject constantIO diff --git a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.C b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.C index 738cde1275..cf05a7c24b 100644 --- a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.C +++ b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.C @@ -253,7 +253,8 @@ Foam::heheuPsiThermo::heheuPsiThermo mesh.time().timeName(), mesh, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh ), @@ -328,7 +329,8 @@ Foam::heheuPsiThermo::heheuPsiThermo mesh.time().timeName(), mesh, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh ), @@ -429,8 +431,8 @@ Foam::heheuPsiThermo::heu const labelList& cells ) const { - tmp theu(new scalarField(Tu.size())); - scalarField& heu = theu.ref(); + auto theu = tmp::New(Tu.size()); + auto& heu = theu.ref(); forAll(Tu, celli) { @@ -450,8 +452,8 @@ Foam::heheuPsiThermo::heu const label patchi ) const { - tmp theu(new scalarField(Tu.size())); - scalarField& heu = theu.ref(); + auto theu = tmp::New(Tu.size()); + auto& heu = theu.ref(); forAll(Tu, facei) { @@ -467,24 +469,14 @@ template Foam::tmp Foam::heheuPsiThermo::Tb() const { - tmp tTb + auto tTb = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Tb", - this->T_.time().timeName(), - this->T_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->T_ - ) + "Tb", + IOobject::NO_REGISTER, + this->T_ ); + auto& Tb_ = tTb.ref(); - volScalarField& Tb_ = tTb.ref(); scalarField& TbCells = Tb_.primitiveFieldRef(); const scalarField& pCells = this->p_; const scalarField& TCells = this->T_; @@ -526,25 +518,15 @@ template Foam::tmp Foam::heheuPsiThermo::psiu() const { - tmp tpsiu + auto tpsiu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "psiu", - this->psi_.time().timeName(), - this->psi_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->psi_.mesh(), - this->psi_.dimensions() - ) + "psiu", + IOobject::NO_REGISTER, + this->psi_.mesh(), + this->psi_.dimensions() ); + auto& psiu = tpsiu.ref(); - volScalarField& psiu = tpsiu.ref(); scalarField& psiuCells = psiu.primitiveFieldRef(); const scalarField& TuCells = this->Tu_; const scalarField& pCells = this->p_; @@ -580,25 +562,15 @@ template Foam::tmp Foam::heheuPsiThermo::psib() const { - tmp tpsib + auto tpsib = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "psib", - this->psi_.time().timeName(), - this->psi_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->psi_.mesh(), - this->psi_.dimensions() - ) + "psib", + IOobject::NO_REGISTER, + this->psi_.mesh(), + this->psi_.dimensions() ); + auto& psib = tpsib.ref(); - volScalarField& psib = tpsib.ref(); scalarField& psibCells = psib.primitiveFieldRef(); const volScalarField Tb_(Tb()); const scalarField& TbCells = Tb_; @@ -635,25 +607,15 @@ template Foam::tmp Foam::heheuPsiThermo::muu() const { - tmp tmuu + auto tmuu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "muu", - this->T_.time().timeName(), - this->T_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->T_.mesh(), - dimensionSet(1, -1, -1, 0, 0) - ) + "muu", + IOobject::NO_REGISTER, + this->T_.mesh(), + dimensionSet(1, -1, -1, 0, 0) ); + auto& muu_ = tmuu.ref(); - volScalarField& muu_ = tmuu.ref(); scalarField& muuCells = muu_.primitiveFieldRef(); const scalarField& pCells = this->p_; const scalarField& TuCells = this->Tu_; @@ -693,25 +655,15 @@ template Foam::tmp Foam::heheuPsiThermo::mub() const { - tmp tmub + auto tmub = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "mub", - this->T_.time().timeName(), - this->T_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->T_.mesh(), - dimensionSet(1, -1, -1, 0, 0) - ) + "mub", + IOobject::NO_REGISTER, + this->T_.mesh(), + dimensionSet(1, -1, -1, 0, 0) ); + auto& mub_ = tmub.ref(); - volScalarField& mub_ = tmub.ref(); scalarField& mubCells = mub_.primitiveFieldRef(); const volScalarField Tb_(Tb()); const scalarField& pCells = this->p_; diff --git a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C index cda0d2ec76..2901ab58e0 100644 --- a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -621,25 +621,14 @@ Foam::pyrolysisChemistryModel::gasHs const label index ) const { - tmp tHs + auto tHs = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Hs_" + pyrolisisGases_[index], - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh_, - dimensionedScalar(dimEnergy/dimMass, Zero) - ) + "Hs_" + pyrolisisGases_[index], + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar(dimEnergy/dimMass, Zero) ); - - volScalarField::Internal& gasHs = tHs.ref(); + auto& gasHs = tHs.ref(); const GasThermo& mixture = gasThermo_[index]; diff --git a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModelI.H b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModelI.H index 5029c4b0f4..742f0e99d4 100644 --- a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModelI.H +++ b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModelI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -81,26 +82,17 @@ inline Foam::tmp> Foam::pyrolysisChemistryModel:: RRg() const { - tmp tRRg + auto tRRg = DimensionedField::New ( - new volScalarField::Internal - ( - IOobject - ( - "RRg", - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar(dimMass/dimVolume/dimTime, Zero) - ) + "RRg", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); + auto& RRg = tRRg.ref(); if (this->chemistry_) { - volScalarField::Internal& RRg = tRRg.ref(); for (label i=0; i < nGases_; i++) { RRg += RRg_[i]; diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C index 6441efddce..f16eb650bc 100644 --- a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -116,28 +117,17 @@ template Foam::tmp Foam::solidChemistryModel::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Qdot", - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::AUTO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh_, - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + "Qdot", + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); + scalarField& Qdot = tQdot.ref(); if (this->chemistry_) { - scalarField& Qdot = tQdot.ref(); - forAll(Ys_, i) { forAll(Qdot, celli) diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H index 855b29fb62..8b4fd00028 100644 --- a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -70,26 +70,17 @@ template inline Foam::tmp> Foam::solidChemistryModel::RRs() const { - tmp tRRs + auto tRRs = DimensionedField::New ( - new volScalarField::Internal - ( - IOobject - ( - "RRs", - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar(dimMass/dimVolume/dimTime, Zero) - ) + "RRs", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); + auto& RRs = tRRs.ref(); if (this->chemistry_) { - volScalarField::Internal& RRs = tRRs.ref(); for (label i=0; i < nSolids_; i++) { RRs += RRs_[i]; @@ -103,27 +94,17 @@ template inline Foam::tmp> Foam::solidChemistryModel::RRsHs() const { - tmp> tRRsHs + auto tRRsHs = DimensionedField::New ( - new DimensionedField - ( - IOobject - ( - "RRsHs", - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + "RRsHs", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); + auto& RRs = tRRsHs.ref(); if (this->chemistry_) { - DimensionedField& RRs = tRRsHs.ref(); - const volScalarField& T = this->solidThermo().T(); const volScalarField& p = this->solidThermo().p(); diff --git a/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C b/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C index e2b581d21d..def7f88fab 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C +++ b/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -219,24 +219,15 @@ Foam::heSolidThermo::Kappa() const { const fvMesh& mesh = this->T_.mesh(); - tmp tKappa + auto tKappa = volVectorField::New ( - new volVectorField - ( - IOobject - ( - "Kappa", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimEnergy/dimTime/dimLength/dimTemperature - ) + "Kappa", + IOobject::NO_REGISTER, + mesh, + dimEnergy/dimTime/dimLength/dimTemperature ); + auto& Kappa = tKappa.ref(); - volVectorField& Kappa = tKappa.ref(); vectorField& KappaCells = Kappa.primitiveFieldRef(); const scalarField& TCells = this->T_; const scalarField& pCells = this->p_; @@ -286,9 +277,9 @@ Foam::heSolidThermo::Kappa { const scalarField& pp = this->p_.boundaryField()[patchi]; const scalarField& Tp = this->T_.boundaryField()[patchi]; - tmp tKappa(new vectorField(pp.size())); - vectorField& Kappap = tKappa.ref(); + auto tKappa = tmp::New(pp.size()); + auto& Kappap = tKappa.ref(); forAll(Tp, facei) { diff --git a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H index 40c4162f94..f741963733 100644 --- a/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H +++ b/src/transportModels/geometricVoF/advectionSchemes/isoAdvection/isoAdvection.H @@ -355,15 +355,15 @@ public: //- Return mass flux tmp getRhoPhi ( - const dimensionedScalar rho1, - const dimensionedScalar rho2 + const dimensionedScalar& rho1, + const dimensionedScalar& rho2 ) const { - return tmp + return surfaceScalarField::New ( - new surfaceScalarField + "rhoPhi", + IOobject::NO_REGISTER, ( - "rhoPhi", (rho1 - rho2)*dVf_/mesh_.time().deltaT() + rho2*phi_ ) ); @@ -376,14 +376,14 @@ public: const volScalarField& rho2 ) { - return tmp - ( - new surfaceScalarField + return surfaceScalarField::New ( "rhoPhi", - fvc::interpolate(rho1 - rho2)*alphaPhi_ - + fvc::interpolate(rho2)*phi_ - ) + IOobject::NO_REGISTER, + ( + fvc::interpolate(rho1 - rho2)*alphaPhi_ + + fvc::interpolate(rho2)*phi_ + ) ); } diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C index 5275ca3017..54df8f0053 100644 --- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C +++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C @@ -130,9 +130,10 @@ Foam::incompressibleTwoPhaseMixture::mu() const clamp(alpha1_, zero_one{}) ); - return tmp::New + return volScalarField::New ( "mu", + IOobject::NO_REGISTER, limitedAlpha1*rho1_*nuModel1_->nu() + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu() ); @@ -155,9 +156,10 @@ Foam::incompressibleTwoPhaseMixture::muf() const clamp(fvc::interpolate(alpha1_), zero_one{}) ); - return tmp::New + return surfaceScalarField::New ( "muf", + IOobject::NO_REGISTER, alpha1f*rho1_*fvc::interpolate(nuModel1_->nu()) + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu()) ); @@ -172,9 +174,10 @@ Foam::incompressibleTwoPhaseMixture::nuf() const clamp(fvc::interpolate(alpha1_), zero_one{}) ); - return tmp::New + return surfaceScalarField::New ( "nuf", + IOobject::NO_REGISTER, ( alpha1f*rho1_*fvc::interpolate(nuModel1_->nu()) + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu()) diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C index d433938fc3..33e3d0fdc5 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C @@ -65,17 +65,10 @@ Foam::surfaceTensionModels::constant::~constant() Foam::tmp Foam::surfaceTensionModels::constant::sigma() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "sigma", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "sigma", + IOobject::NO_REGISTER, mesh_, sigma_ ); diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C index 488cd0e972..8fd8d54ce9 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C @@ -72,17 +72,10 @@ Foam::surfaceTensionModels::temperatureDependent::~temperatureDependent() Foam::tmp Foam::surfaceTensionModels::temperatureDependent::sigma() const { - auto tsigma = tmp::New + auto tsigma = volScalarField::New ( - IOobject - ( - "sigma", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "sigma", + IOobject::NO_REGISTER, mesh_, dimSigma ); From 7bf0aaf99c7cf03683b94f730aa1058d8d993f3c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 11:00:05 +0100 Subject: [PATCH 09/13] ENH: use tmp field factory methods [8] (#2723) - src/combustion --- src/combustionModels/EDC/EDC.C | 37 ++++------ src/combustionModels/FSD/FSD.C | 69 ++++++------------- .../consumptionSpeed/consumptionSpeed.C | 22 ++---- src/combustionModels/PaSR/PaSR.C | 25 ++++--- .../diffusionMulticomponent.C | 47 +++---------- .../eddyDissipationDiffusionModel.C | 23 ++----- src/combustionModels/laminar/laminar.C | 27 +++----- .../noCombustion/noCombustion.C | 22 ++---- 8 files changed, 82 insertions(+), 190 deletions(-) diff --git a/src/combustionModels/EDC/EDC.C b/src/combustionModels/EDC/EDC.C index 3e55ba9ce1..90fc7e2605 100644 --- a/src/combustionModels/EDC/EDC.C +++ b/src/combustionModels/EDC/EDC.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019-2020,2023 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,11 +59,12 @@ Foam::combustionModels::EDC::EDC ( IOobject ( - this->thermo().phasePropertyName(typeName + ":kappa"), + this->thermo().phaseScopedName(typeName, "kappa"), this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimless, Zero) @@ -86,23 +87,23 @@ void Foam::combustionModels::EDC::correct() if (this->active()) { tmp tepsilon(this->turbulence().epsilon()); - const volScalarField& epsilon = tepsilon(); + const auto& epsilon = tepsilon(); tmp tmu(this->turbulence().mu()); - const volScalarField& mu = tmu(); + const auto& mu = tmu(); tmp tk(this->turbulence().k()); - const volScalarField& k = tk(); + const auto& k = tk(); tmp trho(this->rho()); - const volScalarField& rho = trho(); + const auto& rho = trho(); scalarField tauStar(epsilon.size(), Zero); if (version_ == EDCversions::v2016) { tmp ttc(this->chemistryPtr_->tc()); - const volScalarField& tc = ttc(); + const auto& tc = ttc(); forAll(tauStar, i) { @@ -199,22 +200,12 @@ template Foam::tmp Foam::combustionModels::EDC::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); if (this->active()) diff --git a/src/combustionModels/FSD/FSD.C b/src/combustionModels/FSD/FSD.C index ef9f1d382d..03e4b93f68 100644 --- a/src/combustionModels/FSD/FSD.C +++ b/src/combustionModels/FSD/FSD.C @@ -72,7 +72,8 @@ FSD::FSD this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimless, Zero) @@ -149,43 +150,23 @@ void FSD::calculateSourceNorm() s.value()*YFuelFuelStream_.value() + YO2OxiStream_.value() ); - tmp tPc + auto tPc = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName("Pc"), - U.time().timeName(), - U.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U.mesh(), - dimensionedScalar(dimless, Zero) - ) + this->thermo().phasePropertyName("Pc"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedScalar(dimless, Zero) ); + auto& pc = tPc.ref(); - volScalarField& pc = tPc.ref(); - - tmp tomegaFuel + auto tomegaFuel = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName("omegaFuelBar"), - U.time().timeName(), - U.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U.mesh(), - dimensionedScalar(omegaFuel.dimensions(), Zero) - ) + this->thermo().phasePropertyName("omegaFuelBar"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedScalar(omegaFuel.dimensions(), Zero) ); - - volScalarField& omegaFuelBar = tomegaFuel.ref(); + auto& omegaFuelBar = tomegaFuel.ref(); // Calculation of the mixture fraction variance (ftVar) const compressible::LESModel& lesModel = @@ -294,24 +275,14 @@ void FSD::calculateSourceNorm() } } - tmp tproducts + auto tproducts = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName("products"), - U.time().timeName(), - U.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U.mesh(), - dimensionedScalar(dimless, Zero) - ) + this->thermo().phasePropertyName("products"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedScalar(dimless, Zero) ); - - volScalarField& products = tproducts.ref(); + auto& products = tproducts.ref(); forAll(productsIndex, j) { diff --git a/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C b/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C index 2322572550..808348cd20 100644 --- a/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C +++ b/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C @@ -82,24 +82,14 @@ Foam::tmp Foam::consumptionSpeed::omega0Sigma const volScalarField& sigma ) { - tmp tomega0 + auto tomega0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "omega0", - sigma.time().timeName(), - sigma.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - sigma.mesh(), - dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero) - ) + "omega0", + IOobject::NO_REGISTER, + sigma.mesh(), + dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero) ); - - volScalarField& omega0 = tomega0.ref(); + auto& omega0 = tomega0.ref(); volScalarField::Internal& iomega0 = omega0; diff --git a/src/combustionModels/PaSR/PaSR.C b/src/combustionModels/PaSR/PaSR.C index 63559a0aaf..77c75294fb 100644 --- a/src/combustionModels/PaSR/PaSR.C +++ b/src/combustionModels/PaSR/PaSR.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019,2023 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,11 +45,12 @@ Foam::combustionModels::PaSR::PaSR ( IOobject ( - thermo.phasePropertyName(typeName + ":kappa"), + thermo.phaseScopedName(typeName, "kappa"), this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimless, Zero) @@ -74,16 +75,16 @@ void Foam::combustionModels::PaSR::correct() laminar::correct(); tmp tepsilon(this->turbulence().epsilon()); - const scalarField& epsilon = tepsilon(); + const auto& epsilon = tepsilon(); tmp tmuEff(this->turbulence().muEff()); - const scalarField& muEff = tmuEff(); + const auto& muEff = tmuEff(); tmp ttc(this->tc()); - const scalarField& tc = ttc(); + const auto& tc = ttc(); tmp trho(this->rho()); - const scalarField& rho = trho(); + const auto& rho = trho(); forAll(epsilon, i) { @@ -118,13 +119,11 @@ template Foam::tmp Foam::combustionModels::PaSR::Qdot() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - kappa_*laminar::Qdot() - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + kappa_*laminar::Qdot() ); } diff --git a/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C b/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C index fb5c155625..7a10ab2a17 100644 --- a/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C +++ b/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C @@ -60,15 +60,7 @@ diffusionMulticomponent::init() k, new volScalarField ( - IOobject - ( - "Rijk" + Foam::name(k), - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + this->mesh_.newIOobject("Rijk" + Foam::name(k)), this->mesh_, dimensionedScalar(dimMass/dimTime/dimVolume, Zero), fvPatchFieldBase::zeroGradientType() @@ -198,15 +190,7 @@ diffusionMulticomponent::correct() k, new volScalarField ( - IOobject - ( - "Rijl" + Foam::name(k), - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + this->mesh_.newIOobject("Rijl" + Foam::name(k)), this->mesh_, dimensionedScalar(dimMass/dimTime/dimVolume, Zero), fvPatchFieldBase::zeroGradientType() @@ -374,9 +358,8 @@ Foam::combustionModels::diffusionMulticomponent::R volScalarField& Y ) const { - tmp tSu(new fvScalarMatrix(Y, dimMass/dimTime)); - - fvScalarMatrix& Su = tSu.ref(); + auto tSu = tmp::New(Y, dimMass/dimTime); + auto& Su = tSu.ref(); if (this->active()) { @@ -395,23 +378,13 @@ Foam::tmp Foam::combustionModels:: diffusionMulticomponent::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Qdot", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero), - fvPatchFieldBase::zeroGradientType() - ) + "Qdot", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero), + fvPatchFieldBase::zeroGradientType() ); if (this->active()) diff --git a/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C b/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C index fa042bfce0..b8c61234be 100644 --- a/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C +++ b/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C @@ -77,25 +77,16 @@ template Foam::tmp eddyDissipationDiffusionModel::rtDiff() const { - tmp tdelta + auto tdelta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tdelta", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar(dimLength, Zero), - fvPatchFieldBase::zeroGradientType() - ) + "tdelta", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimLength, Zero), + fvPatchFieldBase::zeroGradientType() ); + auto& delta = tdelta.ref(); - volScalarField& delta = tdelta.ref(); delta.ref() = cbrt(this->mesh().V()); delta.correctBoundaryConditions(); diff --git a/src/combustionModels/laminar/laminar.C b/src/combustionModels/laminar/laminar.C index 50f5681643..feb5889bb5 100644 --- a/src/combustionModels/laminar/laminar.C +++ b/src/combustionModels/laminar/laminar.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -123,9 +123,8 @@ template Foam::tmp Foam::combustionModels::laminar::R(volScalarField& Y) const { - tmp tSu(new fvScalarMatrix(Y, dimMass/dimTime)); - - fvScalarMatrix& Su = tSu.ref(); + auto tSu = tmp::New(Y, dimMass/dimTime); + auto& Su = tSu.ref(); if (this->active()) { @@ -143,22 +142,12 @@ template Foam::tmp Foam::combustionModels::laminar::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); if (this->active()) diff --git a/src/combustionModels/noCombustion/noCombustion.C b/src/combustionModels/noCombustion/noCombustion.C index e123b2f2dd..7bbeafa7dc 100644 --- a/src/combustionModels/noCombustion/noCombustion.C +++ b/src/combustionModels/noCombustion/noCombustion.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,12 +65,7 @@ Foam::combustionModels::noCombustion::R volScalarField& Y ) const { - tmp tSu - ( - new fvScalarMatrix(Y, dimMass/dimTime) - ); - - return tSu; + return tmp::New(Y, dimMass/dimTime); } @@ -78,17 +73,10 @@ template Foam::tmp Foam::combustionModels::noCombustion::Qdot() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); From d9483f50803bc87038363ea4001b40e7aebdc7d8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:37:00 +0100 Subject: [PATCH 10/13] ENH: use tmp field factory methods [9] (#2723) - src/phaseSystemModels --- .../constantDiameter/constantDiameter.C | 17 +-- .../dragModels/interface/interface.C | 13 +-- .../multiphaseSystem/multiphaseSystem.C | 104 +++++------------ .../multiphaseSystem/phaseModel/phaseModel.C | 43 ++----- .../InterfaceCompositionModel.C | 70 +++-------- .../MassTransferPhaseSystem.C | 75 ++++-------- .../constantSurfaceTensionCoefficient.C | 21 ++-- .../diffusionGasEvaporation.C | 26 ++--- .../interfaceHeatResistance.C | 10 +- .../interfaceOxideRate/interfaceOxideRate.C | 12 +- .../kineticGasEvaporation.C | 52 +++------ .../multiphaseInterSystem.C | 37 ++---- .../multiphaseSystem/multiphaseSystem.C | 55 +++------ .../MovingPhaseModel/MovingPhaseModel.C | 10 +- .../StaticPhaseModel/StaticPhaseModel.C | 34 ++---- .../BlendedInterfacialModel.C | 22 +--- .../blendingMethods/noBlending/noBlending.C | 12 +- .../MomentumTransferPhaseSystem.C | 53 ++++----- .../constantDiameter/constantDiameter.C | 17 +-- .../constantAspectRatio/constantAspectRatio.C | 6 +- .../multiphaseSystem/multiphaseSystem.C | 24 ++-- .../InertPhaseModel/InertPhaseModel.C | 5 +- .../IsothermalPhaseModel.C | 12 +- .../MovingPhaseModel/MovingPhaseModel.C | 59 +++------- .../phaseSystem/phaseSystem.C | 65 ++++++----- .../populationBalanceModel.C | 110 +++++------------- .../Schaeffer/SchaefferFrictionalStress.C | 23 +--- .../kineticTheoryModel/kineticTheoryModel.C | 34 ++---- .../phasePressureModel/phasePressureModel.C | 58 +++------ .../twoPhaseSystem/twoPhaseSystem.C | 18 +-- .../JohnsonJacksonSchaefferFrictionalStress.C | 23 +--- .../Schaeffer/SchaefferFrictionalStress.C | 23 +--- .../kineticTheoryModel/kineticTheoryModel.C | 34 ++---- .../phasePressureModel/phasePressureModel.C | 37 ++---- .../BlendedInterfacialModel.C | 90 ++++---------- .../blendingMethods/noBlending/noBlending.C | 60 +++------- .../IATE/IATEsources/dummy/dummy.C | 10 +- .../randomCoalescence/randomCoalescence.C | 20 +--- .../turbulentBreakUp/turbulentBreakUp.C | 20 +--- .../constantDiameter/constantDiameter.C | 20 +--- .../constantAspectRatio/constantAspectRatio.C | 12 +- .../constantLiftCoefficient.C | 12 +- .../liftModels/noLift/noLift.C | 45 ++----- .../swarmCorrections/noSwarm/noSwarm.C | 24 ++-- .../noTurbulentDispersion.C | 27 ++--- .../constantVirtualMassCoefficient.C | 22 +--- .../noVirtualMass/noVirtualMass.C | 12 +- .../noWallLubrication/noWallLubrication.C | 30 ++--- .../twoPhaseSystem/twoPhaseSystem.C | 20 +--- 49 files changed, 506 insertions(+), 1132 deletions(-) diff --git a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C index d3667c5204..048ac18ad0 100644 --- a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C +++ b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C @@ -68,19 +68,12 @@ Foam::multiphaseEuler::diameterModels::constant::constant Foam::tmp Foam::multiphaseEuler::diameterModels::constant::d() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "d", - phase_.U().time().timeName(), - phase_.U().mesh() - ), - phase_.U().mesh(), - d_ - ) + "d", + IOobject::NO_REGISTER, + phase_.U().mesh(), + d_ ); } diff --git a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/interfacialModels/dragModels/interface/interface.C b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/interfacialModels/dragModels/interface/interface.C index 4f4e171057..1138db3704 100644 --- a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/interfacialModels/dragModels/interface/interface.C +++ b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/interfacialModels/dragModels/interface/interface.C @@ -70,17 +70,10 @@ Foam::tmp Foam::multiphaseEuler::dragModels::interface::K const volScalarField& Ur ) const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "K", - Ur.mesh().time().timeName(), - Ur.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "K", + IOobject::NO_REGISTER, Ur.mesh(), dimensionedScalar(dimDensity/dimTime, Zero) ); diff --git a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C index c8142628ac..c19e5e5ef8 100644 --- a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C +++ b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C @@ -536,19 +536,12 @@ Foam::tmp Foam::multiphaseSystem::Cvm const phaseModel& phase ) const { - tmp tCvm + auto tCvm = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Cvm", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(dimDensity, Zero) - ) + "Cvm", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimDensity, Zero) ); for (const phaseModel& phase2 : phases_) @@ -584,23 +577,15 @@ Foam::tmp Foam::multiphaseSystem::Svm const phaseModel& phase ) const { - tmp tSvm + auto tSvm = volVectorField::New ( - new volVectorField + "Svm", + IOobject::NO_REGISTER, + mesh_, + dimensionedVector ( - IOobject - ( - "Svm", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedVector - ( - "Svm", - dimensionSet(1, -2, -2, 0, 0), - Zero - ) + dimensionSet(1, -2, -2, 0, 0), + Zero ) ); @@ -653,7 +638,7 @@ Foam::tmp Foam::multiphaseSystem::Svm Foam::autoPtr Foam::multiphaseSystem::dragCoeffs() const { - autoPtr dragCoeffsPtr(new dragCoeffFields); + auto dragCoeffsPtr = autoPtr::New(); forAllConstIters(dragModels_, iter) { @@ -708,24 +693,12 @@ Foam::tmp Foam::multiphaseSystem::dragCoeff const dragCoeffFields& dragCoeffs ) const { - tmp tdragCoeff + auto tdragCoeff = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "dragCoeff", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar - ( - "dragCoeff", - dimensionSet(1, -3, -1, 0, 0), - 0 - ) - ) + "dragCoeff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimensionSet(1, -3, -1, 0, 0), Zero) ); dragModelTable::const_iterator dmIter = dragModels_.begin(); @@ -756,24 +729,12 @@ Foam::tmp Foam::multiphaseSystem::surfaceTension const phaseModel& phase1 ) const { - tmp tSurfaceTension + auto tSurfaceTension = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - "surfaceTension", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar - ( - "surfaceTension", - dimensionSet(1, -2, -2, 0, 0), - 0 - ) - ) + "surfaceTension", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero) ); tSurfaceTension.ref().setOriented(); @@ -805,19 +766,12 @@ Foam::tmp Foam::multiphaseSystem::surfaceTension Foam::tmp Foam::multiphaseSystem::nearInterface() const { - tmp tnearInt + auto tnearInt = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "nearInterface", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar("nearInterface", dimless, 0.0) - ) + "nearInterface", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless, Zero) ); for (const phaseModel& phase : phases_) @@ -872,7 +826,7 @@ void Foam::multiphaseSystem::solve() mesh_ ), mesh_, - dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0) + dimensionedScalar(dimensionSet(0, 3, -1, 0, 0), Zero) ) ); diff --git a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C index 0da2401b99..48df9c09f5 100644 --- a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C +++ b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C @@ -118,39 +118,27 @@ Foam::phaseModel::phaseModel { alphaPhi_.setOriented(); - const word phiName = IOobject::groupName("phi", name_); - - IOobject phiHeader + IOobject io ( - phiName, + IOobject::groupName("phi", name_), mesh.time().timeName(), mesh, - IOobject::NO_READ + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER ); - if (phiHeader.typeHeaderOk(true)) + if (io.typeHeaderOk(true)) { - Info<< "Reading face flux field " << phiName << endl; + Info<< "Reading face flux field " << io.name() << endl; - phiPtr_.reset - ( - new surfaceScalarField - ( - IOobject - ( - phiName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); + phiPtr_.reset(new surfaceScalarField(io, mesh)); } else { - Info<< "Calculating face flux field " << phiName << endl; + Info<< "Calculating face flux field " << io.name() << endl; + + io.readOpt(IOobject::NO_READ); wordList phiTypes ( @@ -175,14 +163,7 @@ Foam::phaseModel::phaseModel ( new surfaceScalarField ( - IOobject - ( - phiName, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), + io, fvc::flux(U_), phiTypes ) diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/InterfaceCompositionModel/InterfaceCompositionModel.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/InterfaceCompositionModel/InterfaceCompositionModel.C index 4c15779cc3..6a91b73136 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/InterfaceCompositionModel/InterfaceCompositionModel.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/InterfaceCompositionModel/InterfaceCompositionModel.C @@ -78,21 +78,14 @@ Foam::InterfaceCompositionModel::getSpecieMassFraction { const fvMesh& mesh = fromThermo_.p().mesh(); - auto tY = tmp::New + auto tY = volScalarField::New ( - IOobject - ( - "tY", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tY", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - auto& Ys = tY.ref(); Ys = mixture.Y(speciesName); @@ -112,16 +105,10 @@ Foam::InterfaceCompositionModel::getSpecieMassFraction { const fvMesh& mesh = fromThermo_.p().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "tY", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tY", + IOobject::NO_REGISTER, mesh, scalar(1), dimless, @@ -140,16 +127,10 @@ Foam::InterfaceCompositionModel::MwMixture { const fvMesh& mesh = fromThermo_.p().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "tM", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tM", + IOobject::NO_REGISTER, mesh, dimensionedScalar ( @@ -230,18 +211,13 @@ Foam::InterfaceCompositionModel::Dto const volScalarField& T = toThermo_.T(); - auto tmpD = tmp::New + auto tmpD = volScalarField::New ( - IOobject - ( - IOobject::groupName("D", pair_.name()), - p.time().timeName(), - p.mesh() - ), + IOobject::groupName("D", pair_.name()), + IOobject::NO_REGISTER, p.mesh(), dimensionedScalar(dimArea/dimTime, Zero) ); - auto& D = tmpD.ref(); forAll(p, celli) @@ -276,18 +252,13 @@ Foam::InterfaceCompositionModel::Dfrom const volScalarField& T(fromThermo_.T()); - auto tmpD = tmp::New + auto tmpD = volScalarField::New ( - IOobject - ( - IOobject::groupName("D", pair_.name()), - p.time().timeName(), - p.mesh() - ), + IOobject::groupName("D", pair_.name()), + IOobject::NO_REGISTER, p.mesh(), dimensionedScalar(dimArea/dimTime, Zero) ); - auto& D = tmpD.ref(); forAll(p, celli) @@ -319,19 +290,14 @@ Foam::InterfaceCompositionModel::L const volScalarField& p(fromThermo_.p()); - auto tmpL = tmp::New + auto tmpL = volScalarField::New ( - IOobject - ( - IOobject::groupName("L", pair_.name()), - p.time().timeName(), - p.mesh() - ), + IOobject::groupName("L", pair_.name()), + IOobject::NO_REGISTER, p.mesh(), dimensionedScalar(dimEnergy/dimMass, Zero), fvPatchFieldBase::zeroGradientType() ); - auto& L = tmpL.ref(); // from Thermo (from) to Thermo (to) diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/MassTransferPhaseSystem/MassTransferPhaseSystem.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/MassTransferPhaseSystem/MassTransferPhaseSystem.C index 9bdd167d89..c1a2aca8cf 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/MassTransferPhaseSystem/MassTransferPhaseSystem.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/MassTransferPhaseSystem/MassTransferPhaseSystem.C @@ -62,7 +62,8 @@ Foam::MassTransferPhaseSystem::MassTransferPhaseSystem this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimDensity/dimTime, Zero) @@ -85,16 +86,10 @@ Foam::MassTransferPhaseSystem::calculateL const volScalarField& T ) const { - auto tL = tmp::New + auto tL = volScalarField::New ( - IOobject - ( - "tL", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tL", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimEnergy/dimMass, Zero) ); @@ -137,14 +132,10 @@ Foam::MassTransferPhaseSystem::dmdt const phasePairKey& key ) const { - auto tdmdt = tmp::New + auto tdmdt = volScalarField::New ( - IOobject - ( - "dmdt", - this->mesh().time().timeName(), - this->mesh() - ), + "dmdt", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimDensity/dimTime, Zero) ); @@ -188,40 +179,28 @@ Foam::MassTransferPhaseSystem::heatTransfer const phasePairKey keyki(phasek.name(), phasei.name(), true); // Net mass transfer from k to i phase - auto tdmdtNetki = tmp::New + auto tdmdtNetki = volScalarField::New ( - IOobject - ( - "tdmdtYki", - this->mesh().time().timeName(), - this->mesh() - ), + "tdmdtYki", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimDensity/dimTime, Zero) ); auto& dmdtNetki = tdmdtNetki.ref(); - auto tSp = tmp::New + auto tSp = volScalarField::New ( - IOobject - ( - "Sp", - this->mesh().time().timeName(), - this->mesh() - ), + "Sp", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimDensity/dimTime/dimTemperature, Zero) ); auto& Sp = tSp.ref(); - auto tSu = tmp::New + auto tSu = volScalarField::New ( - IOobject - ( - "Su", - this->mesh().time().timeName(), - this->mesh() - ), + "Su", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimDensity/dimTime, Zero) ); @@ -311,27 +290,19 @@ Foam::MassTransferPhaseSystem::volTransfer auto teqn = tmp::New(p, dimVolume/dimTime); auto& eqn = teqn.ref(); - auto tSp = tmp::New + auto tSp = volScalarField::New ( - IOobject - ( - "Sp", - this->mesh().time().timeName(), - this->mesh() - ), + "Sp", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimless/dimTime/dimPressure, Zero) ); auto& Sp = tSp.ref(); - auto tSu = tmp::New + auto tSu = volScalarField::New ( - IOobject - ( - "Su", - this->mesh().time().timeName(), - this->mesh() - ), + "Su", + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimless/dimTime, Zero) ); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C index bb4970e78f..ec2730a096 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C @@ -70,20 +70,15 @@ Foam::tmp Foam::multiphaseInter::surfaceTensionModels::constantSurfaceTensionCoefficient:: sigma() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return - tmp::New - ( - IOobject - ( - "zero", - mesh.time().timeName(), - mesh - ), - mesh, - sigma_ - ); + return volScalarField::New + ( + "zero", + IOobject::NO_REGISTER, + mesh, + sigma_ + ); } diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/diffusionGasEvaporation/diffusionGasEvaporation.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/diffusionGasEvaporation/diffusionGasEvaporation.C index 6a7e10ec02..af1f1fd260 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/diffusionGasEvaporation/diffusionGasEvaporation.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/diffusionGasEvaporation/diffusionGasEvaporation.C @@ -144,32 +144,26 @@ Foam::meltingEvaporationModels::diffusionGasEvaporation updateInterface(T); - auto tRhog = tmp::New + auto tRhog = volScalarField::New ( - IOobject - ( - "tRhog", - mesh.time().timeName(), - mesh - ), + "tRhog", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimDensity, Zero) ); - volScalarField& rhog = tRhog.ref(); + auto& rhog = tRhog.ref(); + rhog = this->pair().to().rho(); - auto tDvg = tmp::New + auto tDvg = volScalarField::New ( - IOobject - ( - "tDvg", - mesh.time().timeName(), - mesh - ), + "tDvg", + IOobject::NO_REGISTER, mesh, dimensionedScalar(sqr(dimLength)/dimTime, Zero) ); - volScalarField& Dvg = tDvg.ref(); + auto& Dvg = tDvg.ref(); + Dvg = this->Dto(speciesName); tmp tpSat = saturationModelPtr_->pSat(T); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceHeatResistance/interfaceHeatResistance.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceHeatResistance/interfaceHeatResistance.C index 0dfd7e8b11..a4934d3c3d 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceHeatResistance/interfaceHeatResistance.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceHeatResistance/interfaceHeatResistance.C @@ -195,14 +195,10 @@ Foam::meltingEvaporationModels::interfaceHeatResistance updateInterface(T); - auto tdeltaT = tmp::New + auto tdeltaT = volScalarField::New ( - IOobject - ( - "tdeltaT", - mesh.time().timeName(), - mesh - ), + "tdeltaT", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimTemperature, Zero) ); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceOxideRate/interfaceOxideRate.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceOxideRate/interfaceOxideRate.C index 617940487b..e052f6f3b1 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceOxideRate/interfaceOxideRate.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/interfaceOxideRate/interfaceOxideRate.C @@ -152,18 +152,14 @@ Foam::meltingEvaporationModels::interfaceOxideRate::Kexp const labelUList& fc = mesh.boundary()[patchi].faceCells(); tmp tsb = pp.source(); - auto tRhoto = tmp::New + auto tRhoto = volScalarField::New ( - IOobject - ( - "tRhoto", - mesh.time().timeName(), - mesh - ), + "tRhoto", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimDensity, Zero) ); - volScalarField& rhoto = tRhoto.ref(); + auto& rhoto = tRhoto.ref(); rhoto = this->pair().to().rho(); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/kineticGasEvaporation/kineticGasEvaporation.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/kineticGasEvaporation/kineticGasEvaporation.C index 83f0d399d4..1b42747e0a 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/kineticGasEvaporation/kineticGasEvaporation.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/massTransferModels/kineticGasEvaporation/kineticGasEvaporation.C @@ -167,37 +167,23 @@ Foam::meltingEvaporationModels::kineticGasEvaporation updateInterface(T); - tmp tRhov + auto tRhov = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tRhov", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar(dimDensity, Zero) - ) + "tRhov", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimDensity, Zero) ); - volScalarField& rhov = tRhov.ref(); + auto& rhov = tRhov.ref(); - tmp tdeltaT + auto tdeltaT = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tdeltaT", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar(dimTemperature, Zero) - ) + "tdeltaT", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimTemperature, Zero) ); - volScalarField& deltaT = tdeltaT.ref(); + auto& deltaT = tdeltaT.ref(); dimensionedScalar T0("T0", dimTemperature, Zero); @@ -216,7 +202,7 @@ Foam::meltingEvaporationModels::kineticGasEvaporation mDotc_ = htc_*deltaT*interfaceArea_; - return tmp(new volScalarField(mDotc_)); + return tmp::New(mDotc_); } @@ -241,10 +227,8 @@ Foam::meltingEvaporationModels::kineticGasEvaporation::KSp return(coeff*pos(Tactivate_ - refValue)); } } - else - { - return tmp (); - } + + return nullptr; } @@ -269,10 +253,8 @@ Foam::meltingEvaporationModels::kineticGasEvaporation::KSu return(coeff*pos(Tactivate_ - refValue)); } } - else - { - return tmp (); - } + + return nullptr; } diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseInterSystem/multiphaseInterSystem.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseInterSystem/multiphaseInterSystem.C index 69d2927d87..2a7fb6670e 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseInterSystem/multiphaseInterSystem.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseInterSystem/multiphaseInterSystem.C @@ -94,9 +94,10 @@ Foam::tmp Foam::multiphaseInterSystem::generatePhi { auto iter = phaseModels.cbegin(); - auto tmpPhi = tmp::New + auto tmpPhi = surfaceScalarField::New ( "phi", + IOobject::NO_REGISTER, fvc::interpolate(iter()()) * iter()->phi() ); @@ -925,12 +926,10 @@ Foam::tmp Foam::multiphaseInterSystem::nuEff() const Foam::tmp Foam::multiphaseInterSystem::kappaEff() const { - const volScalarField kappaEff + return ( this->kappa() + this->Cp()*turb_->mut()/Prt_ ); - - return tmp::New(kappaEff); } @@ -1075,14 +1074,10 @@ const Foam::fvMesh& Foam::multiphaseInterSystem::mesh() const Foam::tmp Foam::multiphaseInterSystem::surfaceTensionForce() const { - auto tstf = tmp::New + auto tstf = surfaceScalarField::New ( - IOobject - ( - "surfaceTensionForce", - mesh_.time().timeName(), - mesh_ - ), + "surfaceTensionForce", + IOobject::NO_REGISTER, mesh_, dimensionedScalar({1, -2, -2, 0, 0, 0}, Zero) ); @@ -1125,14 +1120,10 @@ Foam::multiphaseInterSystem::surfaceTensionForce() const Foam::tmp Foam::multiphaseInterSystem::U() const { - auto tstf = tmp::New + auto tstf = volVectorField::New ( - IOobject - ( - "U", - mesh_.time().timeName(), - mesh_ - ), + "U", + IOobject::NO_REGISTER, mesh_, dimensionedVector(dimVelocity, Zero) ); @@ -1232,14 +1223,10 @@ Foam::tmp Foam::multiphaseInterSystem::nearInterface Foam::tmp Foam::multiphaseInterSystem::nearInterface() const { - auto tnearInt = tmp::New + auto tnearInt = volScalarField::New ( - IOobject - ( - "nearInterface", - mesh_.time().timeName(), - mesh_ - ), + "nearInterface", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseSystem/multiphaseSystem.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseSystem/multiphaseSystem.C index 4cf91a30e3..7e2538f964 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseSystem/multiphaseSystem.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/multiphaseSystem/multiphaseSystem.C @@ -84,36 +84,22 @@ Foam::multiphaseInter::multiphaseSystem::multiphaseSystem { const multiphaseInter::phaseModel& pm = iter()(); - Su_.insert + Su_.emplace ( pm.name(), - volScalarField::Internal - ( - IOobject - ( - "Su" + pm.name(), - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(dimless/dimTime, Zero) - ) + // volScalarField::Internal + mesh_.newIOobject("Su" + pm.name()), + mesh_, + dimensionedScalar(dimless/dimTime, Zero) ); - Sp_.insert + Sp_.emplace ( pm.name(), - volScalarField::Internal - ( - IOobject - ( - "Sp" + pm.name(), - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(dimless/dimTime, Zero) - ) + // volScalarField::Internal + mesh_.newIOobject("Sp" + pm.name()), + mesh_, + dimensionedScalar(dimless/dimTime, Zero) ); } } @@ -138,12 +124,7 @@ void Foam::multiphaseInter::multiphaseSystem::solve() { surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - mesh_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("rhoPhiSum"), mesh_, dimensionedScalar(rhoPhi_.dimensions(), Zero) ); @@ -323,12 +304,7 @@ void Foam::multiphaseInter::multiphaseSystem::solveAlphas() volScalarField sumAlpha ( - IOobject - ( - "sumAlpha", - mesh_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("sumAlpha"), mesh_, dimensionedScalar(dimless, Zero) ); @@ -386,12 +362,7 @@ void Foam::multiphaseInter::multiphaseSystem::solveAlphas() { volScalarField sumAlpha ( - IOobject - ( - "sumAlpha", - mesh_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("sumAlpha"), mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C index efe8c61a6a..773bc831b5 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C @@ -124,14 +124,10 @@ template Foam::tmp Foam::MovingPhaseModel:: diffNo() const { - return tmp::New + return surfaceScalarField::New ( - IOobject - ( - IOobject::groupName("diffNo", multiphaseInter::phaseModel::name()), - U_.mesh().time().timeName(), - U_.mesh() - ), + IOobject::groupName("diffNo", multiphaseInter::phaseModel::name()), + IOobject::NO_REGISTER, U_.mesh(), dimensionedScalar(dimless, Zero) ); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/StaticPhaseModel/StaticPhaseModel.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/StaticPhaseModel/StaticPhaseModel.C index b86c773cc7..74e80086dc 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/StaticPhaseModel/StaticPhaseModel.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/StaticPhaseModel/StaticPhaseModel.C @@ -87,14 +87,10 @@ template Foam::tmp Foam::StaticPhaseModel::phi() const { - return tmp::New + return surfaceScalarField::New ( - IOobject - ( - IOobject::groupName("phi", multiphaseInter::phaseModel::name()), - U_.mesh().time().timeName(), - U_.mesh() - ), + IOobject::groupName("phi", multiphaseInter::phaseModel::name()), + IOobject::NO_REGISTER, U_.mesh(), dimensionedScalar(dimensionSet(0, 3, -1, 0, 0), Zero) ); @@ -114,18 +110,14 @@ template Foam::tmp Foam::StaticPhaseModel::alphaPhi() const { - return tmp::New + return surfaceScalarField::New ( - IOobject + IOobject::groupName ( - IOobject::groupName - ( - "alphaPhi", - multiphaseInter::phaseModel::name() - ), - U_.mesh().time().timeName(), - U_.mesh() + "alphaPhi", + multiphaseInter::phaseModel::name() ), + IOobject::NO_REGISTER, U_.mesh(), dimensionedScalar(dimensionSet(0, 3, -1, 0, 0), Zero) ); @@ -145,14 +137,10 @@ template Foam::tmp Foam::StaticPhaseModel::U() const { - return tmp::New + return volVectorField::New ( - IOobject - ( - IOobject::groupName("U", multiphaseInter::phaseModel::name()), - U_.mesh().time().timeName(), - U_.mesh() - ), + IOobject::groupName("U", multiphaseInter::phaseModel::name()), + IOobject::NO_REGISTER, U_.mesh(), dimensionedVector(dimVelocity, Zero) ); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C index 1ecb0a60cf..cafe46b30f 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2018 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -125,22 +125,12 @@ Foam::BlendedInterfacialModel::evaluate ); } - tmp x + auto x = typeGeoField::New ( - new typeGeoField - ( - IOobject - ( - ModelType::typeName + ":" + name, - phase1_.mesh().time().timeName(), - phase1_.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - phase1_.mesh(), - dimensioned(dims, Zero) - ) + IOobject::scopedName(ModelType::typeName, name), + IOobject::NO_REGISTER, + phase1_.mesh(), + dimensioned(dims, Zero) ); if (model_) diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C index 9057336a15..d53f32bef2 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C @@ -73,13 +73,15 @@ Foam::tmp Foam::blendingMethods::noBlending::f1 const phaseModel& phase2 ) const { - const fvMesh& mesh(phase1.mesh()); + const fvMesh& mesh = phase1.mesh(); return volScalarField::New ( "f", + IOobject::NO_REGISTER, mesh, - dimensionedScalar("one", dimless, phase2.name() == continuousPhase_) + scalar(phase2.name() == continuousPhase_), // value 0/1 + dimless ); } @@ -90,13 +92,15 @@ Foam::tmp Foam::blendingMethods::noBlending::f2 const phaseModel& phase2 ) const { - const fvMesh& mesh(phase1.mesh()); + const fvMesh& mesh = phase1.mesh(); return volScalarField::New ( "f", + IOobject::NO_REGISTER, mesh, - dimensionedScalar("one", dimless, phase1.name() == continuousPhase_) + scalar(phase1.name() == continuousPhase_), // value 0/1 + dimless ); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C index fb7c537721..53b1551bb2 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2018 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,15 +61,14 @@ Foam::MomentumTransferPhaseSystem::Kd { return dragModels_[key]->K(); } - else - { - return volScalarField::New - ( - dragModel::typeName + ":K", - this->mesh_, - dimensionedScalar(dragModel::dimK) - ); - } + + return volScalarField::New + ( + IOobject::scopedName(dragModel::typeName, "K"), + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar(dragModel::dimK) + ); } @@ -84,15 +83,14 @@ Foam::MomentumTransferPhaseSystem::Kdf { return dragModels_[key]->Kf(); } - else - { - return surfaceScalarField::New - ( - dragModel::typeName + ":K", - this->mesh_, - dimensionedScalar(dragModel::dimK) - ); - } + + return surfaceScalarField::New + ( + IOobject::scopedName(dragModel::typeName, "K"), + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar(dragModel::dimK) + ); } @@ -107,15 +105,14 @@ Foam::MomentumTransferPhaseSystem::Vm { return virtualMassModels_[key]->K(); } - else - { - return volScalarField::New - ( - virtualMassModel::typeName + ":K", - this->mesh_, - dimensionedScalar(virtualMassModel::dimK) - ); - } + + return volScalarField::New + ( + IOobject::scopedName(virtualMassModel::typeName, "K"), + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar(virtualMassModel::dimK) + ); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C index 8ec8a8be02..45a96bc20d 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.C @@ -70,19 +70,12 @@ Foam::diameterModels::constant::~constant() Foam::tmp Foam::diameterModels::constant::d() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "d", - phase_.time().timeName(), - phase_.mesh() - ), - phase_.mesh(), - d_ - ) + "d", + IOobject::NO_REGISTER, + phase_.mesh(), + d_ ); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C index 9b38688cdc..78c69f65b5 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2018 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -70,11 +71,12 @@ Foam::aspectRatioModels::constantAspectRatio::~constantAspectRatio() Foam::tmp Foam::aspectRatioModels::constantAspectRatio::E() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); return volScalarField::New ( - aspectRatioModel::typeName + ":E", + IOobject::scopedName(aspectRatioModel::typeName, "E"), + IOobject::NO_REGISTER, mesh, E0_ ); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C index e232ec1e39..19e4979a3e 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/multiphaseSystem/multiphaseSystem.C @@ -557,14 +557,12 @@ Foam::tmp Foam::multiphaseSystem::surfaceTension const phaseModel& phase1 ) const { - tmp tSurfaceTension + auto tSurfaceTension = surfaceScalarField::New ( - surfaceScalarField::New - ( - "surfaceTension", - mesh_, - dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero) - ) + "surfaceTension", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero) ); tSurfaceTension.ref().setOriented(); @@ -600,14 +598,12 @@ Foam::tmp Foam::multiphaseSystem::surfaceTension Foam::tmp Foam::multiphaseSystem::nearInterface() const { - tmp tnearInt + auto tnearInt = volScalarField::New ( - volScalarField::New - ( - "nearInterface", - mesh_, - dimensionedScalar(dimless, Zero) - ) + "nearInterface", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless, Zero) ); forAll(phases(), phasei) diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/InertPhaseModel/InertPhaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/InertPhaseModel/InertPhaseModel.C index 275f2faa9e..5497620c46 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/InertPhaseModel/InertPhaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/InertPhaseModel/InertPhaseModel.C @@ -58,10 +58,7 @@ Foam::InertPhaseModel::R volScalarField& Yi ) const { - return tmp - ( - new fvScalarMatrix(Yi, dimMass/dimTime) - ); + return tmp::New(Yi, dimMass/dimTime); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C index 4ffe5c6f65..8a0cbd7956 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/IsothermalPhaseModel/IsothermalPhaseModel.C @@ -50,15 +50,13 @@ void Foam::IsothermalPhaseModel::correctThermo() BasePhaseModel::correctThermo(); // Correct the thermo, but make sure that the temperature remains the same - tmp TCopy + auto TCopy = volScalarField::New ( - volScalarField::New - ( - this->thermo().T().name() + ":Copy", - this->thermo().T() - ) + IOobject::scopedName(this->thermo().T().name(), "Copy"), + IOobject::NO_REGISTER, + this->thermo().T() ); - this->thermo_->he() = this->thermo().he(this->thermo().p(), TCopy); + this->thermo_->he() = this->thermo().he(this->thermo().p(), TCopy()); this->thermo_->correct(); this->thermo_->T() = TCopy; } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C index c8d030117d..8d61626330 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C @@ -48,41 +48,29 @@ template Foam::tmp Foam::MovingPhaseModel::phi(const volVectorField& U) const { - word phiName(IOobject::groupName("phi", this->name())); - - IOobject phiHeader + IOobject io ( - phiName, + IOobject::groupName("phi", this->name()), U.mesh().time().timeName(), U.mesh(), - IOobject::NO_READ + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER ); - if (phiHeader.typeHeaderOk(true)) + if (io.typeHeaderOk(true)) { - Info<< "Reading face flux field " << phiName << endl; + Info<< "Reading face flux field " << io.name() << endl; - return tmp - ( - new surfaceScalarField - ( - IOobject - ( - phiName, - U.mesh().time().timeName(), - U.mesh(), - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - U.mesh() - ) - ); + return tmp::New(io, U.mesh()); } else { - Info<< "Calculating face flux field " << phiName << endl; + Info<< "Calculating face flux field " << io.name() << endl; - wordList phiTypes + io.readOpt(IOobject::NO_READ); + + wordList patchTypes ( U.boundaryField().size(), fvsPatchFieldBase::calculatedType() @@ -97,25 +85,15 @@ Foam::MovingPhaseModel::phi(const volVectorField& U) const || isA(U.boundaryField()[i]) ) { - phiTypes[i] = fixedValueFvPatchScalarField::typeName; + patchTypes[i] = fixedValueFvPatchScalarField::typeName; } } - return tmp + return tmp::New ( - new surfaceScalarField - ( - IOobject - ( - phiName, - U.mesh().time().timeName(), - U.mesh(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - fvc::flux(U), - phiTypes - ) + io, + fvc::flux(U), + patchTypes ); } } @@ -140,7 +118,8 @@ Foam::MovingPhaseModel::MovingPhaseModel fluid.mesh().time().timeName(), fluid.mesh(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), fluid.mesh() ), diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystem.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystem.C index bee5a74ba8..91335c8187 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystem.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystem.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2018 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,13 +53,11 @@ Foam::tmp Foam::phaseSystem::calcPhi const phaseModelList& phaseModels ) const { - tmp tphi + auto tphi = surfaceScalarField::New ( - surfaceScalarField::New - ( - "phi", - fvc::interpolate(phaseModels[0])*phaseModels[0].phi() - ) + "phi", + IOobject::NO_REGISTER, + fvc::interpolate(phaseModels[0])*phaseModels[0].phi() ); for (label phasei=1; phaseiE(); } - else - { - return volScalarField::New - ( - aspectRatioModel::typeName + ":E", - this->mesh_, - dimensionedScalar("one", dimless, 1) - ); - } + + return volScalarField::New + ( + IOobject::scopedName(aspectRatioModel::typeName, "E"), + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar("one", dimless, 1) + ); } @@ -322,19 +320,21 @@ Foam::phaseSystem::sigma(const phasePairKey& key) const { return surfaceTensionModels_[key]->sigma(); } - else - { - return volScalarField::New + + return volScalarField::New + ( + IOobject::scopedName ( - reactingMultiphaseEuler::surfaceTensionModel::typeName + ":sigma", - this->mesh_, - dimensionedScalar - ( - reactingMultiphaseEuler::surfaceTensionModel::dimSigma, - 0 - ) - ); - } + reactingMultiphaseEuler::surfaceTensionModel::typeName, "sigma" + ), + IOobject::NO_REGISTER, + this->mesh_, + dimensionedScalar + ( + reactingMultiphaseEuler::surfaceTensionModel::dimSigma, + Zero + ) + ); } @@ -346,8 +346,9 @@ Foam::tmp Foam::phaseSystem::dmdt return volScalarField::New ( IOobject::groupName("dmdt", phasePairs_[key]->name()), + IOobject::NO_REGISTER, this->mesh_, - dimensionedScalar("zero", dimDensity/dimTime, 0) + dimensionedScalar(dimDensity/dimTime, Zero) ); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C index e3e046cf44..9aac84604c 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C @@ -148,31 +148,23 @@ void Foam::diameterModels::populationBalanceModel::registerSizeGroups Su_.append ( - new volScalarField + volScalarField::New ( - IOobject - ( - "Su", - fluid_.time().timeName(), - mesh_ - ), + "Su", + IOobject::NO_REGISTER, mesh_, - dimensionedScalar("zero", inv(dimTime), 0) + dimensionedScalar(inv(dimTime), Zero) ) ); SuSp_.append ( - new volScalarField + volScalarField::New ( - IOobject - ( - "SuSp", - fluid_.time().timeName(), - mesh_ - ), + "SuSp", + IOobject::NO_REGISTER, mesh_, - dimensionedScalar("zero", inv(dimTime), 0) + dimensionedScalar(inv(dimTime), Zero) ) ); } @@ -957,14 +949,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "coalescenceRate", - mesh_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("coalescenceRate"), mesh_, - dimensionedScalar("zero", dimVolume/dimTime, Zero) + dimensionedScalar(dimVolume/dimTime, Zero) ) ); } @@ -975,14 +962,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "breakupRate", - fluid_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("breakupRate"), mesh_, - dimensionedScalar("zero", inv(dimTime), Zero) + dimensionedScalar(inv(dimTime), Zero) ) ); } @@ -993,19 +975,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "binaryBreakupRate", - fluid_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("binaryBreakupRate"), mesh_, - dimensionedScalar - ( - "binaryBreakupRate", - inv(dimVolume*dimTime), - Zero - ) + dimensionedScalar(inv(dimVolume*dimTime), Zero) ) ); } @@ -1016,14 +988,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "driftRate", - fluid_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("driftRate"), mesh_, - dimensionedScalar("zero", dimVolume/dimTime, Zero) + dimensionedScalar(dimVolume/dimTime, Zero) ) ); @@ -1031,14 +998,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "r", - fluid_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("rx"), mesh_, - dimensionedScalar("zero", dimless, Zero) + dimensionedScalar(dimless, Zero) ) ); @@ -1046,14 +1008,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "r", - fluid_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("rdx"), mesh_, - dimensionedScalar("zero", dimless, Zero) + dimensionedScalar(dimless, Zero) ) ); } @@ -1064,19 +1021,9 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ( new volScalarField ( - IOobject - ( - "nucleationRate", - fluid_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("nucleationRate"), mesh_, - dimensionedScalar - ( - "nucleationRate", - inv(dimTime*dimVolume), - Zero - ) + dimensionedScalar(inv(dimTime*dimVolume), Zero) ) ); } @@ -1093,10 +1040,11 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel fluid_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, - dimensionedScalar("zero", dimless, Zero) + dimensionedScalar(dimless, Zero) ) ); @@ -1110,10 +1058,11 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel fluid_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, - dimensionedScalar("zero", dimLength, Zero) + dimensionedScalar(dimLength, Zero) ) ); @@ -1127,7 +1076,8 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel fluid_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimVelocity, Zero) diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C index d0c5de3052..3f8066a18c 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C @@ -120,25 +120,14 @@ Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu { const volScalarField& alpha = phase; - tmp tnu + auto tnu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Schaeffer:nu", - phase.mesh().time().timeName(), - phase.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - phase.mesh(), - dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) - ) + IOobject::scopedName("Schaeffer", "nu"), + IOobject::NO_REGISTER, + phase.mesh(), + dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) ); - - volScalarField& nuf = tnu.ref(); + auto& nuf = tnu.ref(); forAll(D, celli) { diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 84a80a1a1c..b8bc3af38f 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -113,7 +113,8 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel U.time().timeName(), U.mesh(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), U.mesh() ), @@ -168,7 +169,8 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel U.time().timeName(), U.mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), U.mesh(), dimensionedScalar(dimViscosity, Zero) @@ -244,18 +246,11 @@ Foam::RASModels::kineticTheoryModel::omega() const Foam::tmp Foam::RASModels::kineticTheoryModel::R() const { - return tmp + return volSymmTensorField::New ( - new volSymmTensorField + IOobject::groupName("R", U_.group()), + IOobject::NO_REGISTER, ( - IOobject - ( - IOobject::groupName("R", U_.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - (nut_)*devTwoSymm(fvc::grad(U_)) - (lambda_*fvc::div(phi_))*symmTensor::I ) @@ -323,20 +318,13 @@ Foam::RASModels::kineticTheoryModel::devRhoReff const volVectorField& U ) const { - return tmp + return volSymmTensorField::New ( - new volSymmTensorField + IOobject::groupName("devRhoReff", U.group()), + IOobject::NO_REGISTER, ( - IOobject - ( - IOobject::groupName("devRhoReff", U.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - (rho_*nut_) - *devTwoSymm(fvc::grad(U)) + * devTwoSymm(fvc::grad(U)) - ((rho_*lambda_)*fvc::div(phi_))*symmTensor::I ) ); diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C index bf6fbd3316..0f04837778 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C @@ -123,21 +123,12 @@ Foam::RASModels::phasePressureModel::omega() const Foam::tmp Foam::RASModels::phasePressureModel::R() const { - return tmp + return volSymmTensorField::New ( - new volSymmTensorField - ( - IOobject - ( - IOobject::groupName("R", U_.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensioned(dimensionSet(0, 2, -2, 0, 0), Zero) - ) + IOobject::groupName("R", U_.group()), + IOobject::NO_REGISTER, + mesh_, + dimensioned(dimensionSet(0, 2, -2, 0, 0), Zero) ); } @@ -155,8 +146,7 @@ Foam::RASModels::phasePressureModel::pPrime() const ) ); - volScalarField::Boundary& bpPrime = - tpPrime.ref().boundaryFieldRef(); + auto& bpPrime = tpPrime.ref().boundaryFieldRef(); forAll(bpPrime, patchi) { @@ -183,8 +173,7 @@ Foam::RASModels::phasePressureModel::pPrimef() const ) ); - surfaceScalarField::Boundary& bpPrime = - tpPrime.ref().boundaryFieldRef(); + auto& bpPrime = tpPrime.ref().boundaryFieldRef(); forAll(bpPrime, patchi) { @@ -211,25 +200,15 @@ Foam::RASModels::phasePressureModel::devRhoReff const volVectorField& U ) const { - return tmp + return volSymmTensorField::New ( - new volSymmTensorField + IOobject::groupName("devRhoReff", U.group()), + IOobject::NO_REGISTER, + mesh_, + dimensioned ( - IOobject - ( - IOobject::groupName("devRhoReff", U.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensioned - ( - "R", - rho_.dimensions()*dimensionSet(0, 2, -2, 0, 0), - Zero - ) + rho_.dimensions()*dimensionSet(0, 2, -2, 0, 0), + Zero ) ); } @@ -241,13 +220,10 @@ Foam::RASModels::phasePressureModel::divDevRhoReff volVectorField& U ) const { - return tmp + return tmp::New ( - new fvVectorMatrix - ( - U, - rho_.dimensions()*dimensionSet(0, 4, -2, 0, 0) - ) + U, + rho_.dimensions()*dimensionSet(0, 4, -2, 0, 0) ); } diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C b/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C index d554ea70fe..9c10f71961 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C @@ -121,8 +121,6 @@ Foam::twoPhaseSystem::Vm() const void Foam::twoPhaseSystem::solve() { - const Time& runTime = mesh_.time(); - volScalarField& alpha1 = phase1_; volScalarField& alpha2 = phase2_; @@ -195,24 +193,14 @@ void Foam::twoPhaseSystem::solve() { volScalarField::Internal Sp ( - IOobject - ( - "Sp", - runTime.timeName(), - mesh_ - ), + mesh_.newIOobject("Sp"), mesh_, - dimensionedScalar(dimless/dimTime) + dimensionedScalar(dimless/dimTime, Zero) ); volScalarField::Internal Su ( - IOobject - ( - "Su", - runTime.timeName(), - mesh_ - ), + mesh_.newIOobject("Su"), // Divergence term is handled explicitly to be // consistent with the explicit transport solution fvc::div(phi_)*min(alpha1, scalar(1)) diff --git a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C index 170d0d4df3..cc8302f7c4 100644 --- a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C +++ b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C @@ -130,25 +130,14 @@ JohnsonJacksonSchaeffer::nu { const volScalarField& alpha = phase; - tmp tnu + auto tnu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "JohnsonJacksonSchaeffer:nu", - phase.mesh().time().timeName(), - phase.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - phase.mesh(), - dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) - ) + IOobject::scopedName("JohnsonJacksonSchaeffer", "nu"), + IOobject::NO_REGISTER, + phase.mesh(), + dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) ); - - volScalarField& nuf = tnu.ref(); + auto& nuf = tnu.ref(); forAll(D, celli) { diff --git a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C index ccb2ff83fc..26679d97d2 100644 --- a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C +++ b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C @@ -120,25 +120,14 @@ Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu { const volScalarField& alpha = phase; - tmp tnu + auto tnu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Schaeffer:nu", - phase.mesh().time().timeName(), - phase.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - phase.mesh(), - dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) - ) + IOobject::scopedName("Schaeffer", "nu"), + IOobject::NO_REGISTER, + phase.mesh(), + dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) ); - - volScalarField& nuf = tnu.ref(); + auto& nuf = tnu.ref(); forAll(D, celli) { diff --git a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 53f76222a6..e4228cf5a0 100644 --- a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -113,7 +113,8 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel U.time().timeName(), U.mesh(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), U.mesh() ), @@ -168,7 +169,8 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel U.time().timeName(), U.mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), U.mesh(), dimensionedScalar(dimViscosity, Zero) @@ -244,18 +246,11 @@ Foam::RASModels::kineticTheoryModel::omega() const Foam::tmp Foam::RASModels::kineticTheoryModel::R() const { - return tmp + return volSymmTensorField::New ( - new volSymmTensorField + IOobject::groupName("R", U_.group()), + IOobject::NO_REGISTER, ( - IOobject - ( - IOobject::groupName("R", U_.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - (nut_)*devTwoSymm(fvc::grad(U_)) - (lambda_*fvc::div(phi_))*symmTensor::I ) @@ -322,20 +317,13 @@ Foam::RASModels::kineticTheoryModel::devRhoReff const volVectorField& U ) const { - return tmp + return volSymmTensorField::New ( - new volSymmTensorField + IOobject::groupName("devRhoReff", U.group()), + IOobject::NO_REGISTER, ( - IOobject - ( - IOobject::groupName("devRhoReff", U.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - (rho_*nut_) - *devTwoSymm(fvc::grad(U)) + * devTwoSymm(fvc::grad(U)) - ((rho_*lambda_)*fvc::div(phi_))*symmTensor::I ) ); diff --git a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C index 42fa6cfbac..3534b0abe3 100644 --- a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C +++ b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/phasePressureModel/phasePressureModel.C @@ -106,7 +106,7 @@ Foam::tmp Foam::RASModels::phasePressureModel::k() const { NotImplemented; - return nut_; + return nullptr; } @@ -114,7 +114,7 @@ Foam::tmp Foam::RASModels::phasePressureModel::epsilon() const { NotImplemented; - return nut_; + return nullptr; } @@ -129,16 +129,10 @@ Foam::RASModels::phasePressureModel::omega() const Foam::tmp Foam::RASModels::phasePressureModel::R() const { - return tmp::New + return volSymmTensorField::New ( - IOobject - ( - IOobject::groupName("R", U_.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::groupName("R", U_.group()), + IOobject::NO_REGISTER, mesh_, dimensioned(dimensionSet(0, 2, -2, 0, 0), Zero) ); @@ -214,16 +208,10 @@ Foam::RASModels::phasePressureModel::devRhoReff const volVectorField& U ) const { - return tmp::New + return volSymmTensorField::New ( - IOobject - ( - IOobject::groupName("devRhoReff", U.group()), - runTime_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::groupName("devRhoReff", U.group()), + IOobject::NO_REGISTER, mesh_, dimensioned ( @@ -239,13 +227,10 @@ Foam::RASModels::phasePressureModel::divDevRhoReff volVectorField& U ) const { - return tmp + return tmp::New ( - new fvVectorMatrix - ( - U, - rho_.dimensions()*dimensionSet(0, 4, -2, 0, 0) - ) + U, + rho_.dimensions()*dimensionSet(0, 4, -2, 0, 0) ); } diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C index c9f207655d..6f32ceb265 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,8 +39,7 @@ void Foam::BlendedInterfacialModel::correctFixedFluxBCs GeometricField& field ) const { - typename GeometricField::Boundary& fieldBf = - field.boundaryFieldRef(); + auto& fieldBf = field.boundaryFieldRef(); forAll(pair_.phase1().phi().boundaryField(), patchi) { @@ -140,22 +139,12 @@ Foam::BlendedInterfacialModel::K() const f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } - tmp x + auto x = volScalarField::New ( - new volScalarField - ( - IOobject - ( - modelType::typeName + ":K", - pair_.phase1().mesh().time().timeName(), - pair_.phase1().mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - pair_.phase1().mesh(), - dimensionedScalar(modelType::dimK, Zero) - ) + IOobject::scopedName(modelType::typeName, "K"), + IOobject::NO_REGISTER, + pair_.phase1().mesh(), + dimensionedScalar(modelType::dimK, Zero) ); if (model_) @@ -208,22 +197,11 @@ Foam::BlendedInterfacialModel::Kf() const ); } - tmp x + auto x = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - modelType::typeName + ":Kf", - pair_.phase1().mesh().time().timeName(), - pair_.phase1().mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - pair_.phase1().mesh(), - dimensionedScalar(modelType::dimK, Zero) - ) + IOobject::scopedName(modelType::typeName, "Kf"), + pair_.phase1().mesh(), + dimensionedScalar(modelType::dimK, Zero) ); if (model_) @@ -271,17 +249,10 @@ Foam::BlendedInterfacialModel::F() const f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } - auto x = tmp>::New + auto x = GeometricField::New ( - IOobject - ( - modelType::typeName + ":F", - pair_.phase1().mesh().time().timeName(), - pair_.phase1().mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(modelType::typeName, "F"), + IOobject::NO_REGISTER, pair_.phase1().mesh(), dimensioned(modelType::dimF, Zero) ); @@ -336,17 +307,10 @@ Foam::BlendedInterfacialModel::Ff() const ); } - auto x = tmp::New + auto x = surfaceScalarField::New ( - IOobject - ( - modelType::typeName + ":Ff", - pair_.phase1().mesh().time().timeName(), - pair_.phase1().mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(modelType::typeName, "Ff"), + IOobject::NO_REGISTER, pair_.phase1().mesh(), dimensionedScalar(modelType::dimF*dimArea, Zero) ); @@ -397,22 +361,12 @@ Foam::BlendedInterfacialModel::D() const f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } - tmp x + auto x = volScalarField::New ( - new volScalarField - ( - IOobject - ( - modelType::typeName + ":D", - pair_.phase1().mesh().time().timeName(), - pair_.phase1().mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - pair_.phase1().mesh(), - dimensionedScalar(modelType::dimD, Zero) - ) + IOobject::scopedName(modelType::typeName, "D"), + IOobject::NO_REGISTER, + pair_.phase1().mesh(), + dimensionedScalar(modelType::dimD, Zero) ); if (model_) diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C index 3f3dfe09aa..4ba2773570 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/BlendedInterfacialModel/blendingMethods/noBlending/noBlending.C @@ -73,28 +73,16 @@ Foam::tmp Foam::blendingMethods::noBlending::f1 const phaseModel& phase2 ) const { - const fvMesh& mesh(phase1.mesh()); + const fvMesh& mesh = phase1.mesh(); - return - tmp - ( - new volScalarField - ( - IOobject - ( - "f", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar - ( - "f", - dimless, - phase2.name() != continuousPhase_ - ) - ) - ); + return volScalarField::New + ( + "f", + IOobject::NO_REGISTER, + mesh, + scalar(phase2.name() != continuousPhase_), // value 0/1 + dimless + ); } @@ -104,28 +92,16 @@ Foam::tmp Foam::blendingMethods::noBlending::f2 const phaseModel& phase2 ) const { - const fvMesh& mesh(phase1.mesh()); + const fvMesh& mesh = phase1.mesh(); - return - tmp - ( - new volScalarField - ( - IOobject - ( - "f", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar - ( - "f", - dimless, - phase1.name() == continuousPhase_ - ) - ) - ); + return volScalarField::New + ( + "f", + IOobject::NO_REGISTER, + mesh, + scalar(phase1.name() == continuousPhase_), // value 0/1 + dimless + ); } diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/dummy/dummy.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/dummy/dummy.C index d0e2dfda5b..65f6012b92 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/dummy/dummy.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/dummy/dummy.C @@ -48,14 +48,10 @@ namespace IATEsources Foam::tmp Foam::diameterModels::IATEsources::dummy::R() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "R", - iate_.phase().U().time().timeName(), - iate_.phase().mesh() - ), + "R", + IOobject::NO_REGISTER, iate_.phase().U().mesh(), dimensionedScalar(dimless/dimTime, Zero) ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/randomCoalescence/randomCoalescence.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/randomCoalescence/randomCoalescence.C index 39ee3276db..6f80349065 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/randomCoalescence/randomCoalescence.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/randomCoalescence/randomCoalescence.C @@ -64,22 +64,14 @@ randomCoalescence Foam::tmp Foam::diameterModels::IATEsources::randomCoalescence::R() const { - tmp tR + auto tR = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "R", - iate_.phase().U().time().timeName(), - iate_.phase().mesh() - ), - iate_.phase().U().mesh(), - dimensionedScalar(dimless/dimTime, Zero) - ) + "R", + IOobject::NO_REGISTER, + iate_.phase().U().mesh(), + dimensionedScalar(dimless/dimTime, Zero) ); - - volScalarField R = tR(); + auto& R = tR.ref(); scalar Crc = Crc_.value(); scalar C = C_.value(); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C index f8129e55ed..f7f4921c44 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C @@ -63,22 +63,14 @@ turbulentBreakUp Foam::tmp Foam::diameterModels::IATEsources::turbulentBreakUp::R() const { - tmp tR + auto tR = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "R", - iate_.phase().U().time().timeName(), - iate_.phase().mesh() - ), - iate_.phase().U().mesh(), - dimensionedScalar(dimless/dimTime, Zero) - ) + "R", + IOobject::NO_REGISTER, + iate_.phase().U().mesh(), + dimensionedScalar(dimless/dimTime, Zero) ); - - volScalarField R = tR(); + auto R = tR(); const scalar Cti = Cti_.value(); const scalar WeCr = WeCr_.value(); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.C index c6f0a03f7b..dce8516716 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.C @@ -69,22 +69,12 @@ Foam::diameterModels::constant::~constant() Foam::tmp Foam::diameterModels::constant::d() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "d", - phase_.U().time().timeName(), - phase_.U().mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - phase_.U().mesh(), - d_ - ) + "d", + IOobject::NO_REGISTER, + phase_.U().mesh(), + d_ ); } diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C index 790c071fca..c4ec68bc6a 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/aspectRatioModels/constantAspectRatio/constantAspectRatio.C @@ -70,16 +70,12 @@ Foam::aspectRatioModels::constantAspectRatio::~constantAspectRatio() Foam::tmp Foam::aspectRatioModels::constantAspectRatio::E() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "zero", - mesh.time().timeName(), - mesh - ), + "zero", + IOobject::NO_REGISTER, mesh, E0_ ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/constantLiftCoefficient/constantLiftCoefficient.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/constantLiftCoefficient/constantLiftCoefficient.C index d606d0dc6a..c17e6f9573 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/constantLiftCoefficient/constantLiftCoefficient.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/constantLiftCoefficient/constantLiftCoefficient.C @@ -65,16 +65,12 @@ Foam::liftModels::constantLiftCoefficient::~constantLiftCoefficient() Foam::tmp Foam::liftModels::constantLiftCoefficient::Cl() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "zero", - mesh.time().timeName(), - mesh - ), + "zero", + IOobject::NO_REGISTER, mesh, Cl_ ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/noLift/noLift.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/noLift/noLift.C index 2b540ed3fa..d36090c36d 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/noLift/noLift.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/liftModels/noLift/noLift.C @@ -63,19 +63,12 @@ Foam::liftModels::noLift::~noLift() Foam::tmp Foam::liftModels::noLift::Cl() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "Cl", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "Cl", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimless, Zero) ); @@ -84,19 +77,12 @@ Foam::tmp Foam::liftModels::noLift::Cl() const Foam::tmp Foam::liftModels::noLift::F() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volVectorField::New ( - IOobject - ( - "noLift:F", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noLift", "F"), + IOobject::NO_REGISTER, mesh, dimensionedVector(dimF, Zero) ); @@ -105,19 +91,12 @@ Foam::tmp Foam::liftModels::noLift::F() const Foam::tmp Foam::liftModels::noLift::Ff() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return surfaceScalarField::New ( - IOobject - ( - "noLift:Ff", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noLift", "Ff"), + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimF*dimArea, Zero) ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/swarmCorrections/noSwarm/noSwarm.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/swarmCorrections/noSwarm/noSwarm.C index e799cca447..86192abec2 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/swarmCorrections/noSwarm/noSwarm.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/swarmCorrections/noSwarm/noSwarm.C @@ -63,23 +63,15 @@ Foam::swarmCorrections::noSwarm::~noSwarm() Foam::tmp Foam::swarmCorrections::noSwarm::Cs() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return - tmp - ( - new volScalarField - ( - IOobject - ( - "one", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar("one", dimless, 1) - ) - ); + return volScalarField::New + ( + "one", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar("one", dimless, 1) + ); } diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/turbulentDispersionModels/noTurbulentDispersion/noTurbulentDispersion.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/turbulentDispersionModels/noTurbulentDispersion/noTurbulentDispersion.C index 2d3180152d..cbd4aaa3b1 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/turbulentDispersionModels/noTurbulentDispersion/noTurbulentDispersion.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/turbulentDispersionModels/noTurbulentDispersion/noTurbulentDispersion.C @@ -70,19 +70,12 @@ Foam::turbulentDispersionModels::noTurbulentDispersion:: Foam::tmp Foam::turbulentDispersionModels::noTurbulentDispersion::D() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "zero", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "zero", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimD, Zero) ); @@ -92,16 +85,12 @@ Foam::turbulentDispersionModels::noTurbulentDispersion::D() const Foam::tmp Foam::turbulentDispersionModels::noTurbulentDispersion::F() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volVectorField::New ( - IOobject - ( - "zero", - mesh.time().timeName(), - mesh - ), + "zero", + IOobject::NO_REGISTER, mesh, dimensionedVector(dimF, Zero) ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/constantVirtualMassCoefficient/constantVirtualMassCoefficient.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/constantVirtualMassCoefficient/constantVirtualMassCoefficient.C index 0c8a3bff33..74380463b5 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/constantVirtualMassCoefficient/constantVirtualMassCoefficient.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/constantVirtualMassCoefficient/constantVirtualMassCoefficient.C @@ -73,24 +73,14 @@ Foam::virtualMassModels::constantVirtualMassCoefficient:: Foam::tmp Foam::virtualMassModels::constantVirtualMassCoefficient::Cvm() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Cvm", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - Cvm_ - ) + "Cvm", + IOobject::NO_REGISTER, + mesh, + Cvm_ ); } diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/noVirtualMass/noVirtualMass.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/noVirtualMass/noVirtualMass.C index a135d5d887..a9f4c9f108 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/noVirtualMass/noVirtualMass.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/noVirtualMass/noVirtualMass.C @@ -65,16 +65,12 @@ Foam::virtualMassModels::noVirtualMass::~noVirtualMass() Foam::tmp Foam::virtualMassModels::noVirtualMass::Cvm() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volScalarField::New ( - IOobject - ( - "zero", - mesh.time().timeName(), - mesh - ), + "zero", + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimless, Zero) ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/wallLubricationModels/noWallLubrication/noWallLubrication.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/wallLubricationModels/noWallLubrication/noWallLubrication.C index 4eb415f7e4..d9a23e9ab3 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/wallLubricationModels/noWallLubrication/noWallLubrication.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/wallLubricationModels/noWallLubrication/noWallLubrication.C @@ -69,19 +69,12 @@ Foam::wallLubricationModels::noWallLubrication::~noWallLubrication() Foam::tmp Foam::wallLubricationModels::noWallLubrication::Fi() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volVectorField::New ( - IOobject - ( - "noWallLubrication:Fi", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noWallLubrication", "Fi"), + IOobject::NO_REGISTER, mesh, dimensionedVector(dimF, Zero) ); @@ -91,19 +84,12 @@ Foam::wallLubricationModels::noWallLubrication::Fi() const Foam::tmp Foam::wallLubricationModels::noWallLubrication::F() const { - const fvMesh& mesh(this->pair_.phase1().mesh()); + const fvMesh& mesh = this->pair_.phase1().mesh(); - return tmp::New + return volVectorField::New ( - IOobject - ( - "noWallLubrication:F", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName("noWallLubrication", "F"), + IOobject::NO_REGISTER, mesh, dimensionedVector(dimF, Zero) ); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C index fdb52fea29..ac5bc45b9d 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C @@ -110,7 +110,7 @@ Foam::twoPhaseSystem::twoPhaseSystem IOobject::AUTO_WRITE ), mesh, - dimensionedScalar("dgdt", dimless/dimTime, Zero) + dimensionedScalar(dimless/dimTime, Zero) ) { phase2_.volScalarField::operator=(scalar(1) - phase1_); @@ -351,8 +351,6 @@ Foam::tmp Foam::twoPhaseSystem::D() const void Foam::twoPhaseSystem::solve() { - const Time& runTime = mesh_.time(); - volScalarField& alpha1 = phase1_; volScalarField& alpha2 = phase2_; @@ -396,24 +394,14 @@ void Foam::twoPhaseSystem::solve() { volScalarField::Internal Sp ( - IOobject - ( - "Sp", - runTime.timeName(), - mesh_ - ), + mesh_.newIOobject("Sp"), mesh_, - dimensionedScalar("Sp", dgdt_.dimensions(), 0.0) + dimensionedScalar(dgdt_.dimensions(), Zero) ); volScalarField::Internal Su ( - IOobject - ( - "Su", - runTime.timeName(), - mesh_ - ), + mesh_.newIOobject("Su"), // Divergence term is handled explicitly to be // consistent with the explicit transport solution fvc::div(phi_)*min(alpha1, scalar(1)) From c138f89c1f874a49f2bf6d83b1a1dfb0fdc8a024 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:53:02 +0100 Subject: [PATCH 11/13] ENH: use tmp field factory methods [10] (#2723) - src/TurbulenceModels --- .../ThermalDiffusivity/ThermalDiffusivity.C | 5 +- .../turbulenceModels/DES/DESModel/DESModel.C | 12 +-- .../LES/LESdeltas/IDDESDelta/IDDESDelta.C | 19 ++--- .../anisotropicFilter/anisotropicFilter.C | 34 +++----- .../LES/dynamicKEqn/dynamicKEqn.C | 10 +-- .../turbulenceModels/LES/kEqn/kEqn.C | 10 +-- .../RAS/LaunderSharmaKE/LaunderSharmaKE.C | 20 ++--- .../turbulenceModels/RAS/RASModel/RASModel.C | 20 ++--- .../RAS/RNGkEpsilon/RNGkEpsilon.C | 20 ++--- .../turbulenceModels/RAS/kEpsilon/kEpsilon.C | 20 ++--- .../RAS/kOmegaSSTLM/kOmegaSSTLM.C | 79 +++++++------------ .../RAS/realizableKE/realizableKE.C | 20 ++--- .../eddyViscosity/eddyViscosity.C | 23 ++---- .../turbulenceModels/laminar/Stokes/Stokes.C | 27 ++----- .../laminar/laminarModel/laminarModel.C | 79 +++++-------------- .../turbulenceModels/RAS/kL/kL.C | 39 ++++----- .../multiphaseMangrovesSource.C | 26 ++---- .../multiphaseMangrovesTurbulenceModel.C | 31 ++------ 18 files changed, 148 insertions(+), 346 deletions(-) diff --git a/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C b/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C index b249146c06..e658882d6a 100644 --- a/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C +++ b/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C @@ -143,10 +143,7 @@ Foam::ThermalDiffusivity::alphat const label patchi ) const { - return tmp - ( - new scalarField(this->mesh_.boundary()[patchi].size(), Zero) - ); + return tmp::New(this->mesh_.boundary()[patchi].size(), Zero); } diff --git a/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C b/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C index c99d84c6f7..cf223102f4 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C +++ b/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C @@ -168,16 +168,10 @@ tmp DESModel::Ssigma template tmp DESModel::fd() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "fd", - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "fd", + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C index 5ae16f229b..8386344061 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C @@ -53,21 +53,12 @@ void Foam::LESModels::IDDESDelta::calcDelta() // Wall-normal vectors const volVectorField& n = wallDist::New(mesh).n(); - tmp tfaceToFacenMax + auto tfaceToFacenMax = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "faceToFaceMax", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar(dimLength, Zero) - ) + "faceToFaceMax", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimLength, Zero) ); scalarField& faceToFacenMax = tfaceToFacenMax.ref().primitiveFieldRef(); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C index f0b284fb76..1ef8a7673f 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C @@ -182,19 +182,12 @@ Foam::tmp Foam::anisotropicFilter::operator() { correctBoundaryConditions(unFilteredField); - tmp tmpFilteredField + auto tmpFilteredField = volSymmTensorField::New ( - new volSymmTensorField - ( - IOobject - ( - "anisotropicFilteredSymmTensorField", - mesh().time().timeName(), - mesh() - ), - mesh(), - unFilteredField().dimensions() - ) + "anisotropicFilteredSymmTensorField", + IOobject::NO_REGISTER, + mesh(), + unFilteredField().dimensions() ); for (direction d=0; d Foam::anisotropicFilter::operator() { correctBoundaryConditions(unFilteredField); - tmp tmpFilteredField + auto tmpFilteredField = volTensorField::New ( - new volTensorField - ( - IOobject - ( - "anisotropicFilteredTensorField", - mesh().time().timeName(), - mesh() - ), - mesh(), - unFilteredField().dimensions() - ) + "anisotropicFilteredTensorField", + IOobject::NO_REGISTER, + mesh(), + unFilteredField().dimensions() ); for (direction d=0; d::correctNut() template tmp dynamicKEqn::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C b/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C index 50fb5f029f..6ecd8118f6 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C +++ b/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C @@ -52,14 +52,10 @@ void kEqn::correctNut() template tmp kEqn::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C index f0a84979f4..a414e8bc4e 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -69,14 +69,10 @@ void LaunderSharmaKE::correctNut() template tmp LaunderSharmaKE::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -84,14 +80,10 @@ tmp LaunderSharmaKE::kSource() const template tmp LaunderSharmaKE::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C index 661f65ebba..aefac5045e 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C @@ -193,14 +193,10 @@ Foam::RASModel::epsilon() const { const scalar Cmu = 0.09; - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), - this->mesh_.time().timeName(), - this->mesh_ - ), + IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, Cmu*this->k()*this->omega() ); } @@ -213,14 +209,10 @@ Foam::RASModel::omega() const const scalar betaStar = 0.09; const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL); - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("omega", this->alphaRhoPhi_.group()), - this->mesh_.time().timeName(), - this->mesh_ - ), + IOobject::groupName("omega", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->epsilon()/(betaStar*(this->k() + k0)) ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C b/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C index 3f7df45d61..6760dc8269 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C @@ -53,14 +53,10 @@ void RNGkEpsilon::correctNut() template tmp RNGkEpsilon::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -68,14 +64,10 @@ tmp RNGkEpsilon::kSource() const template tmp RNGkEpsilon::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C b/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C index ead17ff204..d66b80be90 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C @@ -53,14 +53,10 @@ void kEpsilon::correctNut() template tmp kEpsilon::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -68,14 +64,10 @@ tmp kEpsilon::kSource() const template tmp kEpsilon::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C index b691180936..eb3acb2abd 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C @@ -95,11 +95,11 @@ tmp kOmegaSSTLM::Fthetat const volScalarField::Internal ReOmega(sqr(y)*omega/nu); const volScalarField::Internal Fwake(exp(-sqr(ReOmega/1e5))); - return tmp + return volScalarField::Internal::New ( - new volScalarField::Internal + IOobject::groupName("Fthetat", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, ( - IOobject::groupName("Fthetat", this->alphaRhoPhi_.group()), min ( max @@ -118,21 +118,14 @@ template tmp kOmegaSSTLM::ReThetac() const { - tmp tReThetac + auto tReThetac = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - IOobject::groupName("ReThetac", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_ - ), - this->mesh_, - dimless - ) + IOobject::groupName("ReThetac", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->mesh_, + dimless ); - volScalarField::Internal& ReThetac = tReThetac.ref(); + auto& ReThetac = tReThetac.ref(); forAll(ReThetac, celli) { @@ -161,21 +154,14 @@ tmp kOmegaSSTLM::Flength const volScalarField::Internal& nu ) const { - tmp tFlength + auto tFlength = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - IOobject::groupName("Flength", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_ - ), - this->mesh_, - dimless - ) + IOobject::groupName("Flength", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->mesh_, + dimless ); - volScalarField::Internal& Flength = tFlength.ref(); + auto& Flength = tFlength.ref(); const volScalarField::Internal& omega = this->omega_(); const volScalarField::Internal& y = this->y_(); @@ -226,21 +212,14 @@ tmp kOmegaSSTLM::ReThetat0 const volScalarField::Internal& nu ) const { - tmp tReThetat0 + auto tReThetat0 = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - IOobject::groupName("ReThetat0", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_ - ), - this->mesh_, - dimless - ) + IOobject::groupName("ReThetat0", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->mesh_, + dimless ); - volScalarField::Internal& ReThetat0 = tReThetat0.ref(); + auto& ReThetat0 = tReThetat0.ref(); const volScalarField& k = this->k_; @@ -349,13 +328,11 @@ tmp kOmegaSSTLM::Fonset const volScalarField::Internal Fonset3(max(1 - pow3(RT/2.5), scalar(0))); - return tmp + return volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject::groupName("Fonset", this->alphaRhoPhi_.group()), - max(Fonset2 - Fonset3, scalar(0)) - ) + IOobject::groupName("Fonset", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + max(Fonset2 - Fonset3, scalar(0)) ); } @@ -459,7 +436,8 @@ kOmegaSSTLM::kOmegaSSTLM this->runTime_.timeName(), this->mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh_ ), @@ -472,7 +450,8 @@ kOmegaSSTLM::kOmegaSSTLM this->runTime_.timeName(), this->mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh_ ), diff --git a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C index 6e08625a61..b5712400c5 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C @@ -101,14 +101,10 @@ void realizableKE::correctNut() template tmp realizableKE::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -116,14 +112,10 @@ tmp realizableKE::kSource() const template tmp realizableKE::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C b/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C index 65ae0c2d3e..f37ad54b4e 100644 --- a/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C +++ b/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C @@ -65,7 +65,8 @@ Foam::eddyViscosity::eddyViscosity this->runTime_.timeName(), this->mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh_ ) @@ -104,22 +105,12 @@ Foam::eddyViscosity::R() const } } - return tmp + return volSymmTensorField::New ( - new volSymmTensorField - ( - IOobject - ( - IOobject::groupName("R", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - ((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)), - patchFieldTypes - ) + IOobject::groupName("R", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + ((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)), + patchFieldTypes ); } diff --git a/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C b/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C index 0e42398ef3..e45fab2853 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C @@ -89,17 +89,10 @@ template tmp Stokes::nut() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("nut", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("nut", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimViscosity, Zero) ); @@ -113,10 +106,7 @@ Stokes::nut const label patchi ) const { - return tmp - ( - new scalarField(this->mesh_.boundary()[patchi].size(), Zero) - ); + return tmp::New(this->mesh_.boundary()[patchi].size(), Zero); } @@ -124,12 +114,11 @@ template tmp Stokes::nuEff() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), this->nu() - ) + IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->nu() ); } diff --git a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C index 22e7af0fbc..41444d6420 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C @@ -189,17 +189,10 @@ template Foam::tmp Foam::laminarModel::nut() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("nut", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("nut", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimViscosity, Zero) ); @@ -213,10 +206,7 @@ Foam::laminarModel::nut const label patchi ) const { - return tmp - ( - new scalarField(this->mesh_.boundary()[patchi].size(), Zero) - ); + return tmp::New(this->mesh_.boundary()[patchi].size(), Zero); } @@ -224,12 +214,11 @@ template Foam::tmp Foam::laminarModel::nuEff() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), this->nu() - ) + IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->nu() ); } @@ -249,17 +238,10 @@ template Foam::tmp Foam::laminarModel::k() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("k", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("k", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(sqr(this->U_.dimensions()), Zero) ); @@ -270,17 +252,10 @@ template Foam::tmp Foam::laminarModel::epsilon() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(sqr(this->U_.dimensions())/dimTime, Zero) ); @@ -291,17 +266,10 @@ template Foam::tmp Foam::laminarModel::omega() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("omega", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("omega", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimless/dimTime, Zero) ); @@ -312,17 +280,10 @@ template Foam::tmp Foam::laminarModel::R() const { - return tmp::New + return volSymmTensorField::New ( - IOobject - ( - IOobject::groupName("R", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("R", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedSymmTensor(sqr(this->U_.dimensions()), Zero) ); diff --git a/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C b/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C index 982e3cc705..7fded669b3 100644 --- a/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C +++ b/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C @@ -80,17 +80,10 @@ tmp kL::epsilonCanopy() const return Cd*LAD*mag(U)*k_; } - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("epsilonCanopy", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("epsilonCanopy", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(sqr(dimLength)/pow3(dimTime), Zero) ); @@ -118,26 +111,22 @@ tmp kL::epsilon() const template tmp kL::canopyHeight() const { - const auto* canopyHeightPtr = - this->mesh_.template findObject("canopyHeight"); + tmp tcanopy; - if (canopyHeightPtr) + tcanopy.cref + ( + this->mesh_.template cfindObject("canopyHeight") + ); + + if (tcanopy) { - const auto& canopyHeight = *canopyHeightPtr; - return canopyHeight; + return tcanopy; } - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("canopyHeight", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("canopyHeight", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimLength, Zero) ); diff --git a/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C b/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C index 6c9ad94b3e..8be3cd4004 100644 --- a/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C +++ b/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 IH-Cantabria - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,16 +56,10 @@ namespace fv Foam::tmp Foam::fv::multiphaseMangrovesSource::dragCoeff(const volVectorField& U) const { - auto tdragCoeff = tmp::New + auto tdragCoeff = volScalarField::New ( - IOobject - ( - typeName + ":dragCoeff", - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(typeName, "dragCoeff"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless/dimTime, Zero) ); @@ -101,16 +95,10 @@ Foam::fv::multiphaseMangrovesSource::dragCoeff(const volVectorField& U) const Foam::tmp Foam::fv::multiphaseMangrovesSource::inertiaCoeff() const { - auto tinertiaCoeff = tmp::New + auto tinertiaCoeff = volScalarField::New ( - IOobject - ( - typeName + ":inertiaCoeff", - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(typeName, "inertiaCoeff"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C b/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C index e9fd781b4d..4d5effb114 100644 --- a/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C +++ b/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 IH-Cantabria - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,21 +58,14 @@ Foam::fv::multiphaseMangrovesTurbulenceModel::kCoeff const volVectorField& U ) const { - auto tkCoeff = tmp::New + auto tkCoeff = volScalarField::New ( - IOobject - ( - typeName + ":kCoeff", - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(typeName, "kCoeff"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless/dimTime, Zero) ); - - volScalarField& kCoeff = tkCoeff.ref(); + auto& kCoeff = tkCoeff.ref(); forAll(zoneIDs_, i) { @@ -104,21 +97,13 @@ Foam::fv::multiphaseMangrovesTurbulenceModel::epsilonCoeff const volVectorField& U ) const { - auto tepsilonCoeff = tmp::New + auto tepsilonCoeff = volScalarField::New ( - IOobject - ( - typeName + ":epsilonCoeff", - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(typeName, "epsilonCoeff"), mesh_, dimensionedScalar(dimless/dimTime, Zero) ); - - volScalarField& epsilonCoeff = tepsilonCoeff.ref(); + auto& epsilonCoeff = tepsilonCoeff.ref(); forAll(zoneIDs_, i) { From ec2b1be8c550fac69bd634da3d12300d3332d4cc Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 23 Jan 2024 10:55:56 +0100 Subject: [PATCH 12/13] ENH: use tmp field factory methods [11] (#2723) - src/optimisation --- .../adjoint/ATCModel/ATCModel/ATCModel.C | 25 ++---- .../adjoint/ATCModel/ATCUaGradU/ATCUaGradU.C | 21 ++--- ...oundaryAdjointContributionIncompressible.C | 9 +-- .../elasticityMotionSolver.C | 4 +- .../volumetricBSplinesMotionSolver.C | 4 +- .../volPointInterpolateAdjoint.C | 17 ++-- .../designVariables/designVariables.C | 2 +- .../updateMethod/updateMethod/updateMethod.C | 7 +- .../NURBS3DVolume/NURBS3DVolume.C | 32 +++----- .../adjointSolverManager.C | 4 +- .../incompressible/incompressibleVars.C | 9 ++- .../incompressibleAdjointMeanFlowVars.C | 9 ++- .../adjointLaminar/adjointLaminar.C | 77 ++++++------------- .../adjointSpalartAllmaras.C | 55 ++++--------- .../adjointkOmegaSST/adjointkOmegaSST.C | 26 +++---- .../adjointTurbulenceModel.H | 12 +-- .../RAS/RASModelVariables/RASModelVariables.C | 36 +++------ .../RASModelVariables/RASModelVariablesI.H | 21 ++--- .../RAS/SpalartAllmaras/SpalartAllmaras.C | 12 +-- .../RAS/kOmegaSST/kOmegaSST.C | 16 ++-- 20 files changed, 137 insertions(+), 261 deletions(-) diff --git a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C index 9a3bb69b9f..2adc5016f8 100644 --- a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C +++ b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C @@ -229,25 +229,16 @@ tmp ATCModel::createLimiter const labelList& zeroCells = zeroType->getZeroATCcells(); const label nSmooth = dict.getOrDefault