diff --git a/applications/test/autoPtr/Test-autoPtr.C b/applications/test/autoPtr/Test-autoPtr.C index ed621ea0f261e6143ef703d9b89c5fb133add8bc..e084ffb7eeb3d278d381c9357f3d1dc0aa387956 100644 --- a/applications/test/autoPtr/Test-autoPtr.C +++ b/applications/test/autoPtr/Test-autoPtr.C @@ -25,6 +25,8 @@ License \*---------------------------------------------------------------------------*/ +// #define Foam_autoPtr_deprecate_setMethod + #include <memory> #include "autoPtr.H" #include "labelList.H" @@ -236,6 +238,11 @@ int main(int argc, char *argv[]) // Does compile (good!): ptr1 = nullptr; ptr1.reset(std::move(ptr2)); + + autoPtr<labelList> ptr3; + + // set() method - deprecated warning? + ptr3.set(ptr1.release()); } diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index dbc1c8214c3f2bf12ee98f248c005bc8790b0a3e..3b05a0af1d438335bfa41fe070602679166a2757 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -1087,7 +1087,16 @@ void Foam::Time::setDeltaT(const scalar deltaT, const bool adjust) Foam::TimeState Foam::Time::subCycle(const label nSubCycles) { - prevTimeState_.set(new TimeState(*this)); // Fatal if already set + #ifdef FULLDEBUG + if (prevTimeState_) + { + FatalErrorInFunction + << "previous time state already set" << nl + << exit(FatalError); + } + #endif + + prevTimeState_.reset(new TimeState(*this)); setTime(*this - deltaT(), (timeIndex() - 1)*nSubCycles); deltaT_ /= nSubCycles; @@ -1118,7 +1127,7 @@ void Foam::Time::endSubCycle() if (subCycling_) { TimeState::operator=(prevTimeState()); - prevTimeState_.clear(); + prevTimeState_.reset(nullptr); } subCycling_ = 0; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C index d445e4d1f4b467c440dd2923f547599954f6905e..946ae1d49f62f71abe8a71ec656ac4a343f3ddd5 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C @@ -288,7 +288,7 @@ Foam::GAMGSolver::GAMGSolver } else if (matrixLevels_[coarsestLevel].asymmetric()) { - coarsestSolverPtr_.set + coarsestSolverPtr_.reset ( new PBiCGStab ( @@ -303,7 +303,7 @@ Foam::GAMGSolver::GAMGSolver } else { - coarsestSolverPtr_.set + coarsestSolverPtr_.reset ( new PCG ( diff --git a/src/OpenFOAM/memory/autoPtr/autoPtr.H b/src/OpenFOAM/memory/autoPtr/autoPtr.H index 2ac54bdecdfebbf7598190296896593dd3f4602b..4804275bb86d0de41867794426d09cefe57e7a9f 100644 --- a/src/OpenFOAM/memory/autoPtr/autoPtr.H +++ b/src/OpenFOAM/memory/autoPtr/autoPtr.H @@ -49,6 +49,7 @@ SourceFiles // Transitional features/misfeatures #define Foam_autoPtr_copyConstruct #define Foam_autoPtr_castOperator +// #define Foam_autoPtr_deprecate_setMethod #include "stdFoam.H" @@ -163,7 +164,7 @@ public: //- Return reference to the managed object without nullptr checking. // When get() == nullptr, additional guards may be required to avoid - // inadvertent access to a nullptr. + // inadvertent access of a nullptr. T& ref() { return *ptr_; } @@ -274,6 +275,9 @@ 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") + #endif void set(T* p) noexcept { reset(p); } //- Deprecated(2018-02) No copy assignment from plain pointer diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C index 14e6ca4e48455d9ca0861f712bc80a6620c3c145..939f26210abf29a64886b3d58011bd7d0cf973ce 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C @@ -348,7 +348,7 @@ bool Foam::processorCyclicPolyPatch::order UIPstream fromNeighbour(neighbProcNo(), pBufs); fromNeighbour >> masterPts >> masterFaces; SubList<face> fcs(masterFaces, masterFaces.size()); - masterPtr.set(new primitivePatch(fcs, masterPts)); + masterPtr.reset(new primitivePatch(fcs, masterPts)); } const cyclicPolyPatch& cycPatch = diff --git a/src/functionObjects/field/columnAverage/columnAverage.C b/src/functionObjects/field/columnAverage/columnAverage.C index 65623a8e73ebfa90246020f4c03b98a43ab74d63..0ef1f074c9d5edf66125f8fa75ee7e19714620f7 100644 --- a/src/functionObjects/field/columnAverage/columnAverage.C +++ b/src/functionObjects/field/columnAverage/columnAverage.C @@ -88,9 +88,9 @@ Foam::functionObjects::columnAverage::meshAddressing(const polyMesh& mesh) const mesh.points() ); - globalFaces_.set(new globalIndex(uip.size())); - globalEdges_.set(new globalIndex(uip.nEdges())); - globalPoints_.set(new globalIndex(uip.nPoints())); + globalFaces_.reset(new globalIndex(uip.size())); + globalEdges_.reset(new globalIndex(uip.nEdges())); + globalPoints_.reset(new globalIndex(uip.nPoints())); meshStructurePtr_.reset ( new meshStructure diff --git a/src/functionObjects/field/surfaceDistance/surfaceDistance.C b/src/functionObjects/field/surfaceDistance/surfaceDistance.C index 6f08a77b5e4d6318a67092b5a5bac13855f3ce10..81a96f5e6213dc5a8733ea124b9091894723530f 100644 --- a/src/functionObjects/field/surfaceDistance/surfaceDistance.C +++ b/src/functionObjects/field/surfaceDistance/surfaceDistance.C @@ -85,8 +85,8 @@ bool Foam::functionObjects::surfaceDistance::read doCells_ = dict.getOrDefault("calculateCells", true); - geomPtr_.clear(); - geomPtr_.set + geomPtr_.reset(nullptr); + geomPtr_.reset ( new searchableSurfaces ( diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 80aa0bce58485b891cf77c046ff26f8e3f201cb4..293b5058cf6f597ec44d954ca3518c9046594db4 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -3098,9 +3098,9 @@ void Foam::distributedTriSurfaceMesh::findNearest { sendMap[proci].transfer(dynSendMap[proci]); } - map1Ptr.set(new mapDistribute(std::move(sendMap))); + map1Ptr.reset(new mapDistribute(std::move(sendMap))); } - const mapDistribute& map1 = map1Ptr(); + const mapDistribute& map1 = *map1Ptr; if (debug) @@ -4116,9 +4116,9 @@ void Foam::distributedTriSurfaceMesh::getVolumeType } } - mapPtr.set(new mapDistribute(std::move(sendMap))); + mapPtr.reset(new mapDistribute(std::move(sendMap))); } - const mapDistribute& map = mapPtr(); + const mapDistribute& map = *mapPtr; // Get the points I need to test pointField localPoints(samples); diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/PurePhaseModel/PurePhaseModel.C b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/PurePhaseModel/PurePhaseModel.C index e06091e1f37bc705fa6f1ba535b56c2a954b07a8..9415a138eaf0c21b3ac7423948382aba2148c52e 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/PurePhaseModel/PurePhaseModel.C +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/phaseModel/PurePhaseModel/PurePhaseModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,7 @@ License #include "PurePhaseModel.H" #include "phaseSystem.H" #include "basicThermo.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class BasePhaseModel, class phaseThermo> @@ -39,14 +40,14 @@ Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::PurePhaseModel : BasePhaseModel(fluid, phaseName) { - thermoPtr_.set + thermoPtr_.reset ( phaseThermo::New ( fluid.mesh(), phaseName, basicThermo::phasePropertyName(basicThermo::dictName, phaseName) - ).ptr() + ) ); } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystemTemplates.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystemTemplates.C index c16b2dfec0bcc5a6339978bc542b5d40405566d7..c507861860879a94ca24cabc834ecd1a11f967e3 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystemTemplates.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/phaseSystem/phaseSystemTemplates.C @@ -212,7 +212,7 @@ void Foam::phaseSystem::generatePairsAndSubModels << exit(FatalError); } - models[key][pair.index(phase)].set(tempModelIter().ptr()); + models[key][pair.index(phase)].reset(tempModelIter().ptr()); } } } diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C index 8aef864303580e9029b56f06961ad1d8121119be..c50ba7996a09dc6e9426e7b9ce5679ed2a0aba77 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.C @@ -953,7 +953,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel if (coalescence_.size() != 0) { - coalescenceRate_.set + coalescenceRate_.reset ( new volScalarField ( @@ -971,7 +971,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel if (breakup_.size() != 0) { - breakupRate_.set + breakupRate_.reset ( new volScalarField ( @@ -989,7 +989,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel if (binaryBreakup_.size() != 0) { - binaryBreakupRate_.set + binaryBreakupRate_.reset ( new volScalarField ( @@ -1012,7 +1012,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel if (drift_.size() != 0) { - driftRate_.set + driftRate_.reset ( new volScalarField ( @@ -1027,7 +1027,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ) ); - rx_.set + rx_.reset ( new volScalarField ( @@ -1042,7 +1042,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ) ); - rdx_.set + rdx_.reset ( new volScalarField ( @@ -1060,7 +1060,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel if (nucleation_.size() != 0) { - nucleationRate_.set + nucleationRate_.reset ( new volScalarField ( @@ -1083,7 +1083,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel if (velocityGroups_.size() > 1) { - alphas_.set + alphas_.reset ( new volScalarField ( @@ -1100,7 +1100,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ) ); - dsm_.set + dsm_.reset ( new volScalarField ( @@ -1117,7 +1117,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel ) ); - U_.set + U_.reset ( new volVectorField ( @@ -1141,6 +1141,7 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel Foam::diameterModels::populationBalanceModel::~populationBalanceModel() {} + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::autoPtr<Foam::diameterModels::populationBalanceModel> diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C index 7093ecd55c7e57dc856da5c7f8cd500ac24fe201..f4198b56fd1fcd488be7b7a9f0d9288a7ad5cbeb 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/twoPhaseSystem/twoPhaseSystem.C @@ -136,7 +136,7 @@ Foam::twoPhaseSystem::twoPhaseSystem phasePair::scalarTable sigmaTable(lookup("sigma")); phasePair::dictTable aspectRatioTable(lookup("aspectRatio")); - pair_.set + pair_.reset ( new phasePair ( @@ -147,7 +147,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - pair1In2_.set + pair1In2_.reset ( new orderedPhasePair ( @@ -159,7 +159,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - pair2In1_.set + pair2In1_.reset ( new orderedPhasePair ( @@ -174,7 +174,7 @@ Foam::twoPhaseSystem::twoPhaseSystem // Models - drag_.set + drag_.reset ( new BlendedInterfacialModel<dragModel> ( @@ -191,7 +191,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - virtualMass_.set + virtualMass_.reset ( new BlendedInterfacialModel<virtualMassModel> ( @@ -207,7 +207,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - heatTransfer_.set + heatTransfer_.reset ( new BlendedInterfacialModel<heatTransferModel> ( @@ -223,7 +223,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - lift_.set + lift_.reset ( new BlendedInterfacialModel<liftModel> ( @@ -239,7 +239,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - wallLubrication_.set + wallLubrication_.reset ( new BlendedInterfacialModel<wallLubricationModel> ( @@ -255,7 +255,7 @@ Foam::twoPhaseSystem::twoPhaseSystem ) ); - turbulentDispersion_.set + turbulentDispersion_.reset ( new BlendedInterfacialModel<turbulentDispersionModel> ( diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C index 9444a1e9a143b53c70f156dfa614dae66d95bf1a..cfbafa2fcd10f966826f7747a70b0bc1679d25fc 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C @@ -111,7 +111,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission && "none" != coeffsDict_.get<word>("lookUpTableFileName") ) { - lookUpTablePtr_.set + lookUpTablePtr_.reset ( new interpolationLookUpTable<scalar> (