Commit d4b49513 authored by Mark Olesen's avatar Mark Olesen
Browse files

COMP: avoid autoPtr automatic cast conversion in more places

- Can result in inadvertent conversions where the user should really
  know or check if the pointer is valid prior to using.

- Still have several places to fix that are using the deprecated copy
  construct and copy assignment
parent fe6abf0f
......@@ -203,7 +203,7 @@ void Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::solveYi
forAllConstIters(this->fluid().phases(),iter2)
{
const volScalarField& alpha2 = iter2();
const volScalarField& alpha2 = iter2()();
if (&alpha2 == &alpha1)
{
continue;
......@@ -253,7 +253,7 @@ void Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::solveYi
forAllConstIters(this->fluid().phases(), iter2)
{
//const volScalarField& alpha2 = iter2()().oldTime();
const volScalarField& alpha2 = iter2();
const volScalarField& alpha2 = iter2()();
if (&alpha2 == &alpha1)
{
......
......@@ -1016,7 +1016,7 @@ void Foam::phaseSystem::addInterfacePorosity(fvVectorMatrix& UEqn)
forAllConstIters(phaseModels_, iteri)
{
const phaseModel& phasei = iteri();
const phaseModel& phasei = iteri()();
auto iterk = iteri;
......
......@@ -43,7 +43,7 @@ SourceFiles
#ifndef autoPtr_H
#define autoPtr_H
// Transitional features/misfeatures:
// Transitional features/misfeatures
#define Foam_autoPtr_copyConstruct
#define Foam_autoPtr_copyAssign
#define Foam_autoPtr_castOperator
......@@ -93,7 +93,7 @@ public:
// will be constructed.
//
// \note Similar to New but for derived types.
// In the future check for is_convertible on the pointer types
// Future check for std::is_base_of ?
template<class U, class... Args>
inline static autoPtr<T> NewFrom(Args&&... args);
......@@ -114,7 +114,7 @@ public:
//- Move construct, transferring ownership from derived type.
// U must be derivable from T
// \note In the future check for is_convertible on the pointer types
// \note Future check for std::is_base_of ?
template<class U>
inline explicit autoPtr(autoPtr<U>&& ap);
......@@ -226,10 +226,13 @@ public:
// Fatal error if no pointer is managed
inline const T& operator()() const;
//- Automatic cast conversion to the underlying type reference
//- Deprecated(2019-01) Automatic cast conversion to underlying type
// Fatal error if no pointer is managed
// \deprecated(2019-01) Can result in inadvertent conversions
// where the user should really know or check if the pointer
// is valid prior to using.
#ifdef Foam_autoPtr_castOperator
inline operator const T&() const { return operator*(); }
operator const T&() const { return operator*(); }
#else
operator const T&() const = delete;
#endif
......@@ -258,7 +261,7 @@ public:
// Housekeeping
//- No copy assignment from plain pointer
//- Deprecated(2018-02) No copy assignment from plain pointer
// \deprecated(2018-02) Convenient, but uncontrolled access
void operator=(T* p) = delete;
};
......
......@@ -422,7 +422,7 @@ Foam::dynamicRefineFvMesh::refine
// cellTreePtr_.clear();
// Update fields
updateMesh(map);
updateMesh(*map);
// Move mesh
......@@ -442,7 +442,7 @@ Foam::dynamicRefineFvMesh::refine
// Update numbering of cells/vertices.
meshCutter_.updateMesh(map);
meshCutter_.updateMesh(*map);
// Update numbering of protectedCell_
if (protectedCell_.size())
......@@ -517,7 +517,7 @@ Foam::dynamicRefineFvMesh::unrefine
<< endl;
// Update fields
updateMesh(map);
updateMesh(*map);
// Move mesh
......@@ -620,7 +620,7 @@ Foam::dynamicRefineFvMesh::unrefine
// Update numbering of cells/vertices.
meshCutter_.updateMesh(map);
meshCutter_.updateMesh(*map);
// Update numbering of protectedCell_
if (protectedCell_.size())
......
......@@ -95,7 +95,7 @@ timeVaryingMappedFixedValueFvPatchField
(
new PatchFunction1Types::MappedFile<Type>
(
ptf.uniformValue_,
ptf.uniformValue_(),
p.patch()
)
)
......@@ -114,7 +114,7 @@ timeVaryingMappedFixedValueFvPatchField
(
new PatchFunction1Types::MappedFile<Type>
(
ptf.uniformValue_,
ptf.uniformValue_(),
this->patch().patch()
)
)
......@@ -134,7 +134,7 @@ timeVaryingMappedFixedValueFvPatchField
(
new PatchFunction1Types::MappedFile<Type>
(
ptf.uniformValue_,
ptf.uniformValue_(),
this->patch().patch()
)
)
......
......@@ -2742,7 +2742,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::directionalRefine
autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh_, false);
// Update fields
mesh_.updateMesh(morphMap);
mesh_.updateMesh(*morphMap);
// Move mesh (since morphing does not do this)
if (morphMap().hasMotionPoints())
......@@ -2759,10 +2759,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::directionalRefine
mesh_.setInstance(timeName());
// Update stored refinement pattern
meshRefiner.updateMesh(morphMap);
meshRefiner.updateMesh(*morphMap);
// Update intersection info
updateMesh(morphMap, getChangedFaces(morphMap, cellsToRefine));
updateMesh(*morphMap, getChangedFaces(*morphMap, cellsToRefine));
return morphMap;
}
......
......@@ -209,7 +209,7 @@ public:
{
const_cast<cellVolumeWeight&>(*this).update();
}
return cellInterpolationMap_;
return *cellInterpolationMap_;
}
//- Per interpolated cell the neighbour cells (in terms of slots as
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment