mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: replace List<objective*> with UPtrList in incompressiblePrimalSolver (fixes #2946)
This commit is contained in:
committed by
Andrew Heather
parent
b435feffde
commit
e0ea0973b1
@ -119,17 +119,13 @@ bool Foam::incompressiblePrimalSolver::readDict(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::objective*>
|
||||
Foam::UPtrList<Foam::objective>
|
||||
Foam::incompressiblePrimalSolver::getObjectiveFunctions() const
|
||||
{
|
||||
DynamicList<objective*> objectives(10);
|
||||
DynamicList<objective*> objectives;
|
||||
|
||||
auto adjointSolvers = mesh_.lookupClass<adjointSolver>();
|
||||
|
||||
for (adjointSolver* adjointPtr : adjointSolvers)
|
||||
for (auto& adjoint : mesh_.sorted<adjointSolver>())
|
||||
{
|
||||
adjointSolver& adjoint = *adjointPtr;
|
||||
|
||||
if (adjoint.primalSolverName() == solverName_)
|
||||
{
|
||||
PtrList<objective>& managerObjectives =
|
||||
@ -137,12 +133,12 @@ Foam::incompressiblePrimalSolver::getObjectiveFunctions() const
|
||||
|
||||
for (objective& obj : managerObjectives)
|
||||
{
|
||||
objectives.append(&obj);
|
||||
objectives.push_back(&obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objectives;
|
||||
return UPtrList<objective>(objectives);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ public:
|
||||
// Access
|
||||
|
||||
//- Return the list of objectives assodicated with this solver
|
||||
List<objective*> getObjectiveFunctions() const;
|
||||
UPtrList<objective> getObjectiveFunctions() const;
|
||||
|
||||
//- Access to the incompressible variables set
|
||||
const incompressibleVars& getIncoVars() const;
|
||||
|
||||
@ -107,7 +107,7 @@ Foam::simple::simple
|
||||
incoVars_(allocateVars()),
|
||||
MRF_(mesh, word(useSolverNameForFields() ? solverName_ : word::null)),
|
||||
cumulativeContErr_(Zero),
|
||||
objectives_(0)
|
||||
objectives_()
|
||||
{
|
||||
addExtraSchemes();
|
||||
setRefCell
|
||||
@ -248,11 +248,11 @@ void Foam::simple::postIter()
|
||||
|
||||
// Print objective values to screen and compute mean value
|
||||
Info<< endl;
|
||||
for (objective* obj : objectives_)
|
||||
for (auto& obj : objectives_)
|
||||
{
|
||||
Info<< obj->objectiveName() << " : " << obj->J() << endl;
|
||||
obj->accumulateJMean(solverControl_());
|
||||
obj->writeInstantaneousValue();
|
||||
Info<< obj.objectiveName() << " : " << obj.J() << endl;
|
||||
obj.accumulateJMean(solverControl_());
|
||||
obj.writeInstantaneousValue();
|
||||
}
|
||||
|
||||
// Average fields if necessary
|
||||
@ -309,9 +309,9 @@ void Foam::simple::preLoop()
|
||||
|
||||
void Foam::simple::postLoop()
|
||||
{
|
||||
for (objective* obj : objectives_)
|
||||
for (auto& obj : objectives_)
|
||||
{
|
||||
obj->writeInstantaneousSeparator();
|
||||
obj.writeInstantaneousSeparator();
|
||||
}
|
||||
|
||||
// Safety
|
||||
|
||||
@ -84,7 +84,7 @@ protected:
|
||||
scalar cumulativeContErr_;
|
||||
|
||||
//- List of objectives related to this primal solver
|
||||
List<objective*> objectives_;
|
||||
UPtrList<objective> objectives_;
|
||||
|
||||
|
||||
//- Protected Member Functions
|
||||
|
||||
Reference in New Issue
Block a user