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

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