ENH: avoid raw dictionary lookup in functionObjects (issue #762)

Style changes:
    - use lookupObjectRef instead of using const_cast
    - use tmp::New factory
This commit is contained in:
Mark Olesen
2018-08-04 00:23:18 +02:00
parent 1c354e0906
commit 1036cf9612
81 changed files with 492 additions and 639 deletions

View File

@ -59,10 +59,8 @@ Foam::functionObjects::CourantNo::byRho
{
return Co/obr_.lookupObject<volScalarField>(rhoName_);
}
else
{
return Co;
}
return Co;
}
@ -85,35 +83,27 @@ bool Foam::functionObjects::CourantNo::calc()
if (foundObject<volScalarField>(resultName_, false))
{
volScalarField& Co
(
const_cast<volScalarField&>
(
lookupObject<volScalarField>(resultName_)
)
);
volScalarField& Co =
lookupObjectRef<volScalarField>(resultName_);
Co.ref() = Coi();
Co.correctBoundaryConditions();
}
else
{
tmp<volScalarField> tCo
auto tCo = tmp<volScalarField>::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;
}

View File

@ -75,33 +75,28 @@ bool Foam::functionObjects::Curle::calc()
const volVectorField& C = mesh_.C();
tmp<volScalarField> tpDash
auto tpDash = tmp<volScalarField>::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<wordRes>("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

View File

@ -75,26 +75,21 @@ Foam::functionObjects::DESModelRegions::DESModelRegions
{
read(dict);
tmp<volScalarField> tDESModelRegions
auto tmodelRegions = tmp<volScalarField>::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<volScalarField&>
(
lookupObject<volScalarField>(resultName_)
);
lookupObjectRef<volScalarField>(resultName_);
if (foundObject<DESModelBase>(turbulenceModel::propertiesName))

View File

@ -57,10 +57,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::functionObjects::PecletNo::rhoScale
{
return phi/fvc::interpolate(lookupObject<volScalarField>(rhoName_));
}
else
{
return phi;
}
return phi;
}
@ -84,23 +82,19 @@ bool Foam::functionObjects::PecletNo::calc()
const dictionary& model =
mesh_.lookupObject<dictionary>("transportProperties");
nuEff =
tmp<volScalarField>
nuEff = tmp<volScalarField>::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
{

View File

@ -81,22 +81,19 @@ Foam::functionObjects::blendingFactor::blendingFactor
writeFileHeader(file());
setResultName(typeName, "");
tmp<volScalarField> indicatorPtr
auto indicatorPtr = tmp<volScalarField>::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);

View File

@ -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<volScalarField&>
(
lookupObject<volScalarField>(resultName_)
);
lookupObjectRef<volScalarField>(resultName_);
indicator = 1 - fvc::cellReduce(factorf, minEqOp<scalar>(), GREAT);
indicator.correctBoundaryConditions();
}

View File

@ -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;

View File

@ -56,28 +56,24 @@ int Foam::functionObjects::ddt2::apply(const word& inputName, int& state)
: magSqr(input.dimensions()/dimTime)
);
tmp<volScalarField> tddt2
auto tddt2 = tmp<volScalarField>::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<volScalarField&>(lookupObject<volScalarField>(outputName));
volScalarField& output = lookupObjectRef<volScalarField>(outputName);
if (mag_)
{

View File

@ -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<wordList>("readFields"));
const wordList writeFields(groupDict.get<wordList>("writeFields"));
auto fnd = regionToGroups_.find(regionGroupNames_.last());
if (fnd.found())

View File

@ -278,8 +278,8 @@ Foam::functionObjects::externalCoupled::gatherAndCombine
Pstream::gatherList(gatheredValues);
tmp<Field<Type>> tresult(new Field<Type>(0));
Field<Type>& result = tresult.ref();
auto tresult = tmp<Field<Type>>::New();
auto& result = tresult.ref();
if (Pstream::master())
{

View File

@ -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_);

