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:
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user