From 8fabc325395979f0dfddd3d4fff0de0d692bb06e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 17 Oct 2018 16:44:10 +0200 Subject: [PATCH] ENH: simplify objectRegistry access names (issue #322) New name: findObject(), cfindObject() Old name: lookupObjectPtr() Return a const pointer or nullptr on failure. New name: findObject() Old name: -- Return a non-const pointer or nullptr on failure. New name: getObjectPtr() Old name: lookupObjectRefPtr() Return a non-const pointer or nullptr on failure. Can be called on a const object and it will perform a const_cast. - use these updated names and functionality in more places NB: The older methods names are deprecated, but continue to be defined. --- .../phasesSystem/phaseSystem/phaseSystem.H | 13 +- .../ThermalPhaseChangePhaseSystem.C | 34 ++- .../regionFunctionObject.C | 31 ++- .../regionFunctionObject.H | 62 ++++-- .../regionFunctionObjectTemplates.C | 63 ++++-- .../db/objectRegistry/objectRegistry.H | 122 ++++++++--- .../objectRegistry/objectRegistryTemplates.C | 111 +++++----- .../matrices/lduMatrix/lduMatrix/lduMatrix.C | 4 +- ...tletMachNumberPressureFvPatchScalarField.C | 2 +- ...eratureRadCoupledMixedFvPatchScalarField.C | 4 +- .../epsilonWallFunctionFvPatchScalarField.C | 6 +- .../dynamicInkJetFvMesh/dynamicInkJetFvMesh.C | 4 +- .../dynamicMotionSolverListFvMesh.C | 7 +- .../dynamicMultiMotionSolverFvMesh.C | 3 +- .../fvMotionSolverEngineMesh.C | 3 +- .../layeredEngineMesh/layeredEngineMesh.C | 3 +- ...IDControlInletVelocityFvPatchVectorField.C | 22 +- .../waveSurfacePressureFvPatchScalarField.C | 6 +- .../CrankNicolsonDdtScheme.C | 5 +- .../gradSchemes/gradScheme/gradScheme.C | 25 +-- .../LimitedScheme/LimitedScheme.C | 8 +- .../volPointInterpolate.C | 177 +++++++--------- .../field/externalCoupled/externalCoupled.C | 6 +- .../externalCoupledTemplates.C | 6 +- .../fieldAverageItemTemplates.C | 8 +- .../fieldAverage/fieldAverageTemplates.C | 2 +- .../fieldExtents/fieldExtentsTemplates.C | 2 +- .../field/fluxSummary/fluxSummary.C | 4 +- .../field/readFields/readFieldsTemplates.C | 6 +- .../field/reference/referenceTemplates.C | 2 +- src/functionObjects/field/setFlow/setFlow.C | 13 +- .../stabilityBlendingFactor.C | 17 +- .../surfaceInterpolate/surfaceInterpolate.C | 10 +- .../field/turbulenceFields/turbulenceFields.C | 10 +- .../turbulenceFieldsTemplates.C | 7 +- .../field/vorticity/vorticity.C | 6 +- .../field/wallShearStress/wallShearStress.C | 42 +++- .../field/zeroGradient/zeroGradient.C | 11 +- .../lagrangian/vtkCloud/vtkCloud.C | 4 +- .../lagrangian/vtkCloud/vtkCloudTemplates.C | 2 +- .../solvers/energyTransport/energyTransport.C | 4 +- .../solvers/scalarTransport/scalarTransport.C | 62 +++--- .../ensightWrite/ensightWriteTemplates.C | 12 +- .../removeRegisteredObject.C | 22 +- .../utilities/residuals/residuals.C | 3 +- .../writeDictionary/writeDictionary.C | 8 +- ...polatedDisplacementPointPatchVectorField.C | 10 +- .../viscousDissipation/viscousDissipation.C | 9 +- .../interRegionHeatTransferModel.C | 8 +- .../ParticleForces/Interface/InterfaceForce.C | 6 +- .../ParticleForces/Lift/LiftForce/LiftForce.C | 6 +- .../PressureGradient/PressureGradientForce.C | 6 +- .../DispersionRASModel/DispersionRASModel.C | 16 +- .../BrownianMotion/BrownianMotionForce.C | 8 +- src/lumpedPointMotion/lumpedPointIOMovement.C | 2 +- src/lumpedPointMotion/lumpedPointMovement.C | 2 +- .../coordinate/systems/coordinateSystems.C | 3 +- .../regionCoupledBaseGAMGInterface.C | 15 +- .../regionCoupledBase.C | 16 +- .../searchableSurfaceCollection.C | 6 +- .../searchableSurfaceWithGaps.C | 2 +- .../triSurfaceMesh/triSurfaceMesh.C | 15 +- .../refinementHistoryConstraint.C | 55 ++--- .../distributedTriSurfaceMesh.C | 12 +- .../energyRegionCoupledFvPatchScalarField.C | 12 +- ...ysisTemperatureCoupledFvPatchScalarField.C | 41 ++-- ...rolysisVelocityCoupledFvPatchVectorField.C | 42 ++-- .../regionModel/regionModel/regionModelI.H | 19 +- .../regionModel/regionModelTemplates.C | 20 +- ...alphatFilmWallFunctionFvPatchScalarField.C | 24 +-- .../nutkFilmWallFunctionFvPatchScalarField.C | 13 +- .../liquidFilmThermo/liquidFilmThermo.C | 16 +- .../isoSurface/sampledIsoSurface.C | 198 +++++++----------- .../isoSurface/sampledIsoSurfaceCell.C | 2 +- .../sampledThresholdCellFaces.C | 2 +- .../surfMeshSampleDistanceSurfaceTemplates.C | 2 +- .../plane/surfMeshSamplePlaneTemplates.C | 2 +- .../surfMeshSample/surfMeshSampleTemplates.C | 2 +- .../surfMeshSamplers/surfMeshSamplers.C | 4 +- .../surfMeshSampleDiscreteTemplates.C | 2 +- .../triSurfaceMesh/discreteSurfaceTemplates.C | 8 +- ...gidBodyDisplacementPointPatchVectorField.C | 2 +- .../surfaceFormats/vtk/VTKsurfaceFormat.C | 4 +- .../basic/basicThermo/basicThermo.C | 73 +++---- .../greyMeanAbsorptionEmission.C | 54 +++-- .../wideBandAbsorptionEmission.C | 46 ++-- .../moleFractions/moleFractions.C | 10 +- ...emperatureCoupledMixedFvPatchScalarField.C | 33 ++- .../rawTopoChangerFvMesh.C | 7 +- .../rawTopoChangerFvMeshTemplates.C | 5 +- .../viscosityModels/Arrhenius/Arrhenius.C | 7 +- .../viscosityModels/Arrhenius/Arrhenius.H | 7 +- src/waveModels/waveModel/waveModelNew.C | 13 +- .../rutlandVortex2D/system/preProcess | 19 +- 94 files changed, 918 insertions(+), 952 deletions(-) diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/phaseSystem/phaseSystem.H b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/phaseSystem/phaseSystem.H index 031587beeb..932b3a3f8e 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/phaseSystem/phaseSystem.H +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/phaseSystem/phaseSystem.H @@ -260,13 +260,7 @@ public: virtual volScalarField& he() { NotImplemented; - return - ( - const_cast - ( - volScalarField::null() - ) - ); + return const_cast(volScalarField::null()); } //- Return access to the inernal energy field [J/Kg] @@ -274,10 +268,7 @@ public: virtual const volScalarField& he() const { NotImplemented; - return - ( - volScalarField::null() - ); + return volScalarField::null(); } //- Enthalpy/Internal energy diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C index 0a2377b2f3..dfd3a346cc 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C @@ -131,19 +131,15 @@ Foam::ThermalPhaseChangePhaseSystem::heatTransfer() const dimensionedScalar(dimensionSet(1,-1,-3,0,0), Zero) ); - if - ( - otherPhase.mesh().foundObject + const volScalarField* alphatPtr = + otherPhase.mesh().findObject ( "alphat." + otherPhase.name() - ) - ) + ); + + if (alphatPtr) { - const volScalarField& alphat = - otherPhase.mesh().lookupObject - ( - "alphat." + otherPhase.name() - ); + const volScalarField& alphat = *alphatPtr; const fvPatchList& patches = this->mesh().boundary(); forAll(patches, patchi) @@ -427,19 +423,15 @@ void Foam::ThermalPhaseChangePhaseSystem::correctThermo() dimensionedScalar(dimDensity/dimTime, Zero) ); - if - ( - phase2.mesh().foundObject + const volScalarField* alphatPtr = + phase2.mesh().findObject ( - "alphat." + phase2.name() - ) - ) + "alphat." + phase2.name() + ); + + if (alphatPtr) { - const volScalarField& alphat = - phase2.mesh().lookupObject - ( - "alphat." + phase2.name() - ); + const volScalarField& alphat = *alphatPtr; const fvPatchList& patches = this->mesh().boundary(); forAll(patches, patchi) diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C index 21508c38bf..90bdee1e34 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C @@ -52,10 +52,8 @@ Foam::functionObjects::regionFunctionObject::whichSubRegistry { return obr.lookupObject(subName); } - else - { - return obr; - } + + return obr; } @@ -71,22 +69,19 @@ bool Foam::functionObjects::regionFunctionObject::writeObject const word& fieldName ) { - const regIOobject* objPtr = - this->lookupObjectPtr(fieldName); + const regIOobject* obj = this->findObject(fieldName); - if (objPtr) + if (obj) { Log << " functionObjects::" << type() << " " << name() - << " writing field: " << objPtr->name() << endl; + << " writing field: " << obj->name() << endl; - objPtr->write(); + obj->write(); return true; } - else - { - return false; - } + + return false; } @@ -95,12 +90,14 @@ bool Foam::functionObjects::regionFunctionObject::clearObject const word& fieldName ) { - regIOobject* objPtr = lookupObjectRefPtr(fieldName); - if (objPtr) + // Same as getObjectPtr, since the object is already non-const + regIOobject* obj = this->findObject(fieldName); + + if (obj) { - if (objPtr->ownedByRegistry()) + if (obj->ownedByRegistry()) { - return objPtr->checkOut(); + return obj->checkOut(); } else { diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H index 8ce0f95b86..f8a83ee5bf 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -94,6 +94,35 @@ protected: template bool foundObject(const word& fieldName) const; + //- Return const pointer to the object (eg, a field) in the + //- (sub) objectRegistry. + // + // \return nullptr if the object was not found or had incorrect type. + template + const ObjectType* cfindObject(const word& fieldName) const; + + //- Return const pointer to the object (eg, a field) in the + //- (sub) objectRegistry. + // + // \return nullptr if the object was not found or had incorrect type. + template + const ObjectType* findObject(const word& fieldName) const; + + //- Return non-const pointer to the object of the given Type, + //- (sub) objectRegistry. + // + // \return nullptr if the object was not found or had incorrect type. + template + ObjectType* findObject(const word& fieldName); + + //- Return non-const pointer to the object of the given Type, + //- using a const-cast to have it behave like a mutable. + // Exercise caution when using. + // + // \return nullptr if the object was not found or had incorrect type. + template + ObjectType* getObjectPtr(const word& fieldName) const; + //- Lookup and return object (eg, a field) from the (sub) objectRegistry template const ObjectType& lookupObject(const word& fieldName) const; @@ -102,18 +131,6 @@ protected: template ObjectType& lookupObjectRef(const word& fieldName) const; - //- Lookup and return pointer to the object, - // otherwise nullptr if the object was not found, - // or had the incorrect type. - template - const ObjectType* lookupObjectPtr(const word& fieldName) const; - - //- Lookup and return non-const pointer to the object, - // otherwise nullptr if the object was not found, - // or had the incorrect type. - template - ObjectType* lookupObjectRefPtr(const word& fieldName) const; - //- Store the field in the (sub) objectRegistry under the given name // Note: sets the fieldName to tfield().name() if not already set template @@ -177,6 +194,25 @@ public: //- Read optional controls virtual bool read(const dictionary& dict); + + + // Housekeeping + + //- Same as findObject + // \deprecated use findObject (OCT-2018) + template + const ObjectType* lookupObjectPtr(const word& fieldName) const + { + return this->cfindObject(fieldName); + } + + //- Same as getObjectPtr + // \deprecated use getObjectPtr (OCT-2018) + template + ObjectType* lookupObjectRefPtr(const word& fieldName) const + { + return this->getObjectPtr(fieldName); + } }; diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C index a18bff7070..fee651ea89 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,47 @@ bool Foam::functionObjects::regionFunctionObject::foundObject } +template +const ObjectType* Foam::functionObjects::regionFunctionObject::cfindObject +( + const word& fieldName +) const +{ + return obr().cfindObject(fieldName); +} + + +template +const ObjectType* Foam::functionObjects::regionFunctionObject::findObject +( + const word& fieldName +) const +{ + return obr().findObject(fieldName); +} + + +template +ObjectType* Foam::functionObjects::regionFunctionObject::findObject +( + const word& fieldName +) +{ + // Need getObjectPtr to bypass const access on the objectRegistry + return obr().getObjectPtr(fieldName); +} + + +template +ObjectType* Foam::functionObjects::regionFunctionObject::getObjectPtr +( + const word& fieldName +) const +{ + return obr().getObjectPtr(fieldName); +} + + template const ObjectType& Foam::functionObjects::regionFunctionObject::lookupObject ( @@ -58,26 +99,6 @@ ObjectType& Foam::functionObjects::regionFunctionObject::lookupObjectRef } -template -const ObjectType* Foam::functionObjects::regionFunctionObject::lookupObjectPtr -( - const word& fieldName -) const -{ - return obr().lookupObjectPtr(fieldName); -} - - -template -ObjectType* Foam::functionObjects::regionFunctionObject::lookupObjectRefPtr -( - const word& fieldName -) const -{ - return obr().lookupObjectRefPtr(fieldName); -} - - template bool Foam::functionObjects::regionFunctionObject::store ( diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index c4a021308f..042eef2448 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -231,8 +231,9 @@ public: // Lookup //- Lookup and return a const sub-objectRegistry. - // Optionally create it if it does not exist. - // If recursive, search parent registries. + // + // \param forceCreate create it if it does not exist. + // \param recursive search parent registries. const objectRegistry& subRegistry ( const word& name, @@ -250,7 +251,8 @@ public: HashTable lookupClass(const bool strict = false); //- Is the named Type found? - // If recursive, search parent registries. + // + // \param recursive search parent registries template bool foundObject ( @@ -258,8 +260,60 @@ public: const bool recursive = false ) const; - //- Lookup and return the object of the given Type. - // If recursive, search parent registries. + //- Find const pointer to the object of the given Type. + // + // \param recursive search parent registries + // + // \return nullptr if the object was not found or had incorrect type. + template + const Type* cfindObject + ( + const word& name, + const bool recursive = false + ) const; + + //- Return const pointer to the object of the given Type. + // + // \param recursive search parent registries + // + // \return nullptr if the object was not found or had incorrect type. + template + const Type* findObject + ( + const word& name, + const bool recursive = false + ) const; + + //- Return non-const pointer to the object of the given Type. + // + // \param recursive search parent registries + // + // \return nullptr if the object was not found or had incorrect type. + template + Type* findObject + ( + const word& name, + const bool recursive = false + ); + + //- Return non-const pointer to the object of the given Type, + //- using a const-cast to have it behave like a mutable. + // Exercise caution when using. + // + // \param recursive search parent registries. + // + // \return nullptr if the object was not found or had incorrect type. + template + Type* getObjectPtr + ( + const word& name, + const bool recursive = false + ) const; + + //- Lookup and return const reference to the object + //- of the given Type. Fatal if not found or the wrong type. + // + // \param recursive search parent registries. template const Type& lookupObject ( @@ -267,8 +321,10 @@ public: const bool recursive = false ) const; - //- Lookup and return the object of the given Type. - // If recursive, search parent registries. + //- Lookup and return non-const reference to the object + //- of the given Type. Fatal if not found or the wrong type. + // + // \param recursive search parent registries. template Type& lookupObjectRef ( @@ -276,30 +332,6 @@ public: const bool recursive = false ) const; - //- Lookup and return pointer to the object of the given Type, - // otherwise nullptr if the object was not found, - // or had the incorrect type. - // If recursive, search parent registries. - template - const Type* lookupObjectPtr - ( - const word& name, - const bool recursive = false - ) const; - - - //- Lookup and return non-const pointer to the object - // of the given Type, - // otherwise nullptr if the object was not found, - // or had the incorrect type. - // If recursive, search parent registries. - template - Type* lookupObjectRefPtr - ( - const word& name, - const bool recursive = false - ) const; - // Events @@ -349,6 +381,34 @@ public: IOstream::compressionType cmp, const bool valid ) const; + + + // Housekeeping + + //- Same as findObject + // \deprecated use findObject (OCT-2018) + template + const Type* lookupObjectPtr + ( + const word& name, + bool recursive = false + ) const + { + return this->cfindObject(name, recursive); + } + + //- Same as getObjectPtr + // + // \deprecated use getObjectPtr (OCT-2018) + template + Type* lookupObjectRefPtr + ( + const word& name, + bool recursive = false + ) const + { + return this->getObjectPtr(name, recursive); + } }; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C index 551f4055be..6cc9eba56a 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C @@ -156,7 +156,7 @@ Foam::HashTable Foam::objectRegistry::lookupClass forAllConstIters(*this, iter) { - if (strict ? isType(*iter()) : isA(*iter())) + if (strict ? isType(*iter()) : bool(isA(*iter()))) { objectsOfClass.insert ( @@ -180,7 +180,7 @@ Foam::HashTable Foam::objectRegistry::lookupClass forAllIters(*this, iter) { - if (strict ? isType(*iter()) : isA(*iter())) + if (strict ? isType(*iter()) : bool(isA(*iter()))) { objectsOfClass.insert ( @@ -201,14 +201,71 @@ bool Foam::objectRegistry::foundObject const bool recursive ) const { - const Type* ptr = this->lookupObjectPtr(name, recursive); + return this->cfindObject(name, recursive); +} - if (ptr) + +template +const Type* Foam::objectRegistry::cfindObject +( + const word& name, + const bool recursive +) const +{ + const_iterator iter = cfind(name); + + if (iter.found()) { - return true; + const Type* ptr = dynamic_cast(iter()); + + if (ptr) + { + return ptr; + } + } + else if (recursive && this->parentNotTime()) + { + return parent_.cfindObject(name, recursive); } - return false; + return nullptr; +} + + +template +const Type* Foam::objectRegistry::findObject +( + const word& name, + const bool recursive +) const +{ + return this->cfindObject(name, recursive); +} + + +template +Type* Foam::objectRegistry::findObject +( + const word& name, + const bool recursive +) +{ + const Type* ptr = this->cfindObject(name, recursive); + + return const_cast(ptr); +} + + +template +Type* Foam::objectRegistry::getObjectPtr +( + const word& name, + const bool recursive +) const +{ + const Type* ptr = this->cfindObject(name, recursive); + + return const_cast(ptr); } @@ -219,7 +276,7 @@ const Type& Foam::objectRegistry::lookupObject const bool recursive ) const { - const_iterator iter = find(name); + const_iterator iter = cfind(name); if (iter.found()) { @@ -270,44 +327,4 @@ Type& Foam::objectRegistry::lookupObjectRef } -template -const Type* Foam::objectRegistry::lookupObjectPtr -( - const word& name, - const bool recursive -) const -{ - const_iterator iter = find(name); - - if (iter.found()) - { - const Type* ptr = dynamic_cast(iter()); - - if (ptr) - { - return ptr; - } - } - else if (recursive && this->parentNotTime()) - { - return parent_.lookupObjectPtr(name, recursive); - } - - return nullptr; -} - - -template -Type* Foam::objectRegistry::lookupObjectRefPtr -( - const word& name, - const bool recursive -) const -{ - const Type* ptr = this->lookupObjectPtr(name, recursive); - - return const_cast(ptr); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C index e7a7beb6b4..63f51c4d31 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C @@ -338,12 +338,12 @@ void Foam::lduMatrix::setResidualField } IOField* residualPtr = - lduMesh_.thisDb().lookupObjectRefPtr>(lookupName); + lduMesh_.thisDb().getObjectPtr>(lookupName); if (residualPtr) { const IOdictionary* dataPtr = - lduMesh_.thisDb().lookupObjectPtr("data"); + lduMesh_.thisDb().findObject("data"); if (dataPtr) { diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMachNumberPressure/outletMachNumberPressureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMachNumberPressure/outletMachNumberPressureFvPatchScalarField.C index 0e4f3e24a3..a870da6462 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMachNumberPressure/outletMachNumberPressureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMachNumberPressure/outletMachNumberPressureFvPatchScalarField.C @@ -165,7 +165,7 @@ void Foam::outletMachNumberPressureFvPatchScalarField::updateCoeffs() } const fluidThermo* thermoPtr = - db().lookupObjectPtr(basicThermo::dictName); + db().findObject(basicThermo::dictName); const volVectorField& U = db().lookupObject(UName_); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index 2a761d2a49..2fa1e33b81 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -240,7 +240,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() { const basicThermo* thermo = - nbrMesh.lookupObjectPtr(basicThermo::dictName); + nbrMesh.findObject(basicThermo::dictName); if (thermo) { @@ -269,7 +269,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() // Local inertia therm { const basicThermo* thermo = - mesh.lookupObjectPtr(basicThermo::dictName); + mesh.findObject(basicThermo::dictName); if (thermo) { diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index c50aab9cb4..f5ccaf54f0 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -448,11 +448,7 @@ void Foam::epsilonWallFunctionFvPatchScalarField::updateCoeffs() typedef DimensionedField FieldType; - FieldType& G = - const_cast - ( - db().lookupObject(turbModel.GName()) - ); + FieldType& G = db().lookupObjectRef(turbModel.GName()); FieldType& epsilon = const_cast(internalField()); diff --git a/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C b/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C index a25277ed9c..440d170728 100644 --- a/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C +++ b/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C @@ -117,9 +117,7 @@ bool Foam::dynamicInkJetFvMesh::update() fvMesh::movePoints(newPoints); - volVectorField& U = - const_cast(lookupObject("U")); - U.correctBoundaryConditions(); + lookupObjectRef("U").correctBoundaryConditions(); return true; } diff --git a/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C b/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C index 2b75caa5fc..5874a32a17 100644 --- a/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C +++ b/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C @@ -91,10 +91,11 @@ bool Foam::dynamicMotionSolverListFvMesh::update() fvMesh::movePoints(points() + disp); - if (foundObject("U")) + volVectorField* Uptr = getObjectPtr("U"); + + if (Uptr) { - const_cast(lookupObject("U")) - .correctBoundaryConditions(); + Uptr->correctBoundaryConditions(); } } diff --git a/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C b/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C index 1309e0e99e..2f93ca2fb2 100644 --- a/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C +++ b/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C @@ -182,8 +182,7 @@ bool Foam::dynamicMultiMotionSolverFvMesh::update() if (foundObject("U")) { - const_cast(lookupObject("U")) - .correctBoundaryConditions(); + lookupObjectRef("U").correctBoundaryConditions(); } else if (!hasWarned) { diff --git a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C index 583ddde324..7a9100e3cc 100644 --- a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C +++ b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C @@ -91,8 +91,7 @@ void Foam::fvMotionSolverEngineMesh::move() if (engineDB_.foundObject("phi")) { surfaceScalarField& phi = - const_cast - (engineDB_.lookupObject("phi")); + engineDB_.lookupObjectRef("phi"); const volScalarField& rho = engineDB_.lookupObject("rho"); diff --git a/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C b/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C index 390994257c..cd09b47d42 100644 --- a/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C +++ b/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C @@ -86,8 +86,7 @@ void Foam::layeredEngineMesh::move() if (engineDB_.foundObject("phi")) { surfaceScalarField& phi = - const_cast - (engineDB_.lookupObject("phi")); + engineDB_.lookupObjectRef("phi"); const volScalarField& rho = engineDB_.lookupObject("rho"); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C index 0db2d9b520..246e4b5185 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C @@ -37,27 +37,19 @@ License const Foam::surfaceScalarField& Foam::pressurePIDControlInletVelocityFvPatchVectorField::facePressure() const { - const volScalarField& p(db().lookupObject(pName_)); - const word pfName(pName_ + "f"); - if (!db().foundObject(pfName)) - { - surfaceScalarField* pfPtr - ( - new surfaceScalarField(pfName, linearInterpolate(p)) - ); + const volScalarField& p = db().lookupObject(pName_); + surfaceScalarField* pfPtr = db().getObjectPtr(pfName); + + if (!pfPtr) + { + pfPtr = new surfaceScalarField(pfName, linearInterpolate(p)); pfPtr->store(); } - surfaceScalarField& pf - ( - const_cast - ( - db().lookupObject(pfName) - ) - ); + surfaceScalarField& pf = *pfPtr; if (!pf.upToDate(p)) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C index 440c1e2859..65985dab41 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C @@ -144,11 +144,7 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs() const scalar dt = db().time().deltaTValue(); // retrieve non-const access to zeta field from the database - volVectorField& zeta = - const_cast - ( - db().lookupObject(zetaName_) - ); + volVectorField& zeta = db().lookupObjectRef(zetaName_); vectorField& zetap = zeta.boundaryFieldRef()[patchi]; // lookup d/dt scheme from database for zeta diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C index 6d6f2061b5..8331fad013 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C @@ -171,10 +171,7 @@ CrankNicolsonDdtScheme::ddt0_ DDt0Field& ddt0 = static_cast&> ( - const_cast - ( - mesh().objectRegistry::template lookupObject(name) - ) + mesh().objectRegistry::template lookupObjectRef(name) ); return ddt0; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C b/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C index 414fe7b8ce..cb7207785c 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C @@ -103,10 +103,11 @@ Foam::fv::gradScheme::grad } solution::cachePrintMessage("Retrieving", name, vsf); - GradFieldType& gGrad = const_cast - ( - mesh().objectRegistry::template lookupObject(name) - ); + GradFieldType& gGrad = + mesh().objectRegistry::template lookupObjectRef + ( + name + ); if (gGrad.upToDate(vsf)) { @@ -123,13 +124,11 @@ Foam::fv::gradScheme::grad solution::cachePrintMessage("Storing", name, vsf); regIOobject::store(tgGrad.ptr()); - GradFieldType& gGrad = const_cast - ( - mesh().objectRegistry::template lookupObject + GradFieldType& gGrad = + mesh().objectRegistry::template lookupObjectRef ( name - ) - ); + ); return gGrad; } @@ -138,13 +137,11 @@ Foam::fv::gradScheme::grad { if (mesh().objectRegistry::template foundObject(name)) { - GradFieldType& gGrad = const_cast - ( - mesh().objectRegistry::template lookupObject + GradFieldType& gGrad = + mesh().objectRegistry::template lookupObjectRef ( name - ) - ); + ); if (gGrad.ownedByRegistry()) { diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C index 9c19472a1f..22fa5d698c 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C @@ -171,13 +171,7 @@ Foam::LimitedScheme::limiter } surfaceScalarField& limiterField = - const_cast - ( - mesh.lookupObject - ( - limiterFieldName - ) - ); + mesh.lookupObjectRef(limiterFieldName); calcLimiter(phi, limiterField); diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index 3a2c6e12a6..0139613742 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -372,20 +372,17 @@ Foam::volPointInterpolation::interpolate const pointMesh& pm = pointMesh::New(vf.mesh()); // Construct tmp - tmp> tpf + auto tpf = tmp>::New ( - new GeometricField + IOobject ( - IOobject - ( - "volPointInterpolate(" + vf.name() + ')', - vf.instance(), - pm.thisDb() - ), - pm, - vf.dimensions(), - patchFieldTypes - ) + "volPointInterpolate(" + vf.name() + ')', + vf.instance(), + pm.thisDb() + ), + pm, + vf.dimensions(), + patchFieldTypes ); interpolateInternalField(vf, tpf.ref()); @@ -427,73 +424,60 @@ Foam::volPointInterpolation::interpolate const pointMesh& pm = pointMesh::New(vf.mesh()); const objectRegistry& db = pm.thisDb(); + PointFieldType* pfPtr = + db.objectRegistry::template getObjectPtr(name); + if (!cache || vf.mesh().changing()) { // Delete any old occurrences to avoid double registration - if (db.objectRegistry::template foundObject(name)) + if (pfPtr && pfPtr->ownedByRegistry()) { - PointFieldType& pf = const_cast - ( - db.objectRegistry::template lookupObject(name) - ); - - if (pf.ownedByRegistry()) - { - solution::cachePrintMessage("Deleting", name, vf); - pf.release(); - delete &pf; - } + solution::cachePrintMessage("Deleting", name, vf); + pfPtr->release(); + delete pfPtr; } - - tmp> tpf + auto tpf = tmp>::New ( - new GeometricField + IOobject ( - IOobject - ( - name, - vf.instance(), - pm.thisDb() - ), - pm, - vf.dimensions() - ) + name, + vf.instance(), + pm.thisDb() + ), + pm, + vf.dimensions() ); interpolate(vf, tpf.ref()); return tpf; } + + + if (!pfPtr) + { + solution::cachePrintMessage("Calculating and caching", name, vf); + + pfPtr = interpolate(vf, name, false).ptr(); + regIOobject::store(pfPtr); + } else { - if (!db.objectRegistry::template foundObject(name)) + PointFieldType& pf = *pfPtr; + + if (pf.upToDate(vf)) //TBD: , vf.mesh().points())) { - solution::cachePrintMessage("Calculating and caching", name, vf); - tmp tpf = interpolate(vf, name, false); - PointFieldType* pfPtr = tpf.ptr(); - regIOobject::store(pfPtr); - return *pfPtr; + solution::cachePrintMessage("Reusing", name, vf); } else { - PointFieldType& pf = const_cast - ( - db.objectRegistry::template lookupObject(name) - ); - - if (pf.upToDate(vf)) //TBD: , vf.mesh().points())) - { - solution::cachePrintMessage("Reusing", name, vf); - } - else - { - solution::cachePrintMessage("Updating", name, vf); - interpolate(vf, pf); - } - return pf; + solution::cachePrintMessage("Updating", name, vf); + interpolate(vf, pf); } } + + return *pfPtr; } @@ -537,74 +521,61 @@ Foam::volPointInterpolation::interpolate const pointMesh& pm = pointMesh::New(vf.mesh()); const objectRegistry& db = pm.thisDb(); + + PointFieldType* pfPtr = + db.objectRegistry::template getObjectPtr(name); + if (!cache || vf.mesh().changing()) { // Delete any old occurrences to avoid double registration - if (db.objectRegistry::template foundObject(name)) + if (pfPtr && pfPtr->ownedByRegistry()) { - PointFieldType& pf = const_cast - ( - db.objectRegistry::template lookupObject(name) - ); - - if (pf.ownedByRegistry()) - { - solution::cachePrintMessage("Deleting", name, vf); - pf.release(); - delete &pf; - } + solution::cachePrintMessage("Deleting", name, vf); + pfPtr->release(); + delete pfPtr; } - - tmp> tpf + auto tpf = tmp>::New ( - new DimensionedField + IOobject ( - IOobject - ( - name, - vf.instance(), - pm.thisDb() - ), - pm, - vf.dimensions() - ) + name, + vf.instance(), + pm.thisDb() + ), + pm, + vf.dimensions() ); interpolateDimensionedInternalField(vf, tpf.ref()); return tpf; } + + + if (!pfPtr) + { + solution::cachePrintMessage("Calculating and caching", name, vf); + pfPtr = interpolate(vf, name, false).ptr(); + + regIOobject::store(pfPtr); + } else { - if (!db.objectRegistry::template foundObject(name)) + PointFieldType& pf = *pfPtr; + + if (pf.upToDate(vf)) //TBD: , vf.mesh().points())) { - solution::cachePrintMessage("Calculating and caching", name, vf); - tmp tpf = interpolate(vf, name, false); - PointFieldType* pfPtr = tpf.ptr(); - regIOobject::store(pfPtr); - return *pfPtr; + solution::cachePrintMessage("Reusing", name, vf); } else { - PointFieldType& pf = const_cast - ( - db.objectRegistry::template lookupObject(name) - ); - - if (pf.upToDate(vf)) //TBD: , vf.mesh().points())) - { - solution::cachePrintMessage("Reusing", name, vf); - } - else - { - solution::cachePrintMessage("Updating", name, vf); - interpolateDimensionedInternalField(vf, pf); - } - - return pf; + solution::cachePrintMessage("Updating", name, vf); + interpolateDimensionedInternalField(vf, pf); } } + + return *pfPtr; } diff --git a/src/functionObjects/field/externalCoupled/externalCoupled.C b/src/functionObjects/field/externalCoupled/externalCoupled.C index 91450209a9..0c49fd20ef 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupled.C +++ b/src/functionObjects/field/externalCoupled/externalCoupled.C @@ -415,7 +415,7 @@ void Foam::functionObjects::externalCoupled::initCoupling() UPtrList meshes(regionNames.size()); forAll(regionNames, regi) { - meshes.set(regi, time_.lookupObjectPtr(regionNames[regi])); + meshes.set(regi, time_.findObject(regionNames[regi])); } const labelList& groups = regionToGroups_[compName]; @@ -692,7 +692,7 @@ void Foam::functionObjects::externalCoupled::readDataMaster() UPtrList meshes(regionNames.size()); forAll(regionNames, regi) { - meshes.set(regi, time_.lookupObjectPtr(regionNames[regi])); + meshes.set(regi, time_.findObject(regionNames[regi])); } const labelList& groups = regionToGroups_[compName]; @@ -736,7 +736,7 @@ void Foam::functionObjects::externalCoupled::writeDataMaster() const UPtrList meshes(regionNames.size()); forAll(regionNames, regi) { - meshes.set(regi, time_.lookupObjectPtr(regionNames[regi])); + meshes.set(regi, time_.findObject(regionNames[regi])); } const labelList& groups = regionToGroups_[compName]; diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C b/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C index cd78f475f9..6b2f8ddc71 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C @@ -82,8 +82,7 @@ bool Foam::functionObjects::externalCoupled::readData label nFound = 0; for (const fvMesh& mesh : meshes) { - const volFieldType* vfptr = - mesh.lookupObjectPtr(fieldName); + const volFieldType* vfptr = mesh.findObject(fieldName); if (!vfptr) { @@ -358,8 +357,7 @@ bool Foam::functionObjects::externalCoupled::writeData for (const fvMesh& mesh : meshes) { - const volFieldType* vfptr = - mesh.lookupObjectPtr(fieldName); + const volFieldType* vfptr = mesh.findObject(fieldName); if (!vfptr) { diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C index f7a752b993..354b7e9440 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C @@ -37,7 +37,7 @@ bool Foam::functionObjects::fieldAverageItem::calculateMeanField return false; } - const Type* baseFieldPtr = obr.lookupObjectPtr(fieldName_); + const Type* baseFieldPtr = obr.findObject(fieldName_); if (!baseFieldPtr) { @@ -122,7 +122,7 @@ bool Foam::functionObjects::fieldAverageItem::calculateMeanField { const word& fieldName = nameIter(); const scalar dt = timeIter(); - const Type* w = obr.lookupObjectPtr(fieldName); + const Type* w = obr.findObject(fieldName); meanField += dt*(*w); @@ -173,7 +173,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField return false; } - const Type1* baseFieldPtr = obr.lookupObjectPtr(fieldName_); + const Type1* baseFieldPtr = obr.findObject(fieldName_); if (!baseFieldPtr) { @@ -258,7 +258,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField { const word& fieldName = nameIter(); const scalar dt = timeIter(); - const Type1* w = obr.lookupObjectPtr(fieldName); + const Type1* w = obr.findObject(fieldName); prime2MeanField += dt*(sqr((*w) - meanField)); diff --git a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C index 5f34c9de2a..c994a764e5 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C @@ -119,7 +119,7 @@ void Foam::functionObjects::fieldAverage::restoreWindowFieldsType const word& fieldName = item.fieldName(); - const Type* fieldPtr = lookupObjectPtr(fieldName); + const Type* fieldPtr = findObject(fieldName); if (!fieldPtr) { diff --git a/src/functionObjects/field/fieldExtents/fieldExtentsTemplates.C b/src/functionObjects/field/fieldExtents/fieldExtentsTemplates.C index 9ea87aef7d..f478f2eaca 100644 --- a/src/functionObjects/field/fieldExtents/fieldExtentsTemplates.C +++ b/src/functionObjects/field/fieldExtents/fieldExtentsTemplates.C @@ -54,7 +54,7 @@ void Foam::functionObjects::fieldExtents::calcFieldExtents typedef GeometricField VolFieldType; const VolFieldType* fieldPtr = - obr_.lookupObjectPtr(fieldName); + obr_.findObject(fieldName); if (!fieldPtr) { diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.C b/src/functionObjects/field/fluxSummary/fluxSummary.C index 529c2d48d0..a001f9b2b7 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.C +++ b/src/functionObjects/field/fluxSummary/fluxSummary.C @@ -129,7 +129,7 @@ void Foam::functionObjects::fluxSummary::initialiseSurface DynamicList& faceFlip ) const { - const surfMesh* sPtr = mesh_.lookupObjectPtr(surfName); + const surfMesh* sPtr = mesh_.findObject(surfName); if (!sPtr) { FatalErrorInFunction @@ -154,7 +154,7 @@ void Foam::functionObjects::fluxSummary::initialiseSurfaceAndDirection DynamicList& faceFlip ) const { - const surfMesh* sPtr = mesh_.lookupObjectPtr(surfName); + const surfMesh* sPtr = mesh_.findObject(surfName); if (!sPtr) { FatalErrorInFunction diff --git a/src/functionObjects/field/readFields/readFieldsTemplates.C b/src/functionObjects/field/readFields/readFieldsTemplates.C index fa44cd4a4e..cdce885932 100644 --- a/src/functionObjects/field/readFields/readFieldsTemplates.C +++ b/src/functionObjects/field/readFields/readFieldsTemplates.C @@ -47,13 +47,15 @@ bool Foam::functionObjects::readFields::loadField(const word& fieldName) } else if (foundObject(fieldName)) { - DebugInfo<< "readFields: " << SurfaceFieldType::typeName + DebugInfo + << "readFields: " << SurfaceFieldType::typeName << " " << fieldName << " already exists in database" << " already in database" << endl; } else if (foundObject(fieldName)) { - DebugInfo<< "readFields: " << SurfFieldType::typeName + DebugInfo + << "readFields: " << SurfFieldType::typeName << " " << fieldName << " already exists in database" << " already in database" << endl; } diff --git a/src/functionObjects/field/reference/referenceTemplates.C b/src/functionObjects/field/reference/referenceTemplates.C index f32150d233..e09713337d 100644 --- a/src/functionObjects/field/reference/referenceTemplates.C +++ b/src/functionObjects/field/reference/referenceTemplates.C @@ -30,7 +30,7 @@ bool Foam::functionObjects::reference::calcType() { typedef GeometricField VolFieldType; - const VolFieldType* vfPtr = lookupObjectPtr(fieldName_); + const VolFieldType* vfPtr = findObject(fieldName_); if (vfPtr) { diff --git a/src/functionObjects/field/setFlow/setFlow.C b/src/functionObjects/field/setFlow/setFlow.C index 329e2e6b5d..2f89e687f6 100644 --- a/src/functionObjects/field/setFlow/setFlow.C +++ b/src/functionObjects/field/setFlow/setFlow.C @@ -66,7 +66,7 @@ Foam::functionObjects::setFlow::modeTypeNames void Foam::functionObjects::setFlow::setPhi(const volVectorField& U) { surfaceScalarField* phiptr = - mesh_.lookupObjectRefPtr(phiName_); + mesh_.getObjectPtr(phiName_); if (!phiptr) { @@ -76,7 +76,7 @@ void Foam::functionObjects::setFlow::setPhi(const volVectorField& U) if (rhoName_ != "none") { const volScalarField* rhoptr = - mesh_.lookupObjectPtr(rhoName_); + mesh_.findObject(rhoName_); if (rhoptr) { @@ -207,10 +207,11 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict) bool Foam::functionObjects::setFlow::execute() { - volVectorField* Uptr = mesh_.lookupObjectRefPtr(UName_); + volVectorField* Uptr = + mesh_.getObjectPtr(UName_); surfaceScalarField* phiptr = - mesh_.lookupObjectRefPtr(phiName_); + mesh_.getObjectPtr(phiName_); Log << nl << name() << ":" << nl; @@ -431,13 +432,13 @@ bool Foam::functionObjects::setFlow::execute() bool Foam::functionObjects::setFlow::write() { - const auto& Uptr = mesh_.lookupObjectRefPtr(UName_); + const auto* Uptr = mesh_.findObject(UName_); if (Uptr) { Uptr->write(); } - const auto& phiptr = mesh_.lookupObjectRefPtr(phiName_); + const auto* phiptr = mesh_.findObject(phiName_); if (phiptr) { phiptr->write(); diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index 4e6045f8c1..1e0967cdb1 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -102,8 +102,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::calc() bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) { - const IOField* residualPtr = - mesh_.lookupObjectPtr>(residualName_); + const auto* residualPtr = mesh_.findObject>(residualName_); if (residuals_) { @@ -164,7 +163,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) } const volScalarField* nonOrthPtr = - mesh_.lookupObjectPtr(nonOrthogonalityName_); + mesh_.findObject(nonOrthogonalityName_); if (nonOrthogonality_) { @@ -200,7 +199,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) } const volScalarField* skewnessPtr = - mesh_.lookupObjectPtr(skewnessName_); + mesh_.findObject(skewnessName_); if (skewness_) { @@ -235,7 +234,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) } const volScalarField* faceWeightsPtr = - mesh_.lookupObjectPtr(faceWeightName_); + mesh_.findObject(faceWeightName_); if (faceWeight_) { @@ -342,7 +341,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) const volVectorField* UNamePtr = - mesh_.lookupObjectPtr(UName_); + mesh_.findObject(UName_); if (Co_) { @@ -520,7 +519,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor store(resultName_, faceBlendedPtr); const volScalarField* nonOrthPtr = - mesh_.lookupObjectPtr(nonOrthogonalityName_); + mesh_.findObject(nonOrthogonalityName_); if (nonOrthogonality_) { @@ -552,7 +551,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor const volScalarField* faceWeightsPtr = - mesh_.lookupObjectPtr(faceWeightName_); + mesh_.findObject(faceWeightName_); if (faceWeight_) { @@ -583,7 +582,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor } const volScalarField* skewnessPtr = - mesh_.lookupObjectPtr(skewnessName_); + mesh_.findObject(skewnessName_); if (skewness_) { diff --git a/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C b/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C index 513cce3118..35ebcc203d 100644 --- a/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C +++ b/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C @@ -107,14 +107,12 @@ bool Foam::functionObjects::surfaceInterpolate::write() { const word& fieldName = fieldSet_[i].second(); - if (mesh_.foundObject(fieldName)) + const regIOobject* ioptr = obr_.findObject(fieldName); + + if (ioptr) { Log << " " << fieldName << nl; - - const regIOobject& field = - obr_.lookupObject(fieldName); - - field.write(); + ioptr->write(); } else { diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index 559237b84a..3a257d5da6 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -103,12 +103,10 @@ bool Foam::functionObjects::turbulenceFields::compressible() { return false; } - else - { - FatalErrorInFunction - << "Turbulence model not found in database, deactivating" - << exit(FatalError); - } + + FatalErrorInFunction + << "Turbulence model not found in database, deactivating" + << exit(FatalError); return false; } diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index 98613fbc28..3bbbea07e2 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -38,10 +38,11 @@ void Foam::functionObjects::turbulenceFields::processField const word scopedName = modelName + ':' + fieldName; - if (obr_.foundObject(scopedName)) + FieldType* fldPtr = obr_.getObjectPtr(scopedName); + + if (fldPtr) { - FieldType& fld = obr_.lookupObjectRef(scopedName); - fld == tvalue(); + (*fldPtr) == tvalue(); } else if (obr_.found(scopedName)) { diff --git a/src/functionObjects/field/vorticity/vorticity.C b/src/functionObjects/field/vorticity/vorticity.C index 6fd1d38bba..51849e356f 100644 --- a/src/functionObjects/field/vorticity/vorticity.C +++ b/src/functionObjects/field/vorticity/vorticity.C @@ -57,12 +57,8 @@ bool Foam::functionObjects::vorticity::calc() fvc::curl(lookupObject(fieldName_)) ); } - else - { - return false; - } - return true; + return false; } diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C index bbf4a3f394..0019687c56 100644 --- a/src/functionObjects/field/wallShearStress/wallShearStress.C +++ b/src/functionObjects/field/wallShearStress/wallShearStress.C @@ -183,28 +183,48 @@ bool Foam::functionObjects::wallShearStress::execute() volVectorField& wallShearStress = mesh_.lookupObjectRef(type()); - const word& turbModelName = turbulenceModel::propertiesName; - auto cmpModelPtr = - mesh_.lookupObjectPtr(turbModelName); - auto icoModelPtr = - mesh_.lookupObjectPtr(turbModelName); + bool ok = false; - if (cmpModelPtr) + // compressible + if (!ok) { - calcShearStress(cmpModelPtr->devRhoReff(), wallShearStress); + typedef compressible::turbulenceModel turbType; + + const turbType* modelPtr = + findObject(turbulenceModel::propertiesName); + + ok = modelPtr; + + if (ok) + { + calcShearStress(modelPtr->devRhoReff(), wallShearStress); + } } - else if (icoModelPtr) + + // incompressible + if (!ok) { - calcShearStress(icoModelPtr->devReff(), wallShearStress); + typedef incompressible::turbulenceModel turbType; + + const turbType* modelPtr = + findObject(turbulenceModel::propertiesName); + + ok = modelPtr; + + if (ok) + { + calcShearStress(modelPtr->devReff(), wallShearStress); + } } - else + + if (!ok) { FatalErrorInFunction << "Unable to find turbulence model in the " << "database" << exit(FatalError); } - return true; + return ok; } diff --git a/src/functionObjects/field/zeroGradient/zeroGradient.C b/src/functionObjects/field/zeroGradient/zeroGradient.C index f5b36b79a7..719b38d900 100644 --- a/src/functionObjects/field/zeroGradient/zeroGradient.C +++ b/src/functionObjects/field/zeroGradient/zeroGradient.C @@ -176,16 +176,15 @@ bool Foam::functionObjects::zeroGradient::write() } // Consistent output order - const wordList outputList = results_.sortedToc(); - for (const word& fieldName : outputList) + for (const word& fieldName : results_.sortedToc()) { - if (foundObject(fieldName)) - { - const regIOobject& io = lookupObject(fieldName); + const regIOobject* ioptr = findObject(fieldName); + if (ioptr) + { Log << " " << fieldName << endl; - io.write(); + ioptr->write(); } } diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C index dbcbd464cd..07500761ac 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C @@ -106,7 +106,7 @@ bool Foam::functionObjects::vtkCloud::writeCloud const word& cloudName ) { - const auto* objPtr = mesh_.lookupObjectPtr(cloudName); + const auto* objPtr = mesh_.findObject(cloudName); if (!objPtr) { return false; @@ -127,7 +127,7 @@ bool Foam::functionObjects::vtkCloud::writeCloud objPtr->writeObjects(obrTmp); - const auto* pointsPtr = obrTmp.lookupObjectPtr("position"); + const auto* pointsPtr = obrTmp.findObject("position"); if (!pointsPtr) { diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloudTemplates.C b/src/functionObjects/lagrangian/vtkCloud/vtkCloudTemplates.C index 16c07da5d5..b55d4d315c 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloudTemplates.C +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloudTemplates.C @@ -52,7 +52,7 @@ Foam::wordList Foam::functionObjects::vtkCloud::writeFields for (const word& fieldName : fieldNames) { - const auto* fldPtr = obrTmp.lookupObjectPtr>(fieldName); + const auto* fldPtr = obrTmp.findObject>(fieldName); if (Pstream::master()) { diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C index 5fcb5c668e..931d15e77b 100644 --- a/src/functionObjects/solvers/energyTransport/energyTransport.C +++ b/src/functionObjects/solvers/energyTransport/energyTransport.C @@ -83,7 +83,7 @@ Foam::functionObjects::energyTransport::kappaEff() const { typedef incompressible::turbulenceModel turbType; - const turbType* turbPtr = lookupObjectPtr + const turbType* turbPtr = findObject ( turbulenceModel::propertiesName ); @@ -305,7 +305,7 @@ Foam::functionObjects::energyTransport::energyTransport phases_.set ( i, - mesh_.lookupObjectRefPtr(phaseNames_[i]) + mesh_.getObjectPtr(phaseNames_[i]) ); } diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index 7b89363a81..650a8a7723 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -88,10 +88,7 @@ Foam::tmp Foam::functionObjects::scalarTransport::D const surfaceScalarField& phi ) const { - typedef incompressible::turbulenceModel icoModel; - typedef compressible::turbulenceModel cmpModel; - - word Dname("D" + s.name()); + const word Dname("D" + s.name()); if (constantD_) { @@ -109,38 +106,49 @@ Foam::tmp Foam::functionObjects::scalarTransport::D dimensionedScalar(Dname, phi.dimensions()/dimLength, D_) ); } - else if (nutName_ != "none") + + if (nutName_ != "none") { const volScalarField& nutMean = mesh_.lookupObject(nutName_); return tmp::New(Dname, nutMean); } - else if (foundObject(turbulenceModel::propertiesName)) - { - const icoModel& model = lookupObject - ( - turbulenceModel::propertiesName - ); - return tmp::New - ( - Dname, - alphaD_*model.nu() + alphaDt_*model.nut() - ); + // Incompressible + { + const auto* turb = + findObject + ( + turbulenceModel::propertiesName + ); + + if (turb) + { + return tmp::New + ( + Dname, + alphaD_ * turb->nu() + alphaDt_ * turb->nut() + ); + } } - else if (foundObject(turbulenceModel::propertiesName)) - { - const cmpModel& model = lookupObject - ( - turbulenceModel::propertiesName - ); - return tmp::New - ( - Dname, - alphaD_*model.mu() + alphaDt_*model.mut() - ); + // Compressible + { + const auto* turb = + findObject + ( + turbulenceModel::propertiesName + ); + + if (turb) + { + return tmp::New + ( + Dname, + alphaD_ * turb->mu() + alphaDt_ * turb->mut() + ); + } } diff --git a/src/functionObjects/utilities/ensightWrite/ensightWriteTemplates.C b/src/functionObjects/utilities/ensightWrite/ensightWriteTemplates.C index a1da699b44..6958cc7f14 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWriteTemplates.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWriteTemplates.C @@ -38,10 +38,16 @@ int Foam::functionObjects::ensightWrite::writeVolField // State: return 0 (not-processed), -1 (skip), +1 ok typedef GeometricField VolFieldType; - const VolFieldType* fldPtr; + // Already done + if (state) + { + return state; + } - // Already done, or not available - if (state || !(fldPtr = lookupObjectPtr(inputName))) + const VolFieldType* fldPtr = findObject(inputName); + + // Not available + if (!fldPtr) { return state; } diff --git a/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C b/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C index 2441d6ab48..be038b55c5 100644 --- a/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C +++ b/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C @@ -82,22 +82,18 @@ bool Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) bool Foam::functionObjects::removeRegisteredObject::execute() { - forAll(objectNames_, i) + for (const word& objName : objectNames_) { - if (foundObject(objectNames_[i])) + regIOobject* ptr = getObjectPtr(objName); + + if (ptr && ptr->ownedByRegistry()) { - const regIOobject& obj = - lookupObject(objectNames_[i]); + Log << type() << " " << name() << " output:" << nl + << " removing object " << ptr->name() << nl + << endl; - if (obj.ownedByRegistry()) - { - Log << type() << " " << name() << " output:" << nl - << " removing object " << obj.name() << nl - << endl; - - const_cast(obj).release(); - delete &obj; - } + ptr->release(); + delete ptr; } } diff --git a/src/functionObjects/utilities/residuals/residuals.C b/src/functionObjects/utilities/residuals/residuals.C index 907fcdd205..a4aa02c51e 100644 --- a/src/functionObjects/utilities/residuals/residuals.C +++ b/src/functionObjects/utilities/residuals/residuals.C @@ -113,8 +113,7 @@ void Foam::functionObjects::residuals::writeField(const word& fieldName) const { const word residualName("initialResidual:" + fieldName); - const IOField* residualPtr = - mesh_.lookupObjectPtr>(residualName); + const auto* residualPtr = mesh_.findObject>(residualName); if (residualPtr) { diff --git a/src/functionObjects/utilities/writeDictionary/writeDictionary.C b/src/functionObjects/utilities/writeDictionary/writeDictionary.C index a81e5a718b..1dc642d4fb 100644 --- a/src/functionObjects/utilities/writeDictionary/writeDictionary.C +++ b/src/functionObjects/utilities/writeDictionary/writeDictionary.C @@ -160,10 +160,12 @@ bool Foam::functionObjects::writeDictionary::write() bool firstDict = true; forAll(dictNames_, i) { - if (obr_.foundObject(dictNames_[i])) + const dictionary* dictptr = + obr_.findObject(dictNames_[i]); + + if (dictptr) { - const dictionary& dict = - obr_.lookupObject(dictNames_[i]); + const dictionary& dict = *dictptr; if (dict.digest() != digests_[i]) { diff --git a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C index ba7320d68f..5e927a434c 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C @@ -211,13 +211,9 @@ void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs() >(*fieldsCacheIter()); - pointVectorField& d = const_cast - ( - timeCache.lookupObject - ( - fieldName_ - ) - ); + pointVectorField& d = + timeCache.lookupObjectRef(fieldName_); + d.correctBoundaryConditions(); } } diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C index 6c0f0b0950..811eab1e62 100644 --- a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C +++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C @@ -106,7 +106,7 @@ Foam::fv::viscousDissipation::viscousDissipation ) { const basicThermo* thermoPtr = - mesh_.lookupObjectPtr(basicThermo::dictName); + mesh_.findObject(basicThermo::dictName); if (thermoPtr) { @@ -136,7 +136,7 @@ Foam::fv::viscousDissipation::devRhoReff() const // Incompressible { const auto* turbPtr = - mesh_.lookupObjectPtr + mesh_.findObject ( turbulenceModel::propertiesName ); @@ -150,7 +150,7 @@ Foam::fv::viscousDissipation::devRhoReff() const // Compressible { const auto* turbPtr = - mesh_.lookupObjectPtr + mesh_.findObject ( turbulenceModel::propertiesName ); @@ -196,8 +196,7 @@ void Foam::fv::viscousDissipation::addSup ); // Cached? - const GradFieldType* gradUPtr = - mesh_.lookupObjectPtr(gradUName); + const GradFieldType* gradUPtr = mesh_.findObject(gradUName); if (gradUPtr) { diff --git a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C index 0c0ee7252d..fe3ad19a9f 100644 --- a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C +++ b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C @@ -206,10 +206,12 @@ void Foam::fv::interRegionHeatTransferModel::addSup { if (he.dimensions() == dimEnergy/dimMass) { - if (mesh_.foundObject(basicThermo::dictName)) + const basicThermo* thermoPtr = + mesh_.findObject(basicThermo::dictName); + + if (thermoPtr) { - const basicThermo& thermo = - mesh_.lookupObject(basicThermo::dictName); + const basicThermo& thermo = *thermoPtr; volScalarField htcByCpv(htc_/thermo.Cpv()); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Interface/InterfaceForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Interface/InterfaceForce.C index cbba2eb698..64bf5dcfb8 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Interface/InterfaceForce.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Interface/InterfaceForce.C @@ -101,10 +101,10 @@ void Foam::InterfaceForce::cacheFields(const bool store) if (fieldExists) { - const volVectorField& gradInterForce = this->mesh().template - lookupObject(fName); + volVectorField& gradInterForce = + this->mesh().template lookupObjectRef(fName); - const_cast(gradInterForce).checkOut(); + gradInterForce.checkOut(); } } } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForce.C index cc45ca417d..ed757e32d6 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForce.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Lift/LiftForce/LiftForce.C @@ -116,10 +116,10 @@ void Foam::LiftForce::cacheFields(const bool store) if (fieldExists) { - const volVectorField& curlUc = this->mesh().template - lookupObject(fName); + volVectorField& curlUc = + this->mesh().template lookupObjectRef(fName); - const_cast(curlUc).checkOut(); + curlUc.checkOut(); } } } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C index 2d1b322950..b84811e98e 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C @@ -106,10 +106,10 @@ void Foam::PressureGradientForce::cacheFields(const bool store) if (fieldExists) { - const volVectorField& DUcDt = this->mesh().template - lookupObject(fName); + volVectorField& DUcDt = + this->mesh().template lookupObjectRef(fName); - const_cast(DUcDt).checkOut(); + DUcDt.checkOut(); } } } diff --git a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C index b1116d76ce..82bbd3702e 100644 --- a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C +++ b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C @@ -41,11 +41,11 @@ Foam::DispersionRASModel::kModel() const this->owner().U().group() ); - if (obr.foundObject(turbName)) + const turbulenceModel* turb = obr.findObject(turbName); + + if (turb) { - const turbulenceModel& model = - obr.lookupObject(turbName); - return model.k(); + return turb->k(); } FatalErrorInFunction @@ -69,11 +69,11 @@ Foam::DispersionRASModel::epsilonModel() const this->owner().U().group() ); - if (obr.foundObject(turbName)) + const turbulenceModel* turb = obr.findObject(turbName); + + if (turb) { - const turbulenceModel& model = - obr.lookupObject(turbName); - return model.epsilon(); + return turb->epsilon(); } FatalErrorInFunction diff --git a/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C b/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C index c2f42a8c10..2718f36e0e 100644 --- a/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C +++ b/src/lagrangian/turbulence/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C @@ -64,11 +64,11 @@ Foam::BrownianMotionForce::kModel() const this->owner().U().group() ); - if (obr.foundObject(turbName)) + const turbulenceModel* turb = obr.findObject(turbName); + + if (turb) { - const turbulenceModel& model = - obr.lookupObject(turbName); - return model.k(); + return turb->k(); } FatalErrorInFunction diff --git a/src/lumpedPointMotion/lumpedPointIOMovement.C b/src/lumpedPointMotion/lumpedPointIOMovement.C index 81cc4073bb..2f9d02fba4 100644 --- a/src/lumpedPointMotion/lumpedPointIOMovement.C +++ b/src/lumpedPointMotion/lumpedPointIOMovement.C @@ -39,7 +39,7 @@ namespace Foam const Foam::lumpedPointIOMovement* Foam::lumpedPointIOMovement::lookupInRegistry(const objectRegistry& obr) { - return obr.lookupObjectPtr + return obr.findObject ( lumpedPointMovement::canonicalName ); diff --git a/src/lumpedPointMotion/lumpedPointMovement.C b/src/lumpedPointMotion/lumpedPointMovement.C index 3ef592ba70..8ecbe7e3c8 100644 --- a/src/lumpedPointMotion/lumpedPointMovement.C +++ b/src/lumpedPointMotion/lumpedPointMovement.C @@ -495,7 +495,7 @@ bool Foam::lumpedPointMovement::forcesAndMoments // Calculated force per patch - cache PtrMap forceOnPatches; - const volScalarField* pPtr = pmesh.lookupObjectPtr(pName); + const volScalarField* pPtr = pmesh.findObject(pName); // fvMesh and has pressure field if (isA(pmesh) && pPtr) diff --git a/src/meshTools/coordinate/systems/coordinateSystems.C b/src/meshTools/coordinate/systems/coordinateSystems.C index 5fcb359ad5..0da9cb0c8b 100644 --- a/src/meshTools/coordinate/systems/coordinateSystems.C +++ b/src/meshTools/coordinate/systems/coordinateSystems.C @@ -240,8 +240,7 @@ const Foam::coordinateSystems& Foam::coordinateSystems::New { // Previously registered? - const coordinateSystems* ptr = - obr.lookupObjectPtr(typeName); + const coordinateSystems* ptr = obr.findObject(typeName); if (ptr) { diff --git a/src/meshTools/regionCoupled/GAMG/interfaces/regionCoupledGAMGInterface/regionCoupledBaseGAMGInterface.C b/src/meshTools/regionCoupled/GAMG/interfaces/regionCoupledGAMGInterface/regionCoupledBaseGAMGInterface.C index 0dba392624..5bc947e6ef 100644 --- a/src/meshTools/regionCoupled/GAMG/interfaces/regionCoupledGAMGInterface/regionCoupledBaseGAMGInterface.C +++ b/src/meshTools/regionCoupled/GAMG/interfaces/regionCoupledGAMGInterface/regionCoupledBaseGAMGInterface.C @@ -100,19 +100,16 @@ Foam::regionCoupledBaseGAMGInterface::regionCoupledBaseGAMGInterface const polyMesh& nbrMesh = fineRegionCoupledLduInterface_.nbrMesh(); - if - ( - nbrMesh.foundObject(GAMGAgglomeration::typeName) - ) - { - const GAMGAgglomeration& nbrAgg = nbrMesh.thisDb().lookupObject - < - GAMGAgglomeration - > + const GAMGAgglomeration* nbrAggPtr = nbrMesh.thisDb().findObject + ( GAMGAgglomeration::typeName ); + if (nbrAggPtr) + { + const GAMGAgglomeration& nbrAgg = *nbrAggPtr; + label nbrLevel(-1); if (nbrAgg.size() > fineLevelIndex) { diff --git a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C index bd64b8238d..37fc5171a7 100644 --- a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C +++ b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C @@ -187,19 +187,15 @@ Foam::label Foam::regionCoupledBase::neighbPatchID() const { if (nbrPatchID_ == -1) { - if - ( - patch_.boundaryMesh().mesh().time().foundObject + const polyMesh* meshPtr = + patch_.boundaryMesh().mesh().time().findObject ( nbrRegionName_ - ) - ) + ); + + if (meshPtr) { - const polyMesh& mesh = - patch_.boundaryMesh().mesh().time().lookupObject - ( - nbrRegionName_ - ); + const polyMesh& mesh = *meshPtr; nbrPatchID_ = mesh.boundaryMesh().findPatchID(nbrPatchName_); diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C index a55e2c37ff..6f84dd7e7d 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C @@ -205,8 +205,8 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection const word subGeomName(subDict.get("surface")); //Pout<< "Trying to find " << subGeomName << endl; - const searchableSurface& s = - io.db().lookupObject(subGeomName); + searchableSurface& s = + io.db().lookupObjectRef(subGeomName); // I don't know yet how to handle the globalSize combined with // regionOffset. Would cause non-consecutive indices locally @@ -218,7 +218,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection << exit(FatalError); } - subGeom_.set(surfI, &(const_cast(s))); + subGeom_.set(surfI, &s); indexOffset_[surfI] = startIndex; startIndex += subGeom_[surfI].size(); diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C index 6721a4bb5a..d610601933 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C @@ -189,7 +189,7 @@ Foam::searchableSurfaceWithGaps::searchableSurfaceWithGaps subGeom_.set ( 0, - io.db().lookupObjectRefPtr(subGeomName) + io.db().getObjectPtr(subGeomName) ); bounds() = subGeom_[0].bounds(); diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 791c8d993b..74cafc8fc3 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -803,14 +803,15 @@ void Foam::triSurfaceMesh::getNormal void Foam::triSurfaceMesh::setField(const labelList& values) { + auto* fldPtr = getObjectPtr("values"); - if (foundObject("values")) + if (fldPtr) { - lookupObjectRef("values").field() = values; + (*fldPtr).field() = values; } else { - auto fldPtr = autoPtr::New + fldPtr = new triSurfaceLabelField ( IOobject ( @@ -827,7 +828,7 @@ void Foam::triSurfaceMesh::setField(const labelList& values) ); // Store field on triMesh - fldPtr.ptr()->store(); + fldPtr->store(); } } @@ -838,9 +839,11 @@ void Foam::triSurfaceMesh::getField labelList& values ) const { - if (foundObject("values")) + const auto* fldPtr = getObjectPtr("values"); + + if (fldPtr) { - const auto& fld = lookupObject("values"); + const auto& fld = *fldPtr; values.setSize(info.size()); diff --git a/src/parallel/decompose/decompositionMethods/decompositionConstraints/refinementHistory/refinementHistoryConstraint.C b/src/parallel/decompose/decompositionMethods/decompositionConstraints/refinementHistory/refinementHistoryConstraint.C index c1af450d7f..ebdb9f641d 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionConstraints/refinementHistory/refinementHistoryConstraint.C +++ b/src/parallel/decompose/decompositionMethods/decompositionConstraints/refinementHistory/refinementHistoryConstraint.C @@ -84,24 +84,13 @@ void Foam::refinementHistoryConstraint::add List& explicitConnections ) const { - autoPtr storagePtr; - refinementHistory const* refPtr = nullptr; + const refinementHistory* refPtr = + mesh.findObject("refinementHistory"); - if (mesh.foundObject("refinementHistory")) + autoPtr storagePtr; + + if (!refPtr) { - if (decompositionConstraint::debug) - { - Info<< type() << " : found refinementHistory" << endl; - } - refPtr = &mesh.lookupObject("refinementHistory"); - } - else - { - if (decompositionConstraint::debug) - { - Info<< type() << " : reading refinementHistory from time " - << mesh.facesInstance() << endl; - } storagePtr.reset ( new refinementHistory @@ -120,6 +109,19 @@ void Foam::refinementHistoryConstraint::add ); } + if (decompositionConstraint::debug) + { + if (refPtr) + { + Info<< type() << " : found refinementHistory" << nl; + } + else + { + Info<< type() << " : reading refinementHistory from time " + << mesh.facesInstance() << nl; + } + } + const refinementHistory& history = ( storagePtr.valid() @@ -151,24 +153,13 @@ void Foam::refinementHistoryConstraint::apply labelList& decomposition ) const { - autoPtr storagePtr; - refinementHistory const* refPtr = nullptr; + const refinementHistory* refPtr = + mesh.findObject("refinementHistory"); - if (mesh.foundObject("refinementHistory")) + autoPtr storagePtr; + + if (!refPtr) { - //if (decompositionConstraint::debug) - //{ - // Info<< type() << " : found refinementHistory" << endl; - //} - refPtr = &mesh.lookupObject("refinementHistory"); - } - else - { - //if (decompositionConstraint::debug) - //{ - // Info<< type() << " : reading refinementHistory from time " - // << mesh.facesInstance() << endl; - //} storagePtr.reset ( new refinementHistory diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 25686ebb72..7da8ce27f4 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -808,7 +808,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs // here since we've only got Time and not a mesh. const auto* dictPtr = - searchableSurface::time().lookupObjectPtr + searchableSurface::time().findObject ( // == decompositionModel::canonicalName "decomposeParDict" @@ -1914,13 +1914,11 @@ void Foam::distributedTriSurfaceMesh::getField return; } - if (foundObject("values")) - { - const triSurfaceLabelField& fld = lookupObject - ( - "values" - ); + const auto* fldPtr = findObject("values"); + if (fldPtr) + { + const triSurfaceLabelField& fld = *fldPtr; // Get query data (= local index of triangle) // ~~~~~~~~~~~~~~ diff --git a/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C b/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C index 53ba2236c5..0c751ec61e 100644 --- a/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C +++ b/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C @@ -67,23 +67,19 @@ void Foam::energyRegionCoupledFvPatchScalarField::setMethod() const if (!nbrThermoPtr_) { nbrThermoPtr_ = - ( - ®ionCoupledPatch_.nbrMesh().lookupObject + regionCoupledPatch_.nbrMesh().findObject ( basicThermo::dictName - ) - ); + ); } if (!thermoPtr_) { thermoPtr_ = - ( - &this->db().lookupObject + this->db().findObject ( basicThermo::dictName - ) - ); + ); } } diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C index 6b1aee1745..a0badb5c87 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C @@ -123,35 +123,37 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() return; } - typedef regionModels::surfaceFilmModels::surfaceFilmRegionModel - filmModelType; + // Film model + const auto* filmModelPtr = db().time().findObject + + (filmRegionName_); + + // Pyrolysis model + const auto* pyrModelPtr = db().time().findObject + + (pyrolysisRegionName_); + + if (!filmModelPtr || !pyrModelPtr) + { + // Do nothing on construction - film model doesn't exist yet + return; + } + + const auto& filmModel = *filmModelPtr; + const auto& pyrModel = *pyrModelPtr; - typedef regionModels::pyrolysisModels::pyrolysisModel pyrModelType; // Since we're inside initEvaluate/evaluate there might be processor // comms underway. Change the tag we use. int oldTag = UPstream::msgType(); UPstream::msgType() = oldTag+1; - bool filmOk = db().time().foundObject(filmRegionName_); - - - bool pyrOk = db().time().foundObject(pyrolysisRegionName_); - - if (!filmOk || !pyrOk) - { - // Do nothing on construction - film model doesn't exist yet - return; - } scalarField& Tp = *this; const label patchi = patch().index(); - // Retrieve film model - const filmModelType& filmModel = - db().time().lookupObject(filmRegionName_); - + // The film model const label filmPatchi = filmModel.regionPatchID(patchi); scalarField alphaFilm = filmModel.alpha().boundaryField()[filmPatchi]; @@ -160,10 +162,7 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() scalarField TFilm = filmModel.Ts().boundaryField()[filmPatchi]; filmModel.toPrimary(filmPatchi, TFilm); - // Retrieve pyrolysis model - const pyrModelType& pyrModel = - db().time().lookupObject(pyrolysisRegionName_); - + // The pyrolysis model const label pyrPatchi = pyrModel.regionPatchID(patchi); scalarField TPyr = pyrModel.T().boundaryField()[pyrPatchi]; diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C index f4b4d44555..34c22f9e28 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C @@ -123,35 +123,38 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() return; } - typedef regionModels::surfaceFilmModels::surfaceFilmRegionModel - filmModelType; + // Film model + const auto* filmModelPtr = db().time().findObject + + (filmRegionName_); + + // Pyrolysis model + const auto* pyrModelPtr = db().time().findObject + + (pyrolysisRegionName_); + + + if (!filmModelPtr || !pyrModelPtr) + { + // Do nothing on construction - film model doesn't exist yet + return; + } + + const auto& filmModel = *filmModelPtr; + const auto& pyrModel = *pyrModelPtr; - typedef regionModels::pyrolysisModels::pyrolysisModel pyrModelType; // Since we're inside initEvaluate/evaluate there might be processor // comms underway. Change the tag we use. int oldTag = UPstream::msgType(); UPstream::msgType() = oldTag+1; - bool foundFilm = db().time().foundObject(filmRegionName_); - - bool foundPyrolysis = - db().time().foundObject(pyrolysisRegionName_); - - if (!foundFilm || !foundPyrolysis) - { - // Do nothing on construction - film model doesn't exist yet - return; - } vectorField& Up = *this; const label patchi = patch().index(); - // Retrieve film model - const filmModelType& filmModel = - db().time().lookupObject(filmRegionName_); - + // The film model const label filmPatchi = filmModel.regionPatchID(patchi); scalarField alphaFilm = filmModel.alpha().boundaryField()[filmPatchi]; @@ -160,10 +163,7 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() vectorField UFilm = filmModel.Us().boundaryField()[filmPatchi]; filmModel.toPrimary(filmPatchi, UFilm); - // Retrieve pyrolysis model - const pyrModelType& pyrModel = - db().time().lookupObject(pyrolysisRegionName_); - + // The pyrolysis model const label pyrPatchi = pyrModel.regionPatchID(patchi); scalarField phiPyr = pyrModel.phiGas().boundaryField()[pyrPatchi]; diff --git a/src/regionModels/regionModel/regionModel/regionModelI.H b/src/regionModels/regionModel/regionModel/regionModelI.H index b841f0165f..39c0c11b5b 100644 --- a/src/regionModels/regionModel/regionModel/regionModelI.H +++ b/src/regionModels/regionModel/regionModel/regionModelI.H @@ -60,14 +60,16 @@ inline const Foam::word& Foam::regionModels::regionModel::modelName() const inline const Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() const { - if (time_.foundObject(regionName_)) + const fvMesh* regionPtr = time_.findObject(regionName_); + + if (regionPtr) { - return time_.lookupObject(regionName_); + return *regionPtr; } else if (!regionMeshPtr_.valid()) { FatalErrorInFunction - << "Region mesh not available" << abort(FatalError); + << "Region mesh not available" << abort(FatalError); } return *regionMeshPtr_; @@ -76,17 +78,16 @@ inline const Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() const inline Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() { - if (time_.foundObject(regionName_)) + fvMesh* regionPtr = time_.getObjectPtr(regionName_); + + if (regionPtr) { - return const_cast - ( - time_.lookupObject(regionName_) - ); + return *regionPtr; } else if (!regionMeshPtr_.valid()) { FatalErrorInFunction - << "Region mesh not available" << abort(FatalError); + << "Region mesh not available" << abort(FatalError); } return *regionMeshPtr_; diff --git a/src/regionModels/regionModel/regionModel/regionModelTemplates.C b/src/regionModels/regionModel/regionModel/regionModelTemplates.C index a1ef447e49..9813f9f8e3 100644 --- a/src/regionModels/regionModel/regionModel/regionModelTemplates.C +++ b/src/regionModels/regionModel/regionModel/regionModelTemplates.C @@ -87,15 +87,7 @@ Foam::regionModels::regionModel::mapRegionPatchField { const polyPatch& p = regionMesh().boundaryMesh()[regionPatchi]; - return - tmp> - ( - new Field - ( - p.size(), - Zero - ) - ); + return tmp>::New(p.size(), Zero); } } @@ -143,15 +135,7 @@ Foam::regionModels::regionModel::mapRegionPatchInternalField { const polyPatch& p = regionMesh().boundaryMesh()[regionPatchi]; - return - tmp> - ( - new Field - ( - p.size(), - Zero - ) - ); + return tmp>::New(p.size(), Zero); } } diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C index f468aff4c6..3d417419e4 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C @@ -142,27 +142,27 @@ void alphatFilmWallFunctionFvPatchScalarField::updateCoeffs() return; } - typedef regionModels::surfaceFilmModels::surfaceFilmRegionModel modelType; + const auto* filmModelPtr = db().time().findObject + + (filmRegionName_); + + if (!filmModelPtr) + { + // Do nothing on construction - film model doesn't exist yet + return; + } + + const auto& filmModel = *filmModelPtr; + // Since we're inside initEvaluate/evaluate there might be processor // comms underway. Change the tag we use. int oldTag = UPstream::msgType(); UPstream::msgType() = oldTag+1; - bool foundFilm = db().time().foundObject(filmRegionName_); - - if (!foundFilm) - { - // Do nothing on construction - film model doesn't exist yet - return; - } - const label patchi = patch().index(); // Retrieve phase change mass from surface film model - const modelType& filmModel = - db().time().lookupObject(filmRegionName_); - const label filmPatchi = filmModel.regionPatchID(patchi); tmp mDotFilm(filmModel.primaryMassTrans()); diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C index 4b733d8268..b17d6a9ac8 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C @@ -48,14 +48,14 @@ tmp nutkFilmWallFunctionFvPatchScalarField::calcUTau const scalarField& magGradU ) const { - tmp tuTau(new scalarField(patch().size(), 0.0)); + tmp tuTau(new scalarField(patch().size(), Zero)); scalarField& uTau = tuTau.ref(); - typedef regionModels::surfaceFilmModels::surfaceFilmRegionModel modelType; + const auto* filmModelPtr = db().time().findObject + + (filmRegionName_); - bool foundFilm = db().time().foundObject(filmRegionName_); - - if (!foundFilm) + if (!filmModelPtr) { // Do nothing on construction - film model doesn't exist yet return tuTau; @@ -64,8 +64,7 @@ tmp nutkFilmWallFunctionFvPatchScalarField::calcUTau const label patchi = patch().index(); // Retrieve phase change mass from surface film model - const modelType& filmModel = - db().time().lookupObject(filmRegionName_); + const auto& filmModel = *filmModelPtr; const label filmPatchi = filmModel.regionPatchID(patchi); diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C index b857ed3fae..0f20bdc9e0 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/filmThermoModel/liquidFilmThermo/liquidFilmThermo.C @@ -78,19 +78,23 @@ void liquidFilmThermo::initLiquid(const dictionary& dict) dict.readEntry("liquid", name_); - if (filmModel_.primaryMesh().foundObject("SLGThermo")) + const SLGThermo* thermoPtr = + filmModel_.primaryMesh().findObject("SLGThermo"); + + if (thermoPtr) { - // retrieve from film thermo + // Retrieve from film thermo ownLiquid_ = false; - const SLGThermo& thermo = - filmModel_.primaryMesh().lookupObject("SLGThermo"); - label id = thermo.liquidId(name_); + const SLGThermo& thermo = *thermoPtr; + + const label id = thermo.liquidId(name_); + liquidPtr_ = &thermo.liquids().properties()[id]; } else { - // new liquid create + // New liquid create ownLiquid_ = true; liquidPtr_ = diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index 69f971030e..87a847f247 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -52,27 +52,22 @@ void Foam::sampledIsoSurface::getIsoFields() const // Get volField // ~~~~~~~~~~~~ - if (fvm.foundObject(isoField_)) + volFieldPtr_ = fvm.getObjectPtr(isoField_); + + if (volFieldPtr_) { - if (debug) - { - InfoInFunction - << "Lookup volField " << isoField_ << endl; - } + DebugInFunction + << "Lookup volField " << isoField_ << endl; + storedVolFieldPtr_.clear(); - volFieldPtr_ = &fvm.lookupObject(isoField_); } else { // Bit of a hack. Read field and store. - if (debug) - { - InfoInFunction - << "Checking " << isoField_ - << " for same time " << fvm.time().timeName() - << endl; - } + DebugInFunction + << "Checking " << isoField_ + << " for same time " << fvm.time().timeName() << endl; if ( @@ -80,13 +75,9 @@ void Foam::sampledIsoSurface::getIsoFields() const || (fvm.time().timeName() != storedVolFieldPtr_().instance()) ) { - if (debug) - { - InfoInFunction - << "Reading volField " << isoField_ - << " from time " << fvm.time().timeName() - << endl; - } + DebugInFunction + << "Reading volField " << isoField_ + << " from time " << fvm.time().timeName() << endl; IOobject vfHeader ( @@ -141,61 +132,45 @@ void Foam::sampledIsoSurface::getIsoFields() const + isoField_ + ')'; - if (fvm.foundObject(pointFldName)) - { - if (debug) - { - InfoInFunction - << "lookup pointField " << pointFldName << endl; - } - const pointScalarField& pfld = fvm.lookupObject - ( - pointFldName - ); - if (!pfld.upToDate(*volFieldPtr_)) + pointFieldPtr_ = fvm.getObjectPtr(pointFldName); + + if (pointFieldPtr_) + { + DebugInFunction + << "lookup pointField " << pointFldName << endl; + + if (!pointFieldPtr_->upToDate(*volFieldPtr_)) { - if (debug) - { - InfoInFunction - << "updating pointField " - << pointFldName << endl; - } + DebugInFunction + << "updating pointField " << pointFldName << endl; + // Update the interpolated value volPointInterpolation::New(fvm).interpolate ( *volFieldPtr_, - const_cast(pfld) + const_cast(*pointFieldPtr_) ); } - - pointFieldPtr_ = &pfld; } else { // Not in registry. Interpolate. - if (debug) - { - InfoInFunction - << "Checking pointField " << pointFldName - << " for same time " << fvm.time().timeName() - << endl; - } + DebugInFunction + << "creating pointField " << pointFldName << endl; // Interpolate without cache. Note that we're registering it // below so next time round it goes into the condition // above. - tmp tpfld - ( + pointFieldPtr_ = volPointInterpolation::New(fvm).interpolate ( *volFieldPtr_, pointFldName, false - ) - ); - pointFieldPtr_ = tpfld.ptr(); + ).ptr(); + const_cast(pointFieldPtr_)->store(); } @@ -212,17 +187,13 @@ void Foam::sampledIsoSurface::getIsoFields() const } - if (debug) - { - InfoInFunction - << "volField " << volFieldPtr_->name() - << " min:" << min(*volFieldPtr_).value() - << " max:" << max(*volFieldPtr_).value() << endl; - InfoInFunction - << "pointField " << pointFieldPtr_->name() - << " min:" << gMin(pointFieldPtr_->primitiveField()) - << " max:" << gMax(pointFieldPtr_->primitiveField()) << endl; - } + DebugInFunction + << "volField " << volFieldPtr_->name() + << " min:" << min(*volFieldPtr_).value() + << " max:" << max(*volFieldPtr_).value() << nl + << "pointField " << pointFieldPtr_->name() + << " min:" << gMin(pointFieldPtr_->primitiveField()) + << " max:" << gMax(pointFieldPtr_->primitiveField()) << endl; } else { @@ -231,24 +202,20 @@ void Foam::sampledIsoSurface::getIsoFields() const // Either lookup on the submesh or subset the whole-mesh volField - if (subFvm.foundObject(isoField_)) + volSubFieldPtr_ = subFvm.getObjectPtr(isoField_); + + if (volSubFieldPtr_) { - if (debug) - { - InfoInFunction - << "Sub-mesh lookup volField " - << isoField_ << endl; - } + DebugInFunction + << "Sub-mesh lookup volField " << isoField_ << endl; + storedVolSubFieldPtr_.clear(); - volSubFieldPtr_ = &subFvm.lookupObject(isoField_); } else { - if (debug) - { - InfoInFunction - << "Sub-setting volField " << isoField_ << endl; - } + DebugInFunction + << "Sub-setting volField " << isoField_ << endl; + storedVolSubFieldPtr_.reset ( subMeshPtr_().interpolate @@ -270,53 +237,40 @@ void Foam::sampledIsoSurface::getIsoFields() const + volSubFieldPtr_->name() + ')'; - if (subFvm.foundObject(pointFldName)) - { - if (debug) - { - InfoInFunction - << "Sub-mesh lookup pointField " << pointFldName << endl; - } - const pointScalarField& pfld = subFvm.lookupObject - ( - pointFldName - ); - if (!pfld.upToDate(*volSubFieldPtr_)) + pointFieldPtr_ = subFvm.getObjectPtr(pointFldName); + + if (pointFieldPtr_) + { + DebugInFunction + << "Sub-mesh lookup pointField " << pointFldName << endl; + + if (!pointFieldPtr_->upToDate(*volSubFieldPtr_)) { - if (debug) - { - Info<< "sampledIsoSurface::getIsoFields() :" - << " updating submesh pointField " - << pointFldName << endl; - } + DebugInFunction + << "Updating submesh pointField " << pointFldName << endl; + // Update the interpolated value volPointInterpolation::New(subFvm).interpolate ( *volSubFieldPtr_, - const_cast(pfld) + const_cast(*pointFieldPtr_) ); } - - pointFieldPtr_ = &pfld; } else { - if (debug) - { - InfoInFunction - << "Interpolating submesh volField " - << volSubFieldPtr_->name() - << " to get submesh pointField " << pointFldName << endl; - } - tmp tpfld - ( + DebugInFunction + << "Interpolating submesh volField " + << volSubFieldPtr_->name() + << " to get submesh pointField " << pointFldName << endl; + + pointSubFieldPtr_ = volPointInterpolation::New ( subFvm - ).interpolate(*volSubFieldPtr_) - ); - pointSubFieldPtr_ = tpfld.ptr(); + ).interpolate(*volSubFieldPtr_).ptr(); + const_cast(pointSubFieldPtr_)->store(); } @@ -333,19 +287,15 @@ void Foam::sampledIsoSurface::getIsoFields() const } - if (debug) - { - InfoInFunction - << "volSubField " - << volSubFieldPtr_->name() - << " min:" << min(*volSubFieldPtr_).value() - << " max:" << max(*volSubFieldPtr_).value() << endl; - InfoInFunction - << "pointSubField " - << pointSubFieldPtr_->name() - << " min:" << gMin(pointSubFieldPtr_->primitiveField()) - << " max:" << gMax(pointSubFieldPtr_->primitiveField()) << endl; - } + DebugInFunction + << "volSubField " + << volSubFieldPtr_->name() + << " min:" << min(*volSubFieldPtr_).value() + << " max:" << max(*volSubFieldPtr_).value() << nl + << "pointSubField " + << pointSubFieldPtr_->name() + << " min:" << gMin(pointSubFieldPtr_->primitiveField()) + << " max:" << gMax(pointSubFieldPtr_->primitiveField()) << endl; } } diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C index f51b7f1ccf..b5ba01ada1 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C @@ -64,7 +64,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const // Use field from database, or try to read it in - const auto* cellFldPtr = fvm.lookupObjectPtr(isoField_); + const auto* cellFldPtr = fvm.findObject(isoField_); if (debug) { diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C index 82e158111b..a407945430 100644 --- a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C @@ -61,7 +61,7 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const // Use volField from database, or try to read it in - const auto* cellFldPtr = fvm.lookupObjectPtr(fieldName_); + const auto* cellFldPtr = fvm.findObject(fieldName_); if (debug) { diff --git a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C b/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C index 1a179a08d3..7e1834f5d5 100644 --- a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C +++ b/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C @@ -53,7 +53,7 @@ bool Foam::surfMeshSampleDistanceSurface::sampleType { typedef GeometricField VolFieldType; - const auto* volFldPtr = mesh().lookupObjectPtr(fieldName); + const auto* volFldPtr = mesh().findObject(fieldName); if (!volFldPtr) { diff --git a/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C b/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C index 2158020021..fbcd7a6441 100644 --- a/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C +++ b/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C @@ -53,7 +53,7 @@ bool Foam::surfMeshSamplePlane::sampleType { typedef GeometricField VolFieldType; - const auto* volFldPtr = mesh().lookupObjectPtr(fieldName); + const auto* volFldPtr = mesh().findObject(fieldName); if (!volFldPtr) { diff --git a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C b/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C index 316d3384d1..95d969da54 100644 --- a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C +++ b/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C @@ -76,7 +76,7 @@ Foam::surfMeshSample::getOrCreateSurfField const surfMesh& surf = surface(); const word& fieldName = vField.name(); - SurfFieldType* ptr = surf.lookupObjectRefPtr(fieldName); + SurfFieldType* ptr = surf.getObjectPtr(fieldName); if (!ptr) { ptr = new SurfFieldType diff --git a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C b/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C index 62ff7b3530..f51801ae77 100644 --- a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C +++ b/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C @@ -109,7 +109,7 @@ bool Foam::surfMeshSamplers::add_rhoU(const word& derivedName) // rhoU = rho * U - const auto* rhoPtr = mesh_.lookupObjectPtr("rho"); + const auto* rhoPtr = mesh_.findObject("rho"); const volVectorField& U = mesh_.lookupObject("U"); tmp tresult; @@ -152,7 +152,7 @@ bool Foam::surfMeshSamplers::add_pTotal(const word& derivedName) // pTotal = p + rho * U^2 / 2 - const auto* rhoPtr = mesh_.lookupObjectPtr("rho"); + const auto* rhoPtr = mesh_.findObject("rho"); const volScalarField& p = mesh_.lookupObject("p"); const volVectorField& U = mesh_.lookupObject("U"); diff --git a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C b/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C index 78cf386c52..d3f120cac4 100644 --- a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C +++ b/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C @@ -60,7 +60,7 @@ bool Foam::surfMeshSampleDiscrete::sampleType typedef GeometricField VolFieldType; const auto* volFldPtr = - SurfaceSource::mesh().lookupObjectPtr(fieldName); + SurfaceSource::mesh().findObject(fieldName); if (!volFldPtr) { diff --git a/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C b/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C index 3fce29d212..eba3ec1194 100644 --- a/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C +++ b/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C @@ -40,7 +40,7 @@ bool Foam::discreteSurface::sampleType typedef DimensionedField SurfFieldType; typedef IOField TmpFieldType; - const auto* volFldPtr = mesh().lookupObjectPtr(fieldName); + const auto* volFldPtr = mesh().findObject(fieldName); if (!volFldPtr) { @@ -57,7 +57,7 @@ bool Foam::discreteSurface::sampleType { const surfMesh& surf = dynamicCast(obr); - SurfFieldType* ptr = surf.lookupObjectRefPtr(fieldName); + SurfFieldType* ptr = surf.getObjectPtr(fieldName); if (!ptr) { // Doesn't exist or the wrong type @@ -83,7 +83,7 @@ bool Foam::discreteSurface::sampleType } else { - TmpFieldType* ptr = obr.lookupObjectRefPtr(fieldName); + TmpFieldType* ptr = obr.getObjectPtr(fieldName); if (!ptr) { // Doesn't exist or the wrong type @@ -121,7 +121,7 @@ Foam::discreteSurface::sampleType { typedef GeometricField VolFieldType; - const auto* volFldPtr = mesh().lookupObjectPtr(fieldName); + const auto* volFldPtr = mesh().findObject(fieldName); if (volFldPtr) { diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C index 123b128b92..4031fb2764 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -165,7 +165,7 @@ void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() if (db().foundObject("g")) { uniformDimensionedVectorField g = - db().lookupObject("g"); + db().lookupObject("g"); gravity = g.value(); } diff --git a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C index 7e376b2f14..c5ccced0e0 100644 --- a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C @@ -147,7 +147,7 @@ bool Foam::fileFormats::VTKsurfaceFormat::read for (auto fieldName : { "region", "STLSolidLabeling" }) { const labelIOField* lptr = - reader.cellData().lookupObjectPtr(fieldName); + reader.cellData().findObject(fieldName); if (lptr) { @@ -160,7 +160,7 @@ bool Foam::fileFormats::VTKsurfaceFormat::read } const scalarIOField* sptr = - reader.cellData().lookupObjectPtr(fieldName); + reader.cellData().findObject(fieldName); if (sptr) { diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index daf961381f..6b29193690 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -130,37 +130,31 @@ Foam::volScalarField& Foam::basicThermo::lookupOrConstruct bool& isOwner ) { - const volScalarField* p = - mesh.objectRegistry::lookupObjectPtr(name); + volScalarField* ptr = + mesh.objectRegistry::getObjectPtr(name); - isOwner = !p; + isOwner = !ptr; - if (!p) + if (!ptr) { - volScalarField* fPtr + ptr = new volScalarField ( - new volScalarField + IOobject ( - IOobject - ( - name, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) + name, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh ); // Transfer ownership of this object to the objectRegistry - fPtr->store(fPtr); - return *fPtr; - } - else - { - return const_cast(*p); + ptr->store(ptr); } + + return *ptr; } @@ -341,30 +335,25 @@ const Foam::basicThermo& Foam::basicThermo::lookupThermo const fvPatchScalarField& pf ) { - if (pf.db().foundObject(dictName)) - { - return pf.db().lookupObject(dictName); - } - else - { - HashTable thermos = - pf.db().lookupClass(); + const basicThermo* thermo = pf.db().findObject(dictName); - for + if (thermo) + { + return *thermo; + } + + HashTable thermos = + pf.db().lookupClass(); + + forAllConstIters(thermos, iter) + { + if ( - HashTable::iterator iter = thermos.begin(); - iter != thermos.end(); - ++iter + &(iter()->he().internalField()) + == &(pf.internalField()) ) { - if - ( - &(iter()->he().internalField()) - == &(pf.internalField()) - ) - { - return *iter(); - } + return *iter(); } } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C index c5a782b23c..2a414eec94 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C @@ -118,58 +118,53 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission // look-up table and save the corresponding indices of the look-up table label j = 0; - forAllConstIter(HashTable