View File

@ -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<scalar>("restartPeriod");
restartPeriod_ = obr().time().userTimeToTime(userRestartPeriod);
if (restartPeriod_ > 0)

View File

@ -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;

View File

@ -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<bool>("mean");
faItem.prime2Mean_ = entry.get<bool>("prime2Mean");
faItem.base_ = faItem.baseTypeNames_.lookup("base", entry);
faItem.window_ = entry.lookupOrDefault<scalar>("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<bool>("allowRestart");
if (!faItem.allowRestart_)
{

View File

@ -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;

View File

@ -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<scalar>("scaleFactor", 1.0);
return true;

View File

@ -36,7 +36,7 @@ Foam::functionObjects::fieldValue::New
const bool output
)
{
const word modelType(dict.lookup("type"));
const word modelType(dict.get<word>("type"));
if (output)
{

View File

@ -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<word>("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<vector>("direction"));
return gSum(pos0(values*(Sf & n))*mag(values));
}
case opSumDirectionBalance:
{
const vector n(dict_.lookup("direction"));
const vector n(dict_.get<vector>("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<vector>("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<vector>("direction").normalise());
const scalarField nv(n & values);
return gSum(pos0(nv)*n*(nv));

View File

@ -178,7 +178,6 @@ processSameTypeValues
if (canWeight(weightField))
{
tmp<scalarField> weight(weightingFactor(weightField));
result = gSum(weight*values);
}
else
@ -466,8 +465,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
const GeometricField<Type, fvPatchField, volMesh>& field
) const
{
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
Field<Type>& values = tvalues.ref();
auto tvalues = tmp<Field<Type>>::New(faceId_.size());
auto& values = tvalues.ref();
forAll(values, i)
{
@ -501,8 +500,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
) const
{
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
Field<Type>& values = tvalues.ref();
auto tvalues = tmp<Field<Type>>::New(faceId_.size());
auto& values = tvalues.ref();
forAll(values, i)
{

View File

@ -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;

View File

@ -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<word> zones(dict.lookup("faceZones"));
wordList zones(dict.get<wordList>("faceZones"));
forAll(zones, i)
{
@ -853,8 +851,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
}
case mdFaceZoneAndDirection:
{
List<Tuple2<word, vector>>
zoneAndDirection(dict.lookup("faceZoneAndDirection"));
List<Tuple2<word, vector>> zoneAndDirection;
dict.readEntry("faceZoneAndDirection", zoneAndDirection);
forAll(zoneAndDirection, i)
{
@ -873,8 +871,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
}
case mdCellZoneAndDirection:
{
List<Tuple2<word, vector>>
zoneAndDirection(dict.lookup("cellZoneAndDirection"));
List<Tuple2<word, vector>> zoneAndDirection;
dict.readEntry("cellZoneAndDirection", zoneAndDirection);
forAll(zoneAndDirection, i)
{
@ -893,7 +891,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
}
case mdSurface:
{
List<word> surfs(dict.lookup("surfaces"));
wordList surfs(dict.get<wordList>("surfaces"));
forAll(surfs, i)
{
@ -909,8 +907,8 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
}
case mdSurfaceAndDirection:
{
List<Tuple2<word, vector>>
surfAndDirection(dict.lookup("surfaceAndDirection"));
List<Tuple2<word, vector>> surfAndDirection;
dict.readEntry("surfaceAndDirection", surfAndDirection);
forAll(surfAndDirection, i)
{

View File

@ -164,12 +164,8 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cf() const
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
const volVectorField::Boundary& Ubf = U.boundaryField();
tmp<FieldField<Field, scalar>> tCf
(
new FieldField<Field, scalar>(Ubf.size())
);
FieldField<Field, scalar>& Cf = tCf.ref();
auto tCf = tmp<FieldField<Field, scalar>>::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));

View File

@ -68,7 +68,7 @@ bool Foam::heatTransferCoeffModels::fixedReferenceTemperature::read
{
if (heatTransferCoeffModel::read(dict))
{
dict.lookup("TRef") >> TRef_;
dict.readEntry("TRef", TRef_);
return true;
}

View File

@ -46,16 +46,12 @@ Foam::heatTransferCoeffModel::q() const
const volScalarField& T = mesh_.lookupObject<volScalarField>(TName_);
const volScalarField::Boundary& Tbf = T.boundaryField();
tmp<FieldField<Field, scalar>> tq
(
new FieldField<Field, scalar>(Tbf.size())
);
FieldField<Field, scalar>& q = tq.ref();
auto tq = tmp<FieldField<Field, scalar>>::New(Tbf.size());
auto& q = tq.ref();
forAll(q, patchi)
{
q.set(patchi, new Field<scalar>(Tbf[patchi].size(), 0));
q.set(patchi, new Field<scalar>(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<volScalarField>(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<wordRes>("patches"));
dict.readIfPresent("qr", qrName_);

View File

@ -36,7 +36,7 @@ Foam::autoPtr<Foam::heatTransferCoeffModel> Foam::heatTransferCoeffModel::New
const word& TName
)
{
const word modelType(dict.lookup("htcModel"));
const word modelType(dict.get<word>("htcModel"));
Info<< "Selecting heat transfer coefficient model " << modelType << endl;

View File

@ -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<scalar>("max", -GREAT);
min_ = dict.lookupOrDefault<scalar>("min", GREAT);
dict.lookup("nBins") >> nBins_;
dict.readEntry("nBins", nBins_);
word format(dict.lookup("setFormat"));
const word format(dict.get<word>("setFormat"));
formatterPtr_ = writer<scalar>::New(format);
return true;

View File

@ -53,7 +53,7 @@ void Foam::functionObjects::mapFields::createInterpolation
)
{
const fvMesh& meshTarget = mesh_;
const word mapRegionName(dict.lookup("mapRegion"));
const word mapRegionName(dict.get<word>("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<word>("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<bool>("consistent"))
{
interpPtr_.reset
(
@ -119,8 +117,11 @@ void Foam::functionObjects::mapFields::createInterpolation
}
else
{
HashTable<word> patchMap(dict.lookup("patchMap"));
wordList cuttingPatches(dict.lookup("cuttingPatches"));
HashTable<word> 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;
}

View File

@ -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<wordRes>("patches"));
distance_ = dict.get<scalar>("distance");
// Clear out any previously loaded fields

View File

@ -37,9 +37,9 @@ void Foam::functionObjects::nearWallFields::createFields
HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>());
forAllConstIter(typename HashTable<const VolFieldType*>, flds, iter)
forAllConstIters(flds, iter)
{
const VolFieldType& fld = *iter();
const VolFieldType& fld = *(iter.object());
if (fieldMap_.found(fld.name()))
{

View File

@ -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<word>("setFormat"));
writerPtr_ = writer<scalar>::New(format);
Info<< type() << " " << name() << " output:" << nl

View File

@ -70,22 +70,19 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
{
if (p.dimensions() == dimPressure)
{
return tmp<volScalarField>
return tmp<volScalarField>::New
(
new volScalarField
IOobject
(
IOobject
(
"rhoScale",
p.mesh().time().timeName(),
p.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
p,
fvPatchField<scalar>::calculatedType()
)
"rhoScale",
p.mesh().time().timeName(),
p.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
p,
fvPatchField<scalar>::calculatedType()
);
}
else
@ -115,10 +112,8 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
{
return lookupObject<volScalarField>(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<volScalarField>(fieldName_);
tmp<volScalarField> tp
auto tp = tmp<volScalarField>::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<scalar>("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_;

View File

@ -91,10 +91,10 @@ bool Foam::functionObjects::processorField::read(const dictionary& dict)
bool Foam::functionObjects::processorField::execute()
{
const volScalarField& procField =
mesh_.lookupObject<volScalarField>("processorID");
volScalarField& procField =
mesh_.lookupObjectRef<volScalarField>("processorID");
const_cast<volScalarField&>(procField) ==
procField ==
dimensionedScalar("proci", dimless, Pstream::myProcNo());
return true;

View File

@ -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;
}

View File

@ -39,26 +39,25 @@ bool Foam::functionObjects::randomise::calcRandomised()
resultName_ = fieldName_ & "Random";
tmp<VolFieldType> rfieldt(new VolFieldType(field));
VolFieldType& rfield = rfieldt.ref();
auto trfield = tmp<VolFieldType>::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<Type>::one;
rndPert /= mag(rndPert);
rfield[celli] += magPerturbation_*rndPert;
cellval += magPerturbation_*rndPert;
}
return store(resultName_, rfieldt);
}
else
{
return false;
return store(resultName_, trfield);
}
return false;
}

View File

@ -78,24 +78,20 @@ calculateSpeciesRR
const basicChemistryModel& basicChemistry
)
{
tmp<DimensionedField<scalar, volMesh>> RRt
auto RRt = tmp<DimensionedField<scalar, volMesh>>::New
(
new DimensionedField<scalar, volMesh>
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<scalar, volMesh>& RR = RRt.ref();
auto& RR = RRt.ref();
scalar dt = time_.deltaT().value();

View File

@ -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;

View File

@ -209,8 +209,8 @@ Foam::functionObjects::regionSizeDistribution::divide
const scalarField& denom
)
{
tmp<scalarField> tresult(new scalarField(num.size()));
scalarField& result = tresult.ref();
auto tresult = tmp<scalarField>::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<word>("field")),
patchNames_(dict.get<wordRes>("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<word>("setFormat"));
formatterPtr_ = writer<scalar>::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<scalarField> townFld(fvp.patchInternalField());
const scalarField& ownFld = townFld();
tmp<scalarField> tnbrFld(fvp.patchNeighbourField());
const scalarField& nbrFld = tnbrFld();

View File

@ -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<scalar>::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<vector>("refDir").normalise());
const vector axis(dict.get<vector>("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<vector>("refDir").normalise());
const vector axis(dict.get<vector>("axis").normalise());
R_ = tensor(refDir, axis, refDir^axis);
break;
}

View File

@ -279,23 +279,21 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
<< exit(FatalError);
}
tmp<volScalarField> magGradCCPtr
auto tmagGradCC = tmp<volScalarField>::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<vector::nComponents; i++)
{
@ -316,12 +314,12 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
);
cci = mesh_.C().component(i);
cci.correctBoundaryConditions();
magGradCCPtr.ref() += mag(fvc::grad(cci)).ref();
magGradCC += mag(fvc::grad(cci)).ref();
}
if (first)
{
Log << " Max magGradCc : " << max(magGradCCPtr.ref()).value()
Log << " Max magGradCc : " << max(magGradCC.ref()).value()
<< endl;
}
@ -334,7 +332,7 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
max
(
scalar(0),
(magGradCCPtr.ref() - maxGradCc_)
(magGradCC - maxGradCc_)
/ (minGradCc_ - maxGradCc_)
),
scalar(1)
@ -355,25 +353,22 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first)
<< exit(FatalError);
}
tmp<volScalarField> CoPtr
auto CoPtr = tmp<volScalarField>::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<surfaceScalarField>(resultName_)
);
surfaceScalarField& surBlended =
mesh_.lookupObjectRef<surfaceScalarField>(resultName_);
*surBlendedPtr = fvc::interpolate(indicator_);
surBlended = fvc::interpolate(indicator_);
return true;
}
@ -511,21 +504,18 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
read(dict);
setResultName(typeName, "");
tmp<surfaceScalarField> faceBlendedPtr
auto faceBlendedPtr = tmp<surfaceScalarField>::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_);

View File

@ -71,27 +71,21 @@ Foam::tmp<Foam::pointScalarField> Foam::functionObjects::streamFunction::calc
const pointMesh& pMesh = pointMesh::New(mesh_);
tmp<pointScalarField> tstreamFunction
auto tstreamFunction = tmp<pointScalarField>::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::pointScalarField> 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::pointScalarField> Foam::functionObjects::streamFunction::calc
points[curPoints[pointi]] - currentStreamPoint;
edgeHat.replace(slabDir, 0);
edgeHat /= mag(edgeHat);
edgeHat.normalise();
vector nHat = unitAreas[facei];

View File

@ -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<scalar>::New(dict.lookup("setFormat"));
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
scalarFormatterPtr_ = writer<scalar>::New(dict.get<word>("setFormat"));
vectorFormatterPtr_ = writer<vector>::New(dict.get<word>("setFormat"));
return true;
}

View File

@ -76,7 +76,7 @@ bool Foam::functionObjects::surfaceInterpolate::read
{
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> fieldSet_;
dict.readEntry("fields", fieldSet_);
return true;
}

View File

@ -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<word>("field"));
}
else
{
fieldSet_.insert(wordList(dict.lookup("fields")));
fieldSet_.insert(dict.get<wordList>("fields"));
}
Info<< type() << " " << name() << ": ";

View File

@ -40,8 +40,7 @@ void Foam::functionObjects::turbulenceFields::processField
if (obr_.foundObject<FieldType>(scopedName))
{
FieldType& fld =
const_cast<FieldType&>(obr_.lookupObject<FieldType>(scopedName));
FieldType& fld = obr_.lookupObjectRef<FieldType>(scopedName);
fld == tvalue();
}
else if (obr_.found(scopedName))

View File

@ -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<scalar>("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_);

View File

@ -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;

View File

@ -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;

View File

@ -120,10 +120,7 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict)
bool Foam::functionObjects::yPlus::execute()
{
volScalarField& yPlus =
const_cast<volScalarField&>
(
lookupObject<volScalarField>(typeName)
);
lookupObjectRef<volScalarField>(typeName);
if (foundObject<turbulenceModel>(turbulenceModel::propertiesName))
{

View File

@ -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;

View File

@ -83,29 +83,25 @@ int Foam::functionObjects::zeroGradient::apply
if (!foundObject<VolFieldType>(outputName))
{
tmp<VolFieldType> tzg
auto tzeroGrad = tmp<VolFieldType>::New
(
new VolFieldType
IOobject
(
IOobject
(
outputName,
time_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
outputName,
time_.timeName(),
mesh_,
dimensioned<Type>(input.dimensions(), Zero),
zeroGradientFvPatchField<Type>::typeName
)
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>(input.dimensions(), Zero),
zeroGradientFvPatchField<Type>::typeName
);
store(outputName, tzg);
store(outputName, tzeroGrad);
}
VolFieldType& output =
const_cast<VolFieldType&>(lookupObject<VolFieldType>(outputName));
VolFieldType& output = lookupObjectRef<VolFieldType>(outputName);
output = input;
output.correctBoundaryConditions();

View File

@ -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<volVectorField>(fieldName("moment"));
volVectorField& forceCoeff =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("forceCoeff"))
);
lookupObjectRef<volVectorField>(fieldName("forceCoeff"));
volVectorField& momentCoeff =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("momentCoeff"))
);
lookupObjectRef<volVectorField>(fieldName("momentCoeff"));
dimensionedScalar f0("f0", dimForce, Aref_*pDyn);
dimensionedScalar m0("m0", dimForce*dimLength, Aref_*lRef_*pDyn);

View File

@ -292,18 +292,12 @@ void Foam::functionObjects::forces::resetFields()
if (writeFields_)
{
volVectorField& force =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("force"))
);
lookupObjectRef<volVectorField>(fieldName("force"));
force == dimensionedVector(force.dimensions(), Zero);
volVectorField& moment =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("moment"))
);
lookupObjectRef<volVectorField>(fieldName("moment"));
moment == dimensionedVector(moment.dimensions(), Zero);
}
@ -415,25 +409,20 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::rho() const
{
if (rhoName_ == "rhoInf")
{
return tmp<volScalarField>
return tmp<volScalarField>::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<volScalarField>(rhoName_));
}
return(lookupObject<volScalarField>(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<volVectorField&>
(
lookupObject<volVectorField>(fieldName("force"))
);
lookupObjectRef<volVectorField>(fieldName("force"));
vectorField& pf = force.boundaryFieldRef()[patchi];
pf += fN + fT + fP;
volVectorField& moment =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("moment"))
);
lookupObjectRef<volVectorField>(fieldName("moment"));
vectorField& pm = moment.boundaryFieldRef()[patchi];
pm += Md;
@ -543,16 +524,10 @@ void Foam::functionObjects::forces::addToFields
}
volVectorField& force =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("force"))
);
lookupObjectRef<volVectorField>(fieldName("force"));
volVectorField& moment =
const_cast<volVectorField&>
(
lookupObject<volVectorField>(fieldName("moment"))
);
lookupObjectRef<volVectorField>(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<wordRes>("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<const porosityModel*>, models, iter)
forAllConstIters(models, iter)
{
// Non-const access required if mesh is changing
porosityModel& pm = const_cast<porosityModel&>(*iter());

View File

@ -484,7 +484,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
)
:
colours_(colours),
fieldName_(dict.lookup("field")),
fieldName_(dict.get<word>("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;
}

View File

@ -86,7 +86,7 @@ Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase
:
fieldVisualisationBase(dict, colours),
state_(state),
functionObjectName_(dict.lookup("functionObject")),
functionObjectName_(dict.get<word>("functionObject")),
clearObjects_(dict.lookupOrDefault("clearObjects", false))
{}

View File

@ -65,9 +65,9 @@ Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud
:
pointData(parent, dict, colours),
functionObjectBase(parent, dict, colours),
cloudName_(dict.lookup("cloud")),
cloudName_(dict.get<word>("cloud")),
inputFileName_(),
colourFieldName_(dict.lookup("colourField")),
colourFieldName_(dict.get<word>("colourField")),
actor_()
{
actor_ = vtkSmartPointer<vtkActor>::New();

View File

@ -86,7 +86,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
:
parent_(parent),
name_(dict.dictName()),
visible_(readBool(dict.lookup("visible"))),
visible_(dict.get<bool>("visible")),
renderMode_(rmGouraud),
opacity_(nullptr),
colours_(colours)

View File

@ -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

View File

@ -155,7 +155,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline
}
case rtTube:
{
dict.lookup("tubeRadius") >> tubeRadius_;
dict.readEntry("tubeRadius", tubeRadius_);
break;
}
case rtVector:

View File

@ -101,7 +101,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData
(
representationTypeNames.lookup("representation", dict)
),
maxGlyphLength_(readScalar(dict.lookup("maxGlyphLength"))),
maxGlyphLength_(dict.get<scalar>("maxGlyphLength")),
pointColour_(nullptr)
{
if (dict.found("pointColour"))

View File

@ -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()
)
);
}

View File

@ -44,7 +44,7 @@ void Foam::functionObjects::runTimePostProcessing::readObjects
}
const dictionary& objectDict(iter().dict());
word objectType = objectDict.lookup("type");
const word objectType = objectDict.get<word>("type");
objects.append
(

View File

@ -87,7 +87,7 @@ void Foam::functionObjects::runTimePostPro::scene::readCamera
cameraUp_ = Function1<vector>::New("up", dict);
dict.readIfPresent("clipBox", clipBox_);
dict.lookup("parallelProjection") >> parallelProjection_;
dict.readEntry("parallelProjection", parallelProjection_);
if (!parallelProjection_)
{
if (dict.found("viewAngle"))

View File

@ -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_);
}
}

