Replacing const_cast lookupObject to lookupObjectRef
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -85,13 +85,7 @@ bool Foam::functionObjects::CourantNo::calc()
|
||||
|
||||
if (foundObject<volScalarField>(resultName_))
|
||||
{
|
||||
volScalarField& Co
|
||||
(
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupObject<volScalarField>(resultName_)
|
||||
)
|
||||
);
|
||||
volScalarField& Co = lookupObjectRef<volScalarField>(resultName_);
|
||||
|
||||
Co.ref() = Coi();
|
||||
Co.correctBoundaryConditions();
|
||||
|
||||
@ -196,10 +196,8 @@ void Foam::functionObjects::fieldAverage::calculateMeanFieldType
|
||||
{
|
||||
const Type& baseField = obr_.lookupObject<Type>(fieldName);
|
||||
|
||||
Type& meanField = const_cast<Type&>
|
||||
(
|
||||
obr_.lookupObject<Type>(faItems_[fieldi].meanFieldName())
|
||||
);
|
||||
Type& meanField =
|
||||
obr_.lookupObjectRef<Type>(faItems_[fieldi].meanFieldName());
|
||||
|
||||
scalar dt = obr_.time().deltaTValue();
|
||||
scalar Dt = totalTime_[fieldi];
|
||||
@ -258,10 +256,8 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
|
||||
const Type1& meanField =
|
||||
obr_.lookupObject<Type1>(faItems_[fieldi].meanFieldName());
|
||||
|
||||
Type2& prime2MeanField = const_cast<Type2&>
|
||||
(
|
||||
obr_.lookupObject<Type2>(faItems_[fieldi].prime2MeanFieldName())
|
||||
);
|
||||
Type2& prime2MeanField =
|
||||
obr_.lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
|
||||
|
||||
scalar dt = obr_.time().deltaTValue();
|
||||
scalar Dt = totalTime_[fieldi];
|
||||
@ -328,10 +324,8 @@ void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
|
||||
const Type1& meanField =
|
||||
obr_.lookupObject<Type1>(faItems_[fieldi].meanFieldName());
|
||||
|
||||
Type2& prime2MeanField = const_cast<Type2&>
|
||||
(
|
||||
obr_.lookupObject<Type2>(faItems_[fieldi].prime2MeanFieldName())
|
||||
);
|
||||
Type2& prime2MeanField =
|
||||
obr_.lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
|
||||
|
||||
prime2MeanField += sqr(meanField);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -91,10 +91,7 @@ bool Foam::functionObjects::processorField::read(const dictionary& dict)
|
||||
|
||||
bool Foam::functionObjects::processorField::execute()
|
||||
{
|
||||
const volScalarField& procField =
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
const_cast<volScalarField&>(procField) ==
|
||||
mesh_.lookupObjectRef<volScalarField>("processorID") ==
|
||||
dimensionedScalar("proci", dimless, Pstream::myProcNo());
|
||||
|
||||
return true;
|
||||
@ -103,10 +100,7 @@ bool Foam::functionObjects::processorField::execute()
|
||||
|
||||
bool Foam::functionObjects::processorField::write()
|
||||
{
|
||||
const volScalarField& procField =
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
procField.write();
|
||||
mesh_.lookupObject<volScalarField>("processorID").write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -193,10 +193,7 @@ bool Foam::functionObjects::wallShearStress::execute()
|
||||
typedef incompressible::turbulenceModel icoModel;
|
||||
|
||||
volVectorField& wallShearStress =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
mesh_.lookupObject<volVectorField>(type())
|
||||
);
|
||||
mesh_.lookupObjectRef<volVectorField>(type());
|
||||
|
||||
tmp<volSymmTensorField> Reff;
|
||||
if (mesh_.foundObject<cmpModel>(turbulenceModel::propertiesName))
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -169,10 +169,7 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::yPlus::execute()
|
||||
{
|
||||
volScalarField& yPlus =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh_.lookupObject<volScalarField>(type())
|
||||
);
|
||||
mesh_.lookupObjectRef<volScalarField>(type());
|
||||
|
||||
if (mesh_.foundObject<turbulenceModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -91,8 +91,8 @@ bool Foam::functionObjects::removeRegisteredObject::execute()
|
||||
{
|
||||
if (obr_.foundObject<regIOobject>(objectNames_[i]))
|
||||
{
|
||||
const regIOobject& obj =
|
||||
obr_.lookupObject<regIOobject>(objectNames_[i]);
|
||||
regIOobject& obj =
|
||||
obr_.lookupObjectRef<regIOobject>(objectNames_[i]);
|
||||
|
||||
if (obj.ownedByRegistry())
|
||||
{
|
||||
@ -100,7 +100,7 @@ bool Foam::functionObjects::removeRegisteredObject::execute()
|
||||
<< " removing object " << obj.name() << nl
|
||||
<< endl;
|
||||
|
||||
const_cast<regIOobject&>(obj).release();
|
||||
obj.release();
|
||||
delete &obj;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user