From 841b65536baf6339a8b20b52b834b7abed9335de Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 13 May 2020 12:12:24 +0200 Subject: [PATCH] ENH: use unique_ptr for resource handling in dynamicMesh ENH: defaulting for destructors where possible STYLE: clear() instead of setSize(0) for plain Lists STYLE: use bool operator instead of valid()/empty() for autoPtr tests --- src/dynamicMesh/attachDetach/attachDetach.C | 31 +--- src/dynamicMesh/attachDetach/attachDetach.H | 11 +- .../attachDetach/attachDetachPointMatchMap.C | 5 +- src/dynamicMesh/boundaryMesh/boundaryMesh.C | 65 +++---- src/dynamicMesh/boundaryMesh/boundaryMesh.H | 11 +- .../createShellMesh/createShellMesh.H | 7 +- src/dynamicMesh/fvMeshAdder/fvMeshAdder.H | 3 +- .../fvMeshDistribute/fvMeshDistribute.C | 1 - .../fvMeshDistribute/fvMeshDistribute.H | 4 +- src/dynamicMesh/fvMeshSubset/fvMeshSubset.C | 9 +- src/dynamicMesh/fvMeshSubset/fvMeshSubsetI.H | 8 +- .../fvMeshSubsetProxy/fvMeshSubsetProxy.H | 7 +- .../layerAdditionRemoval.C | 45 +---- .../layerAdditionRemoval.H | 19 +- .../layerAdditionRemoval/setLayerPairing.C | 18 +- src/dynamicMesh/meshCut/cellCuts/cellCuts.C | 36 ++-- src/dynamicMesh/meshCut/cellCuts/cellCuts.H | 13 +- .../meshCut/cellLooper/cellLooper.C | 6 - .../meshCut/cellLooper/cellLooper.H | 15 +- .../meshCut/cellLooper/geomCellLooper.C | 29 +-- .../meshCut/cellLooper/geomCellLooper.H | 14 +- .../meshCut/cellLooper/hexCellLooper.C | 12 +- .../meshCut/cellLooper/hexCellLooper.H | 11 +- .../meshCut/cellLooper/topoCellLooper.C | 8 - .../meshCut/cellLooper/topoCellLooper.H | 10 +- .../meshCut/directions/directions.H | 6 +- .../meshCut/edgeVertex/edgeVertex.C | 1 - .../meshCut/edgeVertex/edgeVertex.H | 7 +- .../boundaryCutter/boundaryCutter.C | 7 - .../boundaryCutter/boundaryCutter.H | 7 +- .../meshCutAndRemove/meshCutAndRemove.C | 1 - .../meshCutAndRemove/meshCutAndRemove.H | 17 +- .../meshModifiers/meshCutter/meshCutter.C | 6 - .../meshModifiers/meshCutter/meshCutter.H | 7 +- .../multiDirRefinement/multiDirRefinement.H | 2 +- .../refinementIterator/refinementIterator.C | 3 +- .../refinementIterator/refinementIterator.H | 5 +- .../undoableMeshCutter/undoableMeshCutter.C | 1 - .../undoableMeshCutter/undoableMeshCutter.H | 15 +- .../meshCut/refineCell/refineCell.H | 21 ++- src/dynamicMesh/meshCut/splitCell/splitCell.C | 1 - src/dynamicMesh/meshCut/splitCell/splitCell.H | 12 +- .../polyMeshGeometry/polyMeshGeometry.C | 1 - .../polyMeshGeometry/polyMeshGeometry.H | 3 +- .../codedPoints0/codedPoints0MotionSolver.C | 13 +- .../codedPoints0/codedPoints0MotionSolver.H | 4 +- .../displacement/displacement/zoneMotion.C | 7 +- .../displacement/displacement/zoneMotion.H | 7 +- .../displacementInterpolationMotionSolver.C | 7 - .../displacementInterpolationMotionSolver.H | 6 +- ...yMotionDisplacementPointPatchVectorField.C | 19 +- ...yMotionDisplacementPointPatchVectorField.H | 6 +- .../solidBodyMotionFunctions/SDA/SDA.C | 6 - .../solidBodyMotionFunctions/SDA/SDA.H | 5 +- .../axisRotationMotion/axisRotationMotion.C | 6 - .../axisRotationMotion/axisRotationMotion.H | 5 +- .../drivenLinearMotion/drivenLinearMotion.C | 6 - .../drivenLinearMotion/drivenLinearMotion.H | 2 +- .../linearMotion/linearMotion.C | 6 - .../linearMotion/linearMotion.H | 4 +- .../multiMotion/multiMotion.C | 6 - .../multiMotion/multiMotion.H | 4 +- .../oscillatingLinearMotion.C | 7 - .../oscillatingLinearMotion.H | 5 +- .../oscillatingRotatingMotion.C | 7 - .../oscillatingRotatingMotion.H | 5 +- .../rotatingMotion/rotatingMotion.C | 11 +- .../rotatingMotion/rotatingMotion.H | 5 +- .../solidBodyMotionFunction.C | 6 - .../solidBodyMotionFunction.H | 12 +- .../tabulated6DoFMotion/tabulated6DoFMotion.C | 6 - .../tabulated6DoFMotion/tabulated6DoFMotion.H | 3 +- .../motionSolvers/motionSolver/motionSolver.C | 6 - .../motionSolvers/motionSolver/motionSolver.H | 6 +- .../velocity/velocityMotionSolver.C | 6 - .../velocity/velocityMotionSolver.H | 9 +- .../perfectInterface/perfectInterface.C | 6 - .../perfectInterface/perfectInterface.H | 12 +- .../pointPatchDist/pointPatchDist.C | 6 - .../pointPatchDist/pointPatchDist.H | 5 +- .../polyMeshAdder/faceCoupleInfo.C | 6 - .../polyMeshAdder/faceCoupleInfo.H | 14 +- src/dynamicMesh/polyMeshAdder/polyMeshAdder.H | 8 +- .../polyMeshFilter/polyMeshFilter.C | 6 - .../polyMeshFilter/polyMeshFilter.H | 3 +- .../polyMeshModifier/polyMeshModifier.C | 8 - .../polyMeshModifier/polyMeshModifier.H | 8 +- .../polyTopoChange/addPatchCellLayer.H | 8 +- .../polyTopoChange/combineFaces.H | 8 +- .../polyTopoChange/duplicatePoints.C | 1 - .../polyTopoChange/duplicatePoints.H | 4 +- .../polyTopoChange/edgeCollapser.H | 4 +- .../polyTopoChange/faceCollapser.H | 7 +- .../polyTopoChange/hexRef8/hexRef8.C | 6 +- .../polyTopoChange/hexRef8/hexRef8.H | 9 +- .../polyTopoChange/hexRef8/hexRef8Data.C | 169 +++++++----------- .../polyTopoChange/hexRef8/hexRef8Data.H | 15 +- .../hexRef8/refinementHistory.C | 93 +++++----- .../hexRef8/refinementHistory.H | 48 +++-- .../polyTopoChange/removeCells.H | 2 +- .../polyTopoChange/removeFaces.H | 3 +- .../polyTopoChange/removePoints.H | 19 +- .../polyTopoChanger/polyTopoChanger.H | 11 +- .../repatchPolyTopoChanger.C | 18 +- .../repatchPolyTopoChanger.H | 8 +- src/dynamicMesh/setUpdater/setUpdater.C | 6 - src/dynamicMesh/setUpdater/setUpdater.H | 3 +- .../slidingInterface/coupleSlidingInterface.C | 8 +- .../enrichedPatch/enrichedPatch.C | 27 +-- .../enrichedPatch/enrichedPatch.H | 26 +-- .../enrichedPatch/enrichedPatchCutFaces.C | 18 +- .../enrichedPatch/enrichedPatchFaces.C | 9 +- .../enrichedPatch/enrichedPatchMasterPoints.C | 7 +- .../enrichedPatch/enrichedPatchPointPoints.C | 6 +- .../slidingInterface/slidingInterface.C | 38 ++-- .../slidingInterface/slidingInterface.H | 37 ++-- .../slidingInterfaceAttachedAddressing.C | 94 +++++----- .../slidingInterfaceProjectPoints.C | 119 ++++++------ 118 files changed, 655 insertions(+), 992 deletions(-) diff --git a/src/dynamicMesh/attachDetach/attachDetach.C b/src/dynamicMesh/attachDetach/attachDetach.C index b58659eb7b..1f0d9c6007 100644 --- a/src/dynamicMesh/attachDetach/attachDetach.C +++ b/src/dynamicMesh/attachDetach/attachDetach.C @@ -33,7 +33,6 @@ License #include "primitiveMesh.H" #include "polyTopoChange.H" #include "addToRunTimeSelectionTable.H" -#include "demandDrivenData.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -222,13 +221,12 @@ void Foam::attachDetach::checkDefinition() void Foam::attachDetach::clearAddressing() const { - deleteDemandDrivenData(pointMatchMapPtr_); + pointMatchMapPtr_.reset(nullptr); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::attachDetach::attachDetach ( const word& name, @@ -256,7 +254,6 @@ Foam::attachDetach::attachDetach } -// Construct from components Foam::attachDetach::attachDetach ( const word& name, @@ -292,26 +289,11 @@ Foam::attachDetach::attachDetach } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::attachDetach::~attachDetach() -{ - clearAddressing(); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::attachDetach::setAttach() const { - if (!attached()) - { - trigger_ = true; - } - else - { - trigger_ = false; - } + trigger_ = (!attached()); return trigger_; } @@ -319,14 +301,7 @@ bool Foam::attachDetach::setAttach() const bool Foam::attachDetach::setDetach() const { - if (attached()) - { - trigger_ = true; - } - else - { - trigger_ = false; - } + trigger_ = (attached()); return trigger_; } diff --git a/src/dynamicMesh/attachDetach/attachDetach.H b/src/dynamicMesh/attachDetach/attachDetach.H index a818ddb856..1056a4acac 100644 --- a/src/dynamicMesh/attachDetach/attachDetach.H +++ b/src/dynamicMesh/attachDetach/attachDetach.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,7 +64,7 @@ class attachDetach : public polyMeshModifier { - // Data types + // Data Types //- State of the modifier enum modifierState @@ -74,7 +75,7 @@ class attachDetach }; - // Private data + // Private Data //- Master face zone ID faceZoneID faceZoneID_; @@ -103,8 +104,8 @@ class attachDetach // Private addressing data. Created on topology change - //- Map of matching points - mutable Map