diff --git a/src/functionObjects/field/CourantNo/CourantNo.C b/src/functionObjects/field/CourantNo/CourantNo.C index 472f6ff26c..b74fb8b6dd 100644 --- a/src/functionObjects/field/CourantNo/CourantNo.C +++ b/src/functionObjects/field/CourantNo/CourantNo.C @@ -59,10 +59,8 @@ Foam::functionObjects::CourantNo::byRho { return Co/obr_.lookupObject(rhoName_); } - else - { - return Co; - } + + return Co; } @@ -85,35 +83,27 @@ bool Foam::functionObjects::CourantNo::calc() if (foundObject(resultName_, false)) { - volScalarField& Co - ( - const_cast - ( - lookupObject(resultName_) - ) - ); + volScalarField& Co = + lookupObjectRef(resultName_); Co.ref() = Coi(); Co.correctBoundaryConditions(); } else { - tmp tCo + auto tCo = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - resultName_, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + resultName_, + mesh_.time().timeName(), mesh_, - dimensionedScalar(dimless, Zero), - zeroGradientFvPatchScalarField::typeName - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimless, Zero), + zeroGradientFvPatchScalarField::typeName ); tCo.ref().ref() = Coi(); tCo.ref().correctBoundaryConditions(); @@ -122,10 +112,8 @@ bool Foam::functionObjects::CourantNo::calc() return true; } - else - { - return false; - } + + return false; } diff --git a/src/functionObjects/field/Curle/Curle.C b/src/functionObjects/field/Curle/Curle.C index 67d6675093..b315ebbe8b 100644 --- a/src/functionObjects/field/Curle/Curle.C +++ b/src/functionObjects/field/Curle/Curle.C @@ -75,33 +75,28 @@ bool Foam::functionObjects::Curle::calc() const volVectorField& C = mesh_.C(); - tmp tpDash + auto tpDash = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - resultName_, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + resultName_, + mesh_.time().timeName(), mesh_, - dimensionedScalar(p.dimensions(), Zero) - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(p.dimensions(), Zero) ); + auto& pDash = tpDash.ref(); - volScalarField& pDash = tpDash.ref(); const volVectorField d(scopedName("d"), C - x0_); pDash = (d/magSqr(d) & dfdt)/(4.0*mathematical::pi*c0_); return store(resultName_, tpDash); } - else - { - return false; - } + + return false; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -136,8 +131,7 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict) { if (fieldExpression::read(dict)) { - patchSet_ = - mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches"))); + patchSet_ = mesh_.boundaryMesh().patchSet(dict.get("patches")); if (patchSet_.empty()) { @@ -149,7 +143,7 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict) } // Read the reference speed of sound - dict.lookup("c0") >> c0_; + dict.readEntry("c0", c0_); // Set the location of the effective point source to the area-average diff --git a/src/functionObjects/field/DESModelRegions/DESModelRegions.C b/src/functionObjects/field/DESModelRegions/DESModelRegions.C index 3a8e462510..08dd381231 100644 --- a/src/functionObjects/field/DESModelRegions/DESModelRegions.C +++ b/src/functionObjects/field/DESModelRegions/DESModelRegions.C @@ -75,26 +75,21 @@ Foam::functionObjects::DESModelRegions::DESModelRegions { read(dict); - tmp tDESModelRegions + auto tmodelRegions = tmp::New ( + IOobject ( - new volScalarField - ( - IOobject - ( - resultName_, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimless, Zero) - ) - ) + resultName_, + time_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimless, Zero) ); - store(resultName_, tDESModelRegions); + store(resultName_, tmodelRegions); writeFileHeader(file()); } @@ -124,10 +119,7 @@ bool Foam::functionObjects::DESModelRegions::execute() Log << type() << " " << name() << " execute:" << nl; volScalarField& DESModelRegions = - const_cast - ( - lookupObject(resultName_) - ); + lookupObjectRef(resultName_); if (foundObject(turbulenceModel::propertiesName)) diff --git a/src/functionObjects/field/PecletNo/PecletNo.C b/src/functionObjects/field/PecletNo/PecletNo.C index c8eb2e8f67..c63524651c 100644 --- a/src/functionObjects/field/PecletNo/PecletNo.C +++ b/src/functionObjects/field/PecletNo/PecletNo.C @@ -57,10 +57,8 @@ Foam::tmp Foam::functionObjects::PecletNo::rhoScale { return phi/fvc::interpolate(lookupObject(rhoName_)); } - else - { - return phi; - } + + return phi; } @@ -84,23 +82,19 @@ bool Foam::functionObjects::PecletNo::calc() const dictionary& model = mesh_.lookupObject("transportProperties"); - nuEff = - tmp + nuEff = tmp::New + ( + IOobject ( - new volScalarField - ( - IOobject - ( - "nuEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(model.lookup("nu")) - ) - ); + "nuEff", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(model.lookup("nu")) + ); } else { diff --git a/src/functionObjects/field/blendingFactor/blendingFactor.C b/src/functionObjects/field/blendingFactor/blendingFactor.C index d46014e967..e213f23428 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactor.C +++ b/src/functionObjects/field/blendingFactor/blendingFactor.C @@ -81,22 +81,19 @@ Foam::functionObjects::blendingFactor::blendingFactor writeFileHeader(file()); setResultName(typeName, ""); - tmp indicatorPtr + auto indicatorPtr = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - resultName_, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + resultName_, + time_.timeName(), mesh_, - dimensionedScalar(dimless, Zero), - zeroGradientFvPatchScalarField::typeName - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimless, Zero), + zeroGradientFvPatchScalarField::typeName ); store(resultName_, indicatorPtr); diff --git a/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C b/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C index 923f6a9e89..062136ff3d 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C +++ b/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C @@ -72,10 +72,8 @@ void Foam::functionObjects::blendingFactor::calcBlendingFactor // - factor applied to 1st scheme, and (1-factor) to 2nd scheme // - not using the store(...) mechanism due to need to correct BCs volScalarField& indicator = - const_cast - ( - lookupObject(resultName_) - ); + lookupObjectRef(resultName_); + indicator = 1 - fvc::cellReduce(factorf, minEqOp(), GREAT); indicator.correctBoundaryConditions(); } diff --git a/src/functionObjects/field/ddt2/ddt2.C b/src/functionObjects/field/ddt2/ddt2.C index 5ef7b9fcc7..d00fb6d0c6 100644 --- a/src/functionObjects/field/ddt2/ddt2.C +++ b/src/functionObjects/field/ddt2/ddt2.C @@ -134,7 +134,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict) return false; } - dict.lookup("fields") >> selectFields_; + dict.readEntry("fields", selectFields_); selectFields_.uniq(); Info<< type() << " fields: " << selectFields_ << nl; diff --git a/src/functionObjects/field/ddt2/ddt2Templates.C b/src/functionObjects/field/ddt2/ddt2Templates.C index dc8cab344d..a58d7b0c0e 100644 --- a/src/functionObjects/field/ddt2/ddt2Templates.C +++ b/src/functionObjects/field/ddt2/ddt2Templates.C @@ -56,28 +56,24 @@ int Foam::functionObjects::ddt2::apply(const word& inputName, int& state) : magSqr(input.dimensions()/dimTime) ); - tmp tddt2 + auto tddt2 = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - outputName, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + outputName, + time_.timeName(), mesh_, - dimensionedScalar(dims, Zero) - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dims, Zero) ); store(outputName, tddt2); } - volScalarField& output = - const_cast(lookupObject(outputName)); + volScalarField& output = lookupObjectRef(outputName); if (mag_) { diff --git a/src/functionObjects/field/externalCoupled/externalCoupled.C b/src/functionObjects/field/externalCoupled/externalCoupled.C index 9aa3e0b972..91450209a9 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupled.C +++ b/src/functionObjects/field/externalCoupled/externalCoupled.C @@ -606,8 +606,8 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict) const dictionary& groupDict = regionIter().dict(); const label nGroups = groupNames_.size(); - const wordList readFields(groupDict.lookup("readFields")); - const wordList writeFields(groupDict.lookup("writeFields")); + const wordList readFields(groupDict.get("readFields")); + const wordList writeFields(groupDict.get("writeFields")); auto fnd = regionToGroups_.find(regionGroupNames_.last()); if (fnd.found()) diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C b/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C index 2b93676a41..cd78f475f9 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C @@ -278,8 +278,8 @@ Foam::functionObjects::externalCoupled::gatherAndCombine Pstream::gatherList(gatheredValues); - tmp> tresult(new Field(0)); - Field& result = tresult.ref(); + auto tresult = tmp>::New(); + auto& result = tresult.ref(); if (Pstream::master()) { diff --git a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C index 3614fb336a..12c3495ef0 100644 --- a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C +++ b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C @@ -584,8 +584,8 @@ bool Foam::functionObjects::extractEulerianParticles::read if (fvMeshFunctionObject::read(dict) && writeFile::read(dict)) { - dict.lookup("faceZone") >> faceZoneName_; - dict.lookup("alpha") >> alphaName_; + dict.readEntry("faceZone", faceZoneName_); + dict.readEntry("alpha", alphaName_); dict.readIfPresent("alphaThreshold", alphaThreshold_); dict.readIfPresent("U", UName_); diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C index 7c8aa89d08..ead231abf0 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.C +++ b/src/functionObjects/field/fieldAverage/fieldAverage.C @@ -305,13 +305,13 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) dict.readIfPresent("restartOnRestart", restartOnRestart_); dict.readIfPresent("restartOnOutput", restartOnOutput_); dict.readIfPresent("periodicRestart", periodicRestart_); - dict.lookup("fields") >> faItems_; + dict.readEntry("fields", faItems_); const scalar currentTime = obr().time().value(); if (periodicRestart_) { - scalar userRestartPeriod = readScalar(dict.lookup("restartPeriod")); + scalar userRestartPeriod = dict.get("restartPeriod"); restartPeriod_ = obr().time().userTimeToTime(userRestartPeriod); if (restartPeriod_ > 0) diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C index 74927ea91f..134a49ef36 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C @@ -192,13 +192,13 @@ void Foam::functionObjects::fieldAverageItem::clear bool Foam::functionObjects::fieldAverageItem::readState(const dictionary& dict) { - dict.lookup("totalIter") >> totalIter_; - dict.lookup("totalTime") >> totalTime_; + dict.readEntry("totalIter", totalIter_); + dict.readEntry("totalTime", totalTime_); if (window_ > 0) { - dict.lookup("windowTimes") >> windowTimes_; - dict.lookup("windowFieldNames") >> windowFieldNames_; + dict.readEntry("windowTimes", windowTimes_); + dict.readEntry("windowFieldNames", windowFieldNames_); } return true; diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C index c1c3e1d19a..f7c050a164 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C @@ -66,8 +66,8 @@ Foam::Istream& Foam::functionObjects::operator>> faItem.active_ = false; faItem.fieldName_ = entry.keyword(); - faItem.mean_ = readBool(entry.lookup("mean")); - faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean")); + faItem.mean_ = entry.get("mean"); + faItem.prime2Mean_ = entry.get("prime2Mean"); faItem.base_ = faItem.baseTypeNames_.lookup("base", entry); faItem.window_ = entry.lookupOrDefault("window", -1.0); @@ -94,7 +94,7 @@ Foam::Istream& Foam::functionObjects::operator>> if (faItem.windowType_ == fieldAverageItem::windowType::EXACT) { - faItem.allowRestart_ = readBool(entry.lookup("allowRestart")); + faItem.allowRestart_ = entry.get("allowRestart"); if (!faItem.allowRestart_) { diff --git a/src/functionObjects/field/fieldExpression/fieldExpression.C b/src/functionObjects/field/fieldExpression/fieldExpression.C index 6bb432ca3d..1ff9edbe8b 100644 --- a/src/functionObjects/field/fieldExpression/fieldExpression.C +++ b/src/functionObjects/field/fieldExpression/fieldExpression.C @@ -97,12 +97,12 @@ bool Foam::functionObjects::fieldExpression::read(const dictionary& dict) if (fieldName_.empty() || dict.found("field")) { - dict.lookup("field") >> fieldName_; + dict.readEntry("field", fieldName_); } if (dict.found("result")) { - dict.lookup("result") >> resultName_; + dict.readEntry("result", resultName_); } return true; diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C index 4ebe86bb24..56e792839b 100644 --- a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -95,8 +95,8 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict) fvMeshFunctionObject::read(dict); writeFile::read(dict); - dict.lookup("fields") >> fields_; - dict.lookup("writeFields") >> writeFields_; + dict.readEntry("fields", fields_); + dict.readEntry("writeFields", writeFields_); scaleFactor_ = dict.lookupOrDefault("scaleFactor", 1.0); return true; diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C b/src/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C index b665ee2896..4550d1b8b7 100644 --- a/src/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C +++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C @@ -36,7 +36,7 @@ Foam::functionObjects::fieldValue::New const bool output ) { - const word modelType(dict.lookup("type")); + const word modelType(dict.get("type")); if (output) { diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 1ef718a700..4da57d8516 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -484,7 +484,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise const dictionary& dict ) { - dict.lookup("name") >> regionName_; + dict.readEntry("name", regionName_); switch (regionType_) { @@ -616,7 +616,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise surfaceWriterPtr_.clear(); if (writeFields_) { - const word surfaceFormat(dict.lookup("surfaceFormat")); + const word surfaceFormat(dict.get("surfaceFormat")); if (surfaceFormat != "none") { @@ -687,12 +687,12 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues { case opSumDirection: { - const vector n(dict_.lookup("direction")); + const vector n(dict_.get("direction")); return gSum(pos0(values*(Sf & n))*mag(values)); } case opSumDirectionBalance: { - const vector n(dict_.lookup("direction")); + const vector n(dict_.get("direction")); const scalarField nv(values*(Sf & n)); return gSum(pos0(nv)*mag(values) - neg(nv)*mag(values)); @@ -758,16 +758,14 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues { case opSumDirection: { - vector n(dict_.lookup("direction")); - n /= mag(n) + ROOTVSMALL; + const vector n(dict_.get("direction").normalise()); const scalarField nv(n & values); return gSum(pos0(nv)*n*(nv)); } case opSumDirectionBalance: { - vector n(dict_.lookup("direction")); - n /= mag(n) + ROOTVSMALL; + const vector n(dict_.get("direction").normalise()); const scalarField nv(n & values); return gSum(pos0(nv)*n*(nv)); diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index 2cd561e626..c0dff9e67e 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -178,7 +178,6 @@ processSameTypeValues if (canWeight(weightField)) { tmp weight(weightingFactor(weightField)); - result = gSum(weight*values); } else @@ -466,8 +465,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField const GeometricField& field ) const { - tmp> tvalues(new Field(faceId_.size())); - Field& values = tvalues.ref(); + auto tvalues = tmp>::New(faceId_.size()); + auto& values = tvalues.ref(); forAll(values, i) { @@ -501,8 +500,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField const GeometricField& field ) const { - tmp> tvalues(new Field(faceId_.size())); - Field& values = tvalues.ref(); + auto tvalues = tmp>::New(faceId_.size()); + auto& values = tvalues.ref(); forAll(values, i) { diff --git a/src/functionObjects/field/fieldsExpression/fieldsExpression.C b/src/functionObjects/field/fieldsExpression/fieldsExpression.C index 482c1aa932..a0dd7a1c9b 100644 --- a/src/functionObjects/field/fieldsExpression/fieldsExpression.C +++ b/src/functionObjects/field/fieldsExpression/fieldsExpression.C @@ -111,12 +111,12 @@ bool Foam::functionObjects::fieldsExpression::read(const dictionary& dict) if (fieldNames_.empty() || dict.found("fields")) { - dict.lookup("fields") >> fieldNames_; + dict.readEntry("fields", fieldNames_); } if (dict.found("result")) { - dict.lookup("result") >> resultName_; + dict.readEntry("result", resultName_); } return true; diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.C b/src/functionObjects/field/fluxSummary/fluxSummary.C index 3b365baa85..529c2d48d0 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.C +++ b/src/functionObjects/field/fluxSummary/fluxSummary.C @@ -448,8 +448,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection if (((own != -1) && (nbr == -1)) || ((own == -1) && (nbr != -1))) { - vector n = mesh_.faces()[facei].normal(mesh_.points()); - n /= mag(n) + ROOTVSMALL; + vector n = mesh_.faces()[facei].unitNormal(mesh_.points()); if ((n & refDir) > tolerance_) { @@ -481,8 +480,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection if ((own != -1) && (nbr == -1)) { - vector n = mesh_.faces()[facei].normal(mesh_.points()); - n /= mag(n) + ROOTVSMALL; + vector n = mesh_.faces()[facei].unitNormal(mesh_.points()); if ((n & refDir) > tolerance_) { @@ -835,7 +833,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) { case mdFaceZone: { - List zones(dict.lookup("faceZones")); + wordList zones(dict.get("faceZones")); forAll(zones, i) { @@ -853,8 +851,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) } case mdFaceZoneAndDirection: { - List> - zoneAndDirection(dict.lookup("faceZoneAndDirection")); + List> zoneAndDirection; + dict.readEntry("faceZoneAndDirection", zoneAndDirection); forAll(zoneAndDirection, i) { @@ -873,8 +871,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) } case mdCellZoneAndDirection: { - List> - zoneAndDirection(dict.lookup("cellZoneAndDirection")); + List> zoneAndDirection; + dict.readEntry("cellZoneAndDirection", zoneAndDirection); forAll(zoneAndDirection, i) { @@ -893,7 +891,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) } case mdSurface: { - List surfs(dict.lookup("surfaces")); + wordList surfs(dict.get("surfaces")); forAll(surfs, i) { @@ -909,8 +907,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) } case mdSurfaceAndDirection: { - List> - surfAndDirection(dict.lookup("surfaceAndDirection")); + List> surfAndDirection; + dict.readEntry("surfaceAndDirection", surfAndDirection); forAll(surfAndDirection, i) { diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C index b01313428b..a7df02d563 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C @@ -164,12 +164,8 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cf() const const volVectorField& U = mesh_.lookupObject(UName_); const volVectorField::Boundary& Ubf = U.boundaryField(); - tmp> tCf - ( - new FieldField(Ubf.size()) - ); - - FieldField& Cf = tCf.ref(); + auto tCf = tmp>::New(Ubf.size()); + auto& Cf = tCf.ref(); forAll(Cf, patchi) { @@ -179,7 +175,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cf() const const volSymmTensorField R(devReff()); const volSymmTensorField::Boundary& Rbf = R.boundaryField(); - for (label patchi : patchSet_) + for (const label patchi : patchSet_) { const fvPatchVectorField& Up = Ubf[patchi]; @@ -226,18 +222,18 @@ bool Foam::heatTransferCoeffModels::ReynoldsAnalogy::read { if (heatTransferCoeffModel::read(dict)) { - dict.lookup("UInf") >> URef_; + dict.readEntry("UInf", URef_); dict.readIfPresent("Cp", CpName_); if (CpName_ == "CpInf") { - dict.lookup("CpInf") >> CpRef_; + dict.readEntry("CpInf", CpRef_); } dict.readIfPresent("rho", rhoName_); if (rhoName_ == "rhoInf") { - dict.lookup("rhoInf") >> rhoRef_; + dict.readEntry("rhoInf", rhoRef_); } return true; @@ -253,9 +249,9 @@ void Foam::heatTransferCoeffModels::ReynoldsAnalogy::htc(volScalarField& htc) const scalar magU = mag(URef_); volScalarField::Boundary& htcBf = htc.boundaryFieldRef(); - forAllConstIters(patchSet_, iter) + + for (const label patchi : patchSet_) { - label patchi = iter.key(); const scalarField rhop(rho(patchi)); const scalarField Cpp(Cp(patchi)); diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/fixedReferenceTemperature/fixedReferenceTemperature.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/fixedReferenceTemperature/fixedReferenceTemperature.C index 5a37291e2d..c5ca71ef20 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/fixedReferenceTemperature/fixedReferenceTemperature.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/fixedReferenceTemperature/fixedReferenceTemperature.C @@ -68,7 +68,7 @@ bool Foam::heatTransferCoeffModels::fixedReferenceTemperature::read { if (heatTransferCoeffModel::read(dict)) { - dict.lookup("TRef") >> TRef_; + dict.readEntry("TRef", TRef_); return true; } diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModel.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModel.C index e6bcba2a3f..78f9875b8c 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModel.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModel.C @@ -46,16 +46,12 @@ Foam::heatTransferCoeffModel::q() const const volScalarField& T = mesh_.lookupObject(TName_); const volScalarField::Boundary& Tbf = T.boundaryField(); - tmp> tq - ( - new FieldField(Tbf.size()) - ); - - FieldField& q = tq.ref(); + auto tq = tmp>::New(Tbf.size()); + auto& q = tq.ref(); forAll(q, patchi) { - q.set(patchi, new Field(Tbf[patchi].size(), 0)); + q.set(patchi, new Field(Tbf[patchi].size(), Zero)); } typedef compressible::turbulenceModel cmpTurbModel; @@ -71,7 +67,7 @@ Foam::heatTransferCoeffModel::q() const const volScalarField alphaEff(turb.alphaEff()); const volScalarField::Boundary& alphaEffbf = alphaEff.boundaryField(); - for (label patchi : patchSet_) + for (const label patchi : patchSet_) { q[patchi] = alphaEffbf[patchi]*hebf[patchi].snGrad(); } @@ -105,7 +101,7 @@ Foam::heatTransferCoeffModel::q() const const volScalarField& qr = mesh_.lookupObject(qrName_); const volScalarField::Boundary& qrbf = qr.boundaryField(); - for (label patchi : patchSet_) + for (const label patchi : patchSet_) { q[patchi] += qrbf[patchi]; } @@ -135,8 +131,7 @@ Foam::heatTransferCoeffModel::heatTransferCoeffModel bool Foam::heatTransferCoeffModel::read(const dictionary& dict) { - patchSet_ = - mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches"))); + patchSet_ = mesh_.boundaryMesh().patchSet(dict.get("patches")); dict.readIfPresent("qr", qrName_); diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModelNew.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModelNew.C index aef48b1f9d..9cf1923c7c 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModelNew.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModelNew.C @@ -36,7 +36,7 @@ Foam::autoPtr Foam::heatTransferCoeffModel::New const word& TName ) { - const word modelType(dict.lookup("htcModel")); + const word modelType(dict.get("htcModel")); Info<< "Selecting heat transfer coefficient model " << modelType << endl; diff --git a/src/functionObjects/field/histogram/histogram.C b/src/functionObjects/field/histogram/histogram.C index 39c2649fab..1f2ad880b3 100644 --- a/src/functionObjects/field/histogram/histogram.C +++ b/src/functionObjects/field/histogram/histogram.C @@ -105,13 +105,13 @@ bool Foam::functionObjects::histogram::read(const dictionary& dict) fvMeshFunctionObject::read(dict); writeFile::read(dict); - dict.lookup("field") >> fieldName_; + dict.readEntry("field", fieldName_); max_ = dict.lookupOrDefault("max", -GREAT); min_ = dict.lookupOrDefault("min", GREAT); - dict.lookup("nBins") >> nBins_; + dict.readEntry("nBins", nBins_); - word format(dict.lookup("setFormat")); + const word format(dict.get("setFormat")); formatterPtr_ = writer::New(format); return true; diff --git a/src/functionObjects/field/mapFields/mapFields.C b/src/functionObjects/field/mapFields/mapFields.C index 78f6bd13f0..656274f73c 100644 --- a/src/functionObjects/field/mapFields/mapFields.C +++ b/src/functionObjects/field/mapFields/mapFields.C @@ -53,7 +53,7 @@ void Foam::functionObjects::mapFields::createInterpolation ) { const fvMesh& meshTarget = mesh_; - const word mapRegionName(dict.lookup("mapRegion")); + const word mapRegionName(dict.get("mapRegion")); Info<< name() << ':' << nl << " Reading mesh " << mapRegionName << endl; @@ -71,7 +71,7 @@ void Foam::functionObjects::mapFields::createInterpolation ) ); const fvMesh& mapRegion = mapRegionPtr_(); - const word mapMethodName(dict.lookup("mapMethod")); + const word mapMethodName(dict.get("mapMethod")); if (!meshToMesh::interpolationMethodNames_.found(mapMethodName)) { FatalErrorInFunction @@ -100,11 +100,9 @@ void Foam::functionObjects::mapFields::createInterpolation Info<< " Patch mapping method: " << patchMapMethodName << endl; } - bool consistent = readBool(dict.lookup("consistent")); - Info<< " Creating mesh to mesh interpolation" << endl; - if (consistent) + if (dict.get("consistent")) { interpPtr_.reset ( @@ -119,8 +117,11 @@ void Foam::functionObjects::mapFields::createInterpolation } else { - HashTable patchMap(dict.lookup("patchMap")); - wordList cuttingPatches(dict.lookup("cuttingPatches")); + HashTable patchMap; + wordList cuttingPatches; + + dict.readEntry("patchMap", patchMap); + dict.readEntry("cuttingPatches", cuttingPatches); interpPtr_.reset ( @@ -162,7 +163,7 @@ bool Foam::functionObjects::mapFields::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - dict.lookup("fields") >> fieldNames_; + dict.readEntry("fields", fieldNames_); createInterpolation(dict); return true; } diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index db0e706b5d..b40a6355b3 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -260,10 +260,9 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - dict.lookup("fields") >> fieldSet_; - patchSet_ = - mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches"))); - distance_ = readScalar(dict.lookup("distance")); + dict.readEntry("fields", fieldSet_); + patchSet_ = mesh_.boundaryMesh().patchSet(dict.get("patches")); + distance_ = dict.get("distance"); // Clear out any previously loaded fields diff --git a/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C b/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C index d16f19232d..b72e13a2aa 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C +++ b/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C @@ -37,9 +37,9 @@ void Foam::functionObjects::nearWallFields::createFields HashTable flds(obr_.lookupClass()); - forAllConstIter(typename HashTable, flds, iter) + forAllConstIters(flds, iter) { - const VolFieldType& fld = *iter(); + const VolFieldType& fld = *(iter.object()); if (fieldMap_.found(fld.name())) { diff --git a/src/functionObjects/field/particleDistribution/particleDistribution.C b/src/functionObjects/field/particleDistribution/particleDistribution.C index 832616f8d1..df52bda1d1 100644 --- a/src/functionObjects/field/particleDistribution/particleDistribution.C +++ b/src/functionObjects/field/particleDistribution/particleDistribution.C @@ -80,10 +80,10 @@ bool Foam::functionObjects::particleDistribution::read(const dictionary& dict) { if (fvMeshFunctionObject::read(dict) && writeFile::read(dict)) { - dict.lookup("cloud") >> cloudName_; - dict.lookup("nameVsBinWidth") >> nameVsBinWidth_; + dict.readEntry("cloud", cloudName_); + dict.readEntry("nameVsBinWidth", nameVsBinWidth_); dict.readIfPresent("tagField", tagFieldName_); - word format(dict.lookup("setFormat")); + const word format(dict.get("setFormat")); writerPtr_ = writer::New(format); Info<< type() << " " << name() << " output:" << nl diff --git a/src/functionObjects/field/pressure/pressure.C b/src/functionObjects/field/pressure/pressure.C index 3699e78dcc..9d6d91d375 100644 --- a/src/functionObjects/field/pressure/pressure.C +++ b/src/functionObjects/field/pressure/pressure.C @@ -70,22 +70,19 @@ Foam::tmp Foam::functionObjects::pressure::rhoScale { if (p.dimensions() == dimPressure) { - return tmp + return tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "rhoScale", - p.mesh().time().timeName(), - p.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - p, - fvPatchField::calculatedType() - ) + "rhoScale", + p.mesh().time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + p, + fvPatchField::calculatedType() ); } else @@ -115,10 +112,8 @@ Foam::tmp Foam::functionObjects::pressure::rhoScale { return lookupObject(rhoName_)*tsf; } - else - { - return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*tsf; - } + + return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*tsf; } @@ -192,28 +187,23 @@ bool Foam::functionObjects::pressure::calc() { const volScalarField& p = lookupObject(fieldName_); - tmp tp + auto tp = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - resultName_, - p.mesh().time().timeName(), - p.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - coeff(pRef(pDyn(p, rhoScale(p)))) - ) + resultName_, + p.mesh().time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + coeff(pRef(pDyn(p, rhoScale(p)))) ); return store(resultName_, tp); } - else - { - return false; - } + + return false; } @@ -265,22 +255,22 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict) if (rhoName_ == "rhoInf") { - dict.lookup("rhoInf") >> rhoInf_; + dict.readEntry("rhoInf", rhoInf_); rhoInfInitialised_ = true; } - dict.lookup("calcTotal") >> calcTotal_; + dict.readEntry("calcTotal", calcTotal_); if (calcTotal_) { pRef_ = dict.lookupOrDefault("pRef", 0.0); } - dict.lookup("calcCoeff") >> calcCoeff_; + dict.readEntry("calcCoeff", calcCoeff_); if (calcCoeff_) { - dict.lookup("pInf") >> pInf_; - dict.lookup("UInf") >> UInf_; - dict.lookup("rhoInf") >> rhoInf_; + dict.readEntry("pInf", pInf_); + dict.readEntry("UInf", UInf_); + dict.readEntry("rhoInf", rhoInf_); scalar zeroCheck = 0.5*rhoInf_*magSqr(UInf_) + pInf_; diff --git a/src/functionObjects/field/processorField/processorField.C b/src/functionObjects/field/processorField/processorField.C index e10b70cd4c..3711b65aba 100644 --- a/src/functionObjects/field/processorField/processorField.C +++ b/src/functionObjects/field/processorField/processorField.C @@ -91,10 +91,10 @@ bool Foam::functionObjects::processorField::read(const dictionary& dict) bool Foam::functionObjects::processorField::execute() { - const volScalarField& procField = - mesh_.lookupObject("processorID"); + volScalarField& procField = + mesh_.lookupObjectRef("processorID"); - const_cast(procField) == + procField == dimensionedScalar("proci", dimless, Pstream::myProcNo()); return true; diff --git a/src/functionObjects/field/randomise/randomise.C b/src/functionObjects/field/randomise/randomise.C index 09e3ef5791..a38748d40f 100644 --- a/src/functionObjects/field/randomise/randomise.C +++ b/src/functionObjects/field/randomise/randomise.C @@ -81,7 +81,7 @@ bool Foam::functionObjects::randomise::read(const dictionary& dict) { fieldExpression::read(dict); - dict.lookup("magPerturbation") >> magPerturbation_; + dict.readEntry("magPerturbation", magPerturbation_); return true; } diff --git a/src/functionObjects/field/randomise/randomiseTemplates.C b/src/functionObjects/field/randomise/randomiseTemplates.C index f0c691eb39..c0f1bbf714 100644 --- a/src/functionObjects/field/randomise/randomiseTemplates.C +++ b/src/functionObjects/field/randomise/randomiseTemplates.C @@ -39,26 +39,25 @@ bool Foam::functionObjects::randomise::calcRandomised() resultName_ = fieldName_ & "Random"; - tmp rfieldt(new VolFieldType(field)); - VolFieldType& rfield = rfieldt.ref(); + auto trfield = tmp::New(field); + auto& rfield = trfield.ref(); Random rand(1234567); - forAll(field, celli) + for (Type& cellval : rfield) { Type rndPert; rand.randomise01(rndPert); rndPert = 2.0*rndPert - pTraits::one; rndPert /= mag(rndPert); - rfield[celli] += magPerturbation_*rndPert; + + cellval += magPerturbation_*rndPert; } - return store(resultName_, rfieldt); - } - else - { - return false; + return store(resultName_, trfield); } + + return false; } diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index 47f4cf6a11..b40b244ced 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -78,24 +78,20 @@ calculateSpeciesRR const basicChemistryModel& basicChemistry ) { - tmp> RRt + auto RRt = tmp>::New ( - new DimensionedField + IOobject ( - IOobject - ( - "RR", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "RR", + time_.timeName(), mesh_, - dimensionedScalar(dimMass/dimVolume/dimTime, Zero) - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); - - DimensionedField& RR = RRt.ref(); + auto& RR = RRt.ref(); scalar dt = time_.deltaT().value(); diff --git a/src/functionObjects/field/readFields/readFields.C b/src/functionObjects/field/readFields/readFields.C index 04fb569728..b33931977f 100644 --- a/src/functionObjects/field/readFields/readFields.C +++ b/src/functionObjects/field/readFields/readFields.C @@ -74,7 +74,7 @@ bool Foam::functionObjects::readFields::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - dict.lookup("fields") >> fieldSet_; + dict.readEntry("fields", fieldSet_); dict.readIfPresent("readOnStart", readOnStart_); return true; diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index a75a4e1bd6..98aa128897 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -209,8 +209,8 @@ Foam::functionObjects::regionSizeDistribution::divide const scalarField& denom ) { - tmp tresult(new scalarField(num.size())); - scalarField& result = tresult.ref(); + auto tresult = tmp::New(num.size()); + auto& result = tresult.ref(); forAll(denom, i) { @@ -317,8 +317,8 @@ Foam::functionObjects::regionSizeDistribution::regionSizeDistribution : fvMeshFunctionObject(name, runTime, dict), writeFile(obr_, name), - alphaName_(dict.lookup("field")), - patchNames_(dict.lookup("patches")), + alphaName_(dict.get("field")), + patchNames_(dict.get("patches")), isoPlanes_(dict.lookupOrDefault("isoPlanes", false)) { read(dict); @@ -338,16 +338,16 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) fvMeshFunctionObject::read(dict); writeFile::read(dict); - dict.lookup("field") >> alphaName_; - dict.lookup("patches") >> patchNames_; - dict.lookup("threshold") >> threshold_; - dict.lookup("maxDiameter") >> maxDiam_; + dict.readEntry("field", alphaName_); + dict.readEntry("patches", patchNames_); + dict.readEntry("threshold", threshold_); + dict.readEntry("maxDiameter", maxDiam_); minDiam_ = 0.0; dict.readIfPresent("minDiameter", minDiam_); - dict.lookup("nBins") >> nBins_; - dict.lookup("fields") >> fields_; + dict.readEntry("nBins", nBins_); + dict.readEntry("fields", fields_); - word format(dict.lookup("setFormat")); + const word format(dict.get("setFormat")); formatterPtr_ = writer::New(format); if (dict.found("coordinateSystem")) @@ -360,12 +360,12 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) if (isoPlanes_) { - dict.lookup("origin") >> origin_; - dict.lookup("direction") >> direction_; - dict.lookup("maxDiameter") >> maxDiameter_; - dict.lookup("nDownstreamBins") >> nDownstreamBins_; - dict.lookup("maxDownstream") >> maxDownstream_; - direction_ /= mag(direction_); + dict.readEntry("origin", origin_); + dict.readEntry("direction", direction_); + dict.readEntry("maxDiameter", maxDiameter_); + dict.readEntry("nDownstreamBins", nDownstreamBins_); + dict.readEntry("maxDownstream", maxDownstream_); + direction_.normalise(); } return true; @@ -458,6 +458,7 @@ bool Foam::functionObjects::regionSizeDistribution::write() { tmp townFld(fvp.patchInternalField()); const scalarField& ownFld = townFld(); + tmp tnbrFld(fvp.patchNeighbourField()); const scalarField& nbrFld = tnbrFld(); diff --git a/src/functionObjects/field/setFlow/setFlow.C b/src/functionObjects/field/setFlow/setFlow.C index 7d3353ab64..329e2e6b5d 100644 --- a/src/functionObjects/field/setFlow/setFlow.C +++ b/src/functionObjects/field/setFlow/setFlow.C @@ -137,7 +137,7 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict) if (fvMeshFunctionObject::read(dict)) { Info<< name() << ":" << endl; - mode_ = modeTypeNames.read(dict.lookup("mode")); + mode_ = modeTypeNames.lookup("mode", dict); Info<< " operating mode: " << modeTypeNames[mode_] << endl; @@ -176,22 +176,21 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict) case modeType::ROTATION: { omegaPtr_ = Function1::New("omega", dict); - dict.lookup("origin") >> origin_; - vector refDir(dict.lookup("refDir")); - refDir /= mag(refDir) + ROOTVSMALL; - vector axis(dict.lookup("axis")); - axis /= mag(axis) + ROOTVSMALL; + + dict.readEntry("origin", origin_); + const vector refDir(dict.get("refDir").normalise()); + const vector axis(dict.get("axis").normalise()); + R_ = tensor(refDir, axis, refDir^axis); break; } case modeType::VORTEX2D: case modeType::VORTEX3D: { - dict.lookup("origin") >> origin_; - vector refDir(dict.lookup("refDir")); - refDir /= mag(refDir) + ROOTVSMALL; - vector axis(dict.lookup("axis")); - axis /= mag(axis) + ROOTVSMALL; + dict.readEntry("origin", origin_); + const vector refDir(dict.get("refDir").normalise()); + const vector axis(dict.get("axis").normalise()); + R_ = tensor(refDir, axis, refDir^axis); break; } diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index c73c90afe1..4e6045f8c1 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -279,23 +279,21 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) << exit(FatalError); } - tmp magGradCCPtr + auto tmagGradCC = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "magGradCC", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "magGradCC", + time_.timeName(), mesh_, - dimensionedScalar(dimless, Zero), - zeroGradientFvPatchScalarField::typeName - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimless, Zero), + zeroGradientFvPatchScalarField::typeName ); + auto& magGradCC = tmagGradCC.ref(); for (direction i=0; i CoPtr + auto CoPtr = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "Co", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Co", + time_.timeName(), mesh_, - dimensionedScalar(dimless, Zero), - zeroGradientFvPatchScalarField::typeName - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimless, Zero), + zeroGradientFvPatchScalarField::typeName ); - volScalarField& Co = CoPtr.ref(); + auto& Co = CoPtr.ref(); Co.primitiveFieldRef() = mesh_.time().deltaT()*mag(*UNamePtr)/pow(mesh_.V(), 1.0/3.0); @@ -417,12 +412,10 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) indicator_.max(0.0); // Update the blended surface field - surfaceScalarField* surBlendedPtr = - ( - mesh_.lookupObjectRefPtr(resultName_) - ); + surfaceScalarField& surBlended = + mesh_.lookupObjectRef(resultName_); - *surBlendedPtr = fvc::interpolate(indicator_); + surBlended = fvc::interpolate(indicator_); return true; } @@ -511,21 +504,18 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor read(dict); setResultName(typeName, ""); - tmp faceBlendedPtr + auto faceBlendedPtr = tmp::New ( - new surfaceScalarField + IOobject ( - IOobject - ( - resultName_, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + resultName_, + time_.timeName(), mesh_, - dimensionedScalar(dimless, Zero) - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar(dimless, Zero) ); store(resultName_, faceBlendedPtr); @@ -653,12 +643,12 @@ bool Foam::functionObjects::stabilityBlendingFactor::read { if (fieldExpression::read(dict) && writeFile::read(dict)) { - dict.lookup("switchNonOrtho") >> nonOrthogonality_; - dict.lookup("switchGradCc") >> gradCc_; - dict.lookup("switchResiduals") >> residuals_; - dict.lookup("switchFaceWeight") >> faceWeight_; - dict.lookup("switchSkewness") >> skewness_; - dict.lookup("switchCo") >> Co_; + dict.readEntry("switchNonOrtho", nonOrthogonality_); + dict.readEntry("switchGradCc", gradCc_); + dict.readEntry("switchResiduals", residuals_); + dict.readEntry("switchFaceWeight", faceWeight_); + dict.readEntry("switchSkewness", skewness_); + dict.readEntry("switchCo", Co_); dict.readIfPresent("maxNonOrthogonality", maxNonOrthogonality_); dict.readIfPresent("maxGradCc", maxGradCc_); diff --git a/src/functionObjects/field/streamFunction/streamFunction.C b/src/functionObjects/field/streamFunction/streamFunction.C index 0838a07ecf..da488756c2 100644 --- a/src/functionObjects/field/streamFunction/streamFunction.C +++ b/src/functionObjects/field/streamFunction/streamFunction.C @@ -71,27 +71,21 @@ Foam::tmp Foam::functionObjects::streamFunction::calc const pointMesh& pMesh = pointMesh::New(mesh_); - tmp tstreamFunction + auto tstreamFunction = tmp::New ( - new pointScalarField + IOobject ( - IOobject - ( - "streamFunction", - time_.timeName(), - mesh_ - ), - pMesh, - dimensionedScalar(phi.dimensions(), Zero) - ) + "streamFunction", + time_.timeName(), + mesh_ + ), + pMesh, + dimensionedScalar(phi.dimensions(), Zero) ); pointScalarField& streamFunction = tstreamFunction.ref(); - labelList visitedPoint(mesh_.nPoints()); - forAll(visitedPoint, pointi) - { - visitedPoint[pointi] = 0; - } + labelList visitedPoint(mesh_.nPoints(), Zero); + label nVisited = 0; label nVisitedOld = 0; @@ -263,7 +257,7 @@ Foam::tmp Foam::functionObjects::streamFunction::calc points[curBPoints[pointi]] - currentBStreamPoint; edgeHat.replace(slabDir, 0); - edgeHat /= mag(edgeHat); + edgeHat.normalise(); vector nHat = unitAreas[facei]; @@ -356,7 +350,7 @@ Foam::tmp Foam::functionObjects::streamFunction::calc points[curPoints[pointi]] - currentStreamPoint; edgeHat.replace(slabDir, 0); - edgeHat /= mag(edgeHat); + edgeHat.normalise(); vector nHat = unitAreas[facei]; diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 8b9728b8ba..86d26c54ec 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -865,7 +865,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) if (fields_.empty()) { - dict.lookup("fields") >> fields_; + dict.readEntry("fields", fields_); if (!fields_.found(UName_)) { @@ -878,8 +878,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) Info<< " Employing velocity field " << UName_ << endl; - dict.lookup("trackForward") >> trackForward_; - dict.lookup("lifeTime") >> lifeTime_; + dict.readEntry("trackForward", trackForward_); + dict.readEntry("lifeTime", lifeTime_); if (lifeTime_ < 1) { FatalErrorInFunction @@ -916,8 +916,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) sampledSetPtr_.clear(); sampledSetAxis_.clear(); - scalarFormatterPtr_ = writer::New(dict.lookup("setFormat")); - vectorFormatterPtr_ = writer::New(dict.lookup("setFormat")); + scalarFormatterPtr_ = writer::New(dict.get("setFormat")); + vectorFormatterPtr_ = writer::New(dict.get("setFormat")); return true; } diff --git a/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C b/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C index d81a37ef66..513cce3118 100644 --- a/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C +++ b/src/functionObjects/field/surfaceInterpolate/surfaceInterpolate.C @@ -76,7 +76,7 @@ bool Foam::functionObjects::surfaceInterpolate::read { fvMeshFunctionObject::read(dict); - dict.lookup("fields") >> fieldSet_; + dict.readEntry("fields", fieldSet_); return true; } diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index f4d4a53f6b..559237b84a 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -144,11 +144,11 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict) if (dict.found("field")) { - fieldSet_.insert(word(dict.lookup("field"))); + fieldSet_.insert(dict.get("field")); } else { - fieldSet_.insert(wordList(dict.lookup("fields"))); + fieldSet_.insert(dict.get("fields")); } Info<< type() << " " << name() << ": "; diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index 4ded70c6be..98613fbc28 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -40,8 +40,7 @@ void Foam::functionObjects::turbulenceFields::processField if (obr_.foundObject(scopedName)) { - FieldType& fld = - const_cast(obr_.lookupObject(scopedName)); + FieldType& fld = obr_.lookupObjectRef(scopedName); fld == tvalue(); } else if (obr_.found(scopedName)) diff --git a/src/functionObjects/field/valueAverage/valueAverage.C b/src/functionObjects/field/valueAverage/valueAverage.C index 3e74e5f4b6..3b34734e97 100644 --- a/src/functionObjects/field/valueAverage/valueAverage.C +++ b/src/functionObjects/field/valueAverage/valueAverage.C @@ -87,7 +87,7 @@ Foam::functionObjects::valueAverage::valueAverage if (dict.found(fieldName)) { const dictionary& valueDict = dict.subDict(fieldName); - totalTime_[fieldi] = readScalar(valueDict.lookup("totalTime")); + totalTime_[fieldi] = valueDict.get("totalTime"); } } } @@ -112,8 +112,8 @@ bool Foam::functionObjects::valueAverage::read(const dictionary& dict) // Make certain that the values are consistent with the defaults: resetOnRestart_ = false; - dict.lookup("functionObject") >> functionObjectName_; - dict.lookup("fields") >> fieldNames_; + dict.readEntry("functionObject", functionObjectName_); + dict.readEntry("fields", fieldNames_); if (dict.readIfPresent("window", window_)) { window_ = obr().time().userTimeToTime(window_); diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C index 89fc0d8b22..d9afcabb48 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C @@ -316,8 +316,7 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri // Outwards pointing normal vector edgeNormal = (pt1 - pt0)^n; - - edgeNormal /= mag(edgeNormal) + VSMALL; + edgeNormal.normalise(); // Determine whether position and end point on either side of edge. scalar sEnd = (endPosition - pt0)&edgeNormal; diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C index 23f0a6044c..41b6eb06bf 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C @@ -166,8 +166,7 @@ Foam::scalar Foam::wallBoundedParticle::trackToEdge } const triFace tri(currentTetIndices().faceTriIs(mesh(), false)); - vector n = tri.normal(mesh().points()); - n /= mag(n); + const vector n = tri.unitNormal(mesh().points()); point projectedEndPosition = endPosition; diff --git a/src/functionObjects/field/yPlus/yPlus.C b/src/functionObjects/field/yPlus/yPlus.C index 72740eb4ca..243c766ad1 100644 --- a/src/functionObjects/field/yPlus/yPlus.C +++ b/src/functionObjects/field/yPlus/yPlus.C @@ -120,10 +120,7 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict) bool Foam::functionObjects::yPlus::execute() { volScalarField& yPlus = - const_cast - ( - lookupObject(typeName) - ); + lookupObjectRef(typeName); if (foundObject(turbulenceModel::propertiesName)) { diff --git a/src/functionObjects/field/zeroGradient/zeroGradient.C b/src/functionObjects/field/zeroGradient/zeroGradient.C index 5bf899f84c..1575a9be39 100644 --- a/src/functionObjects/field/zeroGradient/zeroGradient.C +++ b/src/functionObjects/field/zeroGradient/zeroGradient.C @@ -112,7 +112,7 @@ bool Foam::functionObjects::zeroGradient::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - dict.lookup("fields") >> selectFields_; + dict.readEntry("fields", selectFields_); selectFields_.uniq(); Info<< type() << " fields: " << selectFields_ << nl; diff --git a/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C b/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C index 3f8074ab5a..a81532358b 100644 --- a/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C +++ b/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C @@ -83,29 +83,25 @@ int Foam::functionObjects::zeroGradient::apply if (!foundObject(outputName)) { - tmp tzg + auto tzeroGrad = tmp::New ( - new VolFieldType + IOobject ( - IOobject - ( - outputName, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + outputName, + time_.timeName(), mesh_, - dimensioned(input.dimensions(), Zero), - zeroGradientFvPatchField::typeName - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensioned(input.dimensions(), Zero), + zeroGradientFvPatchField::typeName ); - store(outputName, tzg); + store(outputName, tzeroGrad); } - VolFieldType& output = - const_cast(lookupObject(outputName)); + VolFieldType& output = lookupObjectRef(outputName); output = input; output.correctBoundaryConditions(); diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index 39852bcc24..b1b8a54737 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -243,24 +243,24 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict) forces::read(dict); // Directions for lift and drag forces, and pitch moment - dict.lookup("liftDir") >> liftDir_; - dict.lookup("dragDir") >> dragDir_; - dict.lookup("pitchAxis") >> pitchAxis_; + dict.readEntry("liftDir", liftDir_); + dict.readEntry("dragDir", dragDir_); + dict.readEntry("pitchAxis", pitchAxis_); // Free stream velocity magnitude - dict.lookup("magUInf") >> magUInf_; + dict.readEntry("magUInf", magUInf_); // If case is compressible we must read rhoInf (store in rhoRef_) to // calculate the reference dynamic pressure // - note: for incompressible, rhoRef_ is already initialised if (rhoName_ != "rhoInf") { - dict.lookup("rhoInf") >> rhoRef_; + dict.readEntry("rhoInf", rhoRef_); } // Reference length and area scales - dict.lookup("lRef") >> lRef_; - dict.lookup("Aref") >> Aref_; + dict.readEntry("lRef", lRef_); + dict.readEntry("Aref", Aref_); if (writeFields_) { @@ -402,16 +402,10 @@ bool Foam::functionObjects::forceCoeffs::execute() lookupObject(fieldName("moment")); volVectorField& forceCoeff = - const_cast - ( - lookupObject(fieldName("forceCoeff")) - ); + lookupObjectRef(fieldName("forceCoeff")); volVectorField& momentCoeff = - const_cast - ( - lookupObject(fieldName("momentCoeff")) - ); + lookupObjectRef(fieldName("momentCoeff")); dimensionedScalar f0("f0", dimForce, Aref_*pDyn); dimensionedScalar m0("m0", dimForce*dimLength, Aref_*lRef_*pDyn); diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 681ac2b251..cc166499ea 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -292,18 +292,12 @@ void Foam::functionObjects::forces::resetFields() if (writeFields_) { volVectorField& force = - const_cast - ( - lookupObject(fieldName("force")) - ); + lookupObjectRef(fieldName("force")); force == dimensionedVector(force.dimensions(), Zero); volVectorField& moment = - const_cast - ( - lookupObject(fieldName("moment")) - ); + lookupObjectRef(fieldName("moment")); moment == dimensionedVector(moment.dimensions(), Zero); } @@ -415,25 +409,20 @@ Foam::tmp Foam::functionObjects::forces::rho() const { if (rhoName_ == "rhoInf") { - return tmp + return tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "rho", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar("rho", dimDensity, rhoRef_) - ) + "rho", + mesh_.time().timeName(), + mesh_ + ), + mesh_, + dimensionedScalar("rho", dimDensity, rhoRef_) ); } - else - { - return(lookupObject(rhoName_)); - } + + return(lookupObject(rhoName_)); } @@ -443,17 +432,15 @@ Foam::scalar Foam::functionObjects::forces::rho(const volScalarField& p) const { return 1.0; } - else - { - if (rhoName_ != "rhoInf") - { - FatalErrorInFunction - << "Dynamic pressure is expected but kinematic is provided." - << exit(FatalError); - } - return rhoRef_; + if (rhoName_ != "rhoInf") + { + FatalErrorInFunction + << "Dynamic pressure is expected but kinematic is provided." + << exit(FatalError); } + + return rhoRef_; } @@ -509,19 +496,13 @@ void Foam::functionObjects::forces::addToFields } volVectorField& force = - const_cast - ( - lookupObject(fieldName("force")) - ); + lookupObjectRef(fieldName("force")); vectorField& pf = force.boundaryFieldRef()[patchi]; pf += fN + fT + fP; volVectorField& moment = - const_cast - ( - lookupObject(fieldName("moment")) - ); + lookupObjectRef(fieldName("moment")); vectorField& pm = moment.boundaryFieldRef()[patchi]; pm += Md; @@ -543,16 +524,10 @@ void Foam::functionObjects::forces::addToFields } volVectorField& force = - const_cast - ( - lookupObject(fieldName("force")) - ); + lookupObjectRef(fieldName("force")); volVectorField& moment = - const_cast - ( - lookupObject(fieldName("moment")) - ); + lookupObjectRef(fieldName("moment")); forAll(cellIDs, i) { @@ -851,7 +826,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); - patchSet_ = pbm.patchSet(wordReList(dict.lookup("patches"))); + patchSet_ = pbm.patchSet(dict.get("patches")); if (directForceDensity_) { @@ -868,7 +843,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) // Reference density needed for incompressible calculations if (rhoName_ == "rhoInf") { - dict.lookup("rhoInf") >> rhoRef_; + dict.readEntry("rhoInf", rhoRef_); } // Reference pressure, 0 by default @@ -899,7 +874,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) if (dict.found("binData")) { const dictionary& binDict(dict.subDict("binData")); - binDict.lookup("nBin") >> nBin_; + binDict.readEntry("nBin", nBin_); if (nBin_ < 0) { @@ -914,9 +889,9 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) } else { - binDict.lookup("cumulative") >> binCumulative_; - binDict.lookup("direction") >> binDir_; - binDir_ /= mag(binDir_); + binDict.readEntry("cumulative", binCumulative_); + binDict.readEntry("direction", binDir_); + binDir_.normalise(); } } @@ -1062,7 +1037,7 @@ void Foam::functionObjects::forces::calcForcesMoment() << endl; } - forAllConstIter(HashTable, models, iter) + forAllConstIters(models, iter) { // Non-const access required if mesh is changing porosityModel& pm = const_cast(*iter()); diff --git a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C index 78fd350a4f..a7e6ba9db3 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C @@ -484,7 +484,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase ) : colours_(colours), - fieldName_(dict.lookup("field")), + fieldName_(dict.get("field")), colourBy_(cbColour), colourMap_(cmRainbow), range_() @@ -500,7 +500,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase } case cbField: { - dict.lookup("range") >> range_; + dict.readEntry("range", range_); if (dict.found("colourMap")) { @@ -508,15 +508,15 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase } const dictionary& sbarDict = dict.subDict("scalarBar"); - sbarDict.lookup("visible") >> scalarBar_.visible_; + sbarDict.readEntry("visible", scalarBar_.visible_); if (scalarBar_.visible_) { - sbarDict.lookup("vertical") >> scalarBar_.vertical_; - sbarDict.lookup("position") >> scalarBar_.position_; - sbarDict.lookup("title") >> scalarBar_.title_; - sbarDict.lookup("fontSize") >> scalarBar_.fontSize_; - sbarDict.lookup("labelFormat") >> scalarBar_.labelFormat_; - sbarDict.lookup("numberOfLabels") >> scalarBar_.numberOfLabels_; + sbarDict.readEntry("vertical", scalarBar_.vertical_); + sbarDict.readEntry("position", scalarBar_.position_); + sbarDict.readEntry("title", scalarBar_.title_); + sbarDict.readEntry("fontSize", scalarBar_.fontSize_); + sbarDict.readEntry("labelFormat", scalarBar_.labelFormat_); + sbarDict.readEntry("numberOfLabels", scalarBar_.numberOfLabels_); } break; } diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C index 5ca9cac31d..004b391442 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C @@ -86,7 +86,7 @@ Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase : fieldVisualisationBase(dict, colours), state_(state), - functionObjectName_(dict.lookup("functionObject")), + functionObjectName_(dict.get("functionObject")), clearObjects_(dict.lookupOrDefault("clearObjects", false)) {} diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C index c8786cf1fc..74df866dff 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C @@ -65,9 +65,9 @@ Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud : pointData(parent, dict, colours), functionObjectBase(parent, dict, colours), - cloudName_(dict.lookup("cloud")), + cloudName_(dict.get("cloud")), inputFileName_(), - colourFieldName_(dict.lookup("colourField")), + colourFieldName_(dict.get("colourField")), actor_() { actor_ = vtkSmartPointer::New(); diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C index 2bc15a840d..2be283ba58 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C @@ -86,7 +86,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase : parent_(parent), name_(dict.dictName()), - visible_(readBool(dict.lookup("visible"))), + visible_(dict.get("visible")), renderMode_(rmGouraud), opacity_(nullptr), colours_(colours) diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C b/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C index 8c890980dc..06cb8123bf 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C +++ b/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C @@ -140,8 +140,10 @@ Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface ) : surface(parent, dict, colours), - fileNames_(dict.lookup("files")) -{} + fileNames_() +{ + dict.readEntry("files", fileNames_); +} Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface diff --git a/src/functionObjects/graphics/runTimePostProcessing/pathline.C b/src/functionObjects/graphics/runTimePostProcessing/pathline.C index 770356a70c..8f59b9d887 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/pathline.C +++ b/src/functionObjects/graphics/runTimePostProcessing/pathline.C @@ -155,7 +155,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline } case rtTube: { - dict.lookup("tubeRadius") >> tubeRadius_; + dict.readEntry("tubeRadius", tubeRadius_); break; } case rtVector: diff --git a/src/functionObjects/graphics/runTimePostProcessing/pointData.C b/src/functionObjects/graphics/runTimePostProcessing/pointData.C index 82872a3bbb..58bafbdd02 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/pointData.C +++ b/src/functionObjects/graphics/runTimePostProcessing/pointData.C @@ -101,7 +101,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData ( representationTypeNames.lookup("representation", dict) ), - maxGlyphLength_(readScalar(dict.lookup("maxGlyphLength"))), + maxGlyphLength_(dict.get("maxGlyphLength")), pointColour_(nullptr) { if (dict.found("pointColour")) diff --git a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C index c1c0620eb8..7cfe96d511 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C +++ b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C @@ -97,9 +97,9 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict) scene_.read(dict); const dictionary& outputDict = dict.subDict("output"); - outputDict.lookup("name") >> output_.name_; - outputDict.lookup("width") >> output_.width_; - outputDict.lookup("height") >> output_.height_; + outputDict.readEntry("name", output_.name_); + outputDict.readEntry("width", output_.width_); + outputDict.readEntry("height", output_.height_); readObjects(dict.subOrEmptyDict("points"), points_); @@ -117,11 +117,14 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict) << exit(FatalIOError); } - text_.append(new runTimePostPro::text + text_.append ( - *this, - iter().dict(), - scene_.colours()) + new runTimePostPro::text + ( + *this, + iter().dict(), + scene_.colours() + ) ); } diff --git a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessingTemplates.C b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessingTemplates.C index 29b9df1603..84561ee8a1 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessingTemplates.C +++ b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessingTemplates.C @@ -44,7 +44,7 @@ void Foam::functionObjects::runTimePostProcessing::readObjects } const dictionary& objectDict(iter().dict()); - word objectType = objectDict.lookup("type"); + const word objectType = objectDict.get("type"); objects.append ( diff --git a/src/functionObjects/graphics/runTimePostProcessing/scene.C b/src/functionObjects/graphics/runTimePostProcessing/scene.C index 2cdb11df5e..6af579dff4 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/scene.C +++ b/src/functionObjects/graphics/runTimePostProcessing/scene.C @@ -87,7 +87,7 @@ void Foam::functionObjects::runTimePostPro::scene::readCamera cameraUp_ = Function1::New("up", dict); dict.readIfPresent("clipBox", clipBox_); - dict.lookup("parallelProjection") >> parallelProjection_; + dict.readEntry("parallelProjection", parallelProjection_); if (!parallelProjection_) { if (dict.found("viewAngle")) diff --git a/src/functionObjects/graphics/runTimePostProcessing/surface.C b/src/functionObjects/graphics/runTimePostProcessing/surface.C index fe58ffc99a..f2d075df92 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/surface.C +++ b/src/functionObjects/graphics/runTimePostProcessing/surface.C @@ -184,11 +184,11 @@ Foam::functionObjects::runTimePostPro::surface::surface if (representation_ == rtGlyph) { - dict.lookup("maxGlyphLength") >> maxGlyphLength_; + dict.readEntry("maxGlyphLength", maxGlyphLength_); } else { - dict.lookup("featureEdges") >> featureEdges_; + dict.readEntry("featureEdges", featureEdges_); } } diff --git a/src/functionObjects/graphics/runTimePostProcessing/text.C b/src/functionObjects/graphics/runTimePostProcessing/text.C index 8a9f79c852..160ec5be4f 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/text.C +++ b/src/functionObjects/graphics/runTimePostProcessing/text.C @@ -44,13 +44,15 @@ Foam::functionObjects::runTimePostPro::text::text ) : geometryBase(parent, dict, colours), - string_(dict.lookup("string")), - position_(dict.lookup("position")), - size_(readScalar(dict.lookup("size"))), + string_(dict.get("string")), + position_(), + size_(dict.get("size")), colour_(nullptr), - bold_(readBool(dict.lookup("bold"))), + bold_(dict.get("bold")), timeStamp_(dict.lookupOrDefault("timeStamp", false)) { + dict.readEntry("position", position_); + if (dict.found("colour")) { colour_.reset(Function1::New("colour", dict).ptr()); diff --git a/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C b/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C index fc301627e8..d1d379b817 100644 --- a/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C +++ b/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C @@ -90,7 +90,7 @@ bool Foam::functionObjects::cloudInfo::read(const dictionary& dict) { if (regionFunctionObject::read(dict) && logFiles::read(dict)) { - logFiles::resetNames(dict.lookup("clouds")); + logFiles::resetNames(dict.get("clouds")); Info<< type() << " " << name() << ": "; if (writeToFile() && names().size()) diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C index 4575bed954..dbcbd464cd 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C @@ -364,7 +364,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict) writeOpts_.ascii ( dict.found("format") - && (IOstream::formatEnum(dict.lookup("format")) == IOstream::ASCII) + && (IOstream::formatEnum(dict.get("format")) == IOstream::ASCII) ); writeOpts_.append(false); // No append supported diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C index f5f5280301..5fcb5c668e 100644 --- a/src/functionObjects/solvers/energyTransport/energyTransport.C +++ b/src/functionObjects/solvers/energyTransport/energyTransport.C @@ -57,20 +57,17 @@ Foam::volScalarField& Foam::functionObjects::energyTransport::transportedField() { if (!foundObject(fieldName_)) { - tmp tfldPtr + auto tfldPtr = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - fieldName_, - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + fieldName_, + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ ); store(fieldName_, tfldPtr); } @@ -113,21 +110,18 @@ Foam::functionObjects::energyTransport::kappaEff() const Foam::tmp Foam::functionObjects::energyTransport::rho() const { - tmp trho + auto trho = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "trho", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "trho", + mesh_.time().timeName(), mesh_, - rho_ - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + rho_ ); if (phases_.size()) @@ -152,24 +146,19 @@ Foam::functionObjects::energyTransport::Cp() const return tCp; } - tmp tCp + return tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "tCp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tCp", + mesh_.time().timeName(), mesh_, - Cp_ - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + Cp_ ); - - return tCp; } @@ -187,24 +176,19 @@ Foam::functionObjects::energyTransport::kappa() const return tkappa; } - tmp tkappa + return tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "tkappa", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tkappa", + mesh_.time().timeName(), mesh_, - kappa_ - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + kappa_ ); - - return tkappa; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -430,21 +414,18 @@ bool Foam::functionObjects::energyTransport::execute() const surfaceScalarField CpPhi(rhoCp*phi); - tmp trhoCp + auto trhoCp = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - "trhoCp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "trhoCp", + mesh_.time().timeName(), mesh_, - rhoCp - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + rhoCp ); for (label i = 0; i <= nCorr_; i++) diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index 0045bc6e28..7b89363a81 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -58,20 +58,17 @@ Foam::volScalarField& Foam::functionObjects::scalarTransport::transportedField() { if (!foundObject(fieldName_)) { - tmp tfldPtr + auto tfldPtr = tmp::New ( - new volScalarField + IOobject ( - IOobject - ( - fieldName_, - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + fieldName_, + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ ); store(fieldName_, tfldPtr); @@ -81,10 +78,7 @@ Foam::volScalarField& Foam::functionObjects::scalarTransport::transportedField() } } - return const_cast - ( - lookupObject(fieldName_) - ); + return lookupObjectRef(fieldName_); } diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.C b/src/functionObjects/utilities/ensightWrite/ensightWrite.C index d04fe1e9a0..c228b5964a 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.C @@ -109,19 +109,16 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict) // writeOpts_.noPatches(dict.lookupOrDefault("noPatches", false)); - if (dict.found("patches")) + wordRes list; + if (dict.readIfPresent("patches", list)) { - wordRes list(dict.lookup("patches")); list.uniq(); - writeOpts_.patchSelection(list); } - if (dict.found("faceZones")) + if (dict.readIfPresent("faceZones", list)) { - wordRes list(dict.lookup("faceZones")); list.uniq(); - writeOpts_.faceZoneSelection(list); } @@ -147,7 +144,7 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict) // // output fields // - dict.lookup("fields") >> selectFields_; + dict.readEntry("fields", selectFields_); selectFields_.uniq(); return true; diff --git a/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C b/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C index e9776316f2..2441d6ab48 100644 --- a/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C +++ b/src/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C @@ -74,7 +74,7 @@ bool Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) { regionFunctionObject::read(dict); - dict.lookup("objects") >> objectNames_; + dict.readEntry("objects", objectNames_); return true; } diff --git a/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageCondition.C b/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageCondition.C index 37e19ce07e..a4dc98cf61 100644 --- a/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageCondition.C +++ b/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageCondition.C @@ -53,9 +53,9 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition ) : runTimeCondition(name, obr, dict, state), - functionObjectName_(dict.lookup("functionObject")), - fieldNames_(dict.lookup("fields")), - tolerance_(readScalar(dict.lookup("tolerance"))), + functionObjectName_(dict.get("functionObject")), + fieldNames_(dict.get("fields")), + tolerance_(dict.get("tolerance")), window_(dict.lookupOrDefault("window", -1)), totalTime_(fieldNames_.size(), obr_.time().deltaTValue()), resetOnRestart_(false) @@ -71,7 +71,7 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition if (dict.found(fieldName)) { const dictionary& valueDict = dict.subDict(fieldName); - totalTime_[fieldi] = readScalar(valueDict.lookup("totalTime")); + valueDict.readEntry("totalTime", totalTime_[fieldi]); } } } diff --git a/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C b/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C index 8bc3ac5e46..1f77eb09d8 100644 --- a/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C +++ b/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C @@ -76,8 +76,8 @@ equationInitialResidualCondition ) : runTimeCondition(name, obr, dict, state), - fieldNames_(dict.lookup("fields")), - value_(readScalar(dict.lookup("value"))), + fieldNames_(dict.get("fields")), + value_(dict.get("value")), timeStart_(dict.lookupOrDefault("timeStart", -GREAT)), mode_(operatingModeNames.lookup("mode", dict)) { diff --git a/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationMaxIterCondition/equationMaxIterCondition.C b/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationMaxIterCondition/equationMaxIterCondition.C index f23e69a3ea..874c96a6ab 100644 --- a/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationMaxIterCondition/equationMaxIterCondition.C +++ b/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationMaxIterCondition/equationMaxIterCondition.C @@ -60,8 +60,8 @@ equationMaxIterCondition ) : runTimeCondition(name, obr, dict, state), - fieldNames_(dict.lookup("fields")), - threshold_(readLabel(dict.lookup("threshold"))), + fieldNames_(dict.get("fields")), + threshold_(dict.get