diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C index cd7570bf26d7f6ff2537d2050f205c1c4bffb433..89033668c53740abf809a2640bd2de70a311a7f1 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,12 +130,12 @@ Foam::BlendedInterfacialModel<modelType>::K() const { tmp<volScalarField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { 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()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->K()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() += model2In1_->K()*f2; } @@ -175,7 +176,7 @@ Foam::BlendedInterfacialModel<modelType>::K() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -191,7 +192,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const { tmp<surfaceScalarField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = fvc::interpolate ( @@ -199,7 +200,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = fvc::interpolate ( @@ -225,17 +226,17 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const ) ); - if (model_.valid()) + if (model_) { x.ref() += model_->Kf()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->Kf()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() += model2In1_->Kf()*f2; } @@ -243,7 +244,7 @@ Foam::BlendedInterfacialModel<modelType>::Kf() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -260,12 +261,12 @@ Foam::BlendedInterfacialModel<modelType>::F() const { tmp<volScalarField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed()); } @@ -285,17 +286,17 @@ Foam::BlendedInterfacialModel<modelType>::F() const dimensioned<Type>(modelType::dimF, Zero) ); - if (model_.valid()) + if (model_) { x.ref() += model_->F()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->F()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() -= model2In1_->F()*f2; // note : subtraction } @@ -303,7 +304,7 @@ Foam::BlendedInterfacialModel<modelType>::F() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -319,7 +320,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const { tmp<surfaceScalarField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = fvc::interpolate ( @@ -327,7 +328,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = fvc::interpolate ( @@ -352,17 +353,17 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const x.ref().setOriented(); - if (model_.valid()) + if (model_) { x.ref() += model_->Ff()*(f1() - f2()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->Ff()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() -= model2In1_->Ff()*f2; // note : subtraction } @@ -370,7 +371,7 @@ Foam::BlendedInterfacialModel<modelType>::Ff() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -386,12 +387,12 @@ Foam::BlendedInterfacialModel<modelType>::D() const { tmp<volScalarField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed()); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { 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()); } - if (model1In2_.valid()) + if (model1In2_) { x.ref() += model1In2_->D()*(1 - f1); } - if (model2In1_.valid()) + if (model2In1_) { x.ref() += model2In1_->D()*f2; } @@ -432,7 +433,7 @@ Foam::BlendedInterfacialModel<modelType>::D() const if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -451,8 +452,8 @@ bool Foam::BlendedInterfacialModel<modelType>::hasModel return ( &phase == &(pair_.phase1()) - ? model1In2_.valid() - : model2In1_.valid() + ? bool(model1In2_) + : bool(model2In1_) ); } diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.C index d958b5d9452f409658a4b2e7933b00f63b8f6ca1..f61f6ea34c29845b269f3c9bcfe5f510a78fe126 100644 --- a/applications/test/dictionaryTokens/dictionaryTokens.C +++ b/applications/test/dictionaryTokens/dictionaryTokens.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,8 +53,8 @@ Foam::token Foam::dictionaryTokens::keywordToken(const entry& e) bool Foam::dictionaryTokens::setIterator() const { - primIter_.clear(); - dictIter_.clear(); + primIter_.reset(nullptr); + dictIter_.reset(nullptr); if (entryIter_ != dict_.cend()) { @@ -166,8 +166,8 @@ bool Foam::dictionaryTokens::good() const entryIter_ != dict_.cend() && ( - (primIter_.valid() && primIter_().good()) - || (dictIter_.valid() && dictIter_().good()) + (primIter_ && primIter_->good()) + || (dictIter_ && dictIter_->good()) ) ); } @@ -189,8 +189,8 @@ const Foam::token& Foam::dictionaryTokens::operator*() const { if (good()) { - if (primIter_.valid()) return *(primIter_()); - if (dictIter_.valid()) return *(dictIter_()); + if (primIter_) return *(*primIter_); + if (dictIter_) return *(*dictIter_); } return token::undefinedToken; @@ -251,8 +251,8 @@ bool Foam::dictionaryTokens::operator++() if (ok) { - if (primIter_.valid()) ok = ++(primIter_()); - if (dictIter_.valid()) ok = ++(dictIter_()); + if (primIter_) ok = ++(*primIter_); + if (dictIter_) ok = ++(*dictIter_); if (!ok) { diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 971c546c29f3d60c51b1b157de11a2d78fa6decc..6a08caed3840fdb2b3e5305ba6beb0343ba50d20 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -815,9 +815,9 @@ int main(int argc, char *argv[]) polyMesh& mesh = ( - meshFromMesh.valid() - ? meshFromMesh() - : meshFromSurface() + meshFromMesh + ? *meshFromMesh + : *meshFromSurface ); diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 4f1f821681022aaafc0cee51a41dde3840976b90..f1a6b5ff3f1121f604b676de4acd15ad2298aa6a 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -954,7 +954,7 @@ Foam::label Foam::checkGeometry patchWriter.reset(new surfaceWriters::vtkWriter()); } - surfaceWriter& wr = (surfWriter.valid() ? *surfWriter : *patchWriter); + surfaceWriter& wr = (surfWriter ? *surfWriter : *patchWriter); // Currently only do AMI checks diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 9043525a3202e8e0fecc3a7f7bcf40401944bcd2..d624982254e0d96994bcccad2f6b63989c8617cb 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -1415,9 +1415,9 @@ autoPtr<mapDistributePolyMesh> createReconstructMap autoPtr<mapDistributePolyMesh> mapPtr; - if (baseMeshPtr.valid() && baseMeshPtr().nCells()) + if (baseMeshPtr && baseMeshPtr->nCells()) { - const fvMesh& baseMesh = baseMeshPtr(); + const fvMesh& baseMesh = *baseMeshPtr; labelListList cellSubMap(Pstream::nProcs()); cellSubMap[Pstream::masterNo()] = identity(mesh.nCells()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H index 923cf7fabf34d2803a5d451ccf1ff6a0c0ded97a..2466cda860edc9b6373d4fc28894756b64cd6145 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,7 +56,7 @@ if (doFiniteArea) FatalError.throwExceptions(throwing); } - if (faMeshPtr.valid() && nAreaFields) + if (faMeshPtr && nAreaFields) { reportFields::area(Info, objects); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H index bcaf81a9d8dbba33e68deb31a019028b81106166..6bdfa0096ee8322af0e602692de34ece565ba6a9 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeDimFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,7 +85,7 @@ bool writeDimField const auto& field = tfield(); - if (internalWriter.valid() && pInterp.valid()) + if (internalWriter && pInterp) { internalWriter->write(field, *pInterp); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H index 03bb2bbfe9a3802783ba49b895d4f82904e4d573..e92186fe47bfc75db48012c4238ed3b671b039d6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeVolFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,7 +99,7 @@ bool writeVolField const auto& field = tfield(); // Internal - if (internalWriter.valid() && pInterp.valid()) + if (internalWriter && pInterp) { internalWriter->write(field, *pInterp); } diff --git a/applications/utilities/preProcessing/setExprFields/setExprFields.C b/applications/utilities/preProcessing/setExprFields/setExprFields.C index 2b995e0c3184874deb9cecd14f67ee5ad702005f..218c1ecfbf61c91d35a032fb4cb35e773ea5a936 100644 --- a/applications/utilities/preProcessing/setExprFields/setExprFields.C +++ b/applications/utilities/preProcessing/setExprFields/setExprFields.C @@ -723,7 +723,7 @@ int main(int argc, char *argv[]) mesh.readUpdate(); - if (args.found("dummy-phi") && !dummyPhi.valid()) + if (args.found("dummy-phi") && !dummyPhi) { Info<< "Adding a dummy phi" << endl; dummyPhi.reset diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index d7492379baa3772818d6ead9e0eda4f72b437290..05f6f7c09c9abb50f910b41f410832f3cbd1eca6 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -1043,7 +1043,7 @@ int main(int argc, char *argv[]) // ) // ); // - // if (hitInfo.hit() && intStreamPtr.valid()) + // if (hitInfo.hit() && intStreamPtr) // { // intStreamPtr().write(hitInfo.hitPoint()); // diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 010cec6bd6c6ceb953310d0d75eeae9a8102582a..5523ab84173d39acb0abe8bd4402597876757871 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -346,14 +346,14 @@ int main(int argc, char *argv[]) // Load a single file, or load and combine multiple selected files autoPtr<triSurface> surfPtr = loader.load(loadingOption, scaleFactor); - if (!surfPtr.valid() || surfPtr().empty()) + if (!surfPtr || surfPtr->empty()) { FatalErrorInFunction << "Problem loading surface(s) for entry: " << dictName << exit(FatalError); } - triSurface surf = surfPtr(); + triSurface surf = *surfPtr; Info<< nl << "Statistics:" << nl; diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index e7fce79fdf153c55425b2fdee330e655d3161476..a779c4217fc8ddb79b61c2334f98d3aafe00d1b4 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -185,7 +185,7 @@ void Foam::regIOobject::close() { Pout<< "regIOobject::close() : " << "finished reading " - << (isPtr_.valid() ? isPtr_().name() : "dummy") + << (isPtr_ ? isPtr_->name() : "dummy") << endl; } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 4062471af1facc27cedffb7859cfc8bb51a6174e..45a6afaacc504c729acb24cf0db4bada359f866f 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -128,8 +128,8 @@ void Foam::globalMeshData::calcSharedPoints() const if ( nGlobalPoints_ != -1 - || sharedPointLabelsPtr_.valid() - || sharedPointAddrPtr_.valid() + || sharedPointLabelsPtr_ + || sharedPointAddrPtr_ ) { FatalErrorInFunction @@ -295,8 +295,8 @@ void Foam::globalMeshData::calcSharedEdges() const if ( nGlobalEdges_ != -1 - || sharedEdgeLabelsPtr_.valid() - || sharedEdgeAddrPtr_.valid() + || sharedEdgeLabelsPtr_ + || sharedEdgeAddrPtr_ ) { FatalErrorInFunction diff --git a/src/finiteVolume/expressions/base/fvExprDriver.C b/src/finiteVolume/expressions/base/fvExprDriver.C index b363296dc49df156fff1891ebac7a9bd6ddadf48..a73c38986bff9a502c2a2bcf77b0e99fac7e5212 100644 --- a/src/finiteVolume/expressions/base/fvExprDriver.C +++ b/src/finiteVolume/expressions/base/fvExprDriver.C @@ -190,7 +190,7 @@ bool Foam::expressions::fvExprDriver::readDict { ITstream& is = eptr->stream(); - if (writer_.valid() && storedVariables_.size()) + if (writer_ && !storedVariables_.empty()) { WarningInFunction // << "Context: " << driverContext_ << nl @@ -216,7 +216,7 @@ bool Foam::expressions::fvExprDriver::readDict { ITstream& is = eptr->stream(); - if (writer_.valid() && delayedVariables_.size()) + if (writer_ && !delayedVariables_.empty()) { WarningInFunction // << "Context: " << driverContext_ << nl diff --git a/src/finiteVolume/expressions/base/fvExprDriverIO.C b/src/finiteVolume/expressions/base/fvExprDriverIO.C index 3a25df5bdb6d4ec33f824fee81699a4141c01f95..93a64e1a2a7ea545ab5c700f8a3ff27cf09a0a6c 100644 --- a/src/finiteVolume/expressions/base/fvExprDriverIO.C +++ b/src/finiteVolume/expressions/base/fvExprDriverIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com> - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -261,16 +261,16 @@ Foam::Ostream& Foam::expressions::fvExprDriver::writeCommon 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 { - if (writer_.valid() && mesh().time().outputTime()) + if (writer_ && mesh().time().outputTime()) { writer_->write(); } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H index 331d20cb2dc39e2fdd278d81337893bd9090539c..f1ce22a48a45cd3b88d4b71e339cba0833bfee4d 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,7 +38,7 @@ withSurfaceFields() const ( stFaceZone == regionType_ || stPatch == regionType_ - || (sampledPtr_.valid() && sampledPtr_->withSurfaceFields()) + || (sampledPtr_ && sampledPtr_->withSurfaceFields()) ); } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index 620fa7d46a90e04362606d69669b50b758a9c782..8d136cc7afde8df5c038026c424caedeeaf47492 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -370,7 +370,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues Field<Type> values(getFieldValues<Type>(fieldName, true)); // Write raw values on surface if specified - if (surfaceWriterPtr_.valid() && surfaceWriterPtr_->enabled()) + if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled()) { Field<Type> allValues(values); combineFields(allValues); diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index 878ed42ea43eb9e7fc924f4d4338acff43f58ff6..ef50d4e471b6da9a065695c0b319027bc8103499 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -34,7 +34,7 @@ template<class chemistryType> void Foam::functionObjects::reactionsSensitivityAnalysis<chemistryType>:: createFileNames() { - if (writeToFile() && !prodFilePtr_.valid()) + if (writeToFile() && !prodFilePtr_) { prodFilePtr_ = createFile("production"); writeHeader(prodFilePtr_(), "production"); diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 6375a4ca73a0f539518b3dae01684a69ef3df50a..d5c2ee726fefdc776df0d57fa49bd9968f3312e2 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -413,8 +413,8 @@ bool Foam::functionObjects::regionSizeDistribution::write() const volScalarField& alpha = ( - alphaPtr.valid() - ? alphaPtr() + alphaPtr + ? *alphaPtr : obr_.lookupObject<volScalarField>(alphaName_) ); diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index e55aa3ef0723e2e44ddbc441decda54d2e714d37..5b5e2b2d7cf5994e6f738adeeb523a7b38e00c3d 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License 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 - if (writeToFile() && !coeffFilePtr_.valid()) + if (writeToFile() && !coeffFilePtr_) { coeffFilePtr_ = createFile("coefficient"); writeIntegratedHeader("Coefficients", coeffFilePtr_()); diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index b2e824f78160b35a006c960d40f39a4ba56c77a1..e3dbc07f1f967eb828828a3555061f1f431a7a5f 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -58,7 +58,7 @@ void Foam::functionObjects::forces::createFiles() { // Note: Only possible to create bin files after bins have been initialised - if (writeToFile() && !forceFilePtr_.valid()) + if (writeToFile() && !forceFilePtr_) { forceFilePtr_ = createFile("force"); writeIntegratedHeader("Force", forceFilePtr_()); diff --git a/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C b/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C index 3152b74e893f3caf528428d6950c96a02d7c374f..1528db79513db2b4fd48576c84cdf7db962fc0c6 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWriteTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -126,7 +126,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFields const auto& field = tfield(); // Internal - if (internalWriter.valid() && pInterp.valid()) + if (internalWriter && pInterp) { ok = true; internalWriter->write(field, *pInterp); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 9db24f0e39697bcab2911ad274f5b354d1f32d88..752f6d5b95c346ca3e0f188cba6af98affc50339 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -1253,11 +1253,11 @@ void Foam::snappySnapDriver::featureAttractionUsingReconstruction const point& pt = pp.localPoints()[pointi]; - if (patchConstraints[pointi].first() == 2 && feStr.valid()) + if (feStr && patchConstraints[pointi].first() == 2) { feStr().write(linePointRef(pt, pt+patchAttraction[pointi])); } - else if (patchConstraints[pointi].first() == 3 && fpStr.valid()) + else if (fpStr && patchConstraints[pointi].first() == 3) { fpStr().write(linePointRef(pt, pt+patchAttraction[pointi])); } @@ -2580,11 +2580,7 @@ void Foam::snappySnapDriver::determineFeatures hasSnapped = true; // Debug: dump missed feature point - if - ( - missedMP0Str.valid() - && !nearInfo.second().hit() - ) + if (missedMP0Str && !nearInfo.second().hit()) { missedMP0Str().write ( @@ -2649,11 +2645,7 @@ void Foam::snappySnapDriver::determineFeatures } // Debug: dump missed feature point - if - ( - missedMP1Str.valid() - && !nearInfo.second().hit() - ) + if (missedMP1Str && !nearInfo.second().hit()) { missedMP1Str().write ( @@ -2693,8 +2685,8 @@ void Foam::snappySnapDriver::determineFeatures { if ( - patchConstraints[pointi].first() == 3 - && featurePointStr.valid() + featurePointStr + && patchConstraints[pointi].first() == 3 ) { featurePointStr().write @@ -2704,8 +2696,8 @@ void Foam::snappySnapDriver::determineFeatures } else if ( - patchConstraints[pointi].first() == 2 - && featureEdgeStr.valid() + featureEdgeStr + && patchConstraints[pointi].first() == 2 ) { featureEdgeStr().write @@ -2812,7 +2804,7 @@ void Foam::snappySnapDriver::determineFeatures } const pointIndexHit& info = nearInfo.second(); - if (info.hit() && featurePointStr.valid()) + if (featurePointStr && info.hit()) { featurePointStr().write ( diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index cef6859a6f9d70181524113f896a5bb342e86f47..81babc9c45c83883ba80b6c02d0bfcaad0de9b7c 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -763,7 +763,7 @@ const { const word surfType(surfDict_.getOrDefault<word>("type", "none")); - if (!surfPtr_.valid() && surfType != "none") + if (!surfPtr_ && surfType != "none") { word surfName(surfDict_.getOrDefault("name", patch_.name())); diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C index eeb15d95542a12d5ea0e2741076e0af40a29bcf1..46ed2da21d04552d1c70d6934c155bbf894e21a0 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C @@ -63,7 +63,7 @@ Foam::label Foam::NURBS3DVolume::getCPID void Foam::NURBS3DVolume::findPointsInBox(const vectorField& meshPoints) { // It is considered an error to recompute points in the control boxes - if (mapPtr_.valid() || reverseMapPtr_.valid()) + if (mapPtr_ || reverseMapPtr_) { FatalErrorInFunction << "Attempting to recompute points residing within control boxes" diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C index b6e57519d660c6dcd29ae3fb97d4678ccfe9362c..4394e4884be2b9def1bf03c3aa8475763a2fe3d2 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/RASModelVariables/RASModelVariables.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -153,7 +153,7 @@ RASModelVariables::autoTmp RASModelVariables::cloneAutoTmp(const autoTmp& source) const { autoTmp returnField(nullptr); - if (source.valid() && source().valid()) + if (source && source->valid()) { const volScalarField& sf = source()(); DebugInfo diff --git a/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C index 2d673c7d2307b8e9a59d81cdf43141d3f6a38ca5..92f9c06aafecf1fe32b190572faac50fa7decf9c 100644 --- a/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C +++ b/src/phaseSystemModels/reactingEulerFoam/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C @@ -646,12 +646,12 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs() if ( - CHFModel_.valid() - && CHFSoobModel_.valid() - && TDNBModel_.valid() - && MHFModel_.valid() - && LeidenfrostModel_.valid() - && filmBoilingModel_.valid() + CHFModel_ + && CHFSoobModel_ + && TDNBModel_ + && MHFModel_ + && LeidenfrostModel_ + && filmBoilingModel_ ) { diff --git a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C index b2b7ba703199033578d31fbd7e4729bb9a76d95d..8aa6ad3e5d5c659435522c47e1d9f1723567974f 100644 --- a/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/src/phaseSystemModels/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,7 +107,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate tmp<scalarGeoField> f1, f2; - if (model_.valid() || model1In2_.valid()) + if (model_ || model1In2_) { f1 = blendedInterfacialModel::interpolate<scalarGeoField> @@ -115,7 +116,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate ); } - if (model_.valid() || model2In1_.valid()) + if (model_ || model2In1_) { f2 = blendedInterfacialModel::interpolate<scalarGeoField> @@ -177,7 +178,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate if ( correctFixedFluxBCs_ - && (model_.valid() || model1In2_.valid() || model2In1_.valid()) + && (model_ || model1In2_ || model2In1_) ) { correctFixedFluxBCs(x.ref()); @@ -300,8 +301,8 @@ bool Foam::BlendedInterfacialModel<ModelType>::hasModel { return &phase == &(phase1_) - ? model1In2_.valid() - : model2In1_.valid(); + ? bool(model1In2_) + : bool(model2In1_); } diff --git a/src/sampling/sampledSet/shortestPath/shortestPathSet.C b/src/sampling/sampledSet/shortestPath/shortestPathSet.C index 2fcbdd0ed4c7cb08e3d688c36d28ed3a8a4f5512..8b4ba57e65923ad695fb37736de43f908b03ab88 100644 --- a/src/sampling/sampledSet/shortestPath/shortestPathSet.C +++ b/src/sampling/sampledSet/shortestPath/shortestPathSet.C @@ -969,7 +969,7 @@ void Foam::shortestPathSet::genSamples markLeakPath, iter, mesh, - (isBlockedFace.valid() ? isBlockedFace() : isBoundaryFace), + (isBlockedFace ? *isBlockedFace : isBoundaryFace), insidePoint, insideCelli, outsidePoint, diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C index c6d8380b05d13bada7631994e924624867f16148..a5fe5b56f09c6c9dc9154063bc889b40bddbc177 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C @@ -107,7 +107,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const } const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C index 058cf05fcf7bce2908cbd89a164bf50d2c6b0aec..a9ce4fba0154a71848e624fe6de24e5113c7f382 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceTopo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,7 +107,7 @@ bool Foam::sampledIsoSurfaceTopo::updateGeometry() const } const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld); diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 0a9de84b921c69c8e4746ba935ca35d2697113ab..4d846848eb315f3038291aed8d46303ca90cef5e 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -164,8 +164,8 @@ void Foam::sampledCuttingPlane::createGeometry() // Select either the submesh or the underlying mesh const fvMesh& mesh = ( - subMeshPtr_.valid() - ? subMeshPtr_().subMesh() + subMeshPtr_ + ? subMeshPtr_->subMesh() : fvm ); diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 6211ad7d6e3738e29e796b242c9b5b355529db5b..3779ff20d3c396679e015bf4d922a478330b1aa7 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -326,7 +326,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict) surfDict ); - if (!surf.valid() || !surf->enabled()) + if (!surf || !surf->enabled()) { continue; } @@ -392,7 +392,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict) autoPtr<sampledSurface> surf = input.release(inputi); - if (!surf.valid() || !surf->enabled()) + if (!surf || !surf->enabled()) { continue; } diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C index 719286664f0cddcc9fd859917f156b1b265d2048..bdf786158006addaa5ce042e5323c81fbeddaa7d 100644 --- a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C @@ -102,8 +102,9 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const fvm ); } + const volScalarField& cellFld = - (fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr); + (fieldReadPtr ? *fieldReadPtr : *cellFldPtr); thresholdCellFaces surf diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index 315bd43c06ce347cd153d372272e0c964e9af88f..3d2eeb2d2d8eb5b8edebc5013f35e71350351d8d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -439,7 +439,7 @@ void Foam::radiation::solarLoad::calculateQdiff ); - if (finalAgglom_.size() > 0 && coarseMesh_.empty()) + if (!coarseMesh_ && !finalAgglom_.empty()) { coarseMesh_.reset (