Merge branch 'enh-memory-cleanup' into 'develop'

autoPtr/tmp cleanup

See merge request Development/openfoam!378
This commit is contained in:
Andrew Heather
2020-07-17 16:29:16 +01:00
199 changed files with 874 additions and 973 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -129,12 +130,12 @@ Foam::BlendedInterfacialModel<modelType>::K() const
{ {
tmp<volScalarField> f1, f2; tmp<volScalarField> f1, f2;
if (model_.valid() || model1In2_.valid()) if (model_ || model1In2_)
{ {
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
} }
if (model_.valid() || model2In1_.valid()) if (model_ || model2In1_)
{ {
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
} }
@ -157,17 +158,17 @@ Foam::BlendedInterfacialModel<modelType>::K() const
) )
); );
if (model_.valid()) if (model_)
{ {
x.ref() += model_->K()*(f1() - f2()); x.ref() += model_->K()*(f1() - f2());
} }
if (model1In2_.valid()) if (model1In2_)
{ {
x.ref() += model1In2_->K()*(1 - f1); x.ref() += model1In2_->K()*(1 - f1);
} }
if (model2In1_.valid()) if (model2In1_)
{ {
x.ref() += model2In1_->K()*f2; x.ref() += model2In1_->K()*f2;
} }
@ -175,7 +176,7 @@ Foam::BlendedInterfacialModel<modelType>::K() const
if if
( (
correctFixedFluxBCs_ correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid()) && (model_ || model1In2_ || model2In1_)
) )
{ {
correctFixedFluxBCs(x.ref()); correctFixedFluxBCs(x.ref());
@ -191,7 +192,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
{ {
tmp<surfaceScalarField> f1, f2; tmp<surfaceScalarField> f1, f2;
if (model_.valid() || model1In2_.valid()) if (model_ || model1In2_)
{ {
f1 = fvc::interpolate f1 = fvc::interpolate
( (
@ -199,7 +200,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
); );
} }
if (model_.valid() || model2In1_.valid()) if (model_ || model2In1_)
{ {
f2 = fvc::interpolate f2 = fvc::interpolate
( (
@ -225,17 +226,17 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
) )
); );
if (model_.valid()) if (model_)
{ {
x.ref() += model_->Kf()*(f1() - f2()); x.ref() += model_->Kf()*(f1() - f2());
} }
if (model1In2_.valid()) if (model1In2_)
{ {
x.ref() += model1In2_->Kf()*(1 - f1); x.ref() += model1In2_->Kf()*(1 - f1);
} }
if (model2In1_.valid()) if (model2In1_)
{ {
x.ref() += model2In1_->Kf()*f2; x.ref() += model2In1_->Kf()*f2;
} }
@ -243,7 +244,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const
if if
( (
correctFixedFluxBCs_ correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid()) && (model_ || model1In2_ || model2In1_)
) )
{ {
correctFixedFluxBCs(x.ref()); correctFixedFluxBCs(x.ref());
@ -260,12 +261,12 @@ Foam::BlendedInterfacialModel<modelType>::F() const
{ {
tmp<volScalarField> f1, f2; tmp<volScalarField> f1, f2;
if (model_.valid() || model1In2_.valid()) if (model_ || model1In2_)
{ {
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
} }
if (model_.valid() || model2In1_.valid()) if (model_ || model2In1_)
{ {
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
} }
@ -285,17 +286,17 @@ Foam::BlendedInterfacialModel<modelType>::F() const
dimensioned<Type>(modelType::dimF, Zero) dimensioned<Type>(modelType::dimF, Zero)
); );
if (model_.valid()) if (model_)
{ {
x.ref() += model_->F()*(f1() - f2()); x.ref() += model_->F()*(f1() - f2());
} }
if (model1In2_.valid()) if (model1In2_)
{ {
x.ref() += model1In2_->F()*(1 - f1); x.ref() += model1In2_->F()*(1 - f1);
} }
if (model2In1_.valid()) if (model2In1_)
{ {
x.ref() -= model2In1_->F()*f2; // note : subtraction x.ref() -= model2In1_->F()*f2; // note : subtraction
} }
@ -303,7 +304,7 @@ Foam::BlendedInterfacialModel<modelType>::F() const
if if
( (
correctFixedFluxBCs_ correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid()) && (model_ || model1In2_ || model2In1_)
) )
{ {
correctFixedFluxBCs(x.ref()); correctFixedFluxBCs(x.ref());
@ -319,7 +320,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
{ {
tmp<surfaceScalarField> f1, f2; tmp<surfaceScalarField> f1, f2;
if (model_.valid() || model1In2_.valid()) if (model_ || model1In2_)
{ {
f1 = fvc::interpolate f1 = fvc::interpolate
( (
@ -327,7 +328,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
); );
} }
if (model_.valid() || model2In1_.valid()) if (model_ || model2In1_)
{ {
f2 = fvc::interpolate f2 = fvc::interpolate
( (
@ -352,17 +353,17 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
x.ref().setOriented(); x.ref().setOriented();
if (model_.valid()) if (model_)
{ {
x.ref() += model_->Ff()*(f1() - f2()); x.ref() += model_->Ff()*(f1() - f2());
} }
if (model1In2_.valid()) if (model1In2_)
{ {
x.ref() += model1In2_->Ff()*(1 - f1); x.ref() += model1In2_->Ff()*(1 - f1);
} }
if (model2In1_.valid()) if (model2In1_)
{ {
x.ref() -= model2In1_->Ff()*f2; // note : subtraction x.ref() -= model2In1_->Ff()*f2; // note : subtraction
} }
@ -370,7 +371,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const
if if
( (
correctFixedFluxBCs_ correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid()) && (model_ || model1In2_ || model2In1_)
) )
{ {
correctFixedFluxBCs(x.ref()); correctFixedFluxBCs(x.ref());
@ -386,12 +387,12 @@ Foam::BlendedInterfacialModel<modelType>::D() const
{ {
tmp<volScalarField> f1, f2; tmp<volScalarField> f1, f2;
if (model_.valid() || model1In2_.valid()) if (model_ || model1In2_)
{ {
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
} }
if (model_.valid() || model2In1_.valid()) if (model_ || model2In1_)
{ {
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
} }
@ -414,17 +415,17 @@ Foam::BlendedInterfacialModel<modelType>::D() const
) )
); );
if (model_.valid()) if (model_)
{ {
x.ref() += model_->D()*(f1() - f2()); x.ref() += model_->D()*(f1() - f2());
} }
if (model1In2_.valid()) if (model1In2_)
{ {
x.ref() += model1In2_->D()*(1 - f1); x.ref() += model1In2_->D()*(1 - f1);
} }
if (model2In1_.valid()) if (model2In1_)
{ {
x.ref() += model2In1_->D()*f2; x.ref() += model2In1_->D()*f2;
} }
@ -432,7 +433,7 @@ Foam::BlendedInterfacialModel<modelType>::D() const
if if
( (
correctFixedFluxBCs_ correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid()) && (model_ || model1In2_ || model2In1_)
) )
{ {
correctFixedFluxBCs(x.ref()); correctFixedFluxBCs(x.ref());
@ -451,8 +452,8 @@ bool Foam::BlendedInterfacialModel<modelType>::hasModel
return return
( (
&phase == &(pair_.phase1()) &phase == &(pair_.phase1())
? model1In2_.valid() ? bool(model1In2_)
: model2In1_.valid() : bool(model2In1_)
); );
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2015 OpenFOAM Foundation Copyright (C) 2014-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -85,7 +86,7 @@ Foam::word Foam::orderedPhasePair::name() const
Foam::tmp<Foam::volScalarField> Foam::orderedPhasePair::E() const Foam::tmp<Foam::volScalarField> Foam::orderedPhasePair::E() const
{ {
if (!aspectRatio_.valid()) if (!aspectRatio_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Aspect ratio model not specified for " << *this << "." << "Aspect ratio model not specified for " << *this << "."

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,7 +44,7 @@ void testTransfer1(autoPtr<labelList> ap)
// Passed in copy, so automatically removes content // Passed in copy, so automatically removes content
// Transfer would be nice, but not actually needed // Transfer would be nice, but not actually needed
Info<< "recv " << Switch::name(ap.valid()) << nl; Info<< "recv " << Switch::name(bool(ap)) << nl;
} }
@ -53,7 +53,7 @@ void testTransfer1(autoPtr<labelList> ap)
void testTransfer2(autoPtr<labelList>&& ap) void testTransfer2(autoPtr<labelList>&& ap)
{ {
// As rvalue, so this time we actually get to manage content // As rvalue, so this time we actually get to manage content
Info<< "recv " << Switch::name(ap.valid()) << nl; Info<< "recv " << Switch::name(bool(ap)) << nl;
} }
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
testTransfer2(std::move(list)); testTransfer2(std::move(list));
Info<<"now have valid=" << Switch::name(list.valid()); Info<<"now have valid=" << Switch::name(bool(list));
if (list) if (list)
{ {
@ -209,9 +209,9 @@ int main(int argc, char *argv[])
testTransfer2(std::move(list)); testTransfer2(std::move(list));
Info<<"now have valid=" << Switch::name(list.valid()); Info<<"now have valid=" << Switch::name(bool(list));
if (list.valid()) if (list)
{ {
Info<< nl Info<< nl
<< flatOutput(*list) << " @ " << name(list->cdata()) << flatOutput(*list) << " @ " << name(list->cdata())
@ -229,7 +229,7 @@ int main(int argc, char *argv[])
auto ptr1 = autoPtr<labelList>::New(); auto ptr1 = autoPtr<labelList>::New();
auto ptr2 = autoPtr<labelList>::New(); auto ptr2 = autoPtr<labelList>::New();
Info<<"ptr valid: " << ptr1.valid() << nl; Info<<"ptr valid: " << bool(ptr1) << nl;
// Refuses to compile (good!): ptr1 = new labelList(10); // Refuses to compile (good!): ptr1 = new labelList(10);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,8 +53,8 @@ Foam::token Foam::dictionaryTokens::keywordToken(const entry& e)
bool Foam::dictionaryTokens::setIterator() const bool Foam::dictionaryTokens::setIterator() const
{ {
primIter_.clear(); primIter_.reset(nullptr);
dictIter_.clear(); dictIter_.reset(nullptr);
if (entryIter_ != dict_.cend()) if (entryIter_ != dict_.cend())
{ {
@ -166,8 +166,8 @@ bool Foam::dictionaryTokens::good() const
entryIter_ != dict_.cend() entryIter_ != dict_.cend()
&& &&
( (
(primIter_.valid() && primIter_().good()) (primIter_ && primIter_->good())
|| (dictIter_.valid() && dictIter_().good()) || (dictIter_ && dictIter_->good())
) )
); );
} }
@ -189,8 +189,8 @@ const Foam::token& Foam::dictionaryTokens::operator*() const
{ {
if (good()) if (good())
{ {
if (primIter_.valid()) return *(primIter_()); if (primIter_) return *(*primIter_);
if (dictIter_.valid()) return *(dictIter_()); if (dictIter_) return *(*dictIter_);
} }
return token::undefinedToken; return token::undefinedToken;
@ -251,8 +251,8 @@ bool Foam::dictionaryTokens::operator++()
if (ok) if (ok)
{ {
if (primIter_.valid()) ok = ++(primIter_()); if (primIter_) ok = ++(*primIter_);
if (dictIter_.valid()) ok = ++(dictIter_()); if (dictIter_) ok = ++(*dictIter_);
if (!ok) if (!ok)
{ {

View File

@ -137,9 +137,9 @@ label mergePatchFaces
// Faces in error. // Faces in error.
labelHashSet errorFaces; labelHashSet errorFaces;
if (qualDictPtr.valid()) if (qualDictPtr)
{ {
motionSmoother::checkMesh(false, mesh, qualDictPtr(), errorFaces); motionSmoother::checkMesh(false, mesh, *qualDictPtr, errorFaces);
} }
else else
{ {
@ -440,7 +440,7 @@ int main(int argc, char *argv[])
); );
// Merge points on straight edges and remove unused points // Merge points on straight edges and remove unused points
if (qualDict.valid()) if (qualDict)
{ {
Info<< "Merging all 'loose' points on surface edges, " Info<< "Merging all 'loose' points on surface edges, "
<< "regardless of the angle they make." << endl; << "regardless of the angle they make." << endl;

View File

@ -731,9 +731,9 @@ int main(int argc, char *argv[])
); );
// Update // Update
if (refDataPtr.valid()) if (refDataPtr)
{ {
refDataPtr().updateMesh(map()); refDataPtr->updateMesh(map());
} }
// Store added cells // Store added cells
@ -815,9 +815,9 @@ int main(int argc, char *argv[])
polyMesh& mesh = polyMesh& mesh =
( (
meshFromMesh.valid() meshFromMesh
? meshFromMesh() ? *meshFromMesh
: meshFromSurface() : *meshFromSurface
); );
@ -896,9 +896,9 @@ int main(int argc, char *argv[])
updateFaceLabels(map(), backPatchFaces); updateFaceLabels(map(), backPatchFaces);
updateCellSet(map(), addedCellsSet); updateCellSet(map(), addedCellsSet);
if (refDataPtr.valid()) if (refDataPtr)
{ {
refDataPtr().updateMesh(map()); refDataPtr->updateMesh(map());
} }
// Move mesh (if inflation used) // Move mesh (if inflation used)
@ -1029,9 +1029,9 @@ int main(int argc, char *argv[])
// Update local data // Update local data
updateCellSet(map(), addedCellsSet); updateCellSet(map(), addedCellsSet);
if (refDataPtr.valid()) if (refDataPtr)
{ {
refDataPtr().updateMesh(map()); refDataPtr->updateMesh(map());
} }
// Move mesh (if inflation used) // Move mesh (if inflation used)
@ -1067,9 +1067,9 @@ int main(int argc, char *argv[])
} }
} }
if (refDataPtr.valid()) if (refDataPtr)
{ {
refDataPtr().write(); refDataPtr->write();
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -625,7 +626,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::sync
return; return;
} }
if (allBackgroundMeshBounds_.empty()) if (!allBackgroundMeshBounds_)
{ {
distributeBoundBoxes(bb); distributeBoundBoxes(bb);
} }
@ -810,7 +811,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::sync(const boundBox& bb)
return; return;
} }
if (allBackgroundMeshBounds_.empty()) if (!allBackgroundMeshBounds_)
{ {
distributeBoundBoxes(bb); distributeBoundBoxes(bb);
} }

View File

@ -539,7 +539,7 @@ Foam::label Foam::checkGeometry
<< nonAlignedPoints.name() << endl; << nonAlignedPoints.name() << endl;
nonAlignedPoints.instance() = mesh.pointsInstance(); nonAlignedPoints.instance() = mesh.pointsInstance();
nonAlignedPoints.write(); nonAlignedPoints.write();
if (setWriter.valid()) if (setWriter)
{ {
mergeAndWrite(*setWriter, nonAlignedPoints); mergeAndWrite(*setWriter, nonAlignedPoints);
} }
@ -573,7 +573,7 @@ Foam::label Foam::checkGeometry
<< " non closed cells to set " << cells.name() << endl; << " non closed cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, cells); mergeAndWrite(*surfWriter, cells);
} }
@ -589,7 +589,7 @@ Foam::label Foam::checkGeometry
<< aspectCells.name() << endl; << aspectCells.name() << endl;
aspectCells.instance() = mesh.pointsInstance(); aspectCells.instance() = mesh.pointsInstance();
aspectCells.write(); aspectCells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, aspectCells); mergeAndWrite(*surfWriter, aspectCells);
} }
@ -610,7 +610,7 @@ Foam::label Foam::checkGeometry
<< " zero area faces to set " << faces.name() << endl; << " zero area faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -632,7 +632,7 @@ Foam::label Foam::checkGeometry
<< " zero volume cells to set " << cells.name() << endl; << " zero volume cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, cells); mergeAndWrite(*surfWriter, cells);
} }
@ -655,7 +655,7 @@ Foam::label Foam::checkGeometry
<< " non-orthogonal faces to set " << faces.name() << endl; << " non-orthogonal faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -677,7 +677,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -699,7 +699,7 @@ Foam::label Foam::checkGeometry
<< " skew faces to set " << faces.name() << endl; << " skew faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -723,7 +723,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -756,7 +756,7 @@ Foam::label Foam::checkGeometry
<< "decomposition tets to set " << faces.name() << endl; << "decomposition tets to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -781,7 +781,7 @@ Foam::label Foam::checkGeometry
<< endl; << endl;
points.instance() = mesh.pointsInstance(); points.instance() = mesh.pointsInstance();
points.write(); points.write();
if (setWriter.valid()) if (setWriter)
{ {
mergeAndWrite(*setWriter, points); mergeAndWrite(*setWriter, points);
} }
@ -804,7 +804,7 @@ Foam::label Foam::checkGeometry
<< " apart) points to set " << nearPoints.name() << endl; << " apart) points to set " << nearPoints.name() << endl;
nearPoints.instance() = mesh.pointsInstance(); nearPoints.instance() = mesh.pointsInstance();
nearPoints.write(); nearPoints.write();
if (setWriter.valid()) if (setWriter)
{ {
mergeAndWrite(*setWriter, nearPoints); mergeAndWrite(*setWriter, nearPoints);
} }
@ -828,7 +828,7 @@ Foam::label Foam::checkGeometry
<< endl; << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -851,7 +851,7 @@ Foam::label Foam::checkGeometry
<< " warped faces to set " << faces.name() << endl; << " warped faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -872,7 +872,7 @@ Foam::label Foam::checkGeometry
<< " under-determined cells to set " << cells.name() << endl; << " under-determined cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, cells); mergeAndWrite(*surfWriter, cells);
} }
@ -892,7 +892,7 @@ Foam::label Foam::checkGeometry
<< " concave cells to set " << cells.name() << endl; << " concave cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, cells); mergeAndWrite(*surfWriter, cells);
} }
@ -913,7 +913,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -934,7 +934,7 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -949,12 +949,12 @@ Foam::label Foam::checkGeometry
const word procAndTime(Foam::name(Pstream::myProcNo()) + "_" + tmName); const word procAndTime(Foam::name(Pstream::myProcNo()) + "_" + tmName);
autoPtr<surfaceWriter> patchWriter; autoPtr<surfaceWriter> patchWriter;
if (!surfWriter.valid()) if (!surfWriter)
{ {
patchWriter.reset(new surfaceWriters::vtkWriter()); patchWriter.reset(new surfaceWriters::vtkWriter());
} }
surfaceWriter& wr = (surfWriter.valid() ? *surfWriter : *patchWriter); surfaceWriter& wr = (surfWriter ? *surfWriter : *patchWriter);
// Currently only do AMI checks // Currently only do AMI checks

View File

@ -30,7 +30,7 @@ Foam::label Foam::checkMeshQuality
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid()) if (writer)
{ {
mergeAndWrite(*writer, faces); mergeAndWrite(*writer, faces);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -202,7 +202,7 @@ Foam::label Foam::checkTopology
<< " illegal cells to set " << cells.name() << endl; << " illegal cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, cells); mergeAndWrite(*surfWriter, cells);
} }
@ -226,7 +226,7 @@ Foam::label Foam::checkTopology
<< " unused points to set " << points.name() << endl; << " unused points to set " << points.name() << endl;
points.instance() = mesh.pointsInstance(); points.instance() = mesh.pointsInstance();
points.write(); points.write();
if (setWriter.valid()) if (setWriter)
{ {
mergeAndWrite(*setWriter, points); mergeAndWrite(*setWriter, points);
} }
@ -248,7 +248,7 @@ Foam::label Foam::checkTopology
<< " unordered faces to set " << faces.name() << endl; << " unordered faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -268,7 +268,7 @@ Foam::label Foam::checkTopology
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -289,7 +289,7 @@ Foam::label Foam::checkTopology
<< endl; << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, cells); mergeAndWrite(*surfWriter, cells);
} }
@ -313,7 +313,7 @@ Foam::label Foam::checkTopology
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, faces); mergeAndWrite(*surfWriter, faces);
} }
@ -368,7 +368,7 @@ Foam::label Foam::checkTopology
<< endl; << endl;
oneCells.instance() = mesh.pointsInstance(); oneCells.instance() = mesh.pointsInstance();
oneCells.write(); oneCells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, oneCells); mergeAndWrite(*surfWriter, oneCells);
} }
@ -384,7 +384,7 @@ Foam::label Foam::checkTopology
<< endl; << endl;
twoCells.instance() = mesh.pointsInstance(); twoCells.instance() = mesh.pointsInstance();
twoCells.write(); twoCells.write();
if (surfWriter.valid()) if (surfWriter)
{ {
mergeAndWrite(*surfWriter, twoCells); mergeAndWrite(*surfWriter, twoCells);
} }
@ -529,7 +529,7 @@ Foam::label Foam::checkTopology
<< " points that are in multiple regions to set " << " points that are in multiple regions to set "
<< points.name() << endl; << points.name() << endl;
points.write(); points.write();
if (setWriter.valid()) if (setWriter)
{ {
mergeAndWrite(*setWriter, points); mergeAndWrite(*setWriter, points);
} }
@ -640,7 +640,7 @@ Foam::label Foam::checkTopology
<< " conflicting points to set " << points.name() << endl; << " conflicting points to set " << points.name() << endl;
points.instance() = mesh.pointsInstance(); points.instance() = mesh.pointsInstance();
points.write(); points.write();
if (setWriter.valid()) if (setWriter)
{ {
mergeAndWrite(*setWriter, points); mergeAndWrite(*setWriter, points);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1035,9 +1036,9 @@ void Foam::meshDualiser::setRefinement
-1, //masterCellID, -1, //masterCellID,
-1 //zoneID -1 //zoneID
); );
if (dualCcStr.valid()) if (dualCcStr)
{ {
meshTools::writeOBJ(dualCcStr(), mesh_.points()[pointi]); meshTools::writeOBJ(*dualCcStr, mesh_.points()[pointi]);
} }
} }
@ -1079,11 +1080,11 @@ void Foam::meshDualiser::setRefinement
-1, //masterCellID -1, //masterCellID
mesh_.cellZones().whichZone(pCells[pCelli]) //zoneID mesh_.cellZones().whichZone(pCells[pCelli]) //zoneID
); );
if (dualCcStr.valid()) if (dualCcStr)
{ {
meshTools::writeOBJ meshTools::writeOBJ
( (
dualCcStr(), *dualCcStr,
0.5*(mesh_.points()[pointi]+cellCentres[pCells[pCelli]]) 0.5*(mesh_.points()[pointi]+cellCentres[pCells[pCelli]])
); );
} }
@ -1104,9 +1105,9 @@ void Foam::meshDualiser::setRefinement
-1 //zoneID -1 //zoneID
); );
if (dualCcStr.valid()) if (dualCcStr)
{ {
meshTools::writeOBJ(dualCcStr(), mesh_.points()[pointi]); meshTools::writeOBJ(*dualCcStr, mesh_.points()[pointi]);
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -393,9 +393,9 @@ bool doCommand
currentSet.resize(max(currentSet.size(), typSize)); currentSet.resize(max(currentSet.size(), typSize));
} }
if (currentSetPtr.valid()) if (currentSetPtr)
{ {
topoSet& currentSet = currentSetPtr(); topoSet& currentSet = *currentSetPtr;
Info<< " Set:" << currentSet.name() Info<< " Set:" << currentSet.name()
<< " Size:" << returnReduce(currentSet.size(), sumOp<label>()) << " Size:" << returnReduce(currentSet.size(), sumOp<label>())
@ -829,9 +829,9 @@ int main(int argc, char *argv[])
commandStatus stat = INVALID; commandStatus stat = INVALID;
if (fileStreamPtr.valid()) if (fileStreamPtr)
{ {
if (!fileStreamPtr().good()) if (!fileStreamPtr->good())
{ {
Info<< "End of batch file" << endl; Info<< "End of batch file" << endl;
// No error. // No error.

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -394,7 +394,7 @@ int main(int argc, char *argv[])
break; break;
} }
if (currentSet.valid()) if (currentSet)
{ {
Info<< " " Info<< " "
<< currentSet().type() << ' ' << currentSet().type() << ' '

View File

@ -426,9 +426,9 @@ int main(int argc, char *argv[])
if (!lagrangianDirs.empty()) if (!lagrangianDirs.empty())
{ {
if (meshPtr.valid()) if (meshPtr)
{ {
meshPtr().readUpdate(); meshPtr->readUpdate();
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -334,7 +334,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
autoPtr<polyMesh> procMeshPtr; autoPtr<polyMesh> procMeshPtr;
if (facesInstancePointsPtr_.valid()) if (facesInstancePointsPtr_)
{ {
// Construct mesh from facesInstance. // Construct mesh from facesInstance.
pointField facesInstancePoints pointField facesInstancePoints
@ -738,7 +738,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
procMesh.write(); procMesh.write();
// Write points if pointsInstance differing from facesInstance // Write points if pointsInstance differing from facesInstance
if (facesInstancePointsPtr_.valid()) if (facesInstancePointsPtr_)
{ {
pointIOField pointsInstancePoints pointIOField pointsInstancePoints
( (

View File

@ -672,9 +672,9 @@ void readFields
// Load field (but not oldTime) // Load field (but not oldTime)
readField(io, mesh, i, fields); readField(io, mesh, i, fields);
// Create zero sized field and send // Create zero sized field and send
if (subsetterPtr.valid()) if (subsetterPtr)
{ {
tmp<GeoField> tsubfld = subsetterPtr().interpolate(fields[i]); tmp<GeoField> tsubfld = subsetterPtr->interpolate(fields[i]);
// Send to all processors that don't have a mesh // Send to all processors that don't have a mesh
for (label procI = 1; procI < Pstream::nProcs(); ++procI) for (label procI = 1; procI < Pstream::nProcs(); ++procI)
@ -1415,9 +1415,9 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
autoPtr<mapDistributePolyMesh> mapPtr; autoPtr<mapDistributePolyMesh> mapPtr;
if (baseMeshPtr.valid() && baseMeshPtr().nCells()) if (baseMeshPtr && baseMeshPtr->nCells())
{ {
const fvMesh& baseMesh = baseMeshPtr(); const fvMesh& baseMesh = *baseMeshPtr;
labelListList cellSubMap(Pstream::nProcs()); labelListList cellSubMap(Pstream::nProcs());
cellSubMap[Pstream::masterNo()] = identity(mesh.nCells()); cellSubMap[Pstream::masterNo()] = identity(mesh.nCells());
@ -1803,7 +1803,7 @@ void reconstructLagrangian
if (cloudNames.size()) if (cloudNames.size())
{ {
if (!lagrangianReconstructorPtr.valid()) if (!lagrangianReconstructorPtr)
{ {
lagrangianReconstructorPtr.reset lagrangianReconstructorPtr.reset
( (
@ -2116,7 +2116,7 @@ void redistributeLagrangian
{ {
if (clouds.size()) if (clouds.size())
{ {
if (!lagrangianReconstructorPtr.valid()) if (!lagrangianReconstructorPtr)
{ {
lagrangianReconstructorPtr.reset lagrangianReconstructorPtr.reset
( (
@ -2804,7 +2804,7 @@ int main(int argc, char *argv[])
Info<< " Detected topology change;" Info<< " Detected topology change;"
<< " reconstructing addressing" << nl << endl; << " reconstructing addressing" << nl << endl;
if (baseMeshPtr.valid()) if (baseMeshPtr)
{ {
// Cannot do a baseMesh::readUpdate() since not all // Cannot do a baseMesh::readUpdate() since not all
// processors will have mesh files. So instead just // processors will have mesh files. So instead just

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -56,7 +56,7 @@ if (doFiniteArea)
FatalError.throwExceptions(throwing); FatalError.throwExceptions(throwing);
} }
if (faMeshPtr.valid() && nAreaFields) if (faMeshPtr && nAreaFields)
{ {
reportFields::area(Info, objects); reportFields::area(Info, objects);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -153,7 +153,7 @@ Description
// Finish writers // Finish writers
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->close(); internalWriter->close();
} }

View File

@ -262,7 +262,7 @@ Description
// CellData // CellData
{ {
// Begin CellData // Begin CellData
if (internalWriter.valid()) if (internalWriter)
{ {
// Optionally with cellID and procID fields // Optionally with cellID and procID fields
internalWriter->beginCellData internalWriter->beginCellData
@ -323,7 +323,7 @@ Description
if (doPointValues) if (doPointValues)
{ {
// Begin PointData // Begin PointData
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->beginPointData internalWriter->beginPointData
( (
@ -386,7 +386,7 @@ Description
// Finish writers // Finish writers
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->close(); internalWriter->close();
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -60,7 +60,7 @@ bool writeDimField
const auto& field = tfield(); const auto& field = tfield();
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->write(field); internalWriter->write(field);
} }
@ -85,7 +85,7 @@ bool writeDimField
const auto& field = tfield(); const auto& field = tfield();
if (internalWriter.valid() && pInterp.valid()) if (internalWriter && pInterp)
{ {
internalWriter->write(field, *pInterp); internalWriter->write(field, *pInterp);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -83,7 +83,7 @@ bool writePointField
const auto& field = tproxied(); const auto& field = tproxied();
// Internal // Internal
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->write(field); internalWriter->write(field);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -63,7 +63,7 @@ bool writeVolField
const auto& field = tfield(); const auto& field = tfield();
// Internal // Internal
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->write(field); internalWriter->write(field);
} }
@ -99,7 +99,7 @@ bool writeVolField
const auto& field = tfield(); const auto& field = tfield();
// Internal // Internal
if (internalWriter.valid() && pInterp.valid()) if (internalWriter && pInterp)
{ {
internalWriter->write(field, *pInterp); internalWriter->write(field, *pInterp);
} }

View File

@ -99,7 +99,7 @@ int main(int argc, char *argv[])
autoPtr<lumpedPointIOMovement> movement = autoPtr<lumpedPointIOMovement> movement =
lumpedPointIOMovement::New(runTime); lumpedPointIOMovement::New(runTime);
if (!movement.valid()) if (!movement)
{ {
Info<< "No valid movement found" << endl; Info<< "No valid movement found" << endl;
return 1; return 1;
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New(mesh); autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New(mesh);
if (!movement.valid()) if (!movement)
{ {
Info<< "No valid movement found" << endl; Info<< "No valid movement found" << endl;
return 1; return 1;

View File

@ -723,7 +723,7 @@ int main(int argc, char *argv[])
mesh.readUpdate(); mesh.readUpdate();
if (args.found("dummy-phi") && !dummyPhi.valid()) if (args.found("dummy-phi") && !dummyPhi)
{ {
Info<< "Adding a dummy phi" << endl; Info<< "Adding a dummy phi" << endl;
dummyPhi.reset dummyPhi.reset
@ -802,9 +802,9 @@ int main(int argc, char *argv[])
ctrl ctrl
); );
} }
else if (exprDictPtr.valid()) else if (exprDictPtr)
{ {
const dictionary& exprDict = exprDictPtr(); const dictionary& exprDict = *exprDictPtr;
// Read set construct info from dictionary // Read set construct info from dictionary
PtrList<entry> actions(exprDict.lookup("expressions")); PtrList<entry> actions(exprDict.lookup("expressions"));
@ -898,7 +898,7 @@ int main(int argc, char *argv[])
); );
} }
} }
else if (exprDictPtr.valid()) else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "No command-line or dictionary??" << nl << endl << "No command-line or dictionary??" << nl << endl

View File

@ -469,7 +469,7 @@ int main(int argc, char *argv[])
Info<< "Surface has " << illegalFaces.size() Info<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl; << " illegal triangles." << endl;
if (surfWriter.valid()) if (surfWriter)
{ {
boolList isIllegalFace(surf.size(), false); boolList isIllegalFace(surf.size(), false);
UIndirectList<bool>(isIllegalFace, illegalFaces) = true; UIndirectList<bool>(isIllegalFace, illegalFaces) = true;
@ -598,7 +598,7 @@ int main(int argc, char *argv[])
} }
// Dump for subsetting // Dump for subsetting
if (surfWriter.valid()) if (surfWriter)
{ {
// Transcribe faces // Transcribe faces
faceList faces(surf.size()); faceList faces(surf.size());
@ -867,7 +867,7 @@ int main(int argc, char *argv[])
{ {
Info<< "Splitting surface into parts ..." << endl << endl; Info<< "Splitting surface into parts ..." << endl << endl;
if (!surfWriter.valid()) if (!surfWriter)
{ {
surfWriter.reset(new surfaceWriters::vtkWriter()); surfWriter.reset(new surfaceWriters::vtkWriter());
} }
@ -933,7 +933,7 @@ int main(int argc, char *argv[])
if (outputThreshold > 0) if (outputThreshold > 0)
{ {
if (!surfWriter.valid()) if (!surfWriter)
{ {
surfWriter.reset(new surfaceWriters::vtkWriter()); surfWriter.reset(new surfaceWriters::vtkWriter());
} }
@ -1001,7 +1001,7 @@ int main(int argc, char *argv[])
{ {
nInt++; nInt++;
if (intStreamPtr.valid()) if (intStreamPtr)
{ {
intStreamPtr().write(hitInfo.hitPoint()); intStreamPtr().write(hitInfo.hitPoint());
} }
@ -1013,7 +1013,7 @@ int main(int argc, char *argv[])
{ {
nInt++; nInt++;
if (intStreamPtr.valid()) if (intStreamPtr)
{ {
intStreamPtr().write(hitInfo2.hitPoint()); intStreamPtr().write(hitInfo2.hitPoint());
} }
@ -1043,7 +1043,7 @@ int main(int argc, char *argv[])
// ) // )
// ); // );
// //
// if (hitInfo.hit() && intStreamPtr.valid()) // if (hitInfo.hit() && intStreamPtr)
// { // {
// intStreamPtr().write(hitInfo.hitPoint()); // intStreamPtr().write(hitInfo.hitPoint());
// //
@ -1070,7 +1070,7 @@ int main(int argc, char *argv[])
Info<< "Surface is self-intersecting at " << nInt Info<< "Surface is self-intersecting at " << nInt
<< " locations." << endl; << " locations." << endl;
if (intStreamPtr.valid()) if (intStreamPtr)
{ {
Info<< "Writing intersection points to " Info<< "Writing intersection points to "
<< intStreamPtr().name() << endl; << intStreamPtr().name() << endl;

View File

@ -346,14 +346,14 @@ int main(int argc, char *argv[])
// Load a single file, or load and combine multiple selected files // Load a single file, or load and combine multiple selected files
autoPtr<triSurface> surfPtr = loader.load(loadingOption, scaleFactor); autoPtr<triSurface> surfPtr = loader.load(loadingOption, scaleFactor);
if (!surfPtr.valid() || surfPtr().empty()) if (!surfPtr || surfPtr->empty())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Problem loading surface(s) for entry: " << "Problem loading surface(s) for entry: "
<< dictName << exit(FatalError); << dictName << exit(FatalError);
} }
triSurface surf = surfPtr(); triSurface surf = *surfPtr;
Info<< nl Info<< nl
<< "Statistics:" << nl; << "Statistics:" << nl;
@ -711,7 +711,7 @@ int main(int argc, char *argv[])
10 // externalAngleTolerance 10 // externalAngleTolerance
); );
if (vtkWriter.valid()) if (vtkWriter)
{ {
vtkWriter->beginCellData(); vtkWriter->beginCellData();
vtkWriter->write("internalCloseness", tcloseness[0]()); vtkWriter->write("internalCloseness", tcloseness[0]());
@ -735,7 +735,7 @@ int main(int argc, char *argv[])
maxProximity maxProximity
); );
if (vtkWriter.valid()) if (vtkWriter)
{ {
vtkWriter->beginCellData(); vtkWriter->beginCellData();
vtkWriter->write("featureProximity", tproximity()); vtkWriter->write("featureProximity", tproximity());
@ -753,7 +753,7 @@ int main(int argc, char *argv[])
surf surf
); );
if (vtkWriter.valid()) if (vtkWriter)
{ {
vtkWriter->beginPointData(); vtkWriter->beginPointData();
vtkWriter->write("curvature", tcurvature()); vtkWriter->write("curvature", tcurvature());

View File

@ -277,7 +277,7 @@ int main(int argc, char *argv[])
surf.cleanup(true); surf.cleanup(true);
} }
if (fromCsys.valid()) if (fromCsys)
{ {
Info<< "move points from coordinate system: " Info<< "move points from coordinate system: "
<< fromCsys->name() << endl; << fromCsys->name() << endl;
@ -285,7 +285,7 @@ int main(int argc, char *argv[])
surf.movePoints(tpf()); surf.movePoints(tpf());
} }
if (toCsys.valid()) if (toCsys)
{ {
Info<< "move points to coordinate system: " Info<< "move points to coordinate system: "
<< toCsys->name() << endl; << toCsys->name() << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -163,7 +163,7 @@ Foam::IOobjectList::IOobjectList
bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr) bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
{ {
if (objectPtr.valid()) if (objectPtr)
{ {
return insert(objectPtr->name(), objectPtr); return insert(objectPtr->name(), objectPtr);
} }
@ -174,7 +174,7 @@ bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
bool Foam::IOobjectList::add(autoPtr<IOobject>&& objectPtr) bool Foam::IOobjectList::add(autoPtr<IOobject>&& objectPtr)
{ {
if (objectPtr.valid()) if (objectPtr)
{ {
return insert(objectPtr->name(), objectPtr); return insert(objectPtr->name(), objectPtr);
} }

View File

@ -495,7 +495,7 @@ void Foam::functionObjectList::resetState()
Foam::IOdictionary& Foam::functionObjectList::stateDict() Foam::IOdictionary& Foam::functionObjectList::stateDict()
{ {
if (!stateDictPtr_.valid()) if (!stateDictPtr_)
{ {
createStateDict(); createStateDict();
} }
@ -506,7 +506,7 @@ Foam::IOdictionary& Foam::functionObjectList::stateDict()
const Foam::IOdictionary& Foam::functionObjectList::stateDict() const const Foam::IOdictionary& Foam::functionObjectList::stateDict() const
{ {
if (!stateDictPtr_.valid()) if (!stateDictPtr_)
{ {
createStateDict(); createStateDict();
} }
@ -517,7 +517,7 @@ const Foam::IOdictionary& Foam::functionObjectList::stateDict() const
Foam::objectRegistry& Foam::functionObjectList::storedObjects() Foam::objectRegistry& Foam::functionObjectList::storedObjects()
{ {
if (!objectsRegistryPtr_.valid()) if (!objectsRegistryPtr_)
{ {
createOutputRegistry(); createOutputRegistry();
} }
@ -528,7 +528,7 @@ Foam::objectRegistry& Foam::functionObjectList::storedObjects()
const Foam::objectRegistry& Foam::functionObjectList::storedObjects() const const Foam::objectRegistry& Foam::functionObjectList::storedObjects() const
{ {
if (!objectsRegistryPtr_.valid()) if (!objectsRegistryPtr_)
{ {
createOutputRegistry(); createOutputRegistry();
} }
@ -727,7 +727,7 @@ bool Foam::functionObjectList::adjustTimeStep()
bool Foam::functionObjectList::read() bool Foam::functionObjectList::read()
{ {
if (!stateDictPtr_.valid()) if (!stateDictPtr_)
{ {
createStateDict(); createStateDict();
} }
@ -903,7 +903,7 @@ bool Foam::functionObjectList::read()
FatalIOError.throwExceptions(throwingIOerr); FatalIOError.throwExceptions(throwingIOerr);
// Required functionObject to be valid on all processors // Required functionObject to be valid on all processors
if (returnReduce(foPtr.valid(), andOp<bool>())) if (returnReduce(bool(foPtr), andOp<bool>()))
{ {
objPtr.reset(foPtr.release()); objPtr.reset(foPtr.release());
} }

View File

@ -241,7 +241,7 @@ Foam::OFstream& Foam::functionObjects::writeFile::file()
return Snull; return Snull;
} }
if (!filePtr_.valid()) if (!filePtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "File pointer not allocated\n"; << "File pointer not allocated\n";

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -106,7 +106,7 @@ Foam::Istream& Foam::regIOobject::readStream(const bool valid)
} }
// Construct object stream and read header if not already constructed // Construct object stream and read header if not already constructed
if (!isPtr_.valid()) if (!isPtr_)
{ {
fileName objPath; fileName objPath;
if (watchIndices_.size()) if (watchIndices_.size())
@ -152,7 +152,7 @@ Foam::Istream& Foam::regIOobject::readStream
} }
// Construct IFstream if not already constructed // Construct IFstream if not already constructed
if (!isPtr_.valid()) if (!isPtr_)
{ {
readStream(valid); readStream(valid);
@ -185,11 +185,11 @@ void Foam::regIOobject::close()
{ {
Pout<< "regIOobject::close() : " Pout<< "regIOobject::close() : "
<< "finished reading " << "finished reading "
<< (isPtr_.valid() ? isPtr_().name() : "dummy") << (isPtr_ ? isPtr_->name() : "dummy")
<< endl; << endl;
} }
isPtr_.clear(); isPtr_.reset(nullptr);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com> Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -518,7 +518,7 @@ void Foam::expressions::exprResult::operator=(const exprResult& rhs)
<< exit(FatalError); << exit(FatalError);
} }
} }
else if (objectPtr_.valid()) else if (objectPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Assignment with general content not possible" << nl << "Assignment with general content not possible" << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com> Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -283,7 +283,7 @@ inline bool Foam::expressions::exprResult::isBool() const
inline bool Foam::expressions::exprResult::isObject() const inline bool Foam::expressions::exprResult::isObject() const
{ {
return objectPtr_.valid(); return bool(objectPtr_);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -228,7 +228,7 @@ template<class Type>
const Foam::pointPatchField<Type>& const Foam::pointPatchField<Type>&
Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
{ {
if (!redirectPatchFieldPtr_.valid()) if (!redirectPatchFieldPtr_)
{ {
// Construct a patch // Construct a patch
// Make sure to construct the patchfield with up-to-date value // Make sure to construct the patchfield with up-to-date value

View File

@ -1262,7 +1262,7 @@ void Foam::argList::parse
fileHandler().NewIFstream(source) fileHandler().NewIFstream(source)
); );
if (!decompDictStream.valid() || !decompDictStream->good()) if (!decompDictStream || !decompDictStream->good())
{ {
FatalError FatalError
<< "Cannot read decomposeParDict from " << "Cannot read decomposeParDict from "

View File

@ -161,7 +161,7 @@ void Foam::interpolationTable<Type>::write(Ostream& os) const
{ {
os.writeEntry("file", fileName_); os.writeEntry("file", fileName_);
os.writeEntry("outOfBounds", bounds::repeatableBoundingNames[bounding_]); os.writeEntry("outOfBounds", bounds::repeatableBoundingNames[bounding_]);
if (reader_.valid()) if (reader_)
{ {
reader_->write(os); reader_->write(os);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -447,7 +447,7 @@ public:
//- Whether to agglomerate across processors //- Whether to agglomerate across processors
bool processorAgglomerate() const bool processorAgglomerate() const
{ {
return procAgglomeratorPtr_.valid(); return bool(procAgglomeratorPtr_);
} }
//- Mapping from processor to agglomerated processor (global, all //- Mapping from processor to agglomerated processor (global, all

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -170,10 +170,10 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
tmp<labelField> tfineToCoarse(new labelField(0)); tmp<labelField> tfineToCoarse(new labelField(0));
labelField& fineToCoarse = tfineToCoarse.ref(); labelField& fineToCoarse = tfineToCoarse.ref();
if (singleCellMeshPtr.valid()) if (singleCellMeshPtr)
{ {
// On master call the agglomerator // On master call the agglomerator
const lduPrimitiveMesh& singleCellMesh = singleCellMeshPtr(); const lduPrimitiveMesh& singleCellMesh = *singleCellMeshPtr;
label nCoarseProcs; label nCoarseProcs;
fineToCoarse = pairGAMGAgglomeration::agglomerate fineToCoarse = pairGAMGAgglomeration::agglomerate

View File

@ -140,9 +140,12 @@ public:
// Member Functions // Member Functions
// Check // Query
//- True if the managed pointer is null //- Deprecated(2020-07) True if the managed pointer is null
//
// \deprecated(2020-07) - use bool operator
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
bool empty() const noexcept { return !ptr_; } bool empty() const noexcept { return !ptr_; }
//- True if the managed pointer is non-null //- True if the managed pointer is non-null

View File

@ -50,7 +50,7 @@ namespace Foam
class refCount class refCount
{ {
// Private data // Private Data
int count_; int count_;
@ -62,7 +62,7 @@ public:
// Constructors // Constructors
//- Construct null initializing count to 0 //- Default construct, initializing count to 0
constexpr refCount() noexcept constexpr refCount() noexcept
: :
count_(0) count_(0)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,7 +49,7 @@ See also
#include "refCount.H" #include "refCount.H"
#include "word.H" #include "word.H"
#include <utility> #include "stdFoam.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,20 +69,21 @@ class tmp
enum refType enum refType
{ {
PTR, //!< Managing a pointer (ref-counted) PTR, //!< Managing a pointer (ref-counted)
CREF //!< Using a const-reference to an object CREF //!< Using (const) reference to an object
}; };
//- The managed pointer or the address of const-reference object //- The managed pointer or address of the object (reference)
mutable T* ptr_; mutable T* ptr_;
//- The type (managed pointer | const-reference object) //- The type (managed pointer | object reference)
mutable refType type_; mutable refType type_;
// Private Member Operators // Private Member Operators
//- Increment the ref-count for a managed pointer //- Increment the ref-count for a managed pointer
inline void operator++(); //- and check that it is not oversubscribed
inline void incrCount();
public: public:
@ -122,7 +123,7 @@ public:
// Constructors // Constructors
//- Construct with no managed pointer. //- Default construct, no managed pointer.
inline constexpr tmp() noexcept; inline constexpr tmp() noexcept;
//- Construct with no managed pointer. //- Construct with no managed pointer.
@ -159,15 +160,17 @@ public:
// Query // Query
//- True if this is a managed pointer (not a const reference) //- Deprecated(2020-07) True if a null managed pointer
inline bool isTmp() const noexcept; //
// \deprecated(2020-07) - use bool operator
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
bool empty() const noexcept { return !ptr_; }
//- True if this is a non-null managed pointer //- True for non-null pointer/reference
inline bool empty() const noexcept; bool valid() const noexcept { return ptr_; }
//- True if this is a non-null managed pointer, //- True if this is a managed pointer (not a reference)
//- or is a const object reference bool isTmp() const noexcept { return type_ == PTR; }
inline bool valid() const noexcept;
//- True if this is a non-null managed pointer with a unique ref-count //- True if this is a non-null managed pointer with a unique ref-count
inline bool movable() const noexcept; inline bool movable() const noexcept;
@ -179,10 +182,10 @@ public:
// Access // Access
//- Return pointer without nullptr checking. //- Return pointer without nullptr checking.
inline T* get() noexcept; T* get() noexcept { return ptr_; }
//- Return const pointer without nullptr checking. //- Return const pointer without nullptr checking.
inline const T* get() const noexcept; const T* get() const noexcept { return ptr_; }
//- Return the const object reference or a const reference to the //- Return the const object reference or a const reference to the
//- contents of a non-null managed pointer. //- contents of a non-null managed pointer.
@ -211,12 +214,8 @@ public:
//- delete object and set pointer to nullptr //- delete object and set pointer to nullptr
inline void clear() const noexcept; inline void clear() const noexcept;
//- Release ownership of managed temporary object.
// After this call no object is managed.
inline void reset() noexcept;
//- Delete managed temporary object and set to new given pointer //- Delete managed temporary object and set to new given pointer
inline void reset(T* p) noexcept; inline void reset(T* p = nullptr) noexcept;
//- Clear existing and transfer ownership. //- Clear existing and transfer ownership.
inline void reset(tmp<T>&& other) noexcept; inline void reset(tmp<T>&& other) noexcept;
@ -245,12 +244,8 @@ public:
// Fatal for a null managed pointer or if the object is const. // Fatal for a null managed pointer or if the object is const.
inline T* operator->(); inline T* operator->();
//- Is non-null managed pointer or const object reference : valid() //- Non-null pointer/reference : valid()
explicit inline operator bool() const noexcept; explicit operator bool() const noexcept { return ptr_; }
//- Take ownership of the pointer.
// Fatal for a null pointer, or when the pointer is non-unique.
inline void operator=(T* p);
//- Transfer ownership of the managed pointer. //- Transfer ownership of the managed pointer.
// Fatal for a null managed pointer or if the object is const. // Fatal for a null managed pointer or if the object is const.
@ -259,12 +254,12 @@ public:
//- Clear existing and transfer ownership. //- Clear existing and transfer ownership.
inline void operator=(tmp<T>&& other) noexcept; inline void operator=(tmp<T>&& other) noexcept;
//- Take ownership of the pointer.
// Fatal for a null pointer, or when the pointer is non-unique.
inline void operator=(T* p);
// Housekeeping //- Reset via assignment from literal nullptr
inline void operator=(std::nullptr_t) noexcept;
//- No assignment from literal nullptr.
// Consistent with run-time check for nullptr on assignment.
void operator=(std::nullptr_t) = delete;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,7 +32,7 @@ License
// * * * * * * * * * * * * * Private Member Operators * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Operators * * * * * * * * * * * //
template<class T> template<class T>
inline void Foam::tmp<T>::operator++() inline void Foam::tmp<T>::incrCount()
{ {
ptr_->operator++(); ptr_->operator++();
@ -138,7 +138,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t)
{ {
if (ptr_) if (ptr_)
{ {
operator++(); this->incrCount();
} }
else else
{ {
@ -166,7 +166,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t, bool reuse)
} }
else else
{ {
operator++(); this->incrCount();
} }
} }
else else
@ -188,27 +188,6 @@ inline Foam::tmp<T>::~tmp()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline bool Foam::tmp<T>::isTmp() const noexcept
{
return type_ == PTR;
}
template<class T>
inline bool Foam::tmp<T>::empty() const noexcept
{
return (!ptr_ && isTmp());
}
template<class T>
inline bool Foam::tmp<T>::valid() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T> template<class T>
inline bool Foam::tmp<T>::movable() const noexcept inline bool Foam::tmp<T>::movable() const noexcept
{ {
@ -223,20 +202,6 @@ inline Foam::word Foam::tmp<T>::typeName() const
} }
template<class T>
inline T* Foam::tmp<T>::get() noexcept
{
return ptr_; // non-const pointer
}
template<class T>
inline const T* Foam::tmp<T>::get() const noexcept
{
return ptr_; // const pointer
}
template<class T> template<class T>
inline const T& Foam::tmp<T>::cref() const inline const T& Foam::tmp<T>::cref() const
{ {
@ -266,7 +231,7 @@ inline T& Foam::tmp<T>::ref() const
<< abort(FatalError); << abort(FatalError);
} }
} }
else else // if (type_ == CREF)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Attempted non-const reference to const object from a " << "Attempted non-const reference to const object from a "
@ -295,15 +260,16 @@ inline T& Foam::tmp<T>::constCast() const
template<class T> template<class T>
inline T* Foam::tmp<T>::ptr() const inline T* Foam::tmp<T>::ptr() const
{ {
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
if (isTmp()) if (isTmp())
{ {
if (!ptr_) if (!ptr_->unique())
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
else if (!ptr_->unique())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Attempt to acquire pointer to object referred to" << "Attempt to acquire pointer to object referred to"
@ -311,10 +277,10 @@ inline T* Foam::tmp<T>::ptr() const
<< abort(FatalError); << abort(FatalError);
} }
T* ptr = ptr_; T* p = ptr_;
ptr_ = nullptr; ptr_ = nullptr;
return ptr; return p;
} }
return ptr_->clone().ptr(); return ptr_->clone().ptr();
@ -339,15 +305,6 @@ inline void Foam::tmp<T>::clear() const noexcept
} }
template<class T>
inline void Foam::tmp<T>::reset() noexcept
{
clear();
ptr_ = nullptr;
type_ = PTR;
}
template<class T> template<class T>
inline void Foam::tmp<T>::reset(T* p) noexcept inline void Foam::tmp<T>::reset(T* p) noexcept
{ {
@ -455,37 +412,6 @@ inline T* Foam::tmp<T>::operator->()
} }
template<class T>
inline Foam::tmp<T>::operator bool() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T>
inline void Foam::tmp<T>::operator=(T* p)
{
clear();
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
else if (!p->unique())
{
FatalErrorInFunction
<< "Attempted assignment of a " << typeName()
<< " to non-unique pointer"
<< abort(FatalError);
}
ptr_ = p;
type_ = PTR;
}
template<class T> template<class T>
inline void Foam::tmp<T>::operator=(const tmp<T>& t) inline void Foam::tmp<T>::operator=(const tmp<T>& t)
{ {
@ -536,4 +462,32 @@ inline void Foam::tmp<T>::operator=(tmp<T>&& other) noexcept
} }
template<class T>
inline void Foam::tmp<T>::operator=(T* p)
{
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
else if (!p->unique())
{
FatalErrorInFunction
<< "Attempted assignment of a " << typeName()
<< " to non-unique pointer"
<< abort(FatalError);
}
reset(p);
}
template<class T>
inline void Foam::tmp<T>::operator=(std::nullptr_t) noexcept
{
reset(nullptr);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -62,13 +62,13 @@ class tmpNrc
enum refType enum refType
{ {
PTR, //!< Managing a pointer (not ref-counted) PTR, //!< Managing a pointer (not ref-counted)
CREF //!< Using a const-reference to an object CREF //!< Using (const) reference to an object
}; };
//- The managed pointer or the address of const-reference object //- The managed pointer or address of the object (reference)
mutable T* ptr_; mutable T* ptr_;
//- The type (managed pointer | const-reference object) //- The type (managed pointer | object reference)
mutable refType type_; mutable refType type_;
@ -109,7 +109,7 @@ public:
// Constructors // Constructors
//- Construct with no managed pointer. //- Default construct, no managed pointer.
inline constexpr tmpNrc() noexcept; inline constexpr tmpNrc() noexcept;
//- Construct with no managed pointer. //- Construct with no managed pointer.
@ -139,17 +139,19 @@ public:
// Query // Query
//- True if this is a managed pointer (not a const reference) //- Deprecated(2020-07) True if a null managed pointer
inline bool isTmp() const noexcept; //
// \deprecated(2020-07) - use bool operator
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
bool empty() const noexcept { return !ptr_; }
//- True for non-null pointer/reference
bool valid() const noexcept { return ptr_; }
//- True if this is a managed pointer (not a reference)
bool isTmp() const noexcept { return type_ == PTR; }
//- True if this is a non-null managed pointer //- True if this is a non-null managed pointer
inline bool empty() const noexcept;
//- True if this is a non-null managed pointer,
//- or is a const object reference
inline bool valid() const noexcept;
//- True if this is a non-null managed pointer with a unique ref-count
inline bool movable() const noexcept; inline bool movable() const noexcept;
//- Return type-name of the tmp, constructed from type-name of T //- Return type-name of the tmp, constructed from type-name of T
@ -159,10 +161,10 @@ public:
// Access // Access
//- Return pointer without nullptr checking. //- Return pointer without nullptr checking.
inline T* get() noexcept; T* get() noexcept { return ptr_; }
//- Return const pointer without nullptr checking. //- Return const pointer without nullptr checking.
inline const T* get() const noexcept; const T* get() const noexcept { return ptr_; }
//- Return the const object reference or a const reference to the //- Return the const object reference or a const reference to the
//- contents of a non-null managed pointer. //- contents of a non-null managed pointer.
@ -191,12 +193,8 @@ public:
//- delete object and set pointer to nullptr //- delete object and set pointer to nullptr
inline void clear() const noexcept; inline void clear() const noexcept;
//- Release ownership of managed temporary object.
// After this call no object is managed.
inline void reset() noexcept;
//- Delete managed temporary object and set to new given pointer //- Delete managed temporary object and set to new given pointer
inline void reset(T* p) noexcept; inline void reset(T* p = nullptr) noexcept;
//- Clear existing and transfer ownership. //- Clear existing and transfer ownership.
inline void reset(tmpNrc<T>&& other) noexcept; inline void reset(tmpNrc<T>&& other) noexcept;
@ -225,12 +223,8 @@ public:
// Fatal for a null managed pointer or if the object is const. // Fatal for a null managed pointer or if the object is const.
inline T* operator->(); inline T* operator->();
//- Is non-null managed pointer or const object reference : valid() //- Non-null pointer/reference : valid()
explicit inline operator bool() const noexcept; explicit operator bool() const noexcept { return ptr_; }
//- Take ownership of the pointer.
// Fatal for a null pointer, or when the pointer is non-unique.
inline void operator=(T* p);
//- Transfer ownership of the managed pointer. //- Transfer ownership of the managed pointer.
// Fatal for a null managed pointer or if the object is const. // Fatal for a null managed pointer or if the object is const.
@ -239,15 +233,15 @@ public:
//- Clear existing and transfer ownership. //- Clear existing and transfer ownership.
inline void operator=(tmpNrc<T>&& other) noexcept; inline void operator=(tmpNrc<T>&& other) noexcept;
//- Conversion to tmp //- Take ownership of the pointer.
// Fatal for a null pointer
inline void operator=(T* p);
//- Reset via assignment from literal nullptr
inline void operator=(std::nullptr_t) noexcept;
//- Conversion to tmp - releases pointer or copies reference
inline operator tmp<T>(); inline operator tmp<T>();
// Housekeeping
//- No assignment from literal nullptr.
// Consistent with run-time check for nullptr on assignment.
void operator=(std::nullptr_t) = delete;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -152,27 +152,6 @@ inline Foam::tmpNrc<T>::~tmpNrc()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline bool Foam::tmpNrc<T>::isTmp() const noexcept
{
return type_ == PTR;
}
template<class T>
inline bool Foam::tmpNrc<T>::empty() const noexcept
{
return (!ptr_ && isTmp());
}
template<class T>
inline bool Foam::tmpNrc<T>::valid() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T> template<class T>
inline bool Foam::tmpNrc<T>::movable() const noexcept inline bool Foam::tmpNrc<T>::movable() const noexcept
{ {
@ -187,20 +166,6 @@ inline Foam::word Foam::tmpNrc<T>::typeName() const
} }
template<class T>
inline T* Foam::tmpNrc<T>::get() noexcept
{
return ptr_; // non-const pointer
}
template<class T>
inline const T* Foam::tmpNrc<T>::get() const noexcept
{
return ptr_; // const pointer
}
template<class T> template<class T>
inline const T& Foam::tmpNrc<T>::cref() const inline const T& Foam::tmpNrc<T>::cref() const
{ {
@ -230,7 +195,7 @@ inline T& Foam::tmpNrc<T>::ref() const
<< abort(FatalError); << abort(FatalError);
} }
} }
else else // if (type_ == CREF)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Attempted non-const reference to const object from a " << "Attempted non-const reference to const object from a "
@ -259,19 +224,19 @@ inline T& Foam::tmpNrc<T>::constCast() const
template<class T> template<class T>
inline T* Foam::tmpNrc<T>::ptr() const inline T* Foam::tmpNrc<T>::ptr() const
{ {
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
if (isTmp()) if (isTmp())
{ {
if (!ptr_) T* p = ptr_;
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
T* ptr = ptr_;
ptr_ = nullptr; ptr_ = nullptr;
return ptr; return p;
} }
return ptr_->clone().ptr(); return ptr_->clone().ptr();
@ -289,15 +254,6 @@ inline void Foam::tmpNrc<T>::clear() const noexcept
} }
template<class T>
inline void Foam::tmpNrc<T>::reset() noexcept
{
clear();
ptr_ = nullptr;
type_ = PTR;
}
template<class T> template<class T>
inline void Foam::tmpNrc<T>::reset(T* p) noexcept inline void Foam::tmpNrc<T>::reset(T* p) noexcept
{ {
@ -405,30 +361,6 @@ inline T* Foam::tmpNrc<T>::operator->()
} }
template<class T>
inline Foam::tmpNrc<T>::operator bool() const noexcept
{
return (ptr_ || type_ == CREF);
}
template<class T>
inline void Foam::tmpNrc<T>::operator=(T* p)
{
clear();
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
ptr_ = p;
type_ = PTR;
}
template<class T> template<class T>
inline void Foam::tmpNrc<T>::operator=(const tmpNrc<T>& t) inline void Foam::tmpNrc<T>::operator=(const tmpNrc<T>& t)
{ {
@ -479,6 +411,27 @@ inline void Foam::tmpNrc<T>::operator=(tmpNrc<T>&& other) noexcept
} }
template<class T>
inline void Foam::tmpNrc<T>::operator=(T* p)
{
if (!p)
{
FatalErrorInFunction
<< "Attempted copy of a deallocated " << typeName()
<< abort(FatalError);
}
reset(p);
}
template<class T>
inline void Foam::tmpNrc<T>::operator=(std::nullptr_t) noexcept
{
reset(nullptr);
}
template<class T> template<class T>
inline Foam::tmpNrc<T>::operator tmp<T>() inline Foam::tmpNrc<T>::operator tmp<T>()
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -128,8 +128,8 @@ void Foam::globalMeshData::calcSharedPoints() const
if if
( (
nGlobalPoints_ != -1 nGlobalPoints_ != -1
|| sharedPointLabelsPtr_.valid() || sharedPointLabelsPtr_
|| sharedPointAddrPtr_.valid() || sharedPointAddrPtr_
) )
{ {
FatalErrorInFunction FatalErrorInFunction
@ -295,8 +295,8 @@ void Foam::globalMeshData::calcSharedEdges() const
if if
( (
nGlobalEdges_ != -1 nGlobalEdges_ != -1
|| sharedEdgeLabelsPtr_.valid() || sharedEdgeLabelsPtr_
|| sharedEdgeAddrPtr_.valid() || sharedEdgeAddrPtr_
) )
{ {
FatalErrorInFunction FatalErrorInFunction
@ -1837,7 +1837,7 @@ void Foam::globalMeshData::clearOut()
const Foam::labelList& Foam::globalMeshData::sharedPointGlobalLabels() const const Foam::labelList& Foam::globalMeshData::sharedPointGlobalLabels() const
{ {
if (!sharedPointGlobalLabelsPtr_.valid()) if (!sharedPointGlobalLabelsPtr_)
{ {
sharedPointGlobalLabelsPtr_.reset sharedPointGlobalLabelsPtr_.reset
( (
@ -2015,7 +2015,7 @@ Foam::label Foam::globalMeshData::nGlobalPoints() const
const Foam::labelList& Foam::globalMeshData::sharedPointLabels() const const Foam::labelList& Foam::globalMeshData::sharedPointLabels() const
{ {
if (!sharedPointLabelsPtr_.valid()) if (!sharedPointLabelsPtr_)
{ {
calcSharedPoints(); calcSharedPoints();
} }
@ -2025,7 +2025,7 @@ const Foam::labelList& Foam::globalMeshData::sharedPointLabels() const
const Foam::labelList& Foam::globalMeshData::sharedPointAddr() const const Foam::labelList& Foam::globalMeshData::sharedPointAddr() const
{ {
if (!sharedPointAddrPtr_.valid()) if (!sharedPointAddrPtr_)
{ {
calcSharedPoints(); calcSharedPoints();
} }
@ -2045,7 +2045,7 @@ Foam::label Foam::globalMeshData::nGlobalEdges() const
const Foam::labelList& Foam::globalMeshData::sharedEdgeLabels() const const Foam::labelList& Foam::globalMeshData::sharedEdgeLabels() const
{ {
if (!sharedEdgeLabelsPtr_.valid()) if (!sharedEdgeLabelsPtr_)
{ {
calcSharedEdges(); calcSharedEdges();
} }
@ -2055,7 +2055,7 @@ const Foam::labelList& Foam::globalMeshData::sharedEdgeLabels() const
const Foam::labelList& Foam::globalMeshData::sharedEdgeAddr() const const Foam::labelList& Foam::globalMeshData::sharedEdgeAddr() const
{ {
if (!sharedEdgeAddrPtr_.valid()) if (!sharedEdgeAddrPtr_)
{ {
calcSharedEdges(); calcSharedEdges();
} }
@ -2065,7 +2065,7 @@ const Foam::labelList& Foam::globalMeshData::sharedEdgeAddr() const
const Foam::indirectPrimitivePatch& Foam::globalMeshData::coupledPatch() const const Foam::indirectPrimitivePatch& Foam::globalMeshData::coupledPatch() const
{ {
if (!coupledPatchPtr_.valid()) if (!coupledPatchPtr_)
{ {
const polyBoundaryMesh& bMesh = mesh_.boundaryMesh(); const polyBoundaryMesh& bMesh = mesh_.boundaryMesh();
@ -2126,7 +2126,7 @@ const Foam::indirectPrimitivePatch& Foam::globalMeshData::coupledPatch() const
const Foam::labelList& Foam::globalMeshData::coupledPatchMeshEdges() const const Foam::labelList& Foam::globalMeshData::coupledPatchMeshEdges() const
{ {
if (!coupledPatchMeshEdgesPtr_.valid()) if (!coupledPatchMeshEdgesPtr_)
{ {
coupledPatchMeshEdgesPtr_.reset coupledPatchMeshEdgesPtr_.reset
( (
@ -2147,7 +2147,7 @@ const Foam::labelList& Foam::globalMeshData::coupledPatchMeshEdges() const
const Foam::Map<Foam::label>& Foam::globalMeshData::coupledPatchMeshEdgeMap() const Foam::Map<Foam::label>& Foam::globalMeshData::coupledPatchMeshEdgeMap()
const const
{ {
if (!coupledPatchMeshEdgeMapPtr_.valid()) if (!coupledPatchMeshEdgeMapPtr_)
{ {
const labelList& me = coupledPatchMeshEdges(); const labelList& me = coupledPatchMeshEdges();
@ -2165,7 +2165,7 @@ const
const Foam::globalIndex& Foam::globalMeshData::globalPointNumbering() const const Foam::globalIndex& Foam::globalMeshData::globalPointNumbering() const
{ {
if (!globalPointNumberingPtr_.valid()) if (!globalPointNumberingPtr_)
{ {
globalPointNumberingPtr_.reset globalPointNumberingPtr_.reset
( (
@ -2179,7 +2179,7 @@ const Foam::globalIndex& Foam::globalMeshData::globalPointNumbering() const
const Foam::globalIndexAndTransform& const Foam::globalIndexAndTransform&
Foam::globalMeshData::globalTransforms() const Foam::globalMeshData::globalTransforms() const
{ {
if (!globalTransformsPtr_.valid()) if (!globalTransformsPtr_)
{ {
globalTransformsPtr_.reset(new globalIndexAndTransform(mesh_)); globalTransformsPtr_.reset(new globalIndexAndTransform(mesh_));
} }
@ -2189,7 +2189,7 @@ Foam::globalMeshData::globalTransforms() const
const Foam::labelListList& Foam::globalMeshData::globalPointSlaves() const const Foam::labelListList& Foam::globalMeshData::globalPointSlaves() const
{ {
if (!globalPointSlavesPtr_.valid()) if (!globalPointSlavesPtr_)
{ {
calcGlobalPointSlaves(); calcGlobalPointSlaves();
} }
@ -2200,7 +2200,7 @@ const Foam::labelListList& Foam::globalMeshData::globalPointSlaves() const
const Foam::labelListList& Foam::globalMeshData::globalPointTransformedSlaves() const Foam::labelListList& Foam::globalMeshData::globalPointTransformedSlaves()
const const
{ {
if (!globalPointTransformedSlavesPtr_.valid()) if (!globalPointTransformedSlavesPtr_)
{ {
calcGlobalPointSlaves(); calcGlobalPointSlaves();
} }
@ -2210,7 +2210,7 @@ const
const Foam::mapDistribute& Foam::globalMeshData::globalPointSlavesMap() const const Foam::mapDistribute& Foam::globalMeshData::globalPointSlavesMap() const
{ {
if (!globalPointSlavesMapPtr_.valid()) if (!globalPointSlavesMapPtr_)
{ {
calcGlobalPointSlaves(); calcGlobalPointSlaves();
} }
@ -2220,7 +2220,7 @@ const Foam::mapDistribute& Foam::globalMeshData::globalPointSlavesMap() const
const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
{ {
if (!globalEdgeNumberingPtr_.valid()) if (!globalEdgeNumberingPtr_)
{ {
globalEdgeNumberingPtr_.reset globalEdgeNumberingPtr_.reset
( (
@ -2233,7 +2233,7 @@ const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
const Foam::labelListList& Foam::globalMeshData::globalEdgeSlaves() const const Foam::labelListList& Foam::globalMeshData::globalEdgeSlaves() const
{ {
if (!globalEdgeSlavesPtr_.valid()) if (!globalEdgeSlavesPtr_)
{ {
calcGlobalEdgeSlaves(); calcGlobalEdgeSlaves();
} }
@ -2244,7 +2244,7 @@ const Foam::labelListList& Foam::globalMeshData::globalEdgeSlaves() const
const Foam::labelListList& Foam::globalMeshData::globalEdgeTransformedSlaves() const Foam::labelListList& Foam::globalMeshData::globalEdgeTransformedSlaves()
const const
{ {
if (!globalEdgeTransformedSlavesPtr_.valid()) if (!globalEdgeTransformedSlavesPtr_)
{ {
calcGlobalEdgeSlaves(); calcGlobalEdgeSlaves();
} }
@ -2254,7 +2254,7 @@ const
const Foam::bitSet& Foam::globalMeshData::globalEdgeOrientation() const const Foam::bitSet& Foam::globalMeshData::globalEdgeOrientation() const
{ {
if (!globalEdgeOrientationPtr_.valid()) if (!globalEdgeOrientationPtr_)
{ {
calcGlobalEdgeOrientation(); calcGlobalEdgeOrientation();
} }
@ -2264,7 +2264,7 @@ const Foam::bitSet& Foam::globalMeshData::globalEdgeOrientation() const
const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const
{ {
if (!globalEdgeSlavesMapPtr_.valid()) if (!globalEdgeSlavesMapPtr_)
{ {
calcGlobalEdgeSlaves(); calcGlobalEdgeSlaves();
} }
@ -2275,7 +2275,7 @@ const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const
const Foam::globalIndex& Foam::globalMeshData::globalBoundaryFaceNumbering() const Foam::globalIndex& Foam::globalMeshData::globalBoundaryFaceNumbering()
const const
{ {
if (!globalBoundaryFaceNumberingPtr_.valid()) if (!globalBoundaryFaceNumberingPtr_)
{ {
calcGlobalPointBoundaryFaces(); calcGlobalPointBoundaryFaces();
} }
@ -2286,7 +2286,7 @@ const
const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryFaces() const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryFaces()
const const
{ {
if (!globalPointBoundaryFacesPtr_.valid()) if (!globalPointBoundaryFacesPtr_)
{ {
calcGlobalPointBoundaryFaces(); calcGlobalPointBoundaryFaces();
} }
@ -2297,7 +2297,7 @@ const
const Foam::labelListList& const Foam::labelListList&
Foam::globalMeshData::globalPointTransformedBoundaryFaces() const Foam::globalMeshData::globalPointTransformedBoundaryFaces() const
{ {
if (!globalPointTransformedBoundaryFacesPtr_.valid()) if (!globalPointTransformedBoundaryFacesPtr_)
{ {
calcGlobalPointBoundaryFaces(); calcGlobalPointBoundaryFaces();
} }
@ -2308,7 +2308,7 @@ Foam::globalMeshData::globalPointTransformedBoundaryFaces() const
const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryFacesMap() const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryFacesMap()
const const
{ {
if (!globalPointBoundaryFacesMapPtr_.valid()) if (!globalPointBoundaryFacesMapPtr_)
{ {
calcGlobalPointBoundaryFaces(); calcGlobalPointBoundaryFaces();
} }
@ -2318,7 +2318,7 @@ const
const Foam::labelList& Foam::globalMeshData::boundaryCells() const const Foam::labelList& Foam::globalMeshData::boundaryCells() const
{ {
if (!boundaryCellsPtr_.valid()) if (!boundaryCellsPtr_)
{ {
calcGlobalPointBoundaryCells(); calcGlobalPointBoundaryCells();
} }
@ -2329,7 +2329,7 @@ const Foam::labelList& Foam::globalMeshData::boundaryCells() const
const Foam::globalIndex& Foam::globalMeshData::globalBoundaryCellNumbering() const Foam::globalIndex& Foam::globalMeshData::globalBoundaryCellNumbering()
const const
{ {
if (!globalBoundaryCellNumberingPtr_.valid()) if (!globalBoundaryCellNumberingPtr_)
{ {
calcGlobalPointBoundaryCells(); calcGlobalPointBoundaryCells();
} }
@ -2340,7 +2340,7 @@ const
const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryCells() const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryCells()
const const
{ {
if (!globalPointBoundaryCellsPtr_.valid()) if (!globalPointBoundaryCellsPtr_)
{ {
calcGlobalPointBoundaryCells(); calcGlobalPointBoundaryCells();
} }
@ -2351,7 +2351,7 @@ const
const Foam::labelListList& const Foam::labelListList&
Foam::globalMeshData::globalPointTransformedBoundaryCells() const Foam::globalMeshData::globalPointTransformedBoundaryCells() const
{ {
if (!globalPointTransformedBoundaryCellsPtr_.valid()) if (!globalPointTransformedBoundaryCellsPtr_)
{ {
calcGlobalPointBoundaryCells(); calcGlobalPointBoundaryCells();
} }
@ -2362,7 +2362,7 @@ Foam::globalMeshData::globalPointTransformedBoundaryCells() const
const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryCellsMap() const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryCellsMap()
const const
{ {
if (!globalPointBoundaryCellsMapPtr_.valid()) if (!globalPointBoundaryCellsMapPtr_)
{ {
calcGlobalPointBoundaryCells(); calcGlobalPointBoundaryCells();
} }
@ -2372,7 +2372,7 @@ const
const Foam::labelListList& Foam::globalMeshData::globalCoPointSlaves() const const Foam::labelListList& Foam::globalMeshData::globalCoPointSlaves() const
{ {
if (!globalCoPointSlavesPtr_.valid()) if (!globalCoPointSlavesPtr_)
{ {
calcGlobalCoPointSlaves(); calcGlobalCoPointSlaves();
} }
@ -2382,7 +2382,7 @@ const Foam::labelListList& Foam::globalMeshData::globalCoPointSlaves() const
const Foam::mapDistribute& Foam::globalMeshData::globalCoPointSlavesMap() const const Foam::mapDistribute& Foam::globalMeshData::globalCoPointSlavesMap() const
{ {
if (!globalCoPointSlavesMapPtr_.valid()) if (!globalCoPointSlavesMapPtr_)
{ {
calcGlobalCoPointSlaves(); calcGlobalCoPointSlaves();
} }

View File

@ -176,7 +176,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
const Foam::List<Foam::labelPair>& Foam::mapDistributeBase::schedule() const const Foam::List<Foam::labelPair>& Foam::mapDistributeBase::schedule() const
{ {
if (schedulePtr_.empty()) if (!schedulePtr_)
{ {
schedulePtr_.reset schedulePtr_.reset
( (

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -645,7 +646,7 @@ public:
bool hasOldCellVolumes() const bool hasOldCellVolumes() const
{ {
return oldCellVolumesPtr_.valid(); return bool(oldCellVolumesPtr_);
} }
const scalarField& oldCellVolumes() const const scalarField& oldCellVolumes() const

View File

@ -329,7 +329,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
<< " boundaries." << endl; << " boundaries." << endl;
} }
if (!neighbourEdgesPtr_.valid()) if (!neighbourEdgesPtr_)
{ {
neighbourEdgesPtr_.reset(new List<labelPairList>(size())); neighbourEdgesPtr_.reset(new List<labelPairList>(size()));
List<labelPairList>& neighbourEdges = neighbourEdgesPtr_(); List<labelPairList>& neighbourEdges = neighbourEdgesPtr_();
@ -451,7 +451,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
const Foam::labelList& Foam::polyBoundaryMesh::patchID() const const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
{ {
if (!patchIDPtr_.valid()) if (!patchIDPtr_)
{ {
patchIDPtr_.reset(new labelList(mesh_.nBoundaryFaces())); patchIDPtr_.reset(new labelList(mesh_.nBoundaryFaces()));
labelList& list = *patchIDPtr_; labelList& list = *patchIDPtr_;
@ -476,7 +476,7 @@ const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
const Foam::HashTable<Foam::labelList>& const Foam::HashTable<Foam::labelList>&
Foam::polyBoundaryMesh::groupPatchIDs() const Foam::polyBoundaryMesh::groupPatchIDs() const
{ {
if (!groupPatchIDsPtr_.valid()) if (!groupPatchIDsPtr_)
{ {
groupPatchIDsPtr_.reset(new HashTable<labelList>(16)); groupPatchIDsPtr_.reset(new HashTable<labelList>(16));
auto& groupPatchIDs = *groupPatchIDsPtr_; auto& groupPatchIDs = *groupPatchIDsPtr_;

View File

@ -699,25 +699,25 @@ void Foam::polyMesh::resetPrimitives
// Take over new primitive data. // Take over new primitive data.
// Optimized to avoid overwriting data at all // Optimized to avoid overwriting data at all
if (points.valid()) if (points)
{ {
points_.transfer(points()); points_.transfer(*points);
bounds_ = boundBox(points_, validBoundary); bounds_ = boundBox(points_, validBoundary);
} }
if (faces.valid()) if (faces)
{ {
faces_.transfer(faces()); faces_.transfer(*faces);
} }
if (owner.valid()) if (owner)
{ {
owner_.transfer(owner()); owner_.transfer(*owner);
} }
if (neighbour.valid()) if (neighbour)
{ {
neighbour_.transfer(neighbour()); neighbour_.transfer(*neighbour);
} }
@ -860,7 +860,7 @@ Foam::label Foam::polyMesh::nSolutionD() const
const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const
{ {
if (tetBasePtIsPtr_.empty()) if (!tetBasePtIsPtr_)
{ {
if (debug) if (debug)
{ {
@ -894,7 +894,7 @@ const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const
const Foam::indexedOctree<Foam::treeDataCell>& const Foam::indexedOctree<Foam::treeDataCell>&
Foam::polyMesh::cellTree() const Foam::polyMesh::cellTree() const
{ {
if (cellTreePtr_.empty()) if (!cellTreePtr_)
{ {
treeBoundBox overallBb(points()); treeBoundBox overallBb(points());
@ -922,7 +922,7 @@ Foam::polyMesh::cellTree() const
); );
} }
return cellTreePtr_(); return *cellTreePtr_;
} }
@ -1087,7 +1087,7 @@ const Foam::labelList& Foam::polyMesh::faceNeighbour() const
const Foam::pointField& Foam::polyMesh::oldPoints() const const Foam::pointField& Foam::polyMesh::oldPoints() const
{ {
if (oldPointsPtr_.empty()) if (!oldPointsPtr_)
{ {
if (debug) if (debug)
{ {
@ -1160,11 +1160,11 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
points_.instance() = time().timeName(); points_.instance() = time().timeName();
points_.eventNo() = getEvent(); points_.eventNo() = getEvent();
if (tetBasePtIsPtr_.valid()) if (tetBasePtIsPtr_)
{ {
tetBasePtIsPtr_().writeOpt() = IOobject::AUTO_WRITE; tetBasePtIsPtr_->writeOpt() = IOobject::AUTO_WRITE;
tetBasePtIsPtr_().instance() = time().timeName(); tetBasePtIsPtr_->instance() = time().timeName();
tetBasePtIsPtr_().eventNo() = getEvent(); tetBasePtIsPtr_->eventNo() = getEvent();
} }
tmp<scalarField> sweptVols = primitiveMesh::movePoints tmp<scalarField> sweptVols = primitiveMesh::movePoints
@ -1174,9 +1174,9 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
); );
// Adjust parallel shared points // Adjust parallel shared points
if (globalMeshDataPtr_.valid()) if (globalMeshDataPtr_)
{ {
globalMeshDataPtr_().movePoints(points_); globalMeshDataPtr_->movePoints(points_);
} }
// Force recalculation of all geometric data with new points // Force recalculation of all geometric data with new points
@ -1233,7 +1233,7 @@ void Foam::polyMesh::resetMotion() const
const Foam::globalMeshData& Foam::polyMesh::globalData() const const Foam::globalMeshData& Foam::polyMesh::globalData() const
{ {
if (globalMeshDataPtr_.empty()) if (!globalMeshDataPtr_)
{ {
if (debug) if (debug)
{ {

View File

@ -80,7 +80,7 @@ void Foam::polyMesh::updateGeom
DebugInFunction DebugInFunction
<< "Updating geometric data with newPoints:" << "Updating geometric data with newPoints:"
<< newPoints.size() << " newTetBasePtIs:" << newPoints.size() << " newTetBasePtIs:"
<< newTetBasePtIsPtr.valid() << endl; << bool(newTetBasePtIsPtr) << endl;
if (points_.size() != 0 && points_.size() != newPoints.size()) if (points_.size() != 0 && points_.size() != newPoints.size())
{ {
@ -128,7 +128,7 @@ void Foam::polyMesh::updateGeom
points_.transfer(newPoints); points_.transfer(newPoints);
// Optional new tet base points // Optional new tet base points
if (newTetBasePtIsPtr.valid()) if (newTetBasePtIsPtr)
{ {
tetBasePtIsPtr_ = std::move(newTetBasePtIsPtr); tetBasePtIsPtr_ = std::move(newTetBasePtIsPtr);
} }

View File

@ -64,7 +64,7 @@ void Foam::polyMesh::setInstance
cellZones_.writeOpt() = wOpt; cellZones_.writeOpt() = wOpt;
cellZones_.instance() = inst; cellZones_.instance() = inst;
if (tetBasePtIsPtr_.valid()) if (tetBasePtIsPtr_)
{ {
tetBasePtIsPtr_->writeOpt() = wOpt; tetBasePtIsPtr_->writeOpt() = wOpt;
tetBasePtIsPtr_->instance() = inst; tetBasePtIsPtr_->instance() = inst;

View File

@ -59,7 +59,7 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
cellTreePtr_.clear(); cellTreePtr_.clear();
// Update parallel data // Update parallel data
if (globalMeshDataPtr_.valid()) if (globalMeshDataPtr_)
{ {
globalMeshDataPtr_->updateMesh(); globalMeshDataPtr_->updateMesh();
} }
@ -67,12 +67,12 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
setInstance(time().timeName()); setInstance(time().timeName());
// Map the old motion points if present // Map the old motion points if present
if (oldPointsPtr_.valid()) if (oldPointsPtr_)
{ {
// Make a copy of the original points // Make a copy of the original points
pointField oldMotionPoints = oldPointsPtr_(); pointField oldMotionPoints = *oldPointsPtr_;
pointField& newMotionPoints = oldPointsPtr_(); pointField& newMotionPoints = *oldPointsPtr_;
// Resize the list to new size // Resize the list to new size
newMotionPoints.setSize(points_.size()); newMotionPoints.setSize(points_.size());

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -528,7 +528,7 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs)
const Foam::labelList& Foam::processorPolyPatch::neighbPoints() const const Foam::labelList& Foam::processorPolyPatch::neighbPoints() const
{ {
if (!neighbPointsPtr_.valid()) if (!neighbPointsPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "No extended addressing calculated for patch " << name() << "No extended addressing calculated for patch " << name()
@ -540,7 +540,7 @@ const Foam::labelList& Foam::processorPolyPatch::neighbPoints() const
const Foam::labelList& Foam::processorPolyPatch::neighbEdges() const const Foam::labelList& Foam::processorPolyPatch::neighbEdges() const
{ {
if (!neighbEdgesPtr_.valid()) if (!neighbEdgesPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "No extended addressing calculated for patch " << name() << "No extended addressing calculated for patch " << name()

View File

@ -206,7 +206,7 @@ const solidType& thermalBaffle1DFvPatchScalarField<solidType>::solid() const
{ {
if (this->owner()) if (this->owner())
{ {
if (solidPtr_.empty()) if (!solidPtr_)
{ {
solidPtr_.reset(new solidType(solidDict_)); solidPtr_.reset(new solidType(solidDict_));
} }

View File

@ -224,7 +224,7 @@ void mixtureKEpsilon<BasicTurbulenceModel>::correctInletOutlet
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields() void mixtureKEpsilon<BasicTurbulenceModel>::initMixtureFields()
{ {
if (rhom_.valid()) return; if (rhom_) return;
// Local references to gas-phase properties // Local references to gas-phase properties
const volScalarField& kg = this->k_; const volScalarField& kg = this->k_;

View File

@ -91,7 +91,7 @@ Foam::pointHistory::pointHistory
refHistoryPoint_(dict.lookup("refHistoryPoint")), refHistoryPoint_(dict.lookup("refHistoryPoint")),
processor_(-1), processor_(-1),
fileName_(dict.get<word>("fileName")), fileName_(dict.get<word>("fileName")),
historyFilePtr_() historyFilePtr_(nullptr)
{ {
Info<< "Creating " << this->name() << " function object." << endl; Info<< "Creating " << this->name() << " function object." << endl;
@ -144,7 +144,7 @@ Foam::pointHistory::pointHistory
} }
// Create history file if not already created // Create history file if not already created
if (historyFilePtr_.empty()) if (!historyFilePtr_)
{ {
// File update // File update
if (Pstream::master()) if (Pstream::master())
@ -180,13 +180,11 @@ Foam::pointHistory::pointHistory
); );
// Add headers to output data // Add headers to output data
if (historyFilePtr_.valid()) if (historyFilePtr_)
{ {
historyFilePtr_() historyFilePtr_()
<< "# Time" << tab << "X" << tab << "# Time" << tab << "X" << tab << "Y" << tab << "Z"
<< "Y" << tab << "Z"; << endl;
historyFilePtr_() << endl;
} }
} }
} }

View File

@ -190,7 +190,7 @@ bool Foam::expressions::fvExprDriver::readDict
{ {
ITstream& is = eptr->stream(); ITstream& is = eptr->stream();
if (writer_.valid() && storedVariables_.size()) if (writer_ && !storedVariables_.empty())
{ {
WarningInFunction WarningInFunction
// << "Context: " << driverContext_ << nl // << "Context: " << driverContext_ << nl
@ -216,7 +216,7 @@ bool Foam::expressions::fvExprDriver::readDict
{ {
ITstream& is = eptr->stream(); ITstream& is = eptr->stream();
if (writer_.valid() && delayedVariables_.size()) if (writer_ && !delayedVariables_.empty())
{ {
WarningInFunction WarningInFunction
// << "Context: " << driverContext_ << nl // << "Context: " << driverContext_ << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com> Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -261,16 +261,16 @@ Foam::Ostream& Foam::expressions::fvExprDriver::writeCommon
void Foam::expressions::fvExprDriver::createWriterAndRead(const word& name) void Foam::expressions::fvExprDriver::createWriterAndRead(const word& name)
{ {
if (hasDataToWrite() && !writer_.valid()) if (!writer_ && hasDataToWrite())
{ {
writer_.set(new exprDriverWriter(name + "_" + this->type(), *this)); writer_.reset(new exprDriverWriter(name + "_" + this->type(), *this));
} }
} }
void Foam::expressions::fvExprDriver::tryWrite() const void Foam::expressions::fvExprDriver::tryWrite() const
{ {
if (writer_.valid() && mesh().time().outputTime()) if (writer_ && mesh().time().outputTime())
{ {
writer_->write(); writer_->write();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -227,7 +227,7 @@ template<class Type>
const Foam::fvPatchField<Type>& const Foam::fvPatchField<Type>&
Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
{ {
if (!redirectPatchFieldPtr_.valid()) if (!redirectPatchFieldPtr_)
{ {
// Construct a patch // Construct a patch
// Make sure to construct the patchfield with up-to-date value // Make sure to construct the patchfield with up-to-date value

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -226,7 +226,7 @@ template<class Type>
const Foam::mixedFvPatchField<Type>& const Foam::mixedFvPatchField<Type>&
Foam::codedMixedFvPatchField<Type>::redirectPatchField() const Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
{ {
if (!redirectPatchFieldPtr_.valid()) if (!redirectPatchFieldPtr_)
{ {
// Construct a patch // Construct a patch
// Make sure to construct the patchfield with up-to-date value // Make sure to construct the patchfield with up-to-date value

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -131,7 +132,7 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
origin_(ptf.origin_) origin_(ptf.origin_)
{ {
// Evaluate the profile if defined // Evaluate the profile if defined
if (ptf.profile_.valid()) if (ptf.profile_)
{ {
this->evaluate(); this->evaluate();
} }

View File

@ -102,7 +102,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
inletOutletFvPatchField<Type>(ptf, p, iF, mapper), inletOutletFvPatchField<Type>(ptf, p, iF, mapper),
freestreamBCPtr_() freestreamBCPtr_()
{ {
if (ptf.freestreamBCPtr_.valid()) if (ptf.freestreamBCPtr_)
{ {
freestreamBCPtr_ = freestreamBCPtr_ =
fvPatchField<Type>::New(ptf.freestreamBCPtr_(), p, iF, mapper); fvPatchField<Type>::New(ptf.freestreamBCPtr_(), p, iF, mapper);
@ -119,7 +119,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
inletOutletFvPatchField<Type>(ptf), inletOutletFvPatchField<Type>(ptf),
freestreamBCPtr_() freestreamBCPtr_()
{ {
if (ptf.freestreamBCPtr_.valid()) if (ptf.freestreamBCPtr_)
{ {
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone(); freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
} }
@ -136,7 +136,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
inletOutletFvPatchField<Type>(ptf, iF), inletOutletFvPatchField<Type>(ptf, iF),
freestreamBCPtr_() freestreamBCPtr_()
{ {
if (ptf.freestreamBCPtr_.valid()) if (ptf.freestreamBCPtr_)
{ {
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone(); freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
} }
@ -149,7 +149,7 @@ template<class Type>
void Foam::freestreamFvPatchField<Type>::autoMap(const fvPatchFieldMapper& m) void Foam::freestreamFvPatchField<Type>::autoMap(const fvPatchFieldMapper& m)
{ {
inletOutletFvPatchField<Type>::autoMap(m); inletOutletFvPatchField<Type>::autoMap(m);
if (freestreamBCPtr_.valid()) if (freestreamBCPtr_)
{ {
freestreamBCPtr_->autoMap(m); freestreamBCPtr_->autoMap(m);
} }
@ -167,7 +167,7 @@ void Foam::freestreamFvPatchField<Type>::rmap
const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf); const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf);
if (fsptf.freestreamBCPtr_.valid()) if (fsptf.freestreamBCPtr_)
{ {
freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr); freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
} }
@ -182,7 +182,7 @@ void Foam::freestreamFvPatchField<Type>::updateCoeffs()
return; return;
} }
if (freestreamBCPtr_.valid()) if (freestreamBCPtr_)
{ {
freestreamBCPtr_->evaluate(); freestreamBCPtr_->evaluate();
freestreamValue() = freestreamBCPtr_(); freestreamValue() = freestreamBCPtr_();
@ -198,7 +198,7 @@ void Foam::freestreamFvPatchField<Type>::write(Ostream& os) const
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_); os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
if (freestreamBCPtr_.valid()) if (freestreamBCPtr_)
{ {
os.beginBlock("freestreamBC"); os.beginBlock("freestreamBC");
freestreamBCPtr_->write(os); freestreamBCPtr_->write(os);

View File

@ -190,7 +190,7 @@ const Foam::pointToPointPlanarInterpolation&
Foam::turbulentDFSEMInletFvPatchVectorField::patchMapper() const Foam::turbulentDFSEMInletFvPatchVectorField::patchMapper() const
{ {
// Initialise interpolation (2D planar interpolation by triangulation) // Initialise interpolation (2D planar interpolation by triangulation)
if (mapperPtr_.empty()) if (!mapperPtr_)
{ {
const fileName samplePointsFile const fileName samplePointsFile
( (

View File

@ -36,7 +36,7 @@ const Foam::pointToPointPlanarInterpolation&
Foam::turbulentDigitalFilterInletFvPatchVectorField::patchMapper() const Foam::turbulentDigitalFilterInletFvPatchVectorField::patchMapper() const
{ {
// Initialise interpolation (2D planar interpolation by triangulation) // Initialise interpolation (2D planar interpolation by triangulation)
if (mapperPtr_.empty()) if (!mapperPtr_)
{ {
// Reread values and interpolate // Reread values and interpolate
const fileName samplePointsFile const fileName samplePointsFile

View File

@ -107,7 +107,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
uniformGradient_(ptf.uniformGradient_.clone()) uniformGradient_(ptf.uniformGradient_.clone())
{ {
// Evaluate the profile if defined // Evaluate the profile if defined
if (ptf.uniformGradient_.valid()) if (ptf.uniformGradient_)
{ {
this->evaluate(); this->evaluate();
} }

View File

@ -399,9 +399,9 @@ combineSurfaceGeometry
points = s.points(); points = s.points();
} }
} }
else if (sampledPtr_.valid()) else if (sampledPtr_)
{ {
const sampledSurface& s = sampledPtr_(); const sampledSurface& s = *sampledPtr_;
if (Pstream::parRun()) if (Pstream::parRun())
{ {
@ -443,9 +443,9 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
totalArea = gSum(s.magSf()); totalArea = gSum(s.magSf());
} }
else if (sampledPtr_.valid()) else if (sampledPtr_)
{ {
totalArea = gSum(sampledPtr_().magSf()); totalArea = gSum(sampledPtr_->magSf());
} }
else else
{ {
@ -482,7 +482,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::usesSf() const
bool Foam::functionObjects::fieldValues::surfaceFieldValue::update() bool Foam::functionObjects::fieldValues::surfaceFieldValue::update()
{ {
if (sampledPtr_.valid()) if (sampledPtr_)
{ {
sampledPtr_->update(); sampledPtr_->update();
} }
@ -1022,9 +1022,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
const polySurface& s = dynamicCast<const polySurface>(obr()); const polySurface& s = dynamicCast<const polySurface>(obr());
Sf = s.Sf(); Sf = s.Sf();
} }
else if (sampledPtr_.valid()) else if (sampledPtr_)
{ {
Sf = sampledPtr_().Sf(); Sf = sampledPtr_->Sf();
} }
else else
{ {
@ -1036,7 +1036,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
faceList faces; faceList faces;
pointField points; pointField points;
if (surfaceWriterPtr_.valid()) if (surfaceWriterPtr_)
{ {
if (withTopologicalMerge()) if (withTopologicalMerge())
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,7 +38,7 @@ withSurfaceFields() const
( (
stFaceZone == regionType_ stFaceZone == regionType_
|| stPatch == regionType_ || stPatch == regionType_
|| (sampledPtr_.valid() && sampledPtr_->withSurfaceFields()) || (sampledPtr_ && sampledPtr_->withSurfaceFields())
); );
} }

View File

@ -94,19 +94,19 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
{ {
const vf& fld = lookupObject<vf>(fieldName); const vf& fld = lookupObject<vf>(fieldName);
if (sampledPtr_.valid()) if (sampledPtr_)
{ {
if (sampledPtr_().interpolate()) if (sampledPtr_->interpolate())
{ {
const interpolationCellPoint<Type> interp(fld); const interpolationCellPoint<Type> interp(fld);
return sampledPtr_().interpolate(interp); return sampledPtr_->interpolate(interp);
} }
else else
{ {
const interpolationCell<Type> interp(fld); const interpolationCell<Type> interp(fld);
return sampledPtr_().sample(interp); return sampledPtr_->sample(interp);
} }
} }
else else
@ -370,7 +370,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
Field<Type> values(getFieldValues<Type>(fieldName, true)); Field<Type> values(getFieldValues<Type>(fieldName, true));
// Write raw values on surface if specified // Write raw values on surface if specified
if (surfaceWriterPtr_.valid() && surfaceWriterPtr_->enabled()) if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
{ {
Field<Type> allValues(values); Field<Type> allValues(values);
combineFields(allValues); combineFields(allValues);

View File

@ -34,7 +34,7 @@ template<class chemistryType>
void Foam::functionObjects::reactionsSensitivityAnalysis<chemistryType>:: void Foam::functionObjects::reactionsSensitivityAnalysis<chemistryType>::
createFileNames() createFileNames()
{ {
if (writeToFile() && !prodFilePtr_.valid()) if (writeToFile() && !prodFilePtr_)
{ {
prodFilePtr_ = createFile("production"); prodFilePtr_ = createFile("production");
writeHeader(prodFilePtr_(), "production"); writeHeader(prodFilePtr_(), "production");

View File

@ -413,8 +413,8 @@ bool Foam::functionObjects::regionSizeDistribution::write()
const volScalarField& alpha = const volScalarField& alpha =
( (
alphaPtr.valid() alphaPtr
? alphaPtr() ? *alphaPtr
: obr_.lookupObject<volScalarField>(alphaName_) : obr_.lookupObject<volScalarField>(alphaName_)
); );
@ -903,7 +903,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
volVectorField volVectorField
>(fldName).primitiveField(); >(fldName).primitiveField();
if (csysPtr_.valid()) if (csysPtr_)
{ {
Log << "Transforming vector field " << fldName Log << "Transforming vector field " << fldName
<< " with coordinate system " << " with coordinate system "

View File

@ -65,7 +65,7 @@ Foam::functionObjects::streamLineBase::trackDirTypeNames
const Foam::word& const Foam::word&
Foam::functionObjects::streamLineBase::sampledSetAxis() const Foam::functionObjects::streamLineBase::sampledSetAxis() const
{ {
if (sampledSetPtr_.empty()) if (!sampledSetPtr_)
{ {
sampledSetPoints(); sampledSetPoints();
} }
@ -77,7 +77,7 @@ Foam::functionObjects::streamLineBase::sampledSetAxis() const
const Foam::sampledSet& const Foam::sampledSet&
Foam::functionObjects::streamLineBase::sampledSetPoints() const Foam::functionObjects::streamLineBase::sampledSetPoints() const
{ {
if (sampledSetPtr_.empty()) if (!sampledSetPtr_)
{ {
sampledSetPtr_ = sampledSet::New sampledSetPtr_ = sampledSet::New
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +54,7 @@ void Foam::functionObjects::forceCoeffs::createFiles()
{ {
// Note: Only possible to create bin files after bins have been initialised // Note: Only possible to create bin files after bins have been initialised
if (writeToFile() && !coeffFilePtr_.valid()) if (writeToFile() && !coeffFilePtr_)
{ {
coeffFilePtr_ = createFile("coefficient"); coeffFilePtr_ = createFile("coefficient");
writeIntegratedHeader("Coefficients", coeffFilePtr_()); writeIntegratedHeader("Coefficients", coeffFilePtr_());

View File

@ -58,7 +58,7 @@ void Foam::functionObjects::forces::createFiles()
{ {
// Note: Only possible to create bin files after bins have been initialised // Note: Only possible to create bin files after bins have been initialised
if (writeToFile() && !forceFilePtr_.valid()) if (writeToFile() && !forceFilePtr_)
{ {
forceFilePtr_ = createFile("force"); forceFilePtr_ = createFile("force");
writeIntegratedHeader("Force", forceFilePtr_()); writeIntegratedHeader("Force", forceFilePtr_());

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -144,7 +144,7 @@ Foam::functionObjects::codedFunctionObject::codedFunctionObject
Foam::functionObject& Foam::functionObject&
Foam::functionObjects::codedFunctionObject::redirectFunctionObject() const Foam::functionObjects::codedFunctionObject::redirectFunctionObject() const
{ {
if (!redirectFunctionObjectPtr_.valid()) if (!redirectFunctionObjectPtr_)
{ {
dictionary constructDict(dict_); dictionary constructDict(dict_);
constructDict.set("type", name_); constructDict.set("type", name_);

View File

@ -189,7 +189,7 @@ bool Foam::functionObjects::ensightWrite::execute()
bool Foam::functionObjects::ensightWrite::write() bool Foam::functionObjects::ensightWrite::write()
{ {
if (!ensCase_.valid()) if (!ensCase_)
{ {
ensCase_.reset ensCase_.reset
( (

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -146,7 +146,7 @@ bool Foam::functionObjects::ensightWrite::update()
// ensMesh_.clear(); // ensMesh_.clear();
// meshSubset_.clear(); // meshSubset_.clear();
// } // }
// else if (ensMesh_.valid()) // else if (ensMesh_)
// { // {
// ensMesh_->expire(); // ensMesh_->expire();
// } // }
@ -157,13 +157,13 @@ bool Foam::functionObjects::ensightWrite::update()
meshState_ = polyMesh::UNCHANGED; meshState_ = polyMesh::UNCHANGED;
if (!ensMesh_.valid()) if (!ensMesh_)
{ {
ensMesh_.reset(new ensightMesh(meshSubset_.mesh(), writeOpts_)); ensMesh_.reset(new ensightMesh(meshSubset_.mesh(), writeOpts_));
} }
else if (ensMesh_().needsUpdate()) else if (ensMesh_->needsUpdate())
{ {
ensMesh_().correct(); ensMesh_->correct();
} }
return true; return true;

View File

@ -521,7 +521,7 @@ bool Foam::functionObjects::vtkWrite::write()
// CellData // CellData
{ {
if (internalWriter.valid()) if (internalWriter)
{ {
// Optionally with cellID and procID fields // Optionally with cellID and procID fields
internalWriter->beginCellData internalWriter->beginCellData
@ -580,7 +580,7 @@ bool Foam::functionObjects::vtkWrite::write()
if (interpolate_) if (interpolate_)
{ {
// Begin PointData // Begin PointData
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->beginPointData internalWriter->beginPointData
( (
@ -631,7 +631,7 @@ bool Foam::functionObjects::vtkWrite::write()
// Finish writers // Finish writers
if (internalWriter.valid()) if (internalWriter)
{ {
internalWriter->close(); internalWriter->close();
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +54,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFields
const auto& field = tfield(); const auto& field = tfield();
// Internal // Internal
if (internalWriter.valid()) if (internalWriter)
{ {
ok = true; ok = true;
internalWriter->write(field); internalWriter->write(field);
@ -126,7 +126,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFields
const auto& field = tfield(); const auto& field = tfield();
// Internal // Internal
if (internalWriter.valid() && pInterp.valid()) if (internalWriter && pInterp)
{ {
ok = true; ok = true;
internalWriter->write(field, *pInterp); internalWriter->write(field, *pInterp);

View File

@ -145,7 +145,7 @@ Foam::displacementComponentLaplacianFvMotionSolver::curPoints() const
pointDisplacement_ pointDisplacement_
); );
if (pointLocation_.valid()) if (pointLocation_)
{ {
if (debug) if (debug)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -245,7 +245,7 @@ Foam::displacementLaplacianFvMotionSolver::
Foam::motionDiffusivity& Foam::motionDiffusivity&
Foam::displacementLaplacianFvMotionSolver::diffusivity() Foam::displacementLaplacianFvMotionSolver::diffusivity()
{ {
if (!diffusivityPtr_.valid()) if (!diffusivityPtr_)
{ {
diffusivityPtr_ = motionDiffusivity::New diffusivityPtr_ = motionDiffusivity::New
( (
@ -267,7 +267,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const
pointDisplacement_ pointDisplacement_
); );
if (pointLocation_.valid()) if (pointLocation_)
{ {
if (debug) if (debug)
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -249,7 +249,7 @@ Foam::solidBodyDisplacementLaplacianFvMotionSolver::
Foam::motionDiffusivity& Foam::motionDiffusivity&
Foam::solidBodyDisplacementLaplacianFvMotionSolver::diffusivity() Foam::solidBodyDisplacementLaplacianFvMotionSolver::diffusivity()
{ {
if (!diffusivityPtr_.valid()) if (!diffusivityPtr_)
{ {
diffusivityPtr_ = motionDiffusivity::New diffusivityPtr_ = motionDiffusivity::New
( (
@ -277,7 +277,7 @@ Foam::solidBodyDisplacementLaplacianFvMotionSolver::curPoints() const
); );
const pointField& newPoints = tnewPoints(); const pointField& newPoints = tnewPoints();
if (pointLocation_.valid()) if (pointLocation_)
{ {
if (debug) if (debug)
{ {

View File

@ -394,7 +394,7 @@ surfaceDisplacementPointPatchVectorField
const Foam::searchableSurfaces& const Foam::searchableSurfaces&
Foam::surfaceDisplacementPointPatchVectorField::surfaces() const Foam::surfaceDisplacementPointPatchVectorField::surfaces() const
{ {
if (surfacesPtr_.empty()) if (!surfacesPtr_)
{ {
surfacesPtr_.reset surfacesPtr_.reset
( (

View File

@ -380,7 +380,7 @@ surfaceSlipDisplacementPointPatchVectorField
const Foam::searchableSurfaces& const Foam::searchableSurfaces&
Foam::surfaceSlipDisplacementPointPatchVectorField::surfaces() const Foam::surfaceSlipDisplacementPointPatchVectorField::surfaces() const
{ {
if (surfacesPtr_.empty()) if (!surfacesPtr_)
{ {
surfacesPtr_.reset surfacesPtr_.reset
( (

View File

@ -591,7 +591,7 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs()
} }
// Apply offset to mapped values // Apply offset to mapped values
if (offset_.valid()) if (offset_)
{ {
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
this->operator==(*this + offset_->value(t)); this->operator==(*this + offset_->value(t));
@ -633,7 +633,7 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write
mapMethod_ mapMethod_
); );
if (offset_.valid()) if (offset_)
{ {
offset_->writeData(os); offset_->writeData(os);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -155,7 +155,7 @@ void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs()
return; return;
} }
if (!interpolatorPtr_.valid()) if (!interpolatorPtr_)
{ {
interpolatorPtr_ = interpolationWeights::New interpolatorPtr_ = interpolationWeights::New
( (

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,7 +38,7 @@ Foam::fv::interRegionOption::nbrRegionName() const
inline const Foam::meshToMesh& inline const Foam::meshToMesh&
Foam::fv::interRegionOption::meshInterp() const Foam::fv::interRegionOption::meshInterp() const
{ {
if (!meshInterpPtr_.valid()) if (!meshInterpPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Interpolation object not set" << "Interpolation object not set"

View File

@ -501,7 +501,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::constrain
const label const label
) )
{ {
if (invAPtr_.empty()) if (!invAPtr_)
{ {
invAPtr_.reset invAPtr_.reset
( (

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -95,7 +95,7 @@ Foam::fv::jouleHeatingSource::updateSigma
VolFieldType& sigma = VolFieldType& sigma =
mesh_.lookupObjectRef<VolFieldType>(typeName + ":sigma"); mesh_.lookupObjectRef<VolFieldType>(typeName + ":sigma");
if (!sigmaVsTPtr.valid()) if (!sigmaVsTPtr)
{ {
// Electrical conductivity field, sigma, was specified by the user // Electrical conductivity field, sigma, was specified by the user
return sigma; return sigma;

View File

@ -237,7 +237,7 @@ void Foam::fv::meanVelocityForce::constrain
const label const label
) )
{ {
if (rAPtr_.empty()) if (!rAPtr_)
{ {
rAPtr_.reset rAPtr_.reset
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +54,7 @@ void Foam::fv::rotorDiskSource::calculate
scalar AOAmax = -GREAT; scalar AOAmax = -GREAT;
// Cached position-dependent rotations available? // Cached position-dependent rotations available?
const bool hasCache = Rcyl_.valid(); const bool hasCache = bool(Rcyl_);
forAll(cells_, i) forAll(cells_, i)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -134,7 +134,7 @@ Foam::fv::CodedSource<Type>::CodedSource
template<class Type> template<class Type>
Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const
{ {
if (!redirectFvOptionPtr_.valid()) if (!redirectFvOptionPtr_)
{ {
dictionary constructDict(dict_); dictionary constructDict(dict_);
constructDict.set("type", name_); constructDict.set("type", name_);

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,7 +38,7 @@ Foam::fv::interRegionHeatTransferModel::nbrRegionName() const
inline const Foam::meshToMesh& inline const Foam::meshToMesh&
Foam::fv::interRegionHeatTransferModel::meshInterp() const Foam::fv::interRegionHeatTransferModel::meshInterp() const
{ {
if (!meshInterpPtr_.valid()) if (!meshInterpPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Interpolation object not set" << "Interpolation object not set"

View File

@ -51,7 +51,7 @@ namespace fv
const Foam::interpolation2DTable<Foam::scalar>& const Foam::interpolation2DTable<Foam::scalar>&
Foam::fv::tabulatedHeatTransfer::hTable() Foam::fv::tabulatedHeatTransfer::hTable()
{ {
if (!hTable_.valid()) if (!hTable_)
{ {
hTable_.reset(new interpolation2DTable<scalar>(coeffs_)); hTable_.reset(new interpolation2DTable<scalar>(coeffs_));
} }
@ -62,7 +62,7 @@ Foam::fv::tabulatedHeatTransfer::hTable()
const Foam::volScalarField& Foam::fv::tabulatedHeatTransfer::AoV() const Foam::volScalarField& Foam::fv::tabulatedHeatTransfer::AoV()
{ {
if (!AoV_.valid()) if (!AoV_)
{ {
AoV_.reset AoV_.reset
( (

View File

@ -61,7 +61,7 @@ Foam::fv::tabulatedNTUHeatTransfer::geometryModelNames_
const Foam::interpolation2DTable<Foam::scalar>& const Foam::interpolation2DTable<Foam::scalar>&
Foam::fv::tabulatedNTUHeatTransfer::ntuTable() Foam::fv::tabulatedNTUHeatTransfer::ntuTable()
{ {
if (!ntuTable_.valid()) if (!ntuTable_)
{ {
ntuTable_.reset(new interpolation2DTable<scalar>(coeffs_)); ntuTable_.reset(new interpolation2DTable<scalar>(coeffs_));
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -343,7 +344,7 @@ void Foam::Cloud<ParticleType>::move
template<class ParticleType> template<class ParticleType>
void Foam::Cloud<ParticleType>::autoMap(const mapPolyMesh& mapper) void Foam::Cloud<ParticleType>::autoMap(const mapPolyMesh& mapper)
{ {
if (!globalPositionsPtr_.valid()) if (!globalPositionsPtr_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Global positions are not available. " << "Global positions are not available. "

View File

@ -139,7 +139,7 @@ void Foam::KinematicCloud<CloudType>::solve
template<class CloudType> template<class CloudType>
void Foam::KinematicCloud<CloudType>::buildCellOccupancy() void Foam::KinematicCloud<CloudType>::buildCellOccupancy()
{ {
if (cellOccupancyPtr_.empty()) if (!cellOccupancyPtr_)
{ {
cellOccupancyPtr_.reset cellOccupancyPtr_.reset
( (
@ -174,7 +174,7 @@ void Foam::KinematicCloud<CloudType>::updateCellOccupancy()
// Only build the cellOccupancy if the pointer is set, i.e. it has // Only build the cellOccupancy if the pointer is set, i.e. it has
// been requested before. // been requested before.
if (cellOccupancyPtr_.valid()) if (cellOccupancyPtr_)
{ {
buildCellOccupancy(); buildCellOccupancy();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -370,7 +370,7 @@ template<class CloudType>
inline Foam::List<Foam::DynamicList<typename CloudType::particleType*>>& inline Foam::List<Foam::DynamicList<typename CloudType::particleType*>>&
Foam::KinematicCloud<CloudType>::cellOccupancy() Foam::KinematicCloud<CloudType>::cellOccupancy()
{ {
if (cellOccupancyPtr_.empty()) if (!cellOccupancyPtr_)
{ {
buildCellOccupancy(); buildCellOccupancy();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -343,7 +343,7 @@ void Foam::ReactingCloud<CloudType>::info()
template<class CloudType> template<class CloudType>
void Foam::ReactingCloud<CloudType>::writeFields() const void Foam::ReactingCloud<CloudType>::writeFields() const
{ {
if (compositionModel_.valid()) if (compositionModel_)
{ {
CloudType::particleType::writeFields(*this, this->composition()); CloudType::particleType::writeFields(*this, this->composition());
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -279,7 +280,7 @@ void Foam::ReactingMultiphaseCloud<CloudType>::info()
template<class CloudType> template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::writeFields() const void Foam::ReactingMultiphaseCloud<CloudType>::writeFields() const
{ {
if (this->compositionModel_.valid()) if (this->compositionModel_)
{ {
CloudType::particleType::writeFields(*this, this->composition()); CloudType::particleType::writeFields(*this, this->composition());
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,7 +124,7 @@ template<class ParcelType>
inline const Foam::interpolation<Foam::scalar>& inline const Foam::interpolation<Foam::scalar>&
Foam::ThermoParcel<ParcelType>::trackingData::GInterp() const Foam::ThermoParcel<ParcelType>::trackingData::GInterp() const
{ {
if (!GInterp_.valid()) if (!GInterp_)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Radiation G interpolation object not set" << "Radiation G interpolation object not set"

Some files were not shown because too many files have changed in this diff Show More