From 47232ccf664cf0ed7010ceea853d4d6381eaa78d Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin <kutalmis.bercin@esi-group.com> Date: Tue, 27 Feb 2024 13:40:27 +0000 Subject: [PATCH] ENH: finiteArea: replace raw pointers with unique_ptr --- .../distributed/faMeshDistributor.C | 8 +- .../distributed/faMeshDistributor.H | 2 +- .../distributed/faMeshDistributorTemplates.C | 4 +- src/finiteArea/faMesh/faMesh.C | 135 +++------- src/finiteArea/faMesh/faMesh.H | 29 +-- .../faMesh/faMeshDemandDrivenData.C | 231 +++++++++--------- .../faMesh/faMeshMapper/faAreaMapper.C | 45 ++-- .../faMesh/faMeshMapper/faAreaMapper.H | 13 +- .../faMesh/faMeshMapper/faEdgeMapper.C | 7 +- .../faMesh/faMeshMapper/faEdgeMapper.H | 2 +- .../faMesh/faMeshMapper/faPatchMapper.C | 7 +- .../faMesh/faMeshMapper/faPatchMapper.H | 2 +- src/finiteArea/faMesh/faMeshTopology.C | 11 +- .../faMesh/faPatches/faPatch/faPatch.C | 26 +- .../leastSquaresFaVectors.C | 21 +- .../leastSquaresFaVectors.H | 6 +- .../edgeInterpolation/edgeInterpolation.C | 88 +++---- .../edgeInterpolation/edgeInterpolation.H | 24 +- 18 files changed, 257 insertions(+), 404 deletions(-) diff --git a/src/finiteArea/distributed/faMeshDistributor.C b/src/finiteArea/distributed/faMeshDistributor.C index 9ee084fd949..a3b8841d1ec 100644 --- a/src/finiteArea/distributed/faMeshDistributor.C +++ b/src/finiteArea/distributed/faMeshDistributor.C @@ -84,10 +84,10 @@ void Foam::faMeshDistributor::createInternalEdgeMap() const const auto& faEdgeMap = distMap_.faceMap(); // Copy full map - internalEdgeMap_.reset(new mapDistributeBase(faEdgeMap)); + internalEdgeMapPtr_ = std::make_unique<mapDistributeBase>(faEdgeMap); // Retain internal edges - internalEdgeMap_->compactRemoteData + internalEdgeMapPtr_->compactRemoteData ( bitSet(tgtMesh_.nInternalEdges(), true), UPstream::msgType(), @@ -200,8 +200,6 @@ Foam::faMeshDistributor::faMeshDistributor srcMesh_(srcMesh), tgtMesh_(tgtMesh), distMap_(distMap), - internalEdgeMap_(), - patchEdgeMaps_(), dummyHandler_(fileOperation::null()), writeHandler_(dummyHandler_), isWriteProc_(isWriteProc) @@ -221,8 +219,6 @@ Foam::faMeshDistributor::faMeshDistributor srcMesh_(srcMesh), tgtMesh_(tgtMesh), distMap_(distMap), - internalEdgeMap_(), - patchEdgeMaps_(), dummyHandler_(nullptr), writeHandler_(writeHandler), isWriteProc_(Switch::INVALID) diff --git a/src/finiteArea/distributed/faMeshDistributor.H b/src/finiteArea/distributed/faMeshDistributor.H index 05f40ab9ccf..632d6173083 100644 --- a/src/finiteArea/distributed/faMeshDistributor.H +++ b/src/finiteArea/distributed/faMeshDistributor.H @@ -73,7 +73,7 @@ class faMeshDistributor const mapDistributePolyMesh& distMap_; //- Internal edge mapper - mutable std::unique_ptr<mapDistributeBase> internalEdgeMap_; + mutable std::unique_ptr<mapDistributeBase> internalEdgeMapPtr_; //- Patch edge mappers mutable PtrList<mapDistributeBase> patchEdgeMaps_; diff --git a/src/finiteArea/distributed/faMeshDistributorTemplates.C b/src/finiteArea/distributed/faMeshDistributorTemplates.C index 9215cc3b2bf..8df66fe2ab8 100644 --- a/src/finiteArea/distributed/faMeshDistributorTemplates.C +++ b/src/finiteArea/distributed/faMeshDistributorTemplates.C @@ -154,7 +154,7 @@ Foam::faMeshDistributor::distributeField const GeometricField<Type, faePatchField, edgeMesh>& fld ) const { - if (!internalEdgeMap_) + if (!internalEdgeMapPtr_) { createInternalEdgeMap(); } @@ -165,7 +165,7 @@ Foam::faMeshDistributor::distributeField const distributedFieldMapper mapper ( labelUList::null(), - *(internalEdgeMap_) + *(internalEdgeMapPtr_) ); DimensionedField<Type, edgeMesh> internalField diff --git a/src/finiteArea/faMesh/faMesh.C b/src/finiteArea/faMesh/faMesh.C index cfb9e1608cb..49c518363d5 100644 --- a/src/finiteArea/faMesh/faMesh.C +++ b/src/finiteArea/faMesh/faMesh.C @@ -169,14 +169,12 @@ void Foam::faMesh::checkBoundaryEdgeLabelRange void Foam::faMesh::initPatch() const { - patchPtr_.reset + patchPtr_ = std::make_unique<uindirectPrimitivePatch> ( - new uindirectPrimitivePatch - ( - UIndirectList<face>(mesh().faces(), faceLabels_), - mesh().points() - ) + UIndirectList<face>(mesh().faces(), faceLabels_), + mesh().points() ); + // Could set some basic primitive data here... // nEdges_ = patchPtr_->nEdges(); // nInternalEdges_ = patchPtr_->nInternalEdges(); @@ -253,17 +251,17 @@ void Foam::faMesh::clearGeomNotAreas() const polyPatchFacesPtr_.reset(nullptr); polyPatchIdsPtr_.reset(nullptr); bndConnectPtr_.reset(nullptr); - deleteDemandDrivenData(SPtr_); - deleteDemandDrivenData(patchStartsPtr_); - deleteDemandDrivenData(LePtr_); - deleteDemandDrivenData(magLePtr_); - deleteDemandDrivenData(faceCentresPtr_); - deleteDemandDrivenData(edgeCentresPtr_); - deleteDemandDrivenData(faceAreaNormalsPtr_); - deleteDemandDrivenData(edgeAreaNormalsPtr_); + SPtr_.reset(nullptr); + patchStartsPtr_.reset(nullptr); + LePtr_.reset(nullptr); + magLePtr_.reset(nullptr); + faceCentresPtr_.reset(nullptr); + edgeCentresPtr_.reset(nullptr); + faceAreaNormalsPtr_.reset(nullptr); + edgeAreaNormalsPtr_.reset(nullptr); pointAreaNormalsPtr_.reset(nullptr); - deleteDemandDrivenData(faceCurvaturesPtr_); - deleteDemandDrivenData(edgeTransformTensorsPtr_); + faceCurvaturesPtr_.reset(nullptr); + edgeTransformTensorsPtr_.reset(nullptr); } @@ -272,9 +270,9 @@ void Foam::faMesh::clearGeom() const DebugInFunction << "Clearing geometry" << endl; clearGeomNotAreas(); - deleteDemandDrivenData(S0Ptr_); - deleteDemandDrivenData(S00Ptr_); - deleteDemandDrivenData(correctPatchPointNormalsPtr_); + S0Ptr_.reset(nullptr); + S00Ptr_.reset(nullptr); + correctPatchPointNormalsPtr_.reset(nullptr); } @@ -282,7 +280,7 @@ void Foam::faMesh::clearAddressing() const { DebugInFunction << "Clearing addressing" << endl; - deleteDemandDrivenData(lduPtr_); + lduPtr_.reset(nullptr); } @@ -402,33 +400,7 @@ Foam::faMesh::faMesh *this ), comm_(UPstream::worldComm), - curTimeIndex_(time().timeIndex()), - - patchPtr_(nullptr), - polyPatchFacesPtr_(nullptr), - polyPatchIdsPtr_(nullptr), - bndConnectPtr_(nullptr), - lduPtr_(nullptr), - - SPtr_(nullptr), - S0Ptr_(nullptr), - S00Ptr_(nullptr), - patchStartsPtr_(nullptr), - LePtr_(nullptr), - magLePtr_(nullptr), - faceCentresPtr_(nullptr), - edgeCentresPtr_(nullptr), - faceAreaNormalsPtr_(nullptr), - edgeAreaNormalsPtr_(nullptr), - pointAreaNormalsPtr_(nullptr), - faceCurvaturesPtr_(nullptr), - edgeTransformTensorsPtr_(nullptr), - correctPatchPointNormalsPtr_(nullptr), - globalMeshDataPtr_(nullptr), - - haloMapPtr_(nullptr), - haloFaceCentresPtr_(nullptr), - haloFaceNormalsPtr_(nullptr) + curTimeIndex_(time().timeIndex()) { DebugInFunction << "Creating from IOobject" << endl; @@ -459,7 +431,7 @@ Foam::faMesh::faMesh rio.resetHeader("S0"); if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false))) { - S0Ptr_ = new DimensionedField<scalar, areaMesh> + S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>> ( rio, *this, @@ -524,33 +496,7 @@ Foam::faMesh::faMesh label(0) ), comm_(UPstream::worldComm), - curTimeIndex_(time().timeIndex()), - - patchPtr_(nullptr), - polyPatchFacesPtr_(nullptr), - polyPatchIdsPtr_(nullptr), - bndConnectPtr_(nullptr), - lduPtr_(nullptr), - - SPtr_(nullptr), - S0Ptr_(nullptr), - S00Ptr_(nullptr), - patchStartsPtr_(nullptr), - LePtr_(nullptr), - magLePtr_(nullptr), - faceCentresPtr_(nullptr), - edgeCentresPtr_(nullptr), - faceAreaNormalsPtr_(nullptr), - edgeAreaNormalsPtr_(nullptr), - pointAreaNormalsPtr_(nullptr), - faceCurvaturesPtr_(nullptr), - edgeTransformTensorsPtr_(nullptr), - correctPatchPointNormalsPtr_(nullptr), - globalMeshDataPtr_(nullptr), - - haloMapPtr_(nullptr), - haloFaceCentresPtr_(nullptr), - haloFaceNormalsPtr_(nullptr) + curTimeIndex_(time().timeIndex()) { // Not yet much for primitive mesh data possible... nPoints_ = 0; @@ -609,33 +555,7 @@ Foam::faMesh::faMesh label(0) ), comm_(UPstream::worldComm), - curTimeIndex_(time().timeIndex()), - - patchPtr_(nullptr), - polyPatchFacesPtr_(nullptr), - polyPatchIdsPtr_(nullptr), - bndConnectPtr_(nullptr), - lduPtr_(nullptr), - - SPtr_(nullptr), - S0Ptr_(nullptr), - S00Ptr_(nullptr), - patchStartsPtr_(nullptr), - LePtr_(nullptr), - magLePtr_(nullptr), - faceCentresPtr_(nullptr), - edgeCentresPtr_(nullptr), - faceAreaNormalsPtr_(nullptr), - edgeAreaNormalsPtr_(nullptr), - pointAreaNormalsPtr_(nullptr), - faceCurvaturesPtr_(nullptr), - edgeTransformTensorsPtr_(nullptr), - correctPatchPointNormalsPtr_(nullptr), - globalMeshDataPtr_(nullptr), - - haloMapPtr_(nullptr), - haloFaceCentresPtr_(nullptr), - haloFaceNormalsPtr_(nullptr) + curTimeIndex_(time().timeIndex()) { // Not yet much for primitive mesh data possible... nPoints_ = 0; @@ -732,7 +652,7 @@ Foam::faMesh::faMesh rio.resetHeader("S0"); if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false))) { - S0Ptr_ = new DimensionedField<scalar, areaMesh> + S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>> ( rio, *this, @@ -948,7 +868,7 @@ Foam::faMesh::S00() const { if (!S00Ptr_) { - S00Ptr_ = new DimensionedField<scalar, areaMesh> + S00Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>> ( IOobject ( @@ -994,7 +914,7 @@ const Foam::vectorField& Foam::faMesh::pointAreaNormals() const { if (!pointAreaNormalsPtr_) { - pointAreaNormalsPtr_.reset(new vectorField(nPoints())); + pointAreaNormalsPtr_ = std::make_unique<vectorField>(nPoints()); calcPointAreaNormals(*pointAreaNormalsPtr_); @@ -1082,7 +1002,7 @@ bool Foam::faMesh::movePoints() { DebugInfo<< "Creating old cell volumes." << endl; - S0Ptr_ = new DimensionedField<scalar, areaMesh> + S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>> ( IOobject ( @@ -1140,7 +1060,8 @@ Foam::boolList& Foam::faMesh::correctPatchPointNormals() const { if (!correctPatchPointNormalsPtr_) { - correctPatchPointNormalsPtr_ = new boolList(boundary().size(), false); + correctPatchPointNormalsPtr_ = + std::make_unique<boolList>(boundary().size(), false); } return *correctPatchPointNormalsPtr_; diff --git a/src/finiteArea/faMesh/faMesh.H b/src/finiteArea/faMesh/faMesh.H index f5879735308..34e1352250f 100644 --- a/src/finiteArea/faMesh/faMesh.H +++ b/src/finiteArea/faMesh/faMesh.H @@ -261,52 +261,53 @@ class faMesh mutable std::unique_ptr<List<labelPair>> bndConnectPtr_; //- Ldu addressing data - mutable faMeshLduAddressing* lduPtr_; + mutable std::unique_ptr<faMeshLduAddressing> lduPtr_; // Geometric Data //- Face areas - mutable DimensionedField<scalar, areaMesh>* SPtr_; + mutable std::unique_ptr<DimensionedField<scalar, areaMesh>> SPtr_; //- Face areas old time level - mutable DimensionedField<scalar, areaMesh>* S0Ptr_; + mutable std::unique_ptr<DimensionedField<scalar, areaMesh>> S0Ptr_; //- Face areas old-old time level - mutable DimensionedField<scalar, areaMesh>* S00Ptr_; + mutable std::unique_ptr<DimensionedField<scalar, areaMesh>> S00Ptr_; //- Patch starts in the edge list - mutable labelList* patchStartsPtr_; + mutable std::unique_ptr<labelList> patchStartsPtr_; //- Edge length vectors - mutable edgeVectorField* LePtr_; + mutable std::unique_ptr<edgeVectorField> LePtr_; //- Mag edge length vectors - mutable edgeScalarField* magLePtr_; + mutable std::unique_ptr<edgeScalarField> magLePtr_; //- Face centres - mutable areaVectorField* faceCentresPtr_; + mutable std::unique_ptr<areaVectorField> faceCentresPtr_; //- Edge centres - mutable edgeVectorField* edgeCentresPtr_; + mutable std::unique_ptr<edgeVectorField> edgeCentresPtr_; //- Face area normals - mutable areaVectorField* faceAreaNormalsPtr_; + mutable std::unique_ptr<areaVectorField> faceAreaNormalsPtr_; //- Edge area normals - mutable edgeVectorField* edgeAreaNormalsPtr_; + mutable std::unique_ptr<edgeVectorField> edgeAreaNormalsPtr_; //- Point area normals mutable std::unique_ptr<vectorField> pointAreaNormalsPtr_; //- Face curvatures - mutable areaScalarField* faceCurvaturesPtr_; + mutable std::unique_ptr<areaScalarField> faceCurvaturesPtr_; //- Edge transformation tensors - mutable FieldField<Field, tensor>* edgeTransformTensorsPtr_; + mutable std::unique_ptr<FieldField<Field, tensor>> + edgeTransformTensorsPtr_; //- Whether point normals must be corrected for a patch - mutable boolList* correctPatchPointNormalsPtr_; + mutable std::unique_ptr<boolList> correctPatchPointNormalsPtr_; // Other mesh-related data diff --git a/src/finiteArea/faMesh/faMeshDemandDrivenData.C b/src/finiteArea/faMesh/faMeshDemandDrivenData.C index 3f94292886e..49b60d40180 100644 --- a/src/finiteArea/faMesh/faMeshDemandDrivenData.C +++ b/src/finiteArea/faMesh/faMeshDemandDrivenData.C @@ -222,7 +222,7 @@ void Foam::faMesh::calcLduAddressing() const << abort(FatalError); } - lduPtr_ = new faMeshLduAddressing(*this); + lduPtr_ = std::make_unique<faMeshLduAddressing>(*this); } @@ -238,7 +238,7 @@ void Foam::faMesh::calcPatchStarts() const << abort(FatalError); } - patchStartsPtr_ = new labelList(boundary().patchStarts()); + patchStartsPtr_ = std::make_unique<labelList>(boundary().patchStarts()); } @@ -254,9 +254,9 @@ void Foam::faMesh::calcWhichPatchFaces() const const polyBoundaryMesh& pbm = mesh().boundaryMesh(); - polyPatchFacesPtr_.reset + polyPatchFacesPtr_ = std::make_unique<List<labelPair>> ( - new List<labelPair>(pbm.whichPatchFace(faceLabels_)) + pbm.whichPatchFace(faceLabels_) ); labelHashSet ids; @@ -278,7 +278,7 @@ void Foam::faMesh::calcWhichPatchFaces() const this->comm() ); - polyPatchIdsPtr_.reset(new labelList(ids.sortedToc())); + polyPatchIdsPtr_ = std::make_unique<labelList>(ids.sortedToc()); } @@ -675,23 +675,22 @@ void Foam::faMesh::calcLe() const << abort(FatalError); } - LePtr_ = - new edgeVectorField + LePtr_ = std::make_unique<edgeVectorField> + ( + IOobject ( - IOobject - ( - "Le", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimLength - // -> calculatedType() - ); + "Le", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimLength + // -> calculatedType() + ); edgeVectorField& Le = *LePtr_; // Need face centres @@ -773,23 +772,21 @@ void Foam::faMesh::calcMagLe() const << abort(FatalError); } - magLePtr_ = - new edgeScalarField + magLePtr_ = std::make_unique<edgeScalarField> + ( + IOobject ( - IOobject - ( - "magLe", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimLength - ); - + "magLe", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimLength + ); edgeScalarField& magLe = *magLePtr_; const pointField& localPoints = points(); @@ -849,24 +846,22 @@ void Foam::faMesh::calcFaceCentres() const << abort(FatalError); } - faceCentresPtr_ = - new areaVectorField + faceCentresPtr_ = std::make_unique<areaVectorField> + ( + IOobject ( - IOobject - ( - "centres", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimLength - // -> calculatedType() - ); - + "centres", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimLength + // -> calculatedType() + ); areaVectorField& centres = *faceCentresPtr_; // Need local points @@ -931,24 +926,22 @@ void Foam::faMesh::calcEdgeCentres() const << abort(FatalError); } - edgeCentresPtr_ = - new edgeVectorField + edgeCentresPtr_ = std::make_unique<edgeVectorField> + ( + IOobject ( - IOobject - ( - "edgeCentres", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimLength - // -> calculatedType() - ); - + "edgeCentres", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimLength + // -> calculatedType() + ); edgeVectorField& centres = *edgeCentresPtr_; // Need local points @@ -996,7 +989,7 @@ void Foam::faMesh::calcS() const << abort(FatalError); } - SPtr_ = new DimensionedField<scalar, areaMesh> + SPtr_ = std::make_unique<DimensionedField<scalar, areaMesh>> ( IOobject ( @@ -1068,23 +1061,21 @@ void Foam::faMesh::calcFaceAreaNormals() const << abort(FatalError); } - faceAreaNormalsPtr_ = - new areaVectorField + faceAreaNormalsPtr_ = std::make_unique<areaVectorField> + ( + IOobject ( - IOobject - ( - "faceAreaNormals", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimless - ); - + "faceAreaNormals", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimless + ); areaVectorField& faceNormals = *faceAreaNormalsPtr_; const pointField& localPoints = points(); @@ -1149,23 +1140,22 @@ void Foam::faMesh::calcEdgeAreaNormals() const << abort(FatalError); } - edgeAreaNormalsPtr_ = - new edgeVectorField + edgeAreaNormalsPtr_ = std::make_unique<edgeVectorField> + ( + IOobject ( - IOobject - ( - "edgeAreaNormals", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimless - // -> calculatedType() - ); + "edgeAreaNormals", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimless + // -> calculatedType() + ); edgeVectorField& edgeAreaNormals = *edgeAreaNormalsPtr_; @@ -1279,23 +1269,21 @@ void Foam::faMesh::calcFaceCurvatures() const << abort(FatalError); } - faceCurvaturesPtr_ = - new areaScalarField + faceCurvaturesPtr_ = std::make_unique<areaScalarField> + ( + IOobject ( - IOobject - ( - "faceCurvatures", - mesh().pointsInstance(), - faMesh::meshSubDir, - faMesh::thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - *this, - dimless/dimLength - ); - + "faceCurvatures", + mesh().pointsInstance(), + faMesh::meshSubDir, + faMesh::thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimless/dimLength + ); areaScalarField& faceCurvatures = *faceCurvaturesPtr_; @@ -1321,7 +1309,8 @@ void Foam::faMesh::calcEdgeTransformTensors() const << abort(FatalError); } - edgeTransformTensorsPtr_ = new FieldField<Field, tensor>(nEdges_); + edgeTransformTensorsPtr_ = + std::make_unique<FieldField<Field, tensor>>(nEdges_); auto& edgeTransformTensors = *edgeTransformTensorsPtr_; // Initialize all transformation tensors diff --git a/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C b/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C index e079de2bab5..f575d1a6e87 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C +++ b/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C @@ -61,10 +61,18 @@ void Foam::faAreaMapper::calcAddressing() const // Prepare a list of new face labels and (preliminary) addressing // Note: dimensioned to number of boundary faces of polyMesh - newFaceLabelsPtr_ = new labelList(mesh_.mesh().nBoundaryFaces(), -1); - labelList& newFaceLabels = *newFaceLabelsPtr_; + newFaceLabelsPtr_ = std::make_unique<labelList> + ( + mesh_.mesh().nBoundaryFaces(), + -1 + ); + auto& newFaceLabels = *newFaceLabelsPtr_; - newFaceLabelsMapPtr_ = new labelList(mesh_.mesh().nBoundaryFaces(), -1); + newFaceLabelsMapPtr_ = std::make_unique<labelList> + ( + mesh_.mesh().nBoundaryFaces(), + -1 + ); labelList& newFaceLabelsMap = *newFaceLabelsMapPtr_; label nNewFaces = 0; @@ -94,7 +102,7 @@ void Foam::faAreaMapper::calcAddressing() const // Direct mapping: no further faces to add. Resize list newFaceLabels.setSize(nNewFaces); - directAddrPtr_ = new labelList(newFaceLabels.size()); + directAddrPtr_ = std::make_unique<labelList>(newFaceLabels.size()); labelList& addr = *directAddrPtr_; // Adjust for creation of a boundary face from an internal face @@ -114,10 +122,13 @@ void Foam::faAreaMapper::calcAddressing() const { // There are further faces to add. Prepare interpolation addressing // and weights to full size - interpolationAddrPtr_ = new labelListList(newFaceLabels.size()); + interpolationAddrPtr_ = std::make_unique<labelListList> + ( + newFaceLabels.size() + ); labelListList& addr = *interpolationAddrPtr_; - weightsPtr_ = new scalarListList(newFaceLabels.size()); + weightsPtr_ = std::make_unique<scalarListList>(newFaceLabels.size()); scalarListList& w = *weightsPtr_; // Insert single addressing and weights @@ -256,20 +267,20 @@ void Foam::faAreaMapper::calcAddressing() const // Inserted objects cannot appear in the new faMesh as they have no master // HJ, 10/Aug/2011 - insertedObjectLabelsPtr_ = new labelList(0); + insertedObjectLabelsPtr_ = std::make_unique<labelList>(); } void Foam::faAreaMapper::clearOut() { - deleteDemandDrivenData(newFaceLabelsPtr_); - deleteDemandDrivenData(newFaceLabelsMapPtr_); + newFaceLabelsPtr_.reset(nullptr); + newFaceLabelsMapPtr_.reset(nullptr); - deleteDemandDrivenData(directAddrPtr_); - deleteDemandDrivenData(interpolationAddrPtr_); - deleteDemandDrivenData(weightsPtr_); + directAddrPtr_.reset(nullptr); + interpolationAddrPtr_.reset(nullptr); + weightsPtr_.reset(nullptr); - deleteDemandDrivenData(insertedObjectLabelsPtr_); + insertedObjectLabelsPtr_.reset(nullptr); hasUnmapped_ = false; } @@ -286,13 +297,7 @@ Foam::faAreaMapper::faAreaMapper mpm_(mpm), direct_(false), hasUnmapped_(false), - sizeBeforeMapping_(mesh.nFaces()), - newFaceLabelsPtr_(nullptr), - newFaceLabelsMapPtr_(nullptr), - directAddrPtr_(nullptr), - interpolationAddrPtr_(nullptr), - weightsPtr_(nullptr), - insertedObjectLabelsPtr_(nullptr) + sizeBeforeMapping_(mesh.nFaces()) { // Check for possibility of direct mapping if diff --git a/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.H b/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.H index 7569df58f77..9a75decf955 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.H +++ b/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.H @@ -77,23 +77,23 @@ class faAreaMapper label sizeBeforeMapping_; //- New face labels after mapping - mutable labelList* newFaceLabelsPtr_; + mutable std::unique_ptr<labelList> newFaceLabelsPtr_; //- New face labels after mapping - mutable labelList* newFaceLabelsMapPtr_; + mutable std::unique_ptr<labelList> newFaceLabelsMapPtr_; //- Direct addressing (only one form of addressing is used) - mutable labelList* directAddrPtr_; + mutable std::unique_ptr<labelList> directAddrPtr_; //- Interpolated addressing (only one form of addressing is used) - mutable labelListList* interpolationAddrPtr_; + mutable std::unique_ptr<labelListList> interpolationAddrPtr_; //- Interpolation weights - mutable scalarListList* weightsPtr_; + mutable std::unique_ptr<scalarListList> weightsPtr_; //- Inserted faces - mutable labelList* insertedObjectLabelsPtr_; + mutable std::unique_ptr<labelList> insertedObjectLabelsPtr_; // Private Member Functions @@ -127,7 +127,6 @@ public: //- Destructor virtual ~faAreaMapper(); - // Member Functions //- Return new face labels diff --git a/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.C b/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.C index 582faf239a3..2dffd9ed7b2 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.C +++ b/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.C @@ -43,13 +43,13 @@ void Foam::faEdgeMapper::calcAddressing() const hasUnmapped_ = false; // Dummy mapping: take value from edge 0 - directAddrPtr_ = new labelList(size(), Zero); + directAddrPtr_ = std::make_unique<labelList>(size(), Foam::zero{}); } void Foam::faEdgeMapper::clearOut() { - deleteDemandDrivenData(directAddrPtr_); + directAddrPtr_.reset(nullptr); hasUnmapped_ = false; } @@ -64,8 +64,7 @@ Foam::faEdgeMapper::faEdgeMapper : mesh_(mesh), sizeBeforeMapping_(mesh.nInternalEdges()), - hasUnmapped_(false), - directAddrPtr_(nullptr) + hasUnmapped_(false) {} diff --git a/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.H b/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.H index 620795a0e81..05f0cd0fda9 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.H +++ b/src/finiteArea/faMesh/faMeshMapper/faEdgeMapper.H @@ -74,7 +74,7 @@ class faEdgeMapper mutable bool hasUnmapped_; //- Direct addressing - mutable labelList* directAddrPtr_; + mutable std::unique_ptr<labelList> directAddrPtr_; // Private Member Functions diff --git a/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C b/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C index b54faafc132..69aa3177f66 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C +++ b/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.C @@ -43,7 +43,7 @@ void Foam::faPatchMapper::calcAddressing() const // Compatibility change HJ, 12/Aug/2017 hasUnmapped_ = false; - directAddrPtr_ = new labelList(patch_.size(), Zero); + directAddrPtr_ = std::make_unique<labelList>(patch_.size(), Foam::zero{}); labelList& addr = *directAddrPtr_; // Make a map of old edgeFaces, giving edge index in patch given the new @@ -86,7 +86,7 @@ void Foam::faPatchMapper::calcAddressing() const void Foam::faPatchMapper::clearOut() { - deleteDemandDrivenData(directAddrPtr_); + directAddrPtr_.reset(nullptr); hasUnmapped_ = false; } @@ -103,8 +103,7 @@ Foam::faPatchMapper::faPatchMapper mpm_(mpm), sizeBeforeMapping_(patch.size()), oldEdgeFaces_(patch.edgeFaces()), - hasUnmapped_(false), - directAddrPtr_(nullptr) + hasUnmapped_(false) {} diff --git a/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.H b/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.H index 8672301bd8b..b27bd6874df 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.H +++ b/src/finiteArea/faMesh/faMeshMapper/faPatchMapper.H @@ -83,7 +83,7 @@ class faPatchMapper mutable bool hasUnmapped_; //- Direct addressing - mutable labelList* directAddrPtr_; + mutable std::unique_ptr<labelList> directAddrPtr_; // Private Member Functions diff --git a/src/finiteArea/faMesh/faMeshTopology.C b/src/finiteArea/faMesh/faMeshTopology.C index 9c85727b5a1..c9dbb6b130b 100644 --- a/src/finiteArea/faMesh/faMeshTopology.C +++ b/src/finiteArea/faMesh/faMeshTopology.C @@ -849,9 +849,10 @@ void Foam::faMesh::setBoundaryConnections << abort(FatalError); } - bndConnectPtr_.reset + bndConnectPtr_ = std::make_unique<List<labelPair>> ( - new List<labelPair>(nBoundaryEdges, labelPair(-1,-1)) + nBoundaryEdges, + labelPair(-1,-1) ); auto& bndConnect = *bndConnectPtr_; @@ -989,7 +990,7 @@ const Foam::faMeshBoundaryHalo& Foam::faMesh::boundaryHaloMap() const { if (!haloMapPtr_) { - haloMapPtr_.reset(new faMeshBoundaryHalo(*this)); + haloMapPtr_ = std::make_unique<faMeshBoundaryHalo>(*this); } return *haloMapPtr_; @@ -1022,8 +1023,8 @@ void Foam::faMesh::calcHaloFaceGeometry() const const labelList& inputFaceIds = halo.inputMeshFaces(); - haloFaceCentresPtr_.reset(new pointField); - haloFaceNormalsPtr_.reset(new vectorField); + haloFaceCentresPtr_ = std::make_unique<pointField>(); + haloFaceNormalsPtr_ = std::make_unique<vectorField>(); auto& centres = *haloFaceCentresPtr_; auto& normals = *haloFaceNormalsPtr_; diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C index 39c1627d59b..1f0248689a7 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.C @@ -105,10 +105,7 @@ Foam::faPatch::faPatch patchIdentifier(name, index), labelList(edgeLabels), nbrPolyPatchId_(nbrPolyPatchi), - boundaryMesh_(bm), - edgeFacesPtr_(nullptr), - pointLabelsPtr_(nullptr), - pointEdgesPtr_(nullptr) + boundaryMesh_(bm) { if (constraintType(patchType)) { @@ -129,10 +126,7 @@ Foam::faPatch::faPatch patchIdentifier(name, dict, index), labelList(dict.get<labelList>("edgeLabels")), nbrPolyPatchId_(dict.get<label>("ngbPolyPatchIndex")), - boundaryMesh_(bm), - edgeFacesPtr_(nullptr), - pointLabelsPtr_(nullptr), - pointEdgesPtr_(nullptr) + boundaryMesh_(bm) { if (constraintType(patchType)) { @@ -153,10 +147,7 @@ Foam::faPatch::faPatch patchIdentifier(p, index), labelList(edgeLabels), nbrPolyPatchId_(p.nbrPolyPatchId_), - boundaryMesh_(bm), - edgeFacesPtr_(nullptr), - pointLabelsPtr_(nullptr), - pointEdgesPtr_(nullptr) + boundaryMesh_(bm) {} @@ -331,7 +322,7 @@ void Foam::faPatch::calcPointLabels() const } // Transfer to plain list (reuse storage) - pointLabelsPtr_.reset(new labelList(std::move(dynEdgePoints))); + pointLabelsPtr_ = std::make_unique<labelList>(std::move(dynEdgePoints)); /// const auto& edgePoints = *pointLabelsPtr_; /// @@ -381,7 +372,7 @@ void Foam::faPatch::calcPointEdges() const } // Flatten to regular list - pointEdgesPtr_.reset(new labelListList(edgePoints.size())); + pointEdgesPtr_ = std::make_unique<labelListList>(edgePoints.size()); auto& pEdges = *pointEdgesPtr_; forAll(pEdges, pointi) @@ -441,12 +432,9 @@ const Foam::labelUList& Foam::faPatch::edgeFaces() const { if (!edgeFacesPtr_) { - edgeFacesPtr_.reset + edgeFacesPtr_ = std::make_unique<labelList::subList> ( - new labelList::subList - ( - patchSlice(boundaryMesh().mesh().edgeOwner()) - ) + patchSlice(boundaryMesh().mesh().edgeOwner()) ); } diff --git a/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.C b/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.C index 10d4aff3683..f0718e17e18 100644 --- a/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.C +++ b/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.C @@ -43,21 +43,10 @@ namespace Foam Foam::leastSquaresFaVectors::leastSquaresFaVectors(const faMesh& mesh) : - MeshObject<faMesh, Foam::MoveableMeshObject, leastSquaresFaVectors>(mesh), - pVectorsPtr_(nullptr), - nVectorsPtr_(nullptr) + MeshObject<faMesh, Foam::MoveableMeshObject, leastSquaresFaVectors>(mesh) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::leastSquaresFaVectors::~leastSquaresFaVectors() -{ - deleteDemandDrivenData(pVectorsPtr_); - deleteDemandDrivenData(nVectorsPtr_); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const @@ -66,7 +55,7 @@ void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const << "Constructing finite area (invDist) least square gradient vectors" << nl; - pVectorsPtr_ = new edgeVectorField + pVectorsPtr_ = std::make_unique<edgeVectorField> ( IOobject ( @@ -82,7 +71,7 @@ void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const ); auto& lsP = *pVectorsPtr_; - nVectorsPtr_ = new edgeVectorField + nVectorsPtr_ = std::make_unique<edgeVectorField> ( IOobject ( @@ -236,8 +225,8 @@ bool Foam::leastSquaresFaVectors::movePoints() DebugInFunction << "Clearing least square data" << nl; - deleteDemandDrivenData(pVectorsPtr_); - deleteDemandDrivenData(nVectorsPtr_); + pVectorsPtr_.reset(nullptr); + nVectorsPtr_.reset(nullptr); return true; } diff --git a/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.H b/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.H index 9b032a5167f..701dcf29aea 100644 --- a/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.H +++ b/src/finiteArea/finiteArea/gradSchemes/leastSquaresFaGrad/leastSquaresFaVectors.H @@ -60,8 +60,8 @@ class leastSquaresFaVectors // Private Data //- Least-squares gradient vectors - mutable edgeVectorField* pVectorsPtr_; - mutable edgeVectorField* nVectorsPtr_; + mutable std::unique_ptr<edgeVectorField> pVectorsPtr_; + mutable std::unique_ptr<edgeVectorField> nVectorsPtr_; // Private Member Functions @@ -83,7 +83,7 @@ public: //- Destructor - virtual ~leastSquaresFaVectors(); + virtual ~leastSquaresFaVectors() = default; // Member functions diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C index 4bdedcf6b73..5da45321ce3 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C +++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C @@ -37,79 +37,55 @@ namespace Foam defineTypeNameAndDebug(edgeInterpolation, 0); } -// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // - -void Foam::edgeInterpolation::clearOut() -{ - deleteDemandDrivenData(lPN_); - deleteDemandDrivenData(weightingFactors_); - deleteDemandDrivenData(differenceFactors_); - deleteDemandDrivenData(correctionVectors_); - deleteDemandDrivenData(skewCorrectionVectors_); -} - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::edgeInterpolation::edgeInterpolation(const faMesh& fam) : faMesh_(fam), - lPN_(nullptr), - weightingFactors_(nullptr), - differenceFactors_(nullptr), - correctionVectors_(nullptr), - skewCorrectionVectors_(nullptr), orthogonal_(false), skew_(true) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::edgeInterpolation::~edgeInterpolation() -{ - clearOut(); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::edgeScalarField& Foam::edgeInterpolation::lPN() const { - if (!lPN_) + if (!lPNptr_) { makeLPN(); } - return (*lPN_); + return (*lPNptr_); } const Foam::edgeScalarField& Foam::edgeInterpolation::weights() const { - if (!weightingFactors_) + if (!weightingFactorsPtr_) { makeWeights(); } - return (*weightingFactors_); + return (*weightingFactorsPtr_); } const Foam::edgeScalarField& Foam::edgeInterpolation::deltaCoeffs() const { - if (!differenceFactors_) + if (!differenceFactorsPtr_) { makeDeltaCoeffs(); } - return (*differenceFactors_); + return (*differenceFactorsPtr_); } bool Foam::edgeInterpolation::orthogonal() const { - if (orthogonal_ == false && !correctionVectors_) + if (orthogonal_ == false && !correctionVectorsPtr_) { makeCorrectionVectors(); } @@ -127,13 +103,13 @@ const Foam::edgeVectorField& Foam::edgeInterpolation::correctionVectors() const << abort(FatalError); } - return (*correctionVectors_); + return (*correctionVectorsPtr_); } bool Foam::edgeInterpolation::skew() const { - if (skew_ == true && !skewCorrectionVectors_) + if (skew_ == true && !skewCorrectionVectorsPtr_) { makeSkewCorrectionVectors(); } @@ -152,21 +128,21 @@ Foam::edgeInterpolation::skewCorrectionVectors() const << abort(FatalError); } - return (*skewCorrectionVectors_); + return (*skewCorrectionVectorsPtr_); } bool Foam::edgeInterpolation::movePoints() const { - deleteDemandDrivenData(lPN_); - deleteDemandDrivenData(weightingFactors_); - deleteDemandDrivenData(differenceFactors_); + lPNptr_.reset(nullptr); + weightingFactorsPtr_.reset(nullptr); + differenceFactorsPtr_.reset(nullptr); orthogonal_ = false; - deleteDemandDrivenData(correctionVectors_); + correctionVectorsPtr_.reset(nullptr); skew_ = true; - deleteDemandDrivenData(skewCorrectionVectors_); + skewCorrectionVectorsPtr_.reset(nullptr); return true; } @@ -178,14 +154,14 @@ const Foam::vector& Foam::edgeInterpolation::skewCorr(const label edgeI) const return ( - skewCorrectionVectors_ - ? (*skewCorrectionVectors_)[edgeI] + skewCorrectionVectorsPtr_ + ? (*skewCorrectionVectorsPtr_)[edgeI] : pTraits<vector>::zero ); #else - return (*skewCorrectionVectors_)[edgeI]; + return (*skewCorrectionVectorsPtr_)[edgeI]; #endif } @@ -198,7 +174,7 @@ void Foam::edgeInterpolation::makeLPN() const << endl; - lPN_ = new edgeScalarField + lPNptr_ = std::make_unique<edgeScalarField> ( IOobject ( @@ -212,7 +188,7 @@ void Foam::edgeInterpolation::makeLPN() const mesh(), dimLength ); - edgeScalarField& lPN = *lPN_; + edgeScalarField& lPN = *lPNptr_; // Set local references to mesh data const edgeVectorField& edgeCentres = mesh().edgeCentres(); @@ -279,7 +255,7 @@ void Foam::edgeInterpolation::makeWeights() const << endl; - weightingFactors_ = new edgeScalarField + weightingFactorsPtr_ = std::make_unique<edgeScalarField> ( IOobject ( @@ -293,7 +269,7 @@ void Foam::edgeInterpolation::makeWeights() const mesh(), dimensionedScalar(dimless, 1) ); - edgeScalarField& weightingFactors = *weightingFactors_; + edgeScalarField& weightingFactors = *weightingFactorsPtr_; // Set local references to mesh data @@ -359,11 +335,11 @@ void Foam::edgeInterpolation::makeDeltaCoeffs() const // needed to make sure deltaCoeffs are calculated for parallel runs. weights(); - differenceFactors_ = new edgeScalarField + differenceFactorsPtr_ = std::make_unique<edgeScalarField> ( IOobject ( - "differenceFactors_", + "differenceFactors", mesh().pointsInstance(), mesh().thisDb(), IOobject::NO_READ, @@ -373,7 +349,7 @@ void Foam::edgeInterpolation::makeDeltaCoeffs() const mesh(), dimensionedScalar(dimless/dimLength, SMALL) ); - edgeScalarField& DeltaCoeffs = *differenceFactors_; + edgeScalarField& DeltaCoeffs = *differenceFactorsPtr_; scalarField& dc = DeltaCoeffs.primitiveFieldRef(); // Set local references to mesh data @@ -453,7 +429,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const << "Constructing non-orthogonal correction vectors" << endl; - correctionVectors_ = new edgeVectorField + correctionVectorsPtr_ = std::make_unique<edgeVectorField> ( IOobject ( @@ -467,7 +443,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const mesh(), dimless ); - edgeVectorField& CorrVecs = *correctionVectors_; + edgeVectorField& CorrVecs = *correctionVectorsPtr_; // Set local references to mesh data const areaVectorField& faceCentres = mesh().areaCentres(); @@ -541,7 +517,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const if (NonOrthogCoeff < 0.1) { orthogonal_ = true; - deleteDemandDrivenData(correctionVectors_); + correctionVectorsPtr_.reset(nullptr); } else { @@ -560,7 +536,7 @@ void Foam::edgeInterpolation::makeSkewCorrectionVectors() const << "Constructing skew correction vectors" << endl; - skewCorrectionVectors_ = new edgeVectorField + skewCorrectionVectorsPtr_ = std::make_unique<edgeVectorField> ( IOobject ( @@ -574,7 +550,7 @@ void Foam::edgeInterpolation::makeSkewCorrectionVectors() const mesh(), dimensionedVector(dimless, Zero) ); - edgeVectorField& SkewCorrVecs = *skewCorrectionVectors_; + edgeVectorField& SkewCorrVecs = *skewCorrectionVectorsPtr_; // Set local references to mesh data const areaVectorField& C = mesh().areaCentres(); @@ -698,12 +674,12 @@ void Foam::edgeInterpolation::makeSkewCorrectionVectors() const if (skewCoeff < maxSkewRatio) { - deleteDemandDrivenData(skewCorrectionVectors_); + skewCorrectionVectorsPtr_.reset(nullptr); } #endif - skew_ = bool(skewCorrectionVectors_); + skew_ = bool(skewCorrectionVectorsPtr_); DebugInFunction diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.H b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.H index f33a44cbf7c..689b1384d47 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.H +++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.H @@ -68,19 +68,19 @@ class edgeInterpolation // Demand-driven data //- Geodesic distance between centroids of neighbour finite areas - mutable edgeScalarField* lPN_; + mutable std::unique_ptr<edgeScalarField> lPNptr_; //- Central-differencing weighting factors - mutable edgeScalarField* weightingFactors_; + mutable std::unique_ptr<edgeScalarField> weightingFactorsPtr_; //- Face-gradient difference factors - mutable edgeScalarField* differenceFactors_; + mutable std::unique_ptr<edgeScalarField> differenceFactorsPtr_; //- Non-orthogonality correction vectors - mutable edgeVectorField* correctionVectors_; + mutable std::unique_ptr<edgeVectorField> correctionVectorsPtr_; //- Skew correction vectors - mutable edgeVectorField* skewCorrectionVectors_; + mutable std::unique_ptr<edgeVectorField> skewCorrectionVectorsPtr_; //- Is mesh orthogonal mutable bool orthogonal_; @@ -110,16 +110,6 @@ class edgeInterpolation void makeSkewCorrectionVectors() const; -protected: - - // Protected Member Functions - - // Storage Management - - //- Clear all geometry and addressing - void clearOut(); - - public: // Declare name of the class and it's debug switch @@ -142,7 +132,7 @@ public: //- Destructor - ~edgeInterpolation(); + ~edgeInterpolation() = default; // Member Functions @@ -181,7 +171,7 @@ public: // Storage Management //- True if weights exist - bool hasWeights() const noexcept { return bool(weightingFactors_); } + bool hasWeights() const noexcept { return bool(weightingFactorsPtr_); } }; -- GitLab