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")),
|
managerType_(get<word>("optimisationManager")),
|
||||||
optType_(nullptr)
|
optType_(nullptr)
|
||||||
{
|
{
|
||||||
const dictionary& primalSolversDict = subDict("primalSolvers");
|
dictionary& primalSolversDict = subDict("primalSolvers");
|
||||||
const wordList& primalSolverNames = primalSolversDict.toc();
|
const wordList& primalSolverNames = primalSolversDict.toc();
|
||||||
|
|
||||||
// Construct primal solvers
|
// Construct primal solvers
|
||||||
primalSolvers_.setSize(primalSolverNames.size());
|
primalSolvers_.setSize(primalSolverNames.size());
|
||||||
forAll(primalSolvers_, solveri)
|
forAll(primalSolvers_, solveri)
|
||||||
{
|
{
|
||||||
|
dictionary& solverDict =
|
||||||
|
primalSolversDict.subDict(primalSolverNames[solveri]);
|
||||||
|
if (primalSolvers_.size() > 1)
|
||||||
|
{
|
||||||
|
solverDict.add<bool>("useSolverNameForFields", true);
|
||||||
|
}
|
||||||
primalSolvers_.set
|
primalSolvers_.set
|
||||||
(
|
(
|
||||||
solveri,
|
solveri,
|
||||||
@ -75,7 +81,7 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
|||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
managerType_,
|
managerType_,
|
||||||
primalSolversDict.subDict(primalSolverNames[solveri])
|
solverDict
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -86,6 +92,7 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
|||||||
adjointSolverManagers_.setSize(adjointManagerNames.size());
|
adjointSolverManagers_.setSize(adjointManagerNames.size());
|
||||||
|
|
||||||
label nAdjointSolvers(0);
|
label nAdjointSolvers(0);
|
||||||
|
bool overrideUseSolverName(adjointSolverManagers_.size() > 1);
|
||||||
forAll(adjointSolverManagers_, manageri)
|
forAll(adjointSolverManagers_, manageri)
|
||||||
{
|
{
|
||||||
adjointSolverManagers_.set
|
adjointSolverManagers_.set
|
||||||
@ -95,7 +102,8 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
|
|||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
managerType_,
|
managerType_,
|
||||||
adjointManagersDict.subDict(adjointManagerNames[manageri])
|
adjointManagersDict.subDict(adjointManagerNames[manageri]),
|
||||||
|
overrideUseSolverName
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
nAdjointSolvers += adjointSolverManagers_[manageri].nAdjointSolvers();
|
nAdjointSolvers += adjointSolverManagers_[manageri].nAdjointSolvers();
|
||||||
|
|||||||
@ -43,7 +43,8 @@ Foam::adjointSolverManager::adjointSolverManager
|
|||||||
(
|
(
|
||||||
fvMesh& mesh,
|
fvMesh& mesh,
|
||||||
const word& managerType,
|
const word& managerType,
|
||||||
const dictionary& dict
|
const dictionary& dict,
|
||||||
|
bool overrideUseSolverName
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
regIOobject
|
regIOobject
|
||||||
@ -70,7 +71,8 @@ Foam::adjointSolverManager::adjointSolverManager
|
|||||||
dict.getOrDefault<scalar>("operatingPointWeight", 1)
|
dict.getOrDefault<scalar>("operatingPointWeight", 1)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const dictionary& adjointSolversDict = dict.subDict("adjointSolvers");
|
dictionary& adjointSolversDict =
|
||||||
|
const_cast<dictionary&>(dict.subDict("adjointSolvers"));
|
||||||
|
|
||||||
const wordList adjSolverNames = adjointSolversDict.toc();
|
const wordList adjSolverNames = adjointSolversDict.toc();
|
||||||
adjointSolvers_.setSize(adjSolverNames.size());
|
adjointSolvers_.setSize(adjSolverNames.size());
|
||||||
@ -80,6 +82,12 @@ Foam::adjointSolverManager::adjointSolverManager
|
|||||||
label nConstraints(0);
|
label nConstraints(0);
|
||||||
forAll(adjSolverNames, namei)
|
forAll(adjSolverNames, namei)
|
||||||
{
|
{
|
||||||
|
dictionary& solverDict =
|
||||||
|
adjointSolversDict.subDict(adjSolverNames[namei]);
|
||||||
|
if (overrideUseSolverName || adjointSolvers_.size() > 1)
|
||||||
|
{
|
||||||
|
solverDict.add<bool>("useSolverNameForFields", true);
|
||||||
|
}
|
||||||
adjointSolvers_.set
|
adjointSolvers_.set
|
||||||
(
|
(
|
||||||
namei,
|
namei,
|
||||||
@ -87,7 +95,7 @@ Foam::adjointSolverManager::adjointSolverManager
|
|||||||
(
|
(
|
||||||
mesh_,
|
mesh_,
|
||||||
managerType,
|
managerType,
|
||||||
adjointSolversDict.subDict(adjSolverNames[namei]),
|
solverDict,
|
||||||
primalSolverName_
|
primalSolverName_
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -100,7 +100,8 @@ public:
|
|||||||
(
|
(
|
||||||
fvMesh& mesh,
|
fvMesh& mesh,
|
||||||
const word& managerType,
|
const word& managerType,
|
||||||
const dictionary& dict
|
const dictionary& dict,
|
||||||
|
bool overrideUseSolverName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,6 @@ primalSolvers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver simple;
|
solver simple;
|
||||||
useSolverNameForFields false;
|
|
||||||
solutionControls
|
solutionControls
|
||||||
{
|
{
|
||||||
nIters 3000;
|
nIters 3000;
|
||||||
@ -52,7 +51,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields false;
|
|
||||||
computeSensitivities true;
|
computeSensitivities true;
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
|
|||||||
@ -23,7 +23,6 @@ primalSolvers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver simple;
|
solver simple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
solutionControls
|
solutionControls
|
||||||
{
|
{
|
||||||
@ -41,7 +40,6 @@ primalSolvers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver simple;
|
solver simple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
solutionControls
|
solutionControls
|
||||||
{
|
{
|
||||||
@ -71,7 +69,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
@ -124,7 +121,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
|
|||||||
@ -49,7 +49,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
@ -97,7 +96,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
isConstraint true;
|
isConstraint true;
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
|
|||||||
@ -49,7 +49,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
@ -91,7 +90,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
isConstraint true;
|
isConstraint true;
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
|
|||||||
@ -23,7 +23,6 @@ primalSolvers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver simple;
|
solver simple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
solutionControls
|
solutionControls
|
||||||
{
|
{
|
||||||
@ -41,7 +40,6 @@ primalSolvers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver simple;
|
solver simple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
solutionControls
|
solutionControls
|
||||||
{
|
{
|
||||||
@ -71,7 +69,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
@ -124,7 +121,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields true;
|
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
//------------------
|
//------------------
|
||||||
|
|||||||
@ -23,7 +23,6 @@ primalSolvers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver simple;
|
solver simple;
|
||||||
useSolverNameForFields false;
|
|
||||||
|
|
||||||
solutionControls
|
solutionControls
|
||||||
{
|
{
|
||||||
@ -52,7 +51,6 @@ adjointManagers
|
|||||||
active true;
|
active true;
|
||||||
type incompressible;
|
type incompressible;
|
||||||
solver adjointSimple;
|
solver adjointSimple;
|
||||||
useSolverNameForFields false;
|
|
||||||
computeSensitivities true;
|
computeSensitivities true;
|
||||||
|
|
||||||
// manage objectives
|
// manage objectives
|
||||||
|
|||||||
Reference in New Issue
Block a user