From 0ba43df9c595321e7659b56558749f501b1a2e9d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 31 May 2021 09:02:57 +0200 Subject: [PATCH] STYLE: remove erroneous reference in dynamicCast use --- .../test/dictionaryTokens/dictionaryTokens.C | 73 +++++++++---------- .../exprEntry/expressionEntryDimensioned.C | 6 +- .../output/vtk/topoSet/foamVtkWriteTopoSet.C | 44 ++++------- .../surface/cutting/cuttingPlaneCuts.C | 10 +-- .../surface/isoSurface/isoSurfaceCell.C | 2 +- .../surface/isoSurface/isoSurfaceTopo.C | 2 +- .../TDACChemistryModel/TDACChemistryModel.C | 2 +- 7 files changed, 63 insertions(+), 76 deletions(-) diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.C index f61f6ea34c..8c87f829a7 100644 --- a/applications/test/dictionaryTokens/dictionaryTokens.C +++ b/applications/test/dictionaryTokens/dictionaryTokens.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,46 +60,45 @@ bool Foam::dictionaryTokens::setIterator() const { const entry& base = *entryIter_; - if (isA(base)) { - primIter_.reset - ( - new dictionaryTokens::primitive_iterator + const auto* eptr = isA(base); + if (eptr) + { + primIter_.reset ( - dynamicCast(base) - ) - ); - - return true; - } - else if (isA(base)) - { - // Must check for isA before checking - // for isA ! - - dictIter_.reset - ( - new dictionaryTokens::dictionary_iterator - ( - dynamicCast(base) - ) - ); - - return true; - } - else if (isA(base)) - { - dictIter_.reset - ( - new dictionaryTokens::dictionary_iterator - ( - dynamicCast(base) - ) - ); - - return true; + new dictionaryTokens::primitive_iterator(*eptr) + ); + return true; + } } + // NB: Must check for isA before checking + // for isA ! + + { + const auto* eptr = isA(base); + + if (eptr) + { + dictIter_.reset + ( + new dictionaryTokens::dictionary_iterator(*eptr) + ); + return true; + } + } + + { + const auto* eptr = isA(base); + if (eptr) + { + dictIter_.reset + ( + new dictionaryTokens::dictionary_iterator(*eptr) + ); + return true; + } + } } return false; diff --git a/src/OpenFOAM/expressions/exprEntry/expressionEntryDimensioned.C b/src/OpenFOAM/expressions/exprEntry/expressionEntryDimensioned.C index 4ea37686e9..7242e5363b 100644 --- a/src/OpenFOAM/expressions/exprEntry/expressionEntryDimensioned.C +++ b/src/OpenFOAM/expressions/exprEntry/expressionEntryDimensioned.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Original code Copyright (C) 2014-2018 Bernhard Gschaider - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -92,14 +92,14 @@ addNamedToRunTimeSelectionTable #define defineExpressionEntryType(DimType) \ Foam::string Foam::exprTools::DimType##Entry::evaluate(const entry& e) \ { \ - DimType dt(dynamicCast(e)); \ + DimType dt(dynamicCast(e)); \ return toExprStr(dt.value()); \ } Foam::string Foam::exprTools::dimensionedScalarEntry::evaluate(const entry& e) { - dimensionedScalar dt(dynamicCast(e)); + dimensionedScalar dt(dynamicCast(e)); return std::to_string(dt.value()); } diff --git a/src/meshTools/output/vtk/topoSet/foamVtkWriteTopoSet.C b/src/meshTools/output/vtk/topoSet/foamVtkWriteTopoSet.C index 1ab0e9b2d2..048f54387d 100644 --- a/src/meshTools/output/vtk/topoSet/foamVtkWriteTopoSet.C +++ b/src/meshTools/output/vtk/topoSet/foamVtkWriteTopoSet.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,38 +43,26 @@ bool Foam::vtk::writeTopoSet bool parallel ) { - if (isA(set)) { - return vtk::writePointSet - ( - mesh, - dynamicCast(set), - opts, - file, - parallel - ); + const auto* ptr = isA(set); + if (ptr) + { + return vtk::writePointSet(mesh, *ptr, opts, file, parallel); + } } - else if (isA(set)) { - return vtk::writeFaceSet - ( - mesh, - dynamicCast(set), - opts, - file, - parallel - ); + const auto* ptr = isA(set); + if (ptr) + { + return vtk::writeFaceSet(mesh, *ptr, opts, file, parallel); + } } - else if (isA(set)) { - return vtk::writeCellSetFaces - ( - mesh, - dynamicCast(set), - opts, - file, - parallel - ); + const auto* ptr = isA(set); + if (ptr) + { + return vtk::writeCellSetFaces(mesh, *ptr, opts, file, parallel); + } } WarningInFunction diff --git a/src/sampling/surface/cutting/cuttingPlaneCuts.C b/src/sampling/surface/cutting/cuttingPlaneCuts.C index 84c58c24b7..b5e5997167 100644 --- a/src/sampling/surface/cutting/cuttingPlaneCuts.C +++ b/src/sampling/surface/cutting/cuttingPlaneCuts.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -162,20 +162,20 @@ Foam::label Foam::cuttingPlane::calcCellCuts if (debug && isA(mesh)) { - const fvMesh& fvm = dynamicCast(mesh); + const auto& fvmesh = dynamicCast(mesh); volScalarField cCuts ( IOobject ( "cuttingPlane.cellCuts", - fvm.time().timeName(), - fvm.time(), + fvmesh.time().timeName(), + fvmesh.time(), IOobject::NO_READ, IOobject::NO_WRITE, false ), - fvm, + fvmesh, dimensionedScalar(dimless, Zero) ); diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C index bc637cc694..18ab9e1654 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C @@ -1196,7 +1196,7 @@ Foam::isoSurfaceCell::isoSurfaceCell if (debug && isA(mesh)) { - const fvMesh& fvmesh = dynamicCast(mesh); + const auto& fvmesh = dynamicCast(mesh); volScalarField debugField ( diff --git a/src/sampling/surface/isoSurface/isoSurfaceTopo.C b/src/sampling/surface/isoSurface/isoSurfaceTopo.C index e9752abb10..515ae48f99 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceTopo.C +++ b/src/sampling/surface/isoSurface/isoSurfaceTopo.C @@ -1021,7 +1021,7 @@ Foam::isoSurfaceTopo::isoSurfaceTopo if (debug && isA(mesh)) { - const fvMesh& fvmesh = dynamicCast(mesh); + const auto& fvmesh = dynamicCast(mesh); volScalarField debugField ( diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C index 5add9d0bb1..0eb8919d9b 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C @@ -77,7 +77,7 @@ Foam::TDACChemistryModel::TDACChemistryModel autoPtr>> specCompPtr ( - dynamicCast&>(this->thermo()) + dynamicCast>(this->thermo()) .specieComposition() );