diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.C b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.C index d2117d1334b2751eb82473882065fda276b2e038..7e5fa4f286f94ffe72569923a16335d9a1dc099f 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.C @@ -69,7 +69,8 @@ Foam::XiEqModels::Gulder::~Gulder() Foam::tmp<Foam::volScalarField> Foam::XiEqModels::Gulder::XiEq() const { volScalarField up(sqrt((2.0/3.0)*turbulence_.k())); - const volScalarField& epsilon = turbulence_.epsilon(); + const tmp<volScalarField> tepsilon(turbulence_.epsilon()); + const volScalarField& epsilon = tepsilon(); if (subGridSchelkin_) { diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C index d482f3798311471bf74869af7f5b2a1b49e3737a..b80b72a4c7c44b91800cb0819ef3929a327363d6 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C @@ -75,8 +75,10 @@ Foam::XiEqModels::SCOPEXiEq::~SCOPEXiEq() Foam::tmp<Foam::volScalarField> Foam::XiEqModels::SCOPEXiEq::XiEq() const { - const volScalarField& k = turbulence_.k(); - const volScalarField& epsilon = turbulence_.epsilon(); + const tmp<volScalarField> tk(turbulence_.k()); + const volScalarField& k = tk(); + const tmp<volScalarField> tepsilon(turbulence_.epsilon()); + const volScalarField& epsilon = tepsilon(); volScalarField up(sqrt((2.0/3.0)*k)); if (subGridSchelkin_) diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.C b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.C index c586ce291493213cce0a5ed67aa8e190fa68e518..1b44e520691a1fedd5af02c7c5c1780b1299c2cb 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.C @@ -66,7 +66,8 @@ Foam::XiGModels::KTS::~KTS() Foam::tmp<Foam::volScalarField> Foam::XiGModels::KTS::G() const { volScalarField up(sqrt((2.0/3.0)*turbulence_.k())); - const volScalarField& epsilon = turbulence_.epsilon(); + const tmp<volScalarField> tepsilon(turbulence_.epsilon()); + const volScalarField& epsilon = tepsilon(); volScalarField tauEta(sqrt(mag(thermo_.muu()/(thermo_.rhou()*epsilon)))); diff --git a/applications/solvers/compressible/rhoCentralFoam/createFieldRefs.H b/applications/solvers/compressible/rhoCentralFoam/createFieldRefs.H index 5522ccd6aad263919ece3104ea61ee8ef21aee03..f5a13cc9829f397bcbb194e1e25bcceb9f73c546 100644 --- a/applications/solvers/compressible/rhoCentralFoam/createFieldRefs.H +++ b/applications/solvers/compressible/rhoCentralFoam/createFieldRefs.H @@ -1,10 +1,9 @@ volScalarField& p = thermo.p(); const volScalarField& T = thermo.T(); const volScalarField& psi = thermo.psi(); -const volScalarField& mu = thermo.mu(); bool inviscid(true); -if (max(mu.primitiveField()) > 0.0) +if (max(thermo.mu().cref().primitiveField()) > 0.0) { inviscid = false; } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C index f3af8611d318c7a720b441aa27ab8e1d05d19691..b0c52f0f621dc784b0aeb46d316e800da5c7fd61 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C @@ -160,7 +160,8 @@ void VoFPatchTransfer::correct const volScalarField& heVoF = thermo.thermo1().he(); const volScalarField& TVoF = thermo.thermo1().T(); const volScalarField CpVoF(thermo.thermo1().Cp()); - const volScalarField& rhoVoF = thermo.thermo1().rho()(); + const tmp<volScalarField> trhoVoF(thermo.thermo1().rho()); + const volScalarField& rhoVoF = trhoVoF(); const volScalarField& alphaVoF = thermo.alpha1(); forAll(patchIDs_, pidi) diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/pEqn.H index 107fe3c0ccafc5b9c8de8334dad97c47fee5b8bd..a447b1eca851ec4f80d9ea764065325f7fc3387a 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/pEqn.H @@ -28,7 +28,8 @@ forAllConstIters(mixture.phases(), phase) { const rhoThermo& thermo = phase().thermo(); - const volScalarField& rho = thermo.rho()(); + const tmp<volScalarField> trho(thermo.rho()); + const volScalarField& rho = trho(); p_rghEqnComps.set ( diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C index c8b8dc2280abdee23412cc7c80eafac1f3ec53d4..438125651de6fd05fbb07502a375a64ec11347a9 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C @@ -482,8 +482,8 @@ void Foam::searchableSurfaceControl::cellSizeFunctionVertices DynamicList<scalar>& sizes ) const { - const tmp<pointField> tmpPoints = searchableSurface_.points(); - const pointField& points = tmpPoints(); + const tmp<pointField> tpoints(searchableSurface_.points()); + const pointField& points = tpoints(); const scalar nearFeatDistSqrCoeff = 1e-8; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C index 412ef9bb55e5f8cee07928201ca5fefd41269ea1..5d216568d38a5ea946485de351e7118fbabad33e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C @@ -110,7 +110,8 @@ Foam::scalar Foam::nonUniformField::interpolate { const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index); - const pointField& pts = surfaceTriMesh_.points(); + const tmp<pointField> tpoints(surfaceTriMesh_.points()); + const pointField& pts = tpoints(); // const Map<label>& pMap = surfaceTriMesh_.meshPointMap(); triPointRef tri diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index c1cebc026a25ffd6d24f37199f3b00561af2efbf..a90fa8ac514ed843f2c1d25734254094e1b1c0a2 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -982,7 +982,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findOffsetPatchFaces offsetBoundaryCells.write(); } - return std::move(offsetBoundaryCells); + return offsetBoundaryCells; } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index 03f37ea67d1de71b390fc59f6c774042da70ba8c..ccc5b21fe99a74fa41bf1a884c0d88efca74586b 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -1371,7 +1371,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findRemainingProtrusionSet protrudingCells.write(); } - return std::move(protrudingCells); + return protrudingCells; } diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C index 364b00e0e7b33723231c2594754215eb813e119e..69adf9f171d5dea4bc3a9067197e9375a22273d3 100644 --- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C +++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C @@ -221,9 +221,10 @@ void detectSelfIntersections const edgeList& edges = s.edges(); const indexedOctree<treeDataTriSurface>& tree = s.tree(); const labelList& meshPoints = s.meshPoints(); - const pointField& points = s.points(); + const tmp<pointField> tpoints(s.points()); + const pointField& points = tpoints(); - isEdgeIntersecting.setSize(edges.size()); + isEdgeIntersecting.resize_nocopy(edges.size()); isEdgeIntersecting = false; forAll(edges, edgeI) @@ -311,7 +312,8 @@ label detectIntersectionPoints detectSelfIntersections(s, isEdgeIntersecting); const edgeList& edges = s.edges(); - const pointField& points = s.points(); + const tmp<pointField> tpoints(s.points()); + const pointField& points = tpoints(); forAll(edges, edgeI) { @@ -836,9 +838,10 @@ int main(int argc, char *argv[]) // Do some smoothing (Lloyds algorithm) lloydsSmoothing(nSmooth, s, isFeaturePoint, edgeStat, isAffectedPoint); - // Update pointDisplacement - const pointField& pts = s.points(); + const tmp<pointField> tpoints(s.points()); + const pointField& pts = tpoints(); + forAll(meshPoints, i) { label meshPointI = meshPoints[i]; diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index ed1109cdeac300345642ed2cc85d7daaece766bf..e0256fd6dccb6cee599bf673e6e4b1f863b2df4e 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/OpenFOAM/fields/cloud/cloud.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -172,6 +172,21 @@ public: { return obr.lookupObject<IOField<Type>>(fieldName); } + + //- Lookup an IOField within object registry + // Fatal if not found or wrong type + // + // Note: const char signature to avoid spurious + // -Wdangling-reference with gcc-13 + template<class Type> + static const IOField<Type>& lookupIOField + ( + const char* fieldName, + const objectRegistry& obr + ) + { + return obr.lookupObject<IOField<Type>>(word(fieldName)); + } }; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 9341a5ad12924147115c4646fbd19eb738a61588..5813f534cf47a3ca1c8cf3eda939d4da9fcd16fd 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -289,10 +289,12 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) label vertI = 0; - forAll(faceCentres(), facej) + const vectorField::subField ownFaceCentres = faceCentres(); + + forAll(ownFaceCentres, facej) { const point& c0 = neighbFaceCentres_[facej]; - const point& c1 = faceCentres()[facej]; + const point& c1 = ownFaceCentres[facej]; writeOBJ(ccStr, c0, c1, vertI); } diff --git a/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSourceTemplates.C b/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSourceTemplates.C index e1dcf807480da5f7668b864478b8b2cd76cfb187..d4ef78c3cd38f8a8da1e9c5d179e98192fd6ee52 100644 --- a/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSourceTemplates.C +++ b/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSourceTemplates.C @@ -45,7 +45,8 @@ void Foam::fv::atmAmbientTurbSource::atmAmbientTurbSourceEpsilon ( turbulenceModel::propertiesName ); - const volScalarField& epsilon = turbPtr->epsilon(); + const tmp<volScalarField> tepsilon(turbPtr->epsilon()); + const volScalarField& epsilon = tepsilon(); // (Heuristically derived from RS:Eq. 4, rhs-term:5) eqn += @@ -67,7 +68,9 @@ void Foam::fv::atmAmbientTurbSource::atmAmbientTurbSourceOmega ( turbulenceModel::propertiesName ); - const volScalarField& omega = turbPtr->omega(); + const tmp<volScalarField> tomega(turbPtr->omega()); + const volScalarField& omega = tomega(); + const volScalarField::Internal& beta = mesh_.lookupObjectRef<volScalarField::Internal> ( @@ -93,7 +96,8 @@ void Foam::fv::atmAmbientTurbSource::atmAmbientTurbSourceK ( turbulenceModel::propertiesName ); - const volScalarField& k = turbPtr->k(); + const tmp<volScalarField> tk(turbPtr->k()); + const volScalarField& k = tk(); if (isEpsilon_) { diff --git a/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSourceTemplates.C b/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSourceTemplates.C index 468266ee3e50a77d3ac7bd3213e9f450b64d2725..c6a1e7f9b6d8e1faad542c6bbd57462b2a9f4d4d 100644 --- a/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSourceTemplates.C +++ b/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSourceTemplates.C @@ -47,8 +47,10 @@ void Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSourceEpsilon ); // Fetch required fields from the epsilon-based model - const volScalarField& k = turbPtr->k(); - const volScalarField& epsilon = turbPtr->epsilon(); + const tmp<volScalarField> tk(turbPtr->k()); + const volScalarField& k = tk(); + const tmp<volScalarField> tepsilon(turbPtr->epsilon()); + const volScalarField& epsilon = tepsilon(); const volScalarField::Internal& GbyNu = mesh_.lookupObjectRef<volScalarField::Internal> ( @@ -77,8 +79,10 @@ void Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSourceOmega ); // Fetch required fields from the omega-based model - const volScalarField& k = turbPtr->k(); - const volScalarField& omega = turbPtr->omega(); + const tmp<volScalarField> tk(turbPtr->k()); + const volScalarField& k = tk(); + const tmp<volScalarField> tomega(turbPtr->omega()); + const volScalarField& omega = tomega(); const volScalarField::Internal& GbyNu = mesh_.lookupObjectRef<volScalarField::Internal> ( @@ -121,7 +125,8 @@ void Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSourceK turbulenceModel::propertiesName ); - const volScalarField& k = turbPtr->k(); + const tmp<volScalarField> tk(turbPtr->k()); + const volScalarField& k = tk(); eqn += fvm::Sp(alpha()*rho()*B_/k(), k); } diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSourceTemplates.C b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSourceTemplates.C index 0627313a52de8b391d49a405b7d56e1e40c91037..f7125eab8b19d06e8dfad3d8b2c8493a174a2a60 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSourceTemplates.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSourceTemplates.C @@ -45,7 +45,8 @@ void Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSourceEpsilon ( turbulenceModel::propertiesName ); - const volScalarField& epsilon = turbPtr->epsilon(); + const tmp<volScalarField> tepsilon(turbPtr->epsilon()); + const volScalarField& epsilon = tepsilon(); const volVectorField::Internal& U = turbPtr->U()(); eqn -= fvm::Sp(alpha()*rho()*(C1_ - C2_)*calcPlantCanopyTerm(U), epsilon); @@ -66,7 +67,8 @@ void Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSourceOmega ( turbulenceModel::propertiesName ); - const volScalarField& omega = turbPtr->omega(); + const tmp<volScalarField> tomega(turbPtr->omega()); + const volScalarField& omega = tomega(); const volVectorField::Internal& U = turbPtr->U()(); const volScalarField::Internal& gamma = mesh_.lookupObjectRef<volScalarField::Internal> diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H index cdde0dc1870ab00dc4415a117f20964780df66e3..c5b2a4417dbc47dd7409eb8f33c2b55db58e740c 100644 --- a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef singleCellFvMesh_H -#define singleCellFvMesh_H +#ifndef Foam_singleCellFvMesh_H +#define Foam_singleCellFvMesh_H #include "fvPatchFieldMapper.H" #include "fvMesh.H" @@ -58,7 +58,7 @@ class singleCellFvMesh : public fvMesh { - // Private data + // Private Data const labelListIOList patchFaceAgglomeration_; @@ -179,36 +179,39 @@ public: // Member Functions - bool agglomerate() const + bool agglomerate() const noexcept { - return patchFaceAgglomeration_.size() > 0; + return !patchFaceAgglomeration_.empty(); } //- From patchFace on this back to original mesh or agglomeration - const labelListList& patchFaceMap() const + const labelListList& patchFaceMap() const noexcept { return patchFaceMap_; } //- From point on this back to original mesh - const labelList& pointMap() const + const labelList& pointMap() const noexcept { return pointMap_; } //- From face on original mesh to face on this - const labelList& reverseFaceMap() const + const labelList& reverseFaceMap() const noexcept { return reverseFaceMap_; } //- From point on original mesh to point on this (or -1 for removed //- points) - const labelList& reversePointMap() const + const labelList& reversePointMap() const noexcept { return reversePointMap_; } + //- Interpolate for overset (unused) + using fvMesh::interpolate; + //- Map volField. Internal field set to average, patch fields straight //- copies. template<class Type> @@ -217,7 +220,6 @@ public: ( const GeometricField<Type, fvPatchField, volMesh>& ) const; - }; diff --git a/src/fvMotionSolver/motionInterpolation/patchTransformed/patchTransformedInterpolation.C b/src/fvMotionSolver/motionInterpolation/patchTransformed/patchTransformedInterpolation.C index 24dfae4379c75d24688797bf0315d8456b9b047d..ce710d6c2540544755bd0ae594f0001c583e5dc2 100644 --- a/src/fvMotionSolver/motionInterpolation/patchTransformed/patchTransformedInterpolation.C +++ b/src/fvMotionSolver/motionInterpolation/patchTransformed/patchTransformedInterpolation.C @@ -132,9 +132,9 @@ void Foam::patchTransformedInterpolation::interpolate labelList pointDisplacementNSum(nPoints, Zero); vectorField pointDisplacementSum(nPoints, Zero); - forAll(patches_, patchI) + for (const label patchi : patches_) { - const polyPatch& patch(mesh().boundaryMesh()[patches_[patchI]]); + const polyPatch& patch = mesh().boundaryMesh()[patchi]; forAll(patch, pFaceI) { @@ -145,7 +145,7 @@ void Foam::patchTransformedInterpolation::interpolate const labelList cPoints(c.labels(mesh().faces())); // Consider movement around the face centre - const point& xOrigin(patch.faceCentres()[pFaceI]); + const point xOrigin(patch.faceCentres()[pFaceI]); // Mean translation const vector uMean(f.average(points, pointDisplacement)); diff --git a/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSourceTemplates.C b/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSourceTemplates.C index 10cdc62b8c4404259f0f9f9ae9840b4b63750a26..db5ef7b800f25268ad9673c3dbf0902d0b3bf720 100644 --- a/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSourceTemplates.C +++ b/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSourceTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd + Copyright (C) 2020,2023 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,7 +46,8 @@ void Foam::fv::buoyancyTurbSource::buoyancyTurbSourceK ( turbulenceModel::propertiesName ); - const volScalarField& nut = turbPtr->nut(); + const tmp<volScalarField> tnut(turbPtr->nut()); + const volScalarField& nut = tnut(); const dictionary& turbDict = turbPtr->coeffDict(); const scalar Prt diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C index 12fd8ab03624fc3fa610a6517489c077b2a5c9a9..aab3ce1bd8c5cb812a98eb0be9ea83f96349f867 100644 --- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C +++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C @@ -231,7 +231,7 @@ void Foam::FreeStream<CloudType>::inflow() label celli = mesh.faceOwner()[globalFaceIndex]; - const vector& fC = patch.faceCentres()[pFI]; + const vector fC = patch.faceCentres()[pFI]; scalar fA = mag(patch.faceAreas()[pFI]); diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 8dad26141a9a3a656b43503dabd0fdb79b3c977f..8066ce69518da74f9f8e4b466daa4634eabdfd61 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -3805,26 +3805,27 @@ const Foam::dictionary& Foam::meshRefinement::subDict enum keyType::option matchOpt ) { - const auto finder(dict.csearch(keyword, matchOpt)); + const dictionary* dictptr = dict.findDict(keyword, matchOpt); - if (!finder.good()) + if (!dictptr) { - auto& err = FatalIOErrorInFunction(dict); - - err << "Entry '" << keyword << "' not found in dictionary " + FatalIOErrorInFunction(dict) + << "Entry '" << keyword + << "' not found (or not a dictionary) in dictionary " << dict.relativeName() << nl; if (noExit) { + // Dummy return return dictionary::null; } else { - err << exit(FatalIOError); + FatalIOError << exit(FatalIOError); } } - return finder.dict(); + return *dictptr; } @@ -3840,19 +3841,18 @@ Foam::ITstream& Foam::meshRefinement::lookup if (!eptr) { - auto& err = FatalIOErrorInFunction(dict); - - err << "Entry '" << keyword << "' not found in dictionary " + FatalIOErrorInFunction(dict) + << "Entry '" << keyword << "' not found in dictionary " << dict.relativeName() << nl; if (noExit) { - // Fake entry - return dict.first()->stream(); + // Dummy return + return ITstream::empty_stream(); } else { - err << exit(FatalIOError); + FatalIOError << exit(FatalIOError); } } diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/adjointEikonalSolver/adjointEikonalSolver.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/adjointEikonalSolver/adjointEikonalSolver.C index 64735b50804cf9cd9db3f988519bd2f64acc31d6..37e6b9d942bafe47435dd2b2ea00bbf07f746baa 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/adjointEikonalSolver/adjointEikonalSolver.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/adjointEikonalSolver/adjointEikonalSolver.C @@ -83,7 +83,8 @@ void adjointEikonalSolver::read() tmp<surfaceScalarField> adjointEikonalSolver::computeYPhi() { // Primal distance field - const volScalarField& d = adjointSolver_.yWall(); + const tmp<volScalarField> td(adjointSolver_.yWall()); + const volScalarField& d = td(); volVectorField ny ( @@ -198,7 +199,8 @@ void adjointEikonalSolver::solve() read(); // Primal distance field - const volScalarField& d = adjointSolver_.yWall(); + const tmp<volScalarField> td(adjointSolver_.yWall()); + const volScalarField& d = td(); // Convecting flux tmp<surfaceScalarField> tyPhi = computeYPhi(); @@ -275,7 +277,9 @@ boundaryVectorField& adjointEikonalSolver::distanceSensitivities() boundaryVectorField& distanceSens = distanceSensPtr_(); - const volScalarField& d = adjointSolver_.yWall(); + const tmp<volScalarField> td(adjointSolver_.yWall()); + const volScalarField& d = td(); + for (const label patchi : sensitivityPatchIDs_) { vectorField nf(mesh_.boundary()[patchi].nf()); @@ -294,7 +298,8 @@ tmp<volTensorField> adjointEikonalSolver::getFISensitivityTerm() const { Info<< "Calculating distance sensitivities " << endl; - const volScalarField& d = adjointSolver_.yWall(); + const tmp<volScalarField> td(adjointSolver_.yWall()); + const volScalarField& d = td(); const volVectorField gradD(fvc::grad(d)); auto gradDDa @@ -354,7 +359,8 @@ tmp<scalarField> adjointEikonalSolver::topologySensitivities const word& designVarsName ) const { - const volScalarField& d = adjointSolver_.yWall(); + const tmp<volScalarField> td(adjointSolver_.yWall()); + const volScalarField& d = td(); auto tres(tmp<scalarField>::New(d.primitiveField().size(), Zero)); scalarField dSens(d.primitiveField()*da_.primitiveField()); @@ -377,7 +383,9 @@ const volScalarField& adjointEikonalSolver::da() tmp<volVectorField> adjointEikonalSolver::gradEikonal() { - const volScalarField& d = adjointSolver_.yWall(); + const tmp<volScalarField> td(adjointSolver_.yWall()); + const volScalarField& d = td(); + volVectorField gradD(fvc::grad(d)); return tmp<volVectorField>::New("gradEikonal", 2*gradD & fvc::grad(gradD)); } diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C index 9e17b38e59263943a96edf29f24b38948ee4398a..c583938e48408661ded4a98d6a39a80a9a598252 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C @@ -95,7 +95,8 @@ tmp<volScalarField> SpalartAllmaras::nutJacobianVar1 ); auto& nutJacobian = tnutJacobian.ref(); - const volScalarField& nu = laminarTransport.nu(); + const tmp<volScalarField> tnu(laminarTransport.nu()); + const volScalarField& nu = tnu(); const volScalarField& nuTilda = TMVar1(); volScalarField chi(nuTilda/nu); diff --git a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C index 7f1270c5877d8954337021c3b5ec084388688c70..0da2401b99054c3db4841a4e65f1585cdf775633 100644 --- a/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C +++ b/src/phaseSystemModels/multiphaseEuler/multiphaseSystem/phaseModel/phaseModel.C @@ -241,7 +241,8 @@ void Foam::phaseModel::correctInflowOutflow(surfaceScalarField& alphaPhi) const { surfaceScalarField::Boundary& alphaPhiBf = alphaPhi.boundaryFieldRef(); const volScalarField::Boundary& alphaBf = boundaryField(); - const surfaceScalarField::Boundary& phiBf = phi().boundaryField(); + const tmp<surfaceScalarField> tphi(phi()); + const auto& phiBf = tphi().boundaryField(); forAll(alphaPhiBf, patchi) { diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C index 7623bd2d7029e49ae7ee475a15baa2f7a4fce043..fb7c537721100643df81a6a10378ac9bdb616a2c 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C @@ -355,7 +355,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransfer() fvVectorMatrix& eqn = *eqns[phase.name()]; const volVectorField& U = eqn.psi(); - const surfaceScalarField& phi = phase.phi(); + const tmp<surfaceScalarField> tphi(phase.phi()); + const surfaceScalarField& phi = tphi(); eqn -= Vm @@ -408,7 +409,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransferf() if (!phase.stationary()) { - const volVectorField& U = phase.U(); + const tmp<volVectorField> tU(phase.U()); + const volVectorField& U = tU(); UgradUs.set ( diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/segregated/segregated.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/segregated/segregated.C index e3b8208670ac5d7336a83b9e148a76086c6f1e1e..467f1817aedd8a6ae7ead76a4cb2139490e3fda0 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/segregated/segregated.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/segregated/segregated.C @@ -85,8 +85,11 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::segregated::K() const const volScalarField& alpha1(pair_.phase1()); const volScalarField& alpha2(pair_.phase2()); - const volScalarField& rho1(pair_.phase1().rho()); - const volScalarField& rho2(pair_.phase2().rho()); + const tmp<volScalarField> trho1(pair_.phase1().rho()); + const tmp<volScalarField> trho2(pair_.phase2().rho()); + + const volScalarField& rho1 = trho1(); + const volScalarField& rho2 = trho2(); tmp<volScalarField> tnu1(pair_.phase1().nu()); tmp<volScalarField> tnu2(pair_.phase2().nu()); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/AnisothermalPhaseModel/AnisothermalPhaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/AnisothermalPhaseModel/AnisothermalPhaseModel.C index 54b2f2fbcd7076e337f1bbc6b750cc833ce99321..56e2b855dba73f7ed1aeb263b7f8b9bb7759f921 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/AnisothermalPhaseModel/AnisothermalPhaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/AnisothermalPhaseModel/AnisothermalPhaseModel.C @@ -93,7 +93,8 @@ Foam::tmp<Foam::fvScalarMatrix> Foam::AnisothermalPhaseModel<BasePhaseModel>::heEqn() { const volScalarField& alpha = *this; - const volScalarField& rho = this->rho(); + const tmp<volScalarField> trho(this->rho()); + const volScalarField& rho(trho()); const tmp<volVectorField> tU(this->U()); const volVectorField& U(tU()); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C index 4e75adec974092615c6d1146393e096701262d6b..c8d030117d053d18b66cc5c6acb9d7ca63913e3f 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MovingPhaseModel/MovingPhaseModel.C @@ -283,7 +283,8 @@ Foam::tmp<Foam::fvVectorMatrix> Foam::MovingPhaseModel<BasePhaseModel>::UEqn() { const volScalarField& alpha = *this; - const volScalarField& rho = this->thermo().rho(); + const tmp<volScalarField> trho = this->thermo().rho(); + const volScalarField& rho = trho(); return ( @@ -303,14 +304,13 @@ Foam::MovingPhaseModel<BasePhaseModel>::UfEqn() // As the "normal" U-eqn but without the ddt terms const volScalarField& alpha = *this; - const volScalarField& rho = this->thermo().rho(); return ( fvm::div(alphaRhoPhi_, U_) - fvm::Sp(fvc::div(alphaRhoPhi_), U_) + fvm::SuSp(- this->continuityErrorSources(), U_) - + this->fluid().MRF().DDt(alpha*rho, U_) + + this->fluid().MRF().DDt(alpha*this->thermo().rho(), U_) + turbulence_->divDevRhoReff(U_) ); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C index 9482f0244cbf1bb86173005d4cf0e0f8c1c4ee6e..40c5464098bd86d0a10948ac1d120d693f90edc6 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C @@ -152,7 +152,8 @@ Foam::MultiComponentPhaseModel<BasePhaseModel>::YiEqn(volScalarField& Yi) { const volScalarField& alpha = *this; const surfaceScalarField alphaRhoPhi(this->alphaRhoPhi()); - const volScalarField& rho = this->thermo().rho(); + const tmp<volScalarField> trho(this->thermo().rho()); + const volScalarField& rho = trho(); return ( diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/phaseModel/phaseModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/phaseModel/phaseModel.C index 9cb69181e48962d1eed6e8dab179ffb9b15e6a50..d697c19a3890e47ab677ddc8446124917b12b839 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/phaseModel/phaseModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseModel/phaseModel/phaseModel.C @@ -207,7 +207,8 @@ void Foam::phaseModel::correctInflowOutflow(surfaceScalarField& alphaPhi) const { surfaceScalarField::Boundary& alphaPhiBf = alphaPhi.boundaryFieldRef(); const volScalarField::Boundary& alphaBf = boundaryField(); - const surfaceScalarField::Boundary& phiBf = phi()().boundaryField(); + const tmp<surfaceScalarField> tphi(phi()); + const auto& phiBf = tphi().boundaryField(); forAll(alphaPhiBf, patchi) { diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C index a38aaa2824bb864e5826ae35a0e4afabd7e62e33..445162fcb6282037393e78989e505868f741387d 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/nucleationModels/wallBoiling/wallBoiling.C @@ -154,7 +154,8 @@ Foam::diameterModels::nucleationModels::wallBoiling::addToNucleationRate { const sizeGroup& fi = popBal_.sizeGroups()[i]; const phaseModel& phase = fi.phase(); - const volScalarField& rho = phase.rho(); + const tmp<volScalarField> trho(phase.rho()); + const volScalarField& rho = trho(); const tmp<volScalarField> talphat(turbulence_.alphat()); const volScalarField::Boundary& alphatBf = talphat().boundaryField(); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C index db4ccbfac4d3b9053de7f2e24421b72fe1c5ad2b..e3e046cf44d4747c82393cfda3d4ae947a60c0ae 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C @@ -1273,7 +1273,8 @@ void Foam::diameterModels::populationBalanceModel::solve() const phaseModel& phase = fi.phase(); const volScalarField& alpha = phase; const dimensionedScalar& residualAlpha = phase.residualAlpha(); - const volScalarField& rho = phase.thermo().rho(); + const tmp<volScalarField> trho(phase.thermo().rho()); + const volScalarField& rho = trho(); fvScalarMatrix sizeGroupEqn ( diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C index 4bde1a14c053a7461c5267183fb96eaa7b1b41a7..cf5b7670bd2479aa6febef1f2ebfb8b84f4d2fb1 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C @@ -156,7 +156,8 @@ JohnsonJacksonSchaeffer::nu } const fvPatchList& patches = phase.mesh().boundary(); - const volVectorField& U = phase.U(); + const tmp<volVectorField> tU(phase.U()); + const volVectorField& U = tU(); volScalarField::Boundary& nufBf = nuf.boundaryFieldRef(); diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C index b0aac1aa02cf4bd8030543bd19b39d55a0d4abab..d0c5de3052afbab0a99c4e15ee2e5eed80a6314c 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C @@ -154,7 +154,8 @@ Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu } const fvPatchList& patches = phase.mesh().boundary(); - const volVectorField& U = phase.U(); + const tmp<volVectorField> tU(phase.U()); + const volVectorField& U = tU(); volScalarField::Boundary& nufBf = nuf.boundaryFieldRef(); diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 9ac98b1c21c32abd203f654eaab225d26589a5ae..84a80a1a1cbe89d367d3487404d53177a01863b8 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -266,7 +266,8 @@ Foam::RASModels::kineticTheoryModel::R() const Foam::tmp<Foam::volScalarField> Foam::RASModels::kineticTheoryModel::pPrime() const { - const volScalarField& rho = phase_.rho(); + const tmp<volScalarField> trho(phase_.rho()); + const volScalarField& rho = trho(); tmp<volScalarField> tpPrime ( @@ -365,11 +366,13 @@ void Foam::RASModels::kineticTheoryModel::correct() { // Local references volScalarField alpha(max(alpha_, scalar(0))); - const volScalarField& rho = phase_.rho(); + const tmp<volScalarField> trho(phase_.rho()); + const volScalarField& rho = trho(); const surfaceScalarField& alphaRhoPhi = alphaRhoPhi_; const volVectorField& U = U_; - const volVectorField& Uc_ = + const tmp<volVectorField> tUc = refCast<const twoPhaseSystem>(phase_.fluid()).otherPhase(phase_).U(); + const volVectorField& Uc = tUc(); const scalar sqrtPi = sqrt(constant::mathematical::pi); dimensionedScalar ThetaSmall("ThetaSmall", Theta_.dimensions(), 1e-6); @@ -421,7 +424,7 @@ void Foam::RASModels::kineticTheoryModel::correct() volScalarField J2 ( "J2", - 0.25*sqr(beta)*da*magSqr(U - Uc_) + 0.25*sqr(beta)*da*magSqr(U - Uc) /( max(alpha, residualAlpha_)*rho *sqrtPi*(ThetaSqrt + ThetaSmallSqrt) diff --git a/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C b/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C index 51f8dd9898ccc067a4d5e06f05dd6444ad727e12..d554ea70fe996b03e34519a1c88f666ea19e1427 100644 --- a/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C +++ b/src/phaseSystemModels/reactingEuler/twoPhaseSystem/twoPhaseSystem.C @@ -136,8 +136,10 @@ void Foam::twoPhaseSystem::solve() word alphaScheme("div(phi," + alpha1.name() + ')'); word alpharScheme("div(phir," + alpha1.name() + ')'); - const surfaceScalarField& phi1 = phase1_.phi(); - const surfaceScalarField& phi2 = phase2_.phi(); + const tmp<surfaceScalarField> tphi1(phase1_.phi()); + const surfaceScalarField& phi1 = tphi1(); + const tmp<surfaceScalarField> tphi2(phase2_.phi()); + const surfaceScalarField& phi2 = tphi2(); // Construct the dilatation rate source term tmp<volScalarField::Internal> tdgdt; diff --git a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C index c6216517531a3f3f73c69d3a69cb8f6b8bad1a02..ccb2ff83fc1b6a3e2d074d604887b953a255a43f 100644 --- a/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C +++ b/src/phaseSystemModels/twoPhaseEuler/phaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C @@ -154,7 +154,8 @@ Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu } const fvPatchList& patches = phase.mesh().boundary(); - const volVectorField& U = phase.U(); + const tmp<volVectorField> tU(phase.U()); + const volVectorField& U = tU(); volScalarField::Boundary& nufBf = nuf.boundaryFieldRef(); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C index 36d077fae2e857a80518ea4fdfda401fdacead25..f8129e55eda896a94c6a70de36700213df5be95f 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/diameterModels/IATE/IATEsources/turbulentBreakUp/turbulentBreakUp.C @@ -80,11 +80,12 @@ Foam::diameterModels::IATEsources::turbulentBreakUp::R() const volScalarField R = tR(); - scalar Cti = Cti_.value(); - scalar WeCr = WeCr_.value(); + const scalar Cti = Cti_.value(); + const scalar WeCr = WeCr_.value(); volScalarField Ut(this->Ut()); volScalarField We(this->We()); - const volScalarField& d(iate_.d()()); + const tmp<volScalarField> td(iate_.d()); + const volScalarField& d = td(); forAll(R, celli) { diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C index 47642607c373dd935a6f838ee1132267fb90ad49..f7a080808d36bcd368f7e58af04e1f39d9b8a4af 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C @@ -192,7 +192,7 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() } const scalarField UAvePyr(-phiPyr/patch().magSf()); - const vectorField& nf = patch().nf(); + tmp<vectorField> nf(patch().nf()); // Evaluate velocity diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C index b1fb235f0247eca0a62190653accce6c6d742f47..8c02bb90bcf2c53812adc933fcd32db858ed1486 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.C @@ -61,8 +61,8 @@ multiBandZoneAbsorptionEmission emiCoeffs_(maxBands_), nBands_(0), zoneAbsorptivity_(), - zoneEmisivity_(), - zoneCells_() + zoneEmissivity_(), + zoneIds_() { coeffsDict_.readEntry("absorptivity", absCoeffs_); coeffsDict_.readEntry("emissivity", emiCoeffs_); @@ -71,11 +71,11 @@ multiBandZoneAbsorptionEmission const dictionary& zoneDict = coeffsDict_.subDict("zones"); zoneDict.readEntry("absorptivity", zoneAbsorptivity_); - zoneDict.readEntry("emissivity", zoneEmisivity_); + zoneDict.readEntry("emissivity", zoneEmissivity_); - zoneCells_.setSize(zoneAbsorptivity_.size(), -1); + zoneIds_.resize(zoneAbsorptivity_.size(), -1); - label i = 0; + label numZones = 0; forAllConstIters(zoneAbsorptivity_, iter) { label zoneID = mesh.cellZones().findZoneID(iter.key()); @@ -86,9 +86,10 @@ multiBandZoneAbsorptionEmission << "Valid cellZones are " << mesh.cellZones().names() << exit(FatalError); } - zoneCells_[i++] = zoneID; + zoneIds_[numZones] = zoneID; + ++numZones; } - + // zoneIds_.resize(numZones); } @@ -124,24 +125,19 @@ Foam::radiation::multiBandZoneAbsorptionEmission::aCont ) ); - volScalarField& a = ta.ref(); + scalarField& a = ta.ref().primitiveFieldRef(); - forAll(zoneCells_, zonei) + for (const label zonei : zoneIds_) { - const cellZone& cZone = mesh().cellZones()[zoneCells_[zonei]]; - - tmp<volScalarField> tzoneAbs(a*0.0); - volScalarField& zoneAbs = tzoneAbs.ref(); - - const scalarList& abs = zoneAbsorptivity_.find(cZone.name())(); + const cellZone& zn = mesh().cellZones()[zonei]; + const auto iter = zoneAbsorptivity_.cfind(zn.name()); - forAll(cZone, i) + if (iter.good()) // Check is redundant (cannot fail) { - label cellId = cZone[i]; - zoneAbs[cellId] = abs[bandI] - absCoeffs_[bandI]; - } + const scalarList& absorb = iter.val(); - a += zoneAbs; + UIndirectList<scalar>(a, zn) = absorb[bandI]; + } } return ta; @@ -171,26 +167,21 @@ Foam::radiation::multiBandZoneAbsorptionEmission::eCont ) ); - volScalarField& e = te.ref(); + scalarField& e = te.ref().primitiveFieldRef(); - forAll(zoneCells_, zonei) + for (const label zonei : zoneIds_) { - const cellZone& cZone = mesh().cellZones()[zoneCells_[zonei]]; + const cellZone& zn = mesh().cellZones()[zonei]; + const auto iter = zoneEmissivity_.cfind(zn.name()); - tmp<volScalarField> tzoneEm(e*0.0); - volScalarField& zoneEm = tzoneEm.ref(); - - const scalarList& emi = zoneEmisivity_.find(cZone.name())(); - - forAll(cZone, i) + if (iter.good()) // Check is redundant (cannot fail) { - label cellId = cZone[i]; - zoneEm[cellId] = emi[bandI] - emiCoeffs_[bandI]; + const scalarList& emit = iter.val(); + + UIndirectList<scalar>(e, zn) = emit[bandI]; } - e += zoneEm; } - return te; } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.H index 35eb5e7a1bd16ab8f551ccb5d0a6756f259d960e..be139399444ea2fbd688776576e575a6c0a5432d 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/multiBandZoneAbsorptionEmission/multiBandZoneAbsorptionEmission.H @@ -86,11 +86,11 @@ private: //- Cell zones absorptivity HashTable<scalarList> zoneAbsorptivity_; - //- Cell zones emisivity - HashTable<scalarList> zoneEmisivity_; + //- Cell zones emissivity + HashTable<scalarList> zoneEmissivity_; - //- Cells for each zone - labelList zoneCells_; + //- The cellZones selected + labelList zoneIds_; diff --git a/src/waveModels/waveModel/waveModel.C b/src/waveModels/waveModel/waveModel.C index 21c9cf35927b3a568d7910f908301bc172a34b69..94ac68982380f83d9af3217e460fd835b59f1865 100644 --- a/src/waveModels/waveModel/waveModel.C +++ b/src/waveModels/waveModel/waveModel.C @@ -90,8 +90,7 @@ void Foam::waveModel::initialiseGeometry() } // Local face centres - const vectorField& Cf = patch_.faceCentres(); - const vectorField CfLocal(Rgl_ & Cf); + const vectorField CfLocal(Rgl_ & patch_.faceCentres()); z_ = CfLocal.component(2); // Local face extents in z-direction