ENH: finiteArea: replace raw pointers with unique_ptr

This commit is contained in:
Kutalmis Bercin
2024-02-27 13:40:27 +00:00
committed by Andrew Heather
parent cd8bc891f0
commit 47232ccf66
18 changed files with 257 additions and 404 deletions

View File

@ -84,10 +84,10 @@ void Foam::faMeshDistributor::createInternalEdgeMap() const
const auto& faEdgeMap = distMap_.faceMap(); const auto& faEdgeMap = distMap_.faceMap();
// Copy full map // Copy full map
internalEdgeMap_.reset(new mapDistributeBase(faEdgeMap)); internalEdgeMapPtr_ = std::make_unique<mapDistributeBase>(faEdgeMap);
// Retain internal edges // Retain internal edges
internalEdgeMap_->compactRemoteData internalEdgeMapPtr_->compactRemoteData
( (
bitSet(tgtMesh_.nInternalEdges(), true), bitSet(tgtMesh_.nInternalEdges(), true),
UPstream::msgType(), UPstream::msgType(),
@ -200,8 +200,6 @@ Foam::faMeshDistributor::faMeshDistributor
srcMesh_(srcMesh), srcMesh_(srcMesh),
tgtMesh_(tgtMesh), tgtMesh_(tgtMesh),
distMap_(distMap), distMap_(distMap),
internalEdgeMap_(),
patchEdgeMaps_(),
dummyHandler_(fileOperation::null()), dummyHandler_(fileOperation::null()),
writeHandler_(dummyHandler_), writeHandler_(dummyHandler_),
isWriteProc_(isWriteProc) isWriteProc_(isWriteProc)
@ -221,8 +219,6 @@ Foam::faMeshDistributor::faMeshDistributor
srcMesh_(srcMesh), srcMesh_(srcMesh),
tgtMesh_(tgtMesh), tgtMesh_(tgtMesh),
distMap_(distMap), distMap_(distMap),
internalEdgeMap_(),
patchEdgeMaps_(),
dummyHandler_(nullptr), dummyHandler_(nullptr),
writeHandler_(writeHandler), writeHandler_(writeHandler),
isWriteProc_(Switch::INVALID) isWriteProc_(Switch::INVALID)

View File

@ -73,7 +73,7 @@ class faMeshDistributor
const mapDistributePolyMesh& distMap_; const mapDistributePolyMesh& distMap_;
//- Internal edge mapper //- Internal edge mapper
mutable std::unique_ptr<mapDistributeBase> internalEdgeMap_; mutable std::unique_ptr<mapDistributeBase> internalEdgeMapPtr_;
//- Patch edge mappers //- Patch edge mappers
mutable PtrList<mapDistributeBase> patchEdgeMaps_; mutable PtrList<mapDistributeBase> patchEdgeMaps_;

View File

@ -154,7 +154,7 @@ Foam::faMeshDistributor::distributeField
const GeometricField<Type, faePatchField, edgeMesh>& fld const GeometricField<Type, faePatchField, edgeMesh>& fld
) const ) const
{ {
if (!internalEdgeMap_) if (!internalEdgeMapPtr_)
{ {
createInternalEdgeMap(); createInternalEdgeMap();
} }
@ -165,7 +165,7 @@ Foam::faMeshDistributor::distributeField
const distributedFieldMapper mapper const distributedFieldMapper mapper
( (
labelUList::null(), labelUList::null(),
*(internalEdgeMap_) *(internalEdgeMapPtr_)
); );
DimensionedField<Type, edgeMesh> internalField DimensionedField<Type, edgeMesh> internalField

View File

@ -169,14 +169,12 @@ void Foam::faMesh::checkBoundaryEdgeLabelRange
void Foam::faMesh::initPatch() const 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... // Could set some basic primitive data here...
// nEdges_ = patchPtr_->nEdges(); // nEdges_ = patchPtr_->nEdges();
// nInternalEdges_ = patchPtr_->nInternalEdges(); // nInternalEdges_ = patchPtr_->nInternalEdges();
@ -253,17 +251,17 @@ void Foam::faMesh::clearGeomNotAreas() const
polyPatchFacesPtr_.reset(nullptr); polyPatchFacesPtr_.reset(nullptr);
polyPatchIdsPtr_.reset(nullptr); polyPatchIdsPtr_.reset(nullptr);
bndConnectPtr_.reset(nullptr); bndConnectPtr_.reset(nullptr);
deleteDemandDrivenData(SPtr_); SPtr_.reset(nullptr);
deleteDemandDrivenData(patchStartsPtr_); patchStartsPtr_.reset(nullptr);
deleteDemandDrivenData(LePtr_); LePtr_.reset(nullptr);
deleteDemandDrivenData(magLePtr_); magLePtr_.reset(nullptr);
deleteDemandDrivenData(faceCentresPtr_); faceCentresPtr_.reset(nullptr);
deleteDemandDrivenData(edgeCentresPtr_); edgeCentresPtr_.reset(nullptr);
deleteDemandDrivenData(faceAreaNormalsPtr_); faceAreaNormalsPtr_.reset(nullptr);
deleteDemandDrivenData(edgeAreaNormalsPtr_); edgeAreaNormalsPtr_.reset(nullptr);
pointAreaNormalsPtr_.reset(nullptr); pointAreaNormalsPtr_.reset(nullptr);
deleteDemandDrivenData(faceCurvaturesPtr_); faceCurvaturesPtr_.reset(nullptr);
deleteDemandDrivenData(edgeTransformTensorsPtr_); edgeTransformTensorsPtr_.reset(nullptr);
} }
@ -272,9 +270,9 @@ void Foam::faMesh::clearGeom() const
DebugInFunction << "Clearing geometry" << endl; DebugInFunction << "Clearing geometry" << endl;
clearGeomNotAreas(); clearGeomNotAreas();
deleteDemandDrivenData(S0Ptr_); S0Ptr_.reset(nullptr);
deleteDemandDrivenData(S00Ptr_); S00Ptr_.reset(nullptr);
deleteDemandDrivenData(correctPatchPointNormalsPtr_); correctPatchPointNormalsPtr_.reset(nullptr);
} }
@ -282,7 +280,7 @@ void Foam::faMesh::clearAddressing() const
{ {
DebugInFunction << "Clearing addressing" << endl; DebugInFunction << "Clearing addressing" << endl;
deleteDemandDrivenData(lduPtr_); lduPtr_.reset(nullptr);
} }
@ -402,33 +400,7 @@ Foam::faMesh::faMesh
*this *this
), ),
comm_(UPstream::worldComm), comm_(UPstream::worldComm),
curTimeIndex_(time().timeIndex()), 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)
{ {
DebugInFunction << "Creating from IOobject" << endl; DebugInFunction << "Creating from IOobject" << endl;
@ -459,7 +431,7 @@ Foam::faMesh::faMesh
rio.resetHeader("S0"); rio.resetHeader("S0");
if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false))) if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false)))
{ {
S0Ptr_ = new DimensionedField<scalar, areaMesh> S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
( (
rio, rio,
*this, *this,
@ -524,33 +496,7 @@ Foam::faMesh::faMesh
label(0) label(0)
), ),
comm_(UPstream::worldComm), comm_(UPstream::worldComm),
curTimeIndex_(time().timeIndex()), 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)
{ {
// Not yet much for primitive mesh data possible... // Not yet much for primitive mesh data possible...
nPoints_ = 0; nPoints_ = 0;
@ -609,33 +555,7 @@ Foam::faMesh::faMesh
label(0) label(0)
), ),
comm_(UPstream::worldComm), comm_(UPstream::worldComm),
curTimeIndex_(time().timeIndex()), 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)
{ {
// Not yet much for primitive mesh data possible... // Not yet much for primitive mesh data possible...
nPoints_ = 0; nPoints_ = 0;
@ -732,7 +652,7 @@ Foam::faMesh::faMesh
rio.resetHeader("S0"); rio.resetHeader("S0");
if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false))) if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false)))
{ {
S0Ptr_ = new DimensionedField<scalar, areaMesh> S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
( (
rio, rio,
*this, *this,
@ -948,7 +868,7 @@ Foam::faMesh::S00() const
{ {
if (!S00Ptr_) if (!S00Ptr_)
{ {
S00Ptr_ = new DimensionedField<scalar, areaMesh> S00Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
( (
IOobject IOobject
( (
@ -994,7 +914,7 @@ const Foam::vectorField& Foam::faMesh::pointAreaNormals() const
{ {
if (!pointAreaNormalsPtr_) if (!pointAreaNormalsPtr_)
{ {
pointAreaNormalsPtr_.reset(new vectorField(nPoints())); pointAreaNormalsPtr_ = std::make_unique<vectorField>(nPoints());
calcPointAreaNormals(*pointAreaNormalsPtr_); calcPointAreaNormals(*pointAreaNormalsPtr_);
@ -1082,7 +1002,7 @@ bool Foam::faMesh::movePoints()
{ {
DebugInfo<< "Creating old cell volumes." << endl; DebugInfo<< "Creating old cell volumes." << endl;
S0Ptr_ = new DimensionedField<scalar, areaMesh> S0Ptr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
( (
IOobject IOobject
( (
@ -1140,7 +1060,8 @@ Foam::boolList& Foam::faMesh::correctPatchPointNormals() const
{ {
if (!correctPatchPointNormalsPtr_) if (!correctPatchPointNormalsPtr_)
{ {
correctPatchPointNormalsPtr_ = new boolList(boundary().size(), false); correctPatchPointNormalsPtr_ =
std::make_unique<boolList>(boundary().size(), false);
} }
return *correctPatchPointNormalsPtr_; return *correctPatchPointNormalsPtr_;

View File

@ -261,52 +261,53 @@ class faMesh
mutable std::unique_ptr<List<labelPair>> bndConnectPtr_; mutable std::unique_ptr<List<labelPair>> bndConnectPtr_;
//- Ldu addressing data //- Ldu addressing data
mutable faMeshLduAddressing* lduPtr_; mutable std::unique_ptr<faMeshLduAddressing> lduPtr_;
// Geometric Data // Geometric Data
//- Face areas //- Face areas
mutable DimensionedField<scalar, areaMesh>* SPtr_; mutable std::unique_ptr<DimensionedField<scalar, areaMesh>> SPtr_;
//- Face areas old time level //- Face areas old time level
mutable DimensionedField<scalar, areaMesh>* S0Ptr_; mutable std::unique_ptr<DimensionedField<scalar, areaMesh>> S0Ptr_;
//- Face areas old-old time level //- 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 //- Patch starts in the edge list
mutable labelList* patchStartsPtr_; mutable std::unique_ptr<labelList> patchStartsPtr_;
//- Edge length vectors //- Edge length vectors
mutable edgeVectorField* LePtr_; mutable std::unique_ptr<edgeVectorField> LePtr_;
//- Mag edge length vectors //- Mag edge length vectors
mutable edgeScalarField* magLePtr_; mutable std::unique_ptr<edgeScalarField> magLePtr_;
//- Face centres //- Face centres
mutable areaVectorField* faceCentresPtr_; mutable std::unique_ptr<areaVectorField> faceCentresPtr_;
//- Edge centres //- Edge centres
mutable edgeVectorField* edgeCentresPtr_; mutable std::unique_ptr<edgeVectorField> edgeCentresPtr_;
//- Face area normals //- Face area normals
mutable areaVectorField* faceAreaNormalsPtr_; mutable std::unique_ptr<areaVectorField> faceAreaNormalsPtr_;
//- Edge area normals //- Edge area normals
mutable edgeVectorField* edgeAreaNormalsPtr_; mutable std::unique_ptr<edgeVectorField> edgeAreaNormalsPtr_;
//- Point area normals //- Point area normals
mutable std::unique_ptr<vectorField> pointAreaNormalsPtr_; mutable std::unique_ptr<vectorField> pointAreaNormalsPtr_;
//- Face curvatures //- Face curvatures
mutable areaScalarField* faceCurvaturesPtr_; mutable std::unique_ptr<areaScalarField> faceCurvaturesPtr_;
//- Edge transformation tensors //- 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 //- Whether point normals must be corrected for a patch
mutable boolList* correctPatchPointNormalsPtr_; mutable std::unique_ptr<boolList> correctPatchPointNormalsPtr_;
// Other mesh-related data // Other mesh-related data

View File

@ -222,7 +222,7 @@ void Foam::faMesh::calcLduAddressing() const
<< abort(FatalError); << abort(FatalError);
} }
lduPtr_ = new faMeshLduAddressing(*this); lduPtr_ = std::make_unique<faMeshLduAddressing>(*this);
} }
@ -238,7 +238,7 @@ void Foam::faMesh::calcPatchStarts() const
<< abort(FatalError); << 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(); const polyBoundaryMesh& pbm = mesh().boundaryMesh();
polyPatchFacesPtr_.reset polyPatchFacesPtr_ = std::make_unique<List<labelPair>>
( (
new List<labelPair>(pbm.whichPatchFace(faceLabels_)) pbm.whichPatchFace(faceLabels_)
); );
labelHashSet ids; labelHashSet ids;
@ -278,7 +278,7 @@ void Foam::faMesh::calcWhichPatchFaces() const
this->comm() 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); << abort(FatalError);
} }
LePtr_ = LePtr_ = std::make_unique<edgeVectorField>
new edgeVectorField (
IOobject
( (
IOobject "Le",
( mesh().pointsInstance(),
"Le", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimLength
*this, // -> calculatedType()
dimLength );
// -> calculatedType()
);
edgeVectorField& Le = *LePtr_; edgeVectorField& Le = *LePtr_;
// Need face centres // Need face centres
@ -773,23 +772,21 @@ void Foam::faMesh::calcMagLe() const
<< abort(FatalError); << abort(FatalError);
} }
magLePtr_ = magLePtr_ = std::make_unique<edgeScalarField>
new edgeScalarField (
IOobject
( (
IOobject "magLe",
( mesh().pointsInstance(),
"magLe", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimLength
*this, );
dimLength
);
edgeScalarField& magLe = *magLePtr_; edgeScalarField& magLe = *magLePtr_;
const pointField& localPoints = points(); const pointField& localPoints = points();
@ -849,24 +846,22 @@ void Foam::faMesh::calcFaceCentres() const
<< abort(FatalError); << abort(FatalError);
} }
faceCentresPtr_ = faceCentresPtr_ = std::make_unique<areaVectorField>
new areaVectorField (
IOobject
( (
IOobject "centres",
( mesh().pointsInstance(),
"centres", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimLength
*this, // -> calculatedType()
dimLength );
// -> calculatedType()
);
areaVectorField& centres = *faceCentresPtr_; areaVectorField& centres = *faceCentresPtr_;
// Need local points // Need local points
@ -931,24 +926,22 @@ void Foam::faMesh::calcEdgeCentres() const
<< abort(FatalError); << abort(FatalError);
} }
edgeCentresPtr_ = edgeCentresPtr_ = std::make_unique<edgeVectorField>
new edgeVectorField (
IOobject
( (
IOobject "edgeCentres",
( mesh().pointsInstance(),
"edgeCentres", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimLength
*this, // -> calculatedType()
dimLength );
// -> calculatedType()
);
edgeVectorField& centres = *edgeCentresPtr_; edgeVectorField& centres = *edgeCentresPtr_;
// Need local points // Need local points
@ -996,7 +989,7 @@ void Foam::faMesh::calcS() const
<< abort(FatalError); << abort(FatalError);
} }
SPtr_ = new DimensionedField<scalar, areaMesh> SPtr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
( (
IOobject IOobject
( (
@ -1068,23 +1061,21 @@ void Foam::faMesh::calcFaceAreaNormals() const
<< abort(FatalError); << abort(FatalError);
} }
faceAreaNormalsPtr_ = faceAreaNormalsPtr_ = std::make_unique<areaVectorField>
new areaVectorField (
IOobject
( (
IOobject "faceAreaNormals",
( mesh().pointsInstance(),
"faceAreaNormals", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimless
*this, );
dimless
);
areaVectorField& faceNormals = *faceAreaNormalsPtr_; areaVectorField& faceNormals = *faceAreaNormalsPtr_;
const pointField& localPoints = points(); const pointField& localPoints = points();
@ -1149,23 +1140,22 @@ void Foam::faMesh::calcEdgeAreaNormals() const
<< abort(FatalError); << abort(FatalError);
} }
edgeAreaNormalsPtr_ = edgeAreaNormalsPtr_ = std::make_unique<edgeVectorField>
new edgeVectorField (
IOobject
( (
IOobject "edgeAreaNormals",
( mesh().pointsInstance(),
"edgeAreaNormals", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimless
*this, // -> calculatedType()
dimless );
// -> calculatedType()
);
edgeVectorField& edgeAreaNormals = *edgeAreaNormalsPtr_; edgeVectorField& edgeAreaNormals = *edgeAreaNormalsPtr_;
@ -1279,23 +1269,21 @@ void Foam::faMesh::calcFaceCurvatures() const
<< abort(FatalError); << abort(FatalError);
} }
faceCurvaturesPtr_ = faceCurvaturesPtr_ = std::make_unique<areaScalarField>
new areaScalarField (
IOobject
( (
IOobject "faceCurvatures",
( mesh().pointsInstance(),
"faceCurvatures", faMesh::meshSubDir,
mesh().pointsInstance(), faMesh::thisDb(),
faMesh::meshSubDir, IOobject::NO_READ,
faMesh::thisDb(), IOobject::NO_WRITE,
IOobject::NO_READ, IOobject::NO_REGISTER
IOobject::NO_WRITE, ),
IOobject::NO_REGISTER *this,
), dimless/dimLength
*this, );
dimless/dimLength
);
areaScalarField& faceCurvatures = *faceCurvaturesPtr_; areaScalarField& faceCurvatures = *faceCurvaturesPtr_;
@ -1321,7 +1309,8 @@ void Foam::faMesh::calcEdgeTransformTensors() const
<< abort(FatalError); << abort(FatalError);
} }
edgeTransformTensorsPtr_ = new FieldField<Field, tensor>(nEdges_); edgeTransformTensorsPtr_ =
std::make_unique<FieldField<Field, tensor>>(nEdges_);
auto& edgeTransformTensors = *edgeTransformTensorsPtr_; auto& edgeTransformTensors = *edgeTransformTensorsPtr_;
// Initialize all transformation tensors // Initialize all transformation tensors

View File

@ -61,10 +61,18 @@ void Foam::faAreaMapper::calcAddressing() const
// Prepare a list of new face labels and (preliminary) addressing // Prepare a list of new face labels and (preliminary) addressing
// Note: dimensioned to number of boundary faces of polyMesh // Note: dimensioned to number of boundary faces of polyMesh
newFaceLabelsPtr_ = new labelList(mesh_.mesh().nBoundaryFaces(), -1); newFaceLabelsPtr_ = std::make_unique<labelList>
labelList& newFaceLabels = *newFaceLabelsPtr_; (
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_; labelList& newFaceLabelsMap = *newFaceLabelsMapPtr_;
label nNewFaces = 0; label nNewFaces = 0;
@ -94,7 +102,7 @@ void Foam::faAreaMapper::calcAddressing() const
// Direct mapping: no further faces to add. Resize list // Direct mapping: no further faces to add. Resize list
newFaceLabels.setSize(nNewFaces); newFaceLabels.setSize(nNewFaces);
directAddrPtr_ = new labelList(newFaceLabels.size()); directAddrPtr_ = std::make_unique<labelList>(newFaceLabels.size());
labelList& addr = *directAddrPtr_; labelList& addr = *directAddrPtr_;
// Adjust for creation of a boundary face from an internal face // 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 // There are further faces to add. Prepare interpolation addressing
// and weights to full size // and weights to full size
interpolationAddrPtr_ = new labelListList(newFaceLabels.size()); interpolationAddrPtr_ = std::make_unique<labelListList>
(
newFaceLabels.size()
);
labelListList& addr = *interpolationAddrPtr_; labelListList& addr = *interpolationAddrPtr_;
weightsPtr_ = new scalarListList(newFaceLabels.size()); weightsPtr_ = std::make_unique<scalarListList>(newFaceLabels.size());
scalarListList& w = *weightsPtr_; scalarListList& w = *weightsPtr_;
// Insert single addressing and weights // 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 // Inserted objects cannot appear in the new faMesh as they have no master
// HJ, 10/Aug/2011 // HJ, 10/Aug/2011
insertedObjectLabelsPtr_ = new labelList(0); insertedObjectLabelsPtr_ = std::make_unique<labelList>();
} }
void Foam::faAreaMapper::clearOut() void Foam::faAreaMapper::clearOut()
{ {
deleteDemandDrivenData(newFaceLabelsPtr_); newFaceLabelsPtr_.reset(nullptr);
deleteDemandDrivenData(newFaceLabelsMapPtr_); newFaceLabelsMapPtr_.reset(nullptr);
deleteDemandDrivenData(directAddrPtr_); directAddrPtr_.reset(nullptr);
deleteDemandDrivenData(interpolationAddrPtr_); interpolationAddrPtr_.reset(nullptr);
deleteDemandDrivenData(weightsPtr_); weightsPtr_.reset(nullptr);
deleteDemandDrivenData(insertedObjectLabelsPtr_); insertedObjectLabelsPtr_.reset(nullptr);
hasUnmapped_ = false; hasUnmapped_ = false;
} }
@ -286,13 +297,7 @@ Foam::faAreaMapper::faAreaMapper
mpm_(mpm), mpm_(mpm),
direct_(false), direct_(false),
hasUnmapped_(false), hasUnmapped_(false),
sizeBeforeMapping_(mesh.nFaces()), sizeBeforeMapping_(mesh.nFaces())
newFaceLabelsPtr_(nullptr),
newFaceLabelsMapPtr_(nullptr),
directAddrPtr_(nullptr),
interpolationAddrPtr_(nullptr),
weightsPtr_(nullptr),
insertedObjectLabelsPtr_(nullptr)
{ {
// Check for possibility of direct mapping // Check for possibility of direct mapping
if if

View File

@ -77,23 +77,23 @@ class faAreaMapper
label sizeBeforeMapping_; label sizeBeforeMapping_;
//- New face labels after mapping //- New face labels after mapping
mutable labelList* newFaceLabelsPtr_; mutable std::unique_ptr<labelList> newFaceLabelsPtr_;
//- New face labels after mapping //- New face labels after mapping
mutable labelList* newFaceLabelsMapPtr_; mutable std::unique_ptr<labelList> newFaceLabelsMapPtr_;
//- Direct addressing (only one form of addressing is used) //- 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) //- Interpolated addressing (only one form of addressing is used)
mutable labelListList* interpolationAddrPtr_; mutable std::unique_ptr<labelListList> interpolationAddrPtr_;
//- Interpolation weights //- Interpolation weights
mutable scalarListList* weightsPtr_; mutable std::unique_ptr<scalarListList> weightsPtr_;
//- Inserted faces //- Inserted faces
mutable labelList* insertedObjectLabelsPtr_; mutable std::unique_ptr<labelList> insertedObjectLabelsPtr_;
// Private Member Functions // Private Member Functions
@ -127,7 +127,6 @@ public:
//- Destructor //- Destructor
virtual ~faAreaMapper(); virtual ~faAreaMapper();
// Member Functions // Member Functions
//- Return new face labels //- Return new face labels

View File

@ -43,13 +43,13 @@ void Foam::faEdgeMapper::calcAddressing() const
hasUnmapped_ = false; hasUnmapped_ = false;
// Dummy mapping: take value from edge 0 // Dummy mapping: take value from edge 0
directAddrPtr_ = new labelList(size(), Zero); directAddrPtr_ = std::make_unique<labelList>(size(), Foam::zero{});
} }
void Foam::faEdgeMapper::clearOut() void Foam::faEdgeMapper::clearOut()
{ {
deleteDemandDrivenData(directAddrPtr_); directAddrPtr_.reset(nullptr);
hasUnmapped_ = false; hasUnmapped_ = false;
} }
@ -64,8 +64,7 @@ Foam::faEdgeMapper::faEdgeMapper
: :
mesh_(mesh), mesh_(mesh),
sizeBeforeMapping_(mesh.nInternalEdges()), sizeBeforeMapping_(mesh.nInternalEdges()),
hasUnmapped_(false), hasUnmapped_(false)
directAddrPtr_(nullptr)
{} {}

View File

@ -74,7 +74,7 @@ class faEdgeMapper
mutable bool hasUnmapped_; mutable bool hasUnmapped_;
//- Direct addressing //- Direct addressing
mutable labelList* directAddrPtr_; mutable std::unique_ptr<labelList> directAddrPtr_;
// Private Member Functions // Private Member Functions

View File

@ -43,7 +43,7 @@ void Foam::faPatchMapper::calcAddressing() const
// Compatibility change HJ, 12/Aug/2017 // Compatibility change HJ, 12/Aug/2017
hasUnmapped_ = false; hasUnmapped_ = false;
directAddrPtr_ = new labelList(patch_.size(), Zero); directAddrPtr_ = std::make_unique<labelList>(patch_.size(), Foam::zero{});
labelList& addr = *directAddrPtr_; labelList& addr = *directAddrPtr_;
// Make a map of old edgeFaces, giving edge index in patch given the new // 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() void Foam::faPatchMapper::clearOut()
{ {
deleteDemandDrivenData(directAddrPtr_); directAddrPtr_.reset(nullptr);
hasUnmapped_ = false; hasUnmapped_ = false;
} }
@ -103,8 +103,7 @@ Foam::faPatchMapper::faPatchMapper
mpm_(mpm), mpm_(mpm),
sizeBeforeMapping_(patch.size()), sizeBeforeMapping_(patch.size()),
oldEdgeFaces_(patch.edgeFaces()), oldEdgeFaces_(patch.edgeFaces()),
hasUnmapped_(false), hasUnmapped_(false)
directAddrPtr_(nullptr)
{} {}

View File

@ -83,7 +83,7 @@ class faPatchMapper
mutable bool hasUnmapped_; mutable bool hasUnmapped_;
//- Direct addressing //- Direct addressing
mutable labelList* directAddrPtr_; mutable std::unique_ptr<labelList> directAddrPtr_;
// Private Member Functions // Private Member Functions

View File

@ -849,9 +849,10 @@ void Foam::faMesh::setBoundaryConnections
<< abort(FatalError); << abort(FatalError);
} }
bndConnectPtr_.reset bndConnectPtr_ = std::make_unique<List<labelPair>>
( (
new List<labelPair>(nBoundaryEdges, labelPair(-1,-1)) nBoundaryEdges,
labelPair(-1,-1)
); );
auto& bndConnect = *bndConnectPtr_; auto& bndConnect = *bndConnectPtr_;
@ -989,7 +990,7 @@ const Foam::faMeshBoundaryHalo& Foam::faMesh::boundaryHaloMap() const
{ {
if (!haloMapPtr_) if (!haloMapPtr_)
{ {
haloMapPtr_.reset(new faMeshBoundaryHalo(*this)); haloMapPtr_ = std::make_unique<faMeshBoundaryHalo>(*this);
} }
return *haloMapPtr_; return *haloMapPtr_;
@ -1022,8 +1023,8 @@ void Foam::faMesh::calcHaloFaceGeometry() const
const labelList& inputFaceIds = halo.inputMeshFaces(); const labelList& inputFaceIds = halo.inputMeshFaces();
haloFaceCentresPtr_.reset(new pointField); haloFaceCentresPtr_ = std::make_unique<pointField>();
haloFaceNormalsPtr_.reset(new vectorField); haloFaceNormalsPtr_ = std::make_unique<vectorField>();
auto& centres = *haloFaceCentresPtr_; auto& centres = *haloFaceCentresPtr_;
auto& normals = *haloFaceNormalsPtr_; auto& normals = *haloFaceNormalsPtr_;

View File

@ -105,10 +105,7 @@ Foam::faPatch::faPatch
patchIdentifier(name, index), patchIdentifier(name, index),
labelList(edgeLabels), labelList(edgeLabels),
nbrPolyPatchId_(nbrPolyPatchi), nbrPolyPatchId_(nbrPolyPatchi),
boundaryMesh_(bm), boundaryMesh_(bm)
edgeFacesPtr_(nullptr),
pointLabelsPtr_(nullptr),
pointEdgesPtr_(nullptr)
{ {
if (constraintType(patchType)) if (constraintType(patchType))
{ {
@ -129,10 +126,7 @@ Foam::faPatch::faPatch
patchIdentifier(name, dict, index), patchIdentifier(name, dict, index),
labelList(dict.get<labelList>("edgeLabels")), labelList(dict.get<labelList>("edgeLabels")),
nbrPolyPatchId_(dict.get<label>("ngbPolyPatchIndex")), nbrPolyPatchId_(dict.get<label>("ngbPolyPatchIndex")),
boundaryMesh_(bm), boundaryMesh_(bm)
edgeFacesPtr_(nullptr),
pointLabelsPtr_(nullptr),
pointEdgesPtr_(nullptr)
{ {
if (constraintType(patchType)) if (constraintType(patchType))
{ {
@ -153,10 +147,7 @@ Foam::faPatch::faPatch
patchIdentifier(p, index), patchIdentifier(p, index),
labelList(edgeLabels), labelList(edgeLabels),
nbrPolyPatchId_(p.nbrPolyPatchId_), nbrPolyPatchId_(p.nbrPolyPatchId_),
boundaryMesh_(bm), boundaryMesh_(bm)
edgeFacesPtr_(nullptr),
pointLabelsPtr_(nullptr),
pointEdgesPtr_(nullptr)
{} {}
@ -331,7 +322,7 @@ void Foam::faPatch::calcPointLabels() const
} }
// Transfer to plain list (reuse storage) // 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_; /// const auto& edgePoints = *pointLabelsPtr_;
/// ///
@ -381,7 +372,7 @@ void Foam::faPatch::calcPointEdges() const
} }
// Flatten to regular list // Flatten to regular list
pointEdgesPtr_.reset(new labelListList(edgePoints.size())); pointEdgesPtr_ = std::make_unique<labelListList>(edgePoints.size());
auto& pEdges = *pointEdgesPtr_; auto& pEdges = *pointEdgesPtr_;
forAll(pEdges, pointi) forAll(pEdges, pointi)
@ -441,12 +432,9 @@ const Foam::labelUList& Foam::faPatch::edgeFaces() const
{ {
if (!edgeFacesPtr_) if (!edgeFacesPtr_)
{ {
edgeFacesPtr_.reset edgeFacesPtr_ = std::make_unique<labelList::subList>
( (
new labelList::subList patchSlice(boundaryMesh().mesh().edgeOwner())
(
patchSlice(boundaryMesh().mesh().edgeOwner())
)
); );
} }

View File

@ -43,21 +43,10 @@ namespace Foam
Foam::leastSquaresFaVectors::leastSquaresFaVectors(const faMesh& mesh) Foam::leastSquaresFaVectors::leastSquaresFaVectors(const faMesh& mesh)
: :
MeshObject<faMesh, Foam::MoveableMeshObject, leastSquaresFaVectors>(mesh), MeshObject<faMesh, Foam::MoveableMeshObject, leastSquaresFaVectors>(mesh)
pVectorsPtr_(nullptr),
nVectorsPtr_(nullptr)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::leastSquaresFaVectors::~leastSquaresFaVectors()
{
deleteDemandDrivenData(pVectorsPtr_);
deleteDemandDrivenData(nVectorsPtr_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const
@ -66,7 +55,7 @@ void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const
<< "Constructing finite area (invDist) least square gradient vectors" << "Constructing finite area (invDist) least square gradient vectors"
<< nl; << nl;
pVectorsPtr_ = new edgeVectorField pVectorsPtr_ = std::make_unique<edgeVectorField>
( (
IOobject IOobject
( (
@ -82,7 +71,7 @@ void Foam::leastSquaresFaVectors::makeLeastSquaresVectors() const
); );
auto& lsP = *pVectorsPtr_; auto& lsP = *pVectorsPtr_;
nVectorsPtr_ = new edgeVectorField nVectorsPtr_ = std::make_unique<edgeVectorField>
( (
IOobject IOobject
( (
@ -236,8 +225,8 @@ bool Foam::leastSquaresFaVectors::movePoints()
DebugInFunction DebugInFunction
<< "Clearing least square data" << nl; << "Clearing least square data" << nl;
deleteDemandDrivenData(pVectorsPtr_); pVectorsPtr_.reset(nullptr);
deleteDemandDrivenData(nVectorsPtr_); nVectorsPtr_.reset(nullptr);
return true; return true;
} }

View File

@ -60,8 +60,8 @@ class leastSquaresFaVectors
// Private Data // Private Data
//- Least-squares gradient vectors //- Least-squares gradient vectors
mutable edgeVectorField* pVectorsPtr_; mutable std::unique_ptr<edgeVectorField> pVectorsPtr_;
mutable edgeVectorField* nVectorsPtr_; mutable std::unique_ptr<edgeVectorField> nVectorsPtr_;
// Private Member Functions // Private Member Functions
@ -83,7 +83,7 @@ public:
//- Destructor //- Destructor
virtual ~leastSquaresFaVectors(); virtual ~leastSquaresFaVectors() = default;
// Member functions // Member functions

View File

@ -37,79 +37,55 @@ namespace Foam
defineTypeNameAndDebug(edgeInterpolation, 0); defineTypeNameAndDebug(edgeInterpolation, 0);
} }
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::edgeInterpolation::clearOut()
{
deleteDemandDrivenData(lPN_);
deleteDemandDrivenData(weightingFactors_);
deleteDemandDrivenData(differenceFactors_);
deleteDemandDrivenData(correctionVectors_);
deleteDemandDrivenData(skewCorrectionVectors_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::edgeInterpolation::edgeInterpolation(const faMesh& fam) Foam::edgeInterpolation::edgeInterpolation(const faMesh& fam)
: :
faMesh_(fam), faMesh_(fam),
lPN_(nullptr),
weightingFactors_(nullptr),
differenceFactors_(nullptr),
correctionVectors_(nullptr),
skewCorrectionVectors_(nullptr),
orthogonal_(false), orthogonal_(false),
skew_(true) skew_(true)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::edgeInterpolation::~edgeInterpolation()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::edgeScalarField& Foam::edgeInterpolation::lPN() const const Foam::edgeScalarField& Foam::edgeInterpolation::lPN() const
{ {
if (!lPN_) if (!lPNptr_)
{ {
makeLPN(); makeLPN();
} }
return (*lPN_); return (*lPNptr_);
} }
const Foam::edgeScalarField& Foam::edgeInterpolation::weights() const const Foam::edgeScalarField& Foam::edgeInterpolation::weights() const
{ {
if (!weightingFactors_) if (!weightingFactorsPtr_)
{ {
makeWeights(); makeWeights();
} }
return (*weightingFactors_); return (*weightingFactorsPtr_);
} }
const Foam::edgeScalarField& Foam::edgeInterpolation::deltaCoeffs() const const Foam::edgeScalarField& Foam::edgeInterpolation::deltaCoeffs() const
{ {
if (!differenceFactors_) if (!differenceFactorsPtr_)
{ {
makeDeltaCoeffs(); makeDeltaCoeffs();
} }
return (*differenceFactors_); return (*differenceFactorsPtr_);
} }
bool Foam::edgeInterpolation::orthogonal() const bool Foam::edgeInterpolation::orthogonal() const
{ {
if (orthogonal_ == false && !correctionVectors_) if (orthogonal_ == false && !correctionVectorsPtr_)
{ {
makeCorrectionVectors(); makeCorrectionVectors();
} }
@ -127,13 +103,13 @@ const Foam::edgeVectorField& Foam::edgeInterpolation::correctionVectors() const
<< abort(FatalError); << abort(FatalError);
} }
return (*correctionVectors_); return (*correctionVectorsPtr_);
} }
bool Foam::edgeInterpolation::skew() const bool Foam::edgeInterpolation::skew() const
{ {
if (skew_ == true && !skewCorrectionVectors_) if (skew_ == true && !skewCorrectionVectorsPtr_)
{ {
makeSkewCorrectionVectors(); makeSkewCorrectionVectors();
} }
@ -152,21 +128,21 @@ Foam::edgeInterpolation::skewCorrectionVectors() const
<< abort(FatalError); << abort(FatalError);
} }
return (*skewCorrectionVectors_); return (*skewCorrectionVectorsPtr_);
} }
bool Foam::edgeInterpolation::movePoints() const bool Foam::edgeInterpolation::movePoints() const
{ {
deleteDemandDrivenData(lPN_); lPNptr_.reset(nullptr);
deleteDemandDrivenData(weightingFactors_); weightingFactorsPtr_.reset(nullptr);
deleteDemandDrivenData(differenceFactors_); differenceFactorsPtr_.reset(nullptr);
orthogonal_ = false; orthogonal_ = false;
deleteDemandDrivenData(correctionVectors_); correctionVectorsPtr_.reset(nullptr);
skew_ = true; skew_ = true;
deleteDemandDrivenData(skewCorrectionVectors_); skewCorrectionVectorsPtr_.reset(nullptr);
return true; return true;
} }
@ -178,14 +154,14 @@ const Foam::vector& Foam::edgeInterpolation::skewCorr(const label edgeI) const
return return
( (
skewCorrectionVectors_ skewCorrectionVectorsPtr_
? (*skewCorrectionVectors_)[edgeI] ? (*skewCorrectionVectorsPtr_)[edgeI]
: pTraits<vector>::zero : pTraits<vector>::zero
); );
#else #else
return (*skewCorrectionVectors_)[edgeI]; return (*skewCorrectionVectorsPtr_)[edgeI];
#endif #endif
} }
@ -198,7 +174,7 @@ void Foam::edgeInterpolation::makeLPN() const
<< endl; << endl;
lPN_ = new edgeScalarField lPNptr_ = std::make_unique<edgeScalarField>
( (
IOobject IOobject
( (
@ -212,7 +188,7 @@ void Foam::edgeInterpolation::makeLPN() const
mesh(), mesh(),
dimLength dimLength
); );
edgeScalarField& lPN = *lPN_; edgeScalarField& lPN = *lPNptr_;
// Set local references to mesh data // Set local references to mesh data
const edgeVectorField& edgeCentres = mesh().edgeCentres(); const edgeVectorField& edgeCentres = mesh().edgeCentres();
@ -279,7 +255,7 @@ void Foam::edgeInterpolation::makeWeights() const
<< endl; << endl;
weightingFactors_ = new edgeScalarField weightingFactorsPtr_ = std::make_unique<edgeScalarField>
( (
IOobject IOobject
( (
@ -293,7 +269,7 @@ void Foam::edgeInterpolation::makeWeights() const
mesh(), mesh(),
dimensionedScalar(dimless, 1) dimensionedScalar(dimless, 1)
); );
edgeScalarField& weightingFactors = *weightingFactors_; edgeScalarField& weightingFactors = *weightingFactorsPtr_;
// Set local references to mesh data // 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. // needed to make sure deltaCoeffs are calculated for parallel runs.
weights(); weights();
differenceFactors_ = new edgeScalarField differenceFactorsPtr_ = std::make_unique<edgeScalarField>
( (
IOobject IOobject
( (
"differenceFactors_", "differenceFactors",
mesh().pointsInstance(), mesh().pointsInstance(),
mesh().thisDb(), mesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -373,7 +349,7 @@ void Foam::edgeInterpolation::makeDeltaCoeffs() const
mesh(), mesh(),
dimensionedScalar(dimless/dimLength, SMALL) dimensionedScalar(dimless/dimLength, SMALL)
); );
edgeScalarField& DeltaCoeffs = *differenceFactors_; edgeScalarField& DeltaCoeffs = *differenceFactorsPtr_;
scalarField& dc = DeltaCoeffs.primitiveFieldRef(); scalarField& dc = DeltaCoeffs.primitiveFieldRef();
// Set local references to mesh data // Set local references to mesh data
@ -453,7 +429,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const
<< "Constructing non-orthogonal correction vectors" << "Constructing non-orthogonal correction vectors"
<< endl; << endl;
correctionVectors_ = new edgeVectorField correctionVectorsPtr_ = std::make_unique<edgeVectorField>
( (
IOobject IOobject
( (
@ -467,7 +443,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const
mesh(), mesh(),
dimless dimless
); );
edgeVectorField& CorrVecs = *correctionVectors_; edgeVectorField& CorrVecs = *correctionVectorsPtr_;
// Set local references to mesh data // Set local references to mesh data
const areaVectorField& faceCentres = mesh().areaCentres(); const areaVectorField& faceCentres = mesh().areaCentres();
@ -541,7 +517,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const
if (NonOrthogCoeff < 0.1) if (NonOrthogCoeff < 0.1)
{ {
orthogonal_ = true; orthogonal_ = true;
deleteDemandDrivenData(correctionVectors_); correctionVectorsPtr_.reset(nullptr);
} }
else else
{ {
@ -560,7 +536,7 @@ void Foam::edgeInterpolation::makeSkewCorrectionVectors() const
<< "Constructing skew correction vectors" << "Constructing skew correction vectors"
<< endl; << endl;
skewCorrectionVectors_ = new edgeVectorField skewCorrectionVectorsPtr_ = std::make_unique<edgeVectorField>
( (
IOobject IOobject
( (
@ -574,7 +550,7 @@ void Foam::edgeInterpolation::makeSkewCorrectionVectors() const
mesh(), mesh(),
dimensionedVector(dimless, Zero) dimensionedVector(dimless, Zero)
); );
edgeVectorField& SkewCorrVecs = *skewCorrectionVectors_; edgeVectorField& SkewCorrVecs = *skewCorrectionVectorsPtr_;
// Set local references to mesh data // Set local references to mesh data
const areaVectorField& C = mesh().areaCentres(); const areaVectorField& C = mesh().areaCentres();
@ -698,12 +674,12 @@ void Foam::edgeInterpolation::makeSkewCorrectionVectors() const
if (skewCoeff < maxSkewRatio) if (skewCoeff < maxSkewRatio)
{ {
deleteDemandDrivenData(skewCorrectionVectors_); skewCorrectionVectorsPtr_.reset(nullptr);
} }
#endif #endif
skew_ = bool(skewCorrectionVectors_); skew_ = bool(skewCorrectionVectorsPtr_);
DebugInFunction DebugInFunction

View File

@ -68,19 +68,19 @@ class edgeInterpolation
// Demand-driven data // Demand-driven data
//- Geodesic distance between centroids of neighbour finite areas //- Geodesic distance between centroids of neighbour finite areas
mutable edgeScalarField* lPN_; mutable std::unique_ptr<edgeScalarField> lPNptr_;
//- Central-differencing weighting factors //- Central-differencing weighting factors
mutable edgeScalarField* weightingFactors_; mutable std::unique_ptr<edgeScalarField> weightingFactorsPtr_;
//- Face-gradient difference factors //- Face-gradient difference factors
mutable edgeScalarField* differenceFactors_; mutable std::unique_ptr<edgeScalarField> differenceFactorsPtr_;
//- Non-orthogonality correction vectors //- Non-orthogonality correction vectors
mutable edgeVectorField* correctionVectors_; mutable std::unique_ptr<edgeVectorField> correctionVectorsPtr_;
//- Skew correction vectors //- Skew correction vectors
mutable edgeVectorField* skewCorrectionVectors_; mutable std::unique_ptr<edgeVectorField> skewCorrectionVectorsPtr_;
//- Is mesh orthogonal //- Is mesh orthogonal
mutable bool orthogonal_; mutable bool orthogonal_;
@ -110,16 +110,6 @@ class edgeInterpolation
void makeSkewCorrectionVectors() const; void makeSkewCorrectionVectors() const;
protected:
// Protected Member Functions
// Storage Management
//- Clear all geometry and addressing
void clearOut();
public: public:
// Declare name of the class and it's debug switch // Declare name of the class and it's debug switch
@ -142,7 +132,7 @@ public:
//- Destructor //- Destructor
~edgeInterpolation(); ~edgeInterpolation() = default;
// Member Functions // Member Functions
@ -181,7 +171,7 @@ public:
// Storage Management // Storage Management
//- True if weights exist //- True if weights exist
bool hasWeights() const noexcept { return bool(weightingFactors_); } bool hasWeights() const noexcept { return bool(weightingFactorsPtr_); }
}; };