mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user