View File

@ -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>("string")),
position_(),
size_(dict.get<scalar>("size")),
colour_(nullptr),
bold_(readBool(dict.lookup("bold"))),
bold_(dict.get<bool>("bold")),
timeStamp_(dict.lookupOrDefault("timeStamp", false))
{
dict.readEntry("position", position_);
if (dict.found("colour"))
{
colour_.reset(Function1<vector>::New("colour", dict).ptr());

View File

@ -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<wordList>("clouds"));
Info<< type() << " " << name() << ": ";
if (writeToFile() && names().size())

View File

@ -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<word>("format")) == IOstream::ASCII)
);
writeOpts_.append(false); // No append supported

View File

@ -57,20 +57,17 @@ Foam::volScalarField& Foam::functionObjects::energyTransport::transportedField()
{
if (!foundObject<volScalarField>(fieldName_))
{
tmp<volScalarField> tfldPtr
auto tfldPtr = tmp<volScalarField>::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::volScalarField>
Foam::functionObjects::energyTransport::rho() const
{
tmp<volScalarField> trho
auto trho = tmp<volScalarField>::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<volScalarField> tCp
return tmp<volScalarField>::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<volScalarField> tkappa
return tmp<volScalarField>::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<volScalarField> trhoCp
auto trhoCp = tmp<volScalarField>::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++)

View File

@ -58,20 +58,17 @@ Foam::volScalarField& Foam::functionObjects::scalarTransport::transportedField()
{
if (!foundObject<volScalarField>(fieldName_))
{
tmp<volScalarField> tfldPtr
auto tfldPtr = tmp<volScalarField>::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<volScalarField&>
(
lookupObject<volScalarField>(fieldName_)
);
return lookupObjectRef<volScalarField>(fieldName_);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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<word>("functionObject")),
fieldNames_(dict.get<wordList>("fields")),
tolerance_(dict.get<scalar>("tolerance")),
window_(dict.lookupOrDefault<scalar>("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]);
}
}
}

View File

@ -76,8 +76,8 @@ equationInitialResidualCondition
)
:
runTimeCondition(name, obr, dict, state),
fieldNames_(dict.lookup("fields")),
value_(readScalar(dict.lookup("value"))),
fieldNames_(dict.get<wordList>("fields")),
value_(dict.get<scalar>("value")),
timeStart_(dict.lookupOrDefault("timeStart", -GREAT)),
mode_(operatingModeNames.lookup("mode", dict))
{

View File

@ -60,8 +60,8 @@ equationMaxIterCondition
)
:
runTimeCondition(name, obr, dict, state),
fieldNames_(dict.lookup("fields")),
threshold_(readLabel(dict.lookup("threshold"))),
fieldNames_(dict.get<wordList>("fields")),
threshold_(dict.get<label>("threshold")),
startIter_(dict.lookupOrDefault("startIter", 2))
{
if (!fieldNames_.size())

View File

@ -83,10 +83,10 @@ Foam::functionObjects::runTimeControls::minMaxCondition::minMaxCondition
)
:
runTimeCondition(name, obr, dict, state),
functionObjectName_(dict.lookup("functionObject")),
functionObjectName_(dict.get<word>("functionObject")),
mode_(modeTypeNames_.lookup("mode", dict)),
fieldNames_(dict.lookup("fields")),
value_(readScalar(dict.lookup("value")))
fieldNames_(dict.get<wordList>("fields")),
value_(dict.get<scalar>("value"))
{}

View File

@ -59,7 +59,7 @@ minTimeStepCondition
)
:
runTimeCondition(name, obr, dict, state),
minValue_(readScalar(dict.lookup("minValue")))
minValue_(dict.get<scalar>("minValue"))
{}

