mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: useSolverNameForFields is now set to true automatically
in cases with more than one primal or adjoint solvers TUT: removed all occurances of useSolverNameForFields from the optimisation tutorials since it is now set automatically.
This commit is contained in:
committed by
Andrew Heather
parent
06cde7916c
commit
d16ff0a0a5
@ -61,13 +61,19 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
||||
managerType_(get<word>("optimisationManager")),
|
||||
optType_(nullptr)
|
||||
{
|
||||
const dictionary& primalSolversDict = subDict("primalSolvers");
|
||||
dictionary& primalSolversDict = subDict("primalSolvers");
|
||||
const wordList& primalSolverNames = primalSolversDict.toc();
|
||||
|
||||
// Construct primal solvers
|
||||
primalSolvers_.setSize(primalSolverNames.size());
|
||||
forAll(primalSolvers_, solveri)
|
||||
{
|
||||
dictionary& solverDict =
|
||||
primalSolversDict.subDict(primalSolverNames[solveri]);
|
||||
if (primalSolvers_.size() > 1)
|
||||
{
|
||||
solverDict.add<bool>("useSolverNameForFields", true);
|
||||
}
|
||||
primalSolvers_.set
|
||||
(
|
||||
solveri,
|
||||
@ -75,7 +81,7 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
||||
(
|
||||
mesh,
|
||||
managerType_,
|
||||
primalSolversDict.subDict(primalSolverNames[solveri])
|
||||
solverDict
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -86,6 +92,7 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
||||
adjointSolverManagers_.setSize(adjointManagerNames.size());
|
||||
|
||||
label nAdjointSolvers(0);
|
||||
bool overrideUseSolverName(adjointSolverManagers_.size() > 1);
|
||||
forAll(adjointSolverManagers_, manageri)
|
||||
{
|
||||
adjointSolverManagers_.set
|
||||
@ -95,7 +102,8 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
||||
(
|
||||
mesh,
|
||||
managerType_,
|
||||
adjointManagersDict.subDict(adjointManagerNames[manageri])
|
||||
adjointManagersDict.subDict(adjointManagerNames[manageri]),
|
||||
overrideUseSolverName
|
||||
)
|
||||
);
|
||||
nAdjointSolvers += adjointSolverManagers_[manageri].nAdjointSolvers();
|
||||
|
||||
@ -43,7 +43,8 @@ Foam::adjointSolverManager::adjointSolverManager
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const word& managerType,
|
||||
const dictionary& dict
|
||||
const dictionary& dict,
|
||||
bool overrideUseSolverName
|
||||
)
|
||||
:
|
||||
regIOobject
|
||||
@ -70,7 +71,8 @@ Foam::adjointSolverManager::adjointSolverManager
|
||||
dict.getOrDefault<scalar>("operatingPointWeight", 1)
|
||||
)
|
||||
{
|
||||
const dictionary& adjointSolversDict = dict.subDict("adjointSolvers");
|
||||
dictionary& adjointSolversDict =
|
||||
const_cast<dictionary&>(dict.subDict("adjointSolvers"));
|
||||
|
||||
const wordList adjSolverNames = adjointSolversDict.toc();
|
||||
adjointSolvers_.setSize(adjSolverNames.size());
|
||||
@ -80,6 +82,12 @@ Foam::adjointSolverManager::adjointSolverManager
|
||||
label nConstraints(0);
|
||||
forAll(adjSolverNames, namei)
|
||||
{
|
||||
dictionary& solverDict =
|
||||
adjointSolversDict.subDict(adjSolverNames[namei]);
|
||||
if (overrideUseSolverName || adjointSolvers_.size() > 1)
|
||||
{
|
||||
solverDict.add<bool>("useSolverNameForFields", true);
|
||||
}
|
||||
adjointSolvers_.set
|
||||
(
|
||||
namei,
|
||||
@ -87,7 +95,7 @@ Foam::adjointSolverManager::adjointSolverManager
|
||||
(
|
||||
mesh_,
|
||||
managerType,
|
||||
adjointSolversDict.subDict(adjSolverNames[namei]),
|
||||
solverDict,
|
||||
primalSolverName_
|
||||
)
|
||||
);
|
||||
|
||||
@ -100,7 +100,8 @@ public:
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const word& managerType,
|
||||
const dictionary& dict
|
||||
const dictionary& dict,
|
||||
bool overrideUseSolverName
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ primalSolvers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver simple;
|
||||
useSolverNameForFields false;
|
||||
solutionControls
|
||||
{
|
||||
nIters 3000;
|
||||
@ -52,7 +51,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields false;
|
||||
computeSensitivities true;
|
||||
|
||||
// manage objectives
|
||||
|
||||
@ -23,7 +23,6 @@ primalSolvers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver simple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
solutionControls
|
||||
{
|
||||
@ -41,7 +40,6 @@ primalSolvers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver simple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
solutionControls
|
||||
{
|
||||
@ -71,7 +69,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
// manage objectives
|
||||
//------------------
|
||||
@ -124,7 +121,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
// manage objectives
|
||||
//------------------
|
||||
|
||||
@ -49,7 +49,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
// manage objectives
|
||||
//------------------
|
||||
@ -97,7 +96,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
isConstraint true;
|
||||
|
||||
// manage objectives
|
||||
|
||||
@ -49,7 +49,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
// manage objectives
|
||||
//------------------
|
||||
@ -91,7 +90,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
isConstraint true;
|
||||
// manage objectives
|
||||
//------------------
|
||||
|
||||
@ -23,7 +23,6 @@ primalSolvers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver simple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
solutionControls
|
||||
{
|
||||
@ -41,7 +40,6 @@ primalSolvers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver simple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
solutionControls
|
||||
{
|
||||
@ -71,7 +69,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
// manage objectives
|
||||
//------------------
|
||||
@ -124,7 +121,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields true;
|
||||
|
||||
// manage objectives
|
||||
//------------------
|
||||
|
||||
@ -23,7 +23,6 @@ primalSolvers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver simple;
|
||||
useSolverNameForFields false;
|
||||
|
||||
solutionControls
|
||||
{
|
||||
@ -52,7 +51,6 @@ adjointManagers
|
||||
active true;
|
||||
type incompressible;
|
||||
solver adjointSimple;
|
||||
useSolverNameForFields false;
|
||||
computeSensitivities true;
|
||||
|
||||
// manage objectives
|
||||
|
||||
Reference in New Issue
Block a user