mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: replace autoPtr<bool> with Switch (#2777)
- initialise with Switch::INVALID and then test if good() to trigger the initial update. This avoids some overhead, but primarily avoids ambiguity with implicit casting to a 'bool' that autoPtr<bool> has.
This commit is contained in:
@ -172,11 +172,11 @@ adjointBoundaryCondition<Type>::computePatchGrad(word name)
|
||||
template<class Type>
|
||||
bool adjointBoundaryCondition<Type>::addATCUaGradUTerm()
|
||||
{
|
||||
if (!addATCUaGradUTerm_)
|
||||
if (!addATCUaGradUTerm_.good())
|
||||
{
|
||||
addATCUaGradUTerm_.reset(new bool(isA<ATCUaGradU>(getATC())));
|
||||
addATCUaGradUTerm_ = bool(isA<ATCUaGradU>(getATC()));
|
||||
}
|
||||
return addATCUaGradUTerm_();
|
||||
return addATCUaGradUTerm_;
|
||||
}
|
||||
|
||||
|
||||
@ -202,7 +202,7 @@ adjointBoundaryCondition<Type>::adjointBoundaryCondition
|
||||
adjointBC.patch_
|
||||
)
|
||||
),
|
||||
addATCUaGradUTerm_(adjointBC.addATCUaGradUTerm_)
|
||||
addATCUaGradUTerm_(Switch::INVALID)
|
||||
{}
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ adjointBoundaryCondition<Type>::adjointBoundaryCondition
|
||||
adjointSolverName_(solverName),
|
||||
simulationType_("incompressible"),
|
||||
boundaryContrPtr_(nullptr),
|
||||
addATCUaGradUTerm_(nullptr)
|
||||
addATCUaGradUTerm_(Switch::INVALID)
|
||||
{
|
||||
// Set the boundaryContribution pointer
|
||||
setBoundaryContributionPtr();
|
||||
|
||||
@ -39,6 +39,7 @@ Description
|
||||
|
||||
#include "boundaryAdjointContribution.H"
|
||||
#include "ATCModel.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -73,11 +74,10 @@ protected:
|
||||
//- to the adjoint boundary conditions
|
||||
autoPtr<boundaryAdjointContribution> boundaryContrPtr_;
|
||||
|
||||
|
||||
//- Whether to add the extra term from the UaGradU formulation
|
||||
// autoPtr since ATCModel has not been allocated at the time
|
||||
// adjointBoundaryConditions are constructed
|
||||
autoPtr<bool> addATCUaGradUTerm_;
|
||||
//- Whether to add the extra term from the UaGradU formulation.
|
||||
// As a Switch with delayed evaluation since ATCModel
|
||||
// has not been allocated at the time of construction
|
||||
Switch addATCUaGradUTerm_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
Reference in New Issue
Block a user