View File

@ -36,7 +36,7 @@ Foam::functionObjects::runTimeControls::runTimeCondition::New
stateFunctionObject& state
)
{
const word conditionType(dict.lookup("type"));
const word conditionType(dict.get<word>("type"));
Info<< "Selecting runTimeCondition " << conditionType << endl;
@ -52,7 +52,8 @@ Foam::functionObjects::runTimeControls::runTimeCondition::New
<< exit(FatalError);
}
return autoPtr<runTimeCondition>
return
autoPtr<runTimeCondition>
(
cstrIter()(conditionName, obr, dict, state)
);

View File

@ -56,7 +56,7 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
probes(name, runTime, dict, loadFromFiles, false),
ODESystem(),
UName_(dict.lookupOrDefault<word>("U", "U")),
radiationFieldName_(dict.lookup("radiationField")),
radiationFieldName_(dict.get<word>("radiationField")),
thermo_(mesh_.lookupObject<fluidThermo>(basicThermo::dictName)),
odeSolver_(nullptr),
Ttc_()
@ -71,7 +71,7 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
dictionary probeDict;
if (getDict(typeName, probeDict))
{
probeDict.lookup("Tc") >> Ttc_;
probeDict.readEntry("Tc", Ttc_);
}
else
{
@ -198,10 +198,10 @@ bool Foam::functionObjects::thermoCoupleProbes::read(const dictionary& dict)
{
if (probes::read(dict))
{
rho_ = readScalar(dict.lookup("rho"));
Cp_ = readScalar(dict.lookup("Cp"));
d_ = readScalar(dict.lookup("d"));
epsilon_ = readScalar(dict.lookup("epsilon"));
dict.readEntry("rho", rho_);
dict.readEntry("Cp", Cp_);
dict.readEntry("d", d_);
dict.readEntry("epsilon", epsilon_);
return true;
}

View File

@ -115,8 +115,8 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
{
functionObject::read(dict);
dict.lookup("fileToUpdate") >> fileToUpdate_;
dict.lookup("timeVsFile") >> timeVsFile_;
dict.readEntry("fileToUpdate", fileToUpdate_);
dict.readEntry("timeVsFile", timeVsFile_);
lastIndex_ = -1;
fileToUpdate_.expand();

View File

@ -87,7 +87,7 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
writeOpts_.ascii
(
dict.found("format")
&& (IOstream::formatEnum(dict.lookup("format")) == IOstream::ASCII)
&& (IOstream::formatEnum(dict.get<word>("format")) == IOstream::ASCII)
);
// FUTURE?
@ -115,7 +115,7 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
//
// output fields
//
dict.lookup("fields") >> selectFields_;
dict.readEntry("fields", selectFields_);
selectFields_.uniq();
return true;

View File

@ -125,7 +125,7 @@ bool Foam::functionObjects::writeDictionary::read(const dictionary& dict)
{
regionFunctionObject::read(dict);
wordList dictNames(dict.lookup("dictNames"));
wordList dictNames(dict.get<wordList>("dictNames"));
wordHashSet uniqueNames(dictNames);
dictNames_ = uniqueNames.toc();
@ -134,9 +134,9 @@ bool Foam::functionObjects::writeDictionary::read(const dictionary& dict)
Info<< type() << " " << name() << ": monitoring dictionaries:" << nl;
if (dictNames_.size())
{
forAll(dictNames_, i)
for (const word & dictName : dictNames_)
{
Info<< " " << dictNames_[i] << endl;
Info<< " " << dictName << endl;
}
}
else

View File

@ -90,15 +90,15 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
if (dict.found("field"))
{
objectNames_.setSize(1);
dict.lookup("field") >> objectNames_[0];
dict.readEntry("field", objectNames_[0]);
}
else if (dict.found("fields"))
{
dict.lookup("fields") >> objectNames_;
dict.readEntry("fields", objectNames_);
}
else
{
dict.lookup("objects") >> objectNames_;
dict.readEntry("objects", objectNames_);
}
writeOption_ = writeOptionNames_.lookupOrDefault