diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index a6b843f388..64e15ea5d4 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -716,7 +716,7 @@ void writeProcAddressing } autoPtr defaultHandler; - if (writeHandler.valid()) + if (writeHandler) { defaultHandler = fileHandler(std::move(writeHandler)); } @@ -726,7 +726,7 @@ void writeProcAddressing const bool pointOk = pointMap.write(); const bool patchOk = patchMap.write(); - if (defaultHandler.valid()) + if (defaultHandler) { writeHandler = fileHandler(std::move(defaultHandler)); } @@ -1412,14 +1412,14 @@ autoPtr redistributeAndWrite else { autoPtr defaultHandler; - if (writeHandler.valid()) + if (writeHandler) { defaultHandler = fileHandler(std::move(writeHandler)); } mesh.write(); - if (defaultHandler.valid()) + if (defaultHandler) { writeHandler = fileHandler(std::move(defaultHandler)); } @@ -2543,7 +2543,7 @@ int main(int argc, char *argv[]) // File handler to be used for writing const fileOperation& fh ( - writeHandler.valid() + writeHandler ? writeHandler() : fileHandler() ); @@ -2989,7 +2989,7 @@ int main(int argc, char *argv[]) ); fvMesh& mesh = meshPtr(); - if (writeHandler.valid() && Pstream::master()) + if (writeHandler && Pstream::master()) { // Remove any left-over empty processor directories created // by loadOrCreateMesh to get around e.g. collated start-up @@ -3290,7 +3290,7 @@ int main(int argc, char *argv[]) ); fvMesh& mesh = meshPtr(); - if (writeHandler.valid()) + if (writeHandler) { // Remove any left-over empty processor directories created // by loadOrCreateMesh to get around the collated start-up diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/readFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/readFields.H index 8f378f9cb9..3804b0a3a0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/readFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,7 +90,7 @@ makeZeroGradientField >& tdf ) { - if (tdf.valid()) + if (tdf) { auto& df = tdf.ref(); @@ -125,7 +125,7 @@ makeZeroGradientField const tmp>& tdf ) { - if (tdf.valid()) + if (tdf) { auto& df = tdf.ref(); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeAreaFields.H index 7f0609fd2f..2e5e1d4fc2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeAreaFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -37,7 +37,7 @@ bool writeAreaField const tmp>& tfield ) { - if (!tfield.valid()) + if (!tfield) { return false; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeDimFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeDimFields.H index 3573531f42..35b47ef06a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeDimFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeDimFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -36,7 +36,7 @@ bool writeDimField const tmp>& tdf ) { - if (!tdf.valid()) + if (!tdf) { return false; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writePointFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writePointFields.H index 12256306c3..714598e81d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writePointFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writePointFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -38,7 +38,7 @@ bool writePointField const tmp>& tfield ) { - if (!tfield.valid()) + if (!tfield) { return false; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeVolFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeVolFields.H index f6b6358a2a..fbc79a0749 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeVolFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/writeVolFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -38,7 +38,7 @@ bool writeVolField const bool nearCellValue = false ) { - if (!tfield.valid()) + if (!tfield) { return false; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C index c5dc09ba24..40ca84d709 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -118,7 +118,7 @@ Foam::PtrList Foam::readFields auto tfield = getField(mesh, objects, fieldName, syncPar); - if (tfield.valid()) + if (tfield) { fields.set(nFields++, tfield.ptr()); } @@ -157,7 +157,7 @@ Foam::PtrList Foam::readFields auto tfield = getField(proxy, objects, fieldName, syncPar); - if (tfield.valid()) + if (tfield) { fields.set(nFields++, tfield.ptr()); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H index ca265a25c9..958c56954d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,7 +56,7 @@ bool writeAreaField const tmp& tfield ) { - if (tfield.valid()) + if (tfield) { writer.write(tfield()); tfield.clear(); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H index 345c467eeb..45e8d79476 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,7 +53,7 @@ bool writeDimField const tmp& tfield ) { - if (!tfield.valid()) + if (!tfield) { return false; } @@ -78,7 +78,7 @@ bool writeDimField const tmp& tfield ) { - if (!tfield.valid()) + if (!tfield) { return false; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H index 6c845d7c0d..cb1e311f4f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,7 +57,7 @@ bool writePointField const fvMeshSubsetProxy& proxy ) { - if (!tfield.valid()) + if (!tfield) { return false; } @@ -73,7 +73,7 @@ bool writePointField tproxied = tfield; } - if (!tproxied.valid()) + if (!tproxied) { // Or Error? return false; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H index 66ce5331bb..6df3d101a3 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +55,7 @@ bool writeVolField const tmp& tfield ) { - if (!tfield.valid()) + if (!tfield) { return false; } @@ -91,7 +91,7 @@ bool writeVolField const tmp& tfield ) { - if (!tfield.valid()) + if (!tfield) { return false; } diff --git a/src/OpenFOAM/expressions/fields/fieldExprDriverTemplates.C b/src/OpenFOAM/expressions/fields/fieldExprDriverTemplates.C index 073171f0c9..6cb9b3454f 100644 --- a/src/OpenFOAM/expressions/fields/fieldExprDriverTemplates.C +++ b/src/OpenFOAM/expressions/fields/fieldExprDriverTemplates.C @@ -45,7 +45,7 @@ Foam::expressions::fieldExpr::parseDriver::getField } - if (tvar.valid()) + if (tvar) { const auto& var = tvar.cref(); const Field& vals = var.cref(); diff --git a/src/OpenFOAM/memory/PrecisionAdaptor/PrecisionAdaptor.H b/src/OpenFOAM/memory/PrecisionAdaptor/PrecisionAdaptor.H index e225a30981..82792f5971 100644 --- a/src/OpenFOAM/memory/PrecisionAdaptor/PrecisionAdaptor.H +++ b/src/OpenFOAM/memory/PrecisionAdaptor/PrecisionAdaptor.H @@ -36,8 +36,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef PrecisionAdaptor_H -#define PrecisionAdaptor_H +#ifndef Foam_PrecisionAdaptor_H +#define Foam_PrecisionAdaptor_H #include // For std::copy #include // For std::is_same diff --git a/src/OpenFOAM/memory/autoPtr/autoPtr.H b/src/OpenFOAM/memory/autoPtr/autoPtr.H index 9b78fe9279..a7d7ff2149 100644 --- a/src/OpenFOAM/memory/autoPtr/autoPtr.H +++ b/src/OpenFOAM/memory/autoPtr/autoPtr.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,13 +43,13 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef autoPtr_H -#define autoPtr_H +#ifndef Foam_autoPtr_H +#define Foam_autoPtr_H // Transitional features/misfeatures #define Foam_autoPtr_copyConstruct #define Foam_autoPtr_castOperator -// #define Foam_autoPtr_deprecate_setMethod +// #define Foam_autoPtr_nodeprecate_setMethod #include "stdFoam.H" @@ -283,8 +283,8 @@ public: // enforced a run-time check (Fatal if pointer was already set) // but this was rarely used. // \deprecated(2018-02) Identical to reset(). - #ifdef Foam_autoPtr_deprecate_setMethod - FOAM_DEPRECATED_FOR(2018-02, "reset() - same behaviour") + #ifndef Foam_autoPtr_nodeprecate_setMethod + FOAM_DEPRECATED_FOR(2022-01, "reset() - same behaviour") #endif void set(T* p) noexcept { reset(p); } }; diff --git a/src/OpenFOAM/memory/refCount/refCount.H b/src/OpenFOAM/memory/refCount/refCount.H index 281d653590..58ef0d0aa8 100644 --- a/src/OpenFOAM/memory/refCount/refCount.H +++ b/src/OpenFOAM/memory/refCount/refCount.H @@ -36,8 +36,8 @@ See also \*---------------------------------------------------------------------------*/ -#ifndef refCount_H -#define refCount_H +#ifndef Foam_refCount_H +#define Foam_refCount_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/memory/refPtr/refPtr.H b/src/OpenFOAM/memory/refPtr/refPtr.H index 4469d09a87..90cb3b5691 100644 --- a/src/OpenFOAM/memory/refPtr/refPtr.H +++ b/src/OpenFOAM/memory/refPtr/refPtr.H @@ -39,8 +39,8 @@ See also \*---------------------------------------------------------------------------*/ -#ifndef refPtr_H -#define refPtr_H +#ifndef Foam_refPtr_H +#define Foam_refPtr_H #include "autoPtr.H" #include "tmp.H" diff --git a/src/OpenFOAM/memory/refPtr/refPtrI.H b/src/OpenFOAM/memory/refPtr/refPtrI.H index ff5ce5ee8f..c5d87ab160 100644 --- a/src/OpenFOAM/memory/refPtr/refPtrI.H +++ b/src/OpenFOAM/memory/refPtr/refPtrI.H @@ -31,6 +31,13 @@ License // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // +template +inline Foam::word Foam::refPtr::typeName() +{ + return "refPtr<" + word(typeid(T).name()) + '>'; +} + + template template inline Foam::refPtr Foam::refPtr::New(Args&&... args) @@ -47,13 +54,6 @@ inline Foam::refPtr Foam::refPtr::NewFrom(Args&&... args) } -template -inline Foam::word Foam::refPtr::typeName() -{ - return "refPtr<" + word(typeid(T).name()) + '>'; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/memory/tmp/tmp.H b/src/OpenFOAM/memory/tmp/tmp.H index c24f5260fb..c76ae912a5 100644 --- a/src/OpenFOAM/memory/tmp/tmp.H +++ b/src/OpenFOAM/memory/tmp/tmp.H @@ -45,8 +45,8 @@ See also \*---------------------------------------------------------------------------*/ -#ifndef tmp_H -#define tmp_H +#ifndef Foam_tmp_H +#define Foam_tmp_H #include "refCount.H" #include "word.H" @@ -81,7 +81,7 @@ class tmp mutable refType type_; - // Private Member Operators + // Private Member Functions //- Increment the ref-count for a managed pointer //- and check that it is not oversubscribed diff --git a/src/OpenFOAM/memory/tmp/tmpI.H b/src/OpenFOAM/memory/tmp/tmpI.H index d378e2a612..ab21fef60f 100644 --- a/src/OpenFOAM/memory/tmp/tmpI.H +++ b/src/OpenFOAM/memory/tmp/tmpI.H @@ -29,7 +29,7 @@ License #include "error.H" #include -// * * * * * * * * * * * * * Private Member Operators * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template inline void Foam::tmp::incrCount() @@ -49,6 +49,13 @@ inline void Foam::tmp::incrCount() // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // +template +inline Foam::word Foam::tmp::typeName() +{ + return "tmp<" + word(typeid(T).name()) + '>'; +} + + template template inline Foam::tmp Foam::tmp::New(Args&&... args) @@ -65,13 +72,6 @@ inline Foam::tmp Foam::tmp::NewFrom(Args&&... args) } -template -inline Foam::word Foam::tmp::typeName() -{ - return "tmp<" + word(typeid(T).name()) + '>'; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/memory/tmp/tmpNrc.H b/src/OpenFOAM/memory/tmp/tmpNrc.H index fa63980fbd..0f58697e70 100644 --- a/src/OpenFOAM/memory/tmp/tmpNrc.H +++ b/src/OpenFOAM/memory/tmp/tmpNrc.H @@ -18,8 +18,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef tmpNrc_H -#define tmpNrc_H +#ifndef Foam_tmpNrc_H +#define Foam_tmpNrc_H #include "refPtr.H" diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 367389c0e2..64431fabe5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -198,7 +198,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh Istream& is = readStream(typeName); PtrList patchEntries(is); - patches.setSize(patchEntries.size()); + patches.resize(patchEntries.size()); forAll(patches, patchi) { @@ -225,7 +225,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh patches.setSize(ppl.size()); forAll(patches, patchi) { - patches.set(patchi, ppl[patchi].clone(*this).ptr()); + patches.set(patchi, ppl[patchi].clone(*this)); } } } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index bca75b0844..22103ed846 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -254,7 +254,7 @@ Foam::ZoneMesh::ZoneMesh forAll(zones, zonei) { - zones.set(zonei, pzm[zonei].clone(*this).ptr()); + zones.set(zonei, pzm[zonei].clone(*this)); } } } diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C index bda893b7e6..d55137a27a 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -148,14 +148,14 @@ void Foam::fvMeshDistribute::saveBoundaryFields mesh_.objectRegistry::lookupClass() ); - bflds.setSize(flds.size()); + bflds.resize(flds.size()); label i = 0; forAllConstIters(flds, iter) { const fldType& fld = *iter(); - bflds.set(i, fld.boundaryField().clone().ptr()); + bflds.set(i, fld.boundaryField().clone()); ++i; } @@ -236,7 +236,7 @@ void Foam::fvMeshDistribute::saveInternalFields mesh_.objectRegistry::lookupClass() ); - iflds.setSize(flds.size()); + iflds.resize(flds.size()); label i = 0; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index a7b0a8041d..fb0b880cfc 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -407,7 +407,7 @@ void Foam::cyclicAMIFvPatchField::collectStencilData ) { expandedData.setSize(stencil.size()); - if (mapPtr.valid()) + if (mapPtr) { Type2 work(data); mapPtr().distribute(work); diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C index 30fc454607..6374a34e3f 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -686,7 +686,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints() autoPtr writerPtr; if (debug) { - osPtr.set + osPtr.reset ( new OBJstream ( diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C index efa537d6ff..2e54d2d5cb 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C @@ -79,7 +79,7 @@ bool Foam::patchDistMethods::Poisson::correct volVectorField& n ) { - if (!tyPsi_.valid()) + if (!tyPsi_) { tyPsi_ = tmp ( diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C index e4f516980e..2ab9488043 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,6 +60,7 @@ void Foam::surfaceInterpolation::clearOut() Foam::surfaceInterpolation::surfaceInterpolation(const fvMesh& fvm) : mesh_(fvm), + geometryPtr_(nullptr), weights_(nullptr), deltaCoeffs_(nullptr), nonOrthDeltaCoeffs_(nullptr), @@ -79,7 +80,7 @@ Foam::surfaceInterpolation::~surfaceInterpolation() const Foam::fvGeometryScheme& Foam::surfaceInterpolation::geometry() const { - if (!geometryPtr_.valid()) + if (!geometryPtr_) { geometryPtr_ = fvGeometryScheme::New ( @@ -101,9 +102,9 @@ void Foam::surfaceInterpolation::geometry(tmp& schemePtr) const Foam::surfaceScalarField& Foam::surfaceInterpolation::weights() const { - if (!weights_.valid()) + if (!weights_) { - weights_.set(geometry().weights().ptr()); + weights_.reset(geometry().weights().ptr()); } return weights_(); @@ -112,9 +113,9 @@ const Foam::surfaceScalarField& Foam::surfaceInterpolation::weights() const const Foam::surfaceScalarField& Foam::surfaceInterpolation::deltaCoeffs() const { - if (!deltaCoeffs_.valid()) + if (!deltaCoeffs_) { - deltaCoeffs_.set(geometry().deltaCoeffs().ptr()); + deltaCoeffs_.reset(geometry().deltaCoeffs().ptr()); } return deltaCoeffs_(); @@ -124,9 +125,9 @@ const Foam::surfaceScalarField& Foam::surfaceInterpolation::deltaCoeffs() const const Foam::surfaceScalarField& Foam::surfaceInterpolation::nonOrthDeltaCoeffs() const { - if (!nonOrthDeltaCoeffs_.valid()) + if (!nonOrthDeltaCoeffs_) { - nonOrthDeltaCoeffs_.set(geometry().nonOrthDeltaCoeffs().ptr()); + nonOrthDeltaCoeffs_.reset(geometry().nonOrthDeltaCoeffs().ptr()); } return nonOrthDeltaCoeffs_(); @@ -136,9 +137,9 @@ Foam::surfaceInterpolation::nonOrthDeltaCoeffs() const const Foam::surfaceVectorField& Foam::surfaceInterpolation::nonOrthCorrectionVectors() const { - if (!nonOrthCorrectionVectors_.valid()) + if (!nonOrthCorrectionVectors_) { - nonOrthCorrectionVectors_.set + nonOrthCorrectionVectors_.reset ( geometry().nonOrthCorrectionVectors().ptr() ); diff --git a/src/functionObjects/field/histogram/histogram.C b/src/functionObjects/field/histogram/histogram.C index f6882e71e8..8c05eabc59 100644 --- a/src/functionObjects/field/histogram/histogram.C +++ b/src/functionObjects/field/histogram/histogram.C @@ -160,9 +160,9 @@ bool Foam::functionObjects::histogram::write() const volScalarField& field = ( - fieldPtr.valid() - ? fieldPtr() - : obr_.lookupObject(fieldName_) + fieldPtr + ? fieldPtr() + : obr_.lookupObject(fieldName_) ); diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H index 3471bc2eef..cb9401d885 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,7 +28,7 @@ License inline const Foam::primitivePatch& Foam::AMIInterpolation::srcPatch0() const { - if (!tsrcPatch0_.valid()) + if (!tsrcPatch0_) { FatalErrorInFunction << "tsrcPatch0Ptr_ not set" @@ -42,7 +42,7 @@ inline const Foam::primitivePatch& Foam::AMIInterpolation::srcPatch0() const inline const Foam::primitivePatch& Foam::AMIInterpolation::tgtPatch0() const { - if (!ttgtPatch0_.valid()) + if (!ttgtPatch0_) { FatalErrorInFunction << "ttgtPatch0Ptr_ not set" diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMII.H b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMII.H index e044134538..616dd92398 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMII.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMII.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +27,7 @@ License inline const Foam::primitivePatch& Foam::advancingFrontAMI::srcPatch() const { - if (!tsrcPatch0_.valid()) + if (!tsrcPatch0_) { FatalErrorInFunction << "tsrcPatch0_ not allocated" @@ -45,7 +45,7 @@ inline const Foam::primitivePatch& Foam::advancingFrontAMI::tgtPatch() const return extendedTgtPatchPtr_(); } - if (!ttgtPatch0_.valid()) + if (!ttgtPatch0_) { FatalErrorInFunction << "srcPatch0Ptr not allocated" diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index 4d4f1c61f6..4ef5fec66d 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +69,7 @@ bool Foam::cyclicACMIPolyPatch::updateAreas() const // Check if scaling enabled (and necessary) if ( - srcScalePtr_.valid() + srcScalePtr_ && (updated || prevTimeIndex_ != mesh.time().timeIndex()) ) { @@ -103,7 +103,7 @@ bool Foam::cyclicACMIPolyPatch::updateAreas() const ); - if (!tgtScalePtr_.valid()) + if (!tgtScalePtr_) { tgtScalePtr_= srcScalePtr_.clone(neighbPatch()); } @@ -361,7 +361,7 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas() const cyclicACMIPolyPatch& nbrPatch = this->neighbPatch(); const polyPatch& nbrNonOverlapPatch = nbrPatch.nonOverlapPatch(); - if (srcScalePtr_.valid()) + if (srcScalePtr_) { // Save overlap geometry for later scaling thisSf_ = this->faceAreas(); @@ -476,7 +476,7 @@ void Foam::cyclicACMIPolyPatch::clearGeom() const Foam::scalarField& Foam::cyclicACMIPolyPatch::srcMask() const { - if (srcScalePtr_.valid()) + if (srcScalePtr_) { // Make sure areas are up-to-date updateAreas(); @@ -492,7 +492,7 @@ const Foam::scalarField& Foam::cyclicACMIPolyPatch::srcMask() const const Foam::scalarField& Foam::cyclicACMIPolyPatch::tgtMask() const { - if (tgtScalePtr_.valid()) + if (tgtScalePtr_) { // Make sure areas are up-to-date updateAreas(); @@ -619,12 +619,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch nonOverlapPatchID_(-1), srcMask_(), tgtMask_(), - srcScalePtr_ - ( - pp.srcScalePtr_.valid() - ? pp.srcScalePtr_.clone(*this) - : nullptr - ), + srcScalePtr_(pp.srcScalePtr_.clone(*this)), AMITime_ ( IOobject @@ -663,12 +658,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch nonOverlapPatchID_(-1), srcMask_(), tgtMask_(), - srcScalePtr_ - ( - pp.srcScalePtr_.valid() - ? pp.srcScalePtr_.clone(*this) - : nullptr - ), + srcScalePtr_(pp.srcScalePtr_.clone(*this)), AMITime_ ( IOobject @@ -713,12 +703,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch nonOverlapPatchID_(-1), srcMask_(), tgtMask_(), - srcScalePtr_ - ( - pp.srcScalePtr_.valid() - ? pp.srcScalePtr_.clone(*this) - : nullptr - ), + srcScalePtr_(pp.srcScalePtr_.clone(*this)), AMITime_ ( IOobject @@ -804,7 +789,7 @@ const Foam::cyclicACMIPolyPatch& Foam::cyclicACMIPolyPatch::neighbPatch() const const polyPatch& pp = this->boundaryMesh()[neighbPatchID()]; // Bit of checking now we know neighbour patch - if (!owner() && srcScalePtr_.valid()) + if (!owner() && srcScalePtr_) { WarningInFunction << "Ignoring \"scale\" setting in slave patch " << name() @@ -911,7 +896,7 @@ void Foam::cyclicACMIPolyPatch::write(Ostream& os) const os.writeEntry("nonOverlapPatch", nonOverlapPatchName_); - if (owner() && srcScalePtr_.valid()) + if (owner() && srcScalePtr_) { srcScalePtr_->writeData(os); } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index cd68f4d9b4..b81b905323 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -290,8 +290,6 @@ void Foam::cyclicAMIPolyPatch::calcTransforms Foam::autoPtr Foam::cyclicAMIPolyPatch::cylindricalCS() const { - autoPtr csPtr; - const label periodicID = periodicPatchID(); if (periodicID != -1) { @@ -328,10 +326,10 @@ Foam::cyclicAMIPolyPatch::cylindricalCS() const << exit(FatalError); } - csPtr.set(new coordSystem::cylindrical(axisPoint, axis)); + return autoPtr::New(axisPoint, axis); } } - return csPtr; + return nullptr; } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C index 6b8abe0a23..ca7282c03a 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C @@ -60,7 +60,7 @@ Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate else { autoPtr cs(cylindricalCS()); - if (!cs.valid()) + if (!cs) { return interpolateUntransformed(fld, defaultValues); } @@ -173,7 +173,7 @@ void Foam::cyclicAMIPolyPatch::interpolate /* autoPtr cs(cylindricalCS()); - if (cs.valid() && pTraits::rank > 0) + if (cs && pTraits::rank > 0) { const cyclicAMIPolyPatch& nbrPp = this->neighbPatch(); diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index ebbd171087..29647d4d04 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -91,32 +91,26 @@ Foam::autoPtr Foam::mappedPatchBase::readDatabase const dictionary& dict ) { - autoPtr dbNamePtr_; - if (dict.found("sampleDatabase")) { - const bool useDb = dict.get("sampleDatabase"); - if (useDb) + if (dict.get("sampleDatabase")) { - dbNamePtr_.set + return autoPtr::New ( - new fileName + dict.lookupOrDefault ( - dict.lookupOrDefault - ( - "sampleDatabasePath", - fileName::null - ) + "sampleDatabasePath", + fileName::null ) ); } } else if (dict.found("sampleDatabasePath")) { - dbNamePtr_.set(new fileName(dict.get("sampleDatabasePath"))); + return autoPtr::New(dict.get("sampleDatabasePath")); } - return dbNamePtr_; + return nullptr; } diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C index 1917b21473..6af212c2fa 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/MultiComponentPhaseModel/MultiComponentPhaseModel.C @@ -55,14 +55,14 @@ MultiComponentPhaseModel species_(), inertIndex_(-1) { - thermoPtr_.set + thermoPtr_.reset ( phaseThermo::New ( fluid.mesh(), phaseName, basicThermo::phasePropertyName(basicThermo::dictName, phaseName) - ).ptr() + ) ); if (thermoPtr_->composition().species().empty()) diff --git a/src/regionFaModels/regionFaModel/regionFaModelI.H b/src/regionFaModels/regionFaModel/regionFaModelI.H index 7f45fa6ec4..da8c018f61 100644 --- a/src/regionFaModels/regionFaModel/regionFaModelI.H +++ b/src/regionFaModels/regionFaModel/regionFaModelI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,7 +68,7 @@ inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const { return *regionPtr; } - else if (!regionMeshPtr_.valid()) + else if (!regionMeshPtr_) { FatalErrorInFunction << "Region mesh not available" << abort(FatalError); @@ -86,7 +86,7 @@ inline Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() { return *regionPtr; } - else if (!regionMeshPtr_.valid()) + else if (!regionMeshPtr_) { FatalErrorInFunction << "Region mesh not available" << abort(FatalError);