Commit 5e954d28 authored by Mark Olesen's avatar Mark Olesen

STYLE: use autoPtr instead of tmp for holding sensitivities

- since only pointers are stored, autoPtr is better fit than tmp
parent e2021550
......@@ -81,7 +81,7 @@ protected:
autoPtr<objectiveManager> objectiveManagerPtr_;
//- Sensitivities field
tmp<scalarField> sensitivities_;
autoPtr<scalarField> sensitivities_;
//- Are sensitivities computed
bool computeSensitivities_;
......
......@@ -7,7 +7,7 @@
-------------------------------------------------------------------------------
Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -161,7 +161,7 @@ bool Foam::adjointSimple::readDict(const dictionary& dict)
{
if (incompressibleAdjointSolver::readDict(dict))
{
if (adjointSensitivity_.valid())
if (adjointSensitivity_)
{
const IOdictionary& optDict =
mesh_.lookupObject<IOdictionary>("optimisationDict");
......@@ -336,11 +336,11 @@ void Foam::adjointSimple::computeObjectiveSensitivities()
{
adjointSensitivity_->accumulateIntegrand(scalar(1));
const scalarField& sens = adjointSensitivity_->calculateSensitivities();
if (sensitivities_.empty())
if (!sensitivities_)
{
sensitivities_.reset(new scalarField(sens.size(), Zero));
}
sensitivities_.ref() = sens;
*sensitivities_ = sens;
}
else
{
......@@ -351,7 +351,7 @@ void Foam::adjointSimple::computeObjectiveSensitivities()
const Foam::scalarField& Foam::adjointSimple::getObjectiveSensitivities()
{
if (!sensitivities_.valid())
if (!sensitivities_)
{
computeObjectiveSensitivities();
}
......@@ -372,7 +372,7 @@ void Foam::adjointSimple::clearSensitivities()
Foam::sensitivity& Foam::adjointSimple::getSensitivityBase()
{
if (!adjointSensitivity_.valid())
if (!adjointSensitivity_)
{
FatalErrorInFunction
<< "Sensitivity object not allocated" << nl
......
......@@ -7,7 +7,7 @@
-------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -173,7 +173,7 @@ Foam::incompressibleAdjointSolver::getFvOptionsAdjoint()
void Foam::incompressibleAdjointSolver::updatePrimalBasedQuantities()
{
if (vars_.valid())
if (vars_)
{
getAdjointVars().adjointTurbulence()->setChangedPrimalSolution();
}
......
......@@ -151,7 +151,7 @@ void Foam::solver::updateOptTypeSource
const autoPtr<volScalarField>& optSourcePtr
)
{
if (optSourcePtr.valid())
if (optSourcePtr)
{
const volScalarField& optSource = optSourcePtr();
optTypeSource_ = &optSource;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment