43 Foam::optimisationManager::optimisationManager(
fvMesh&
mesh)
58 time_(const_cast<
Time&>(
mesh.time())),
60 adjointSolverManagers_(),
61 managerType_(
get<
word>(
"optimisationManager")),
65 const wordList& primalSolverNames = primalSolversDict.
toc();
72 primalSolversDict.
subDict(primalSolverNames[solveri]);
75 solverDict.
add<
bool>(
"useSolverNameForFields",
true);
91 const wordList& adjointManagerNames = adjointManagersDict.toc();
94 label nAdjointSolvers(0);
101 new adjointSolverManager
105 adjointManagersDict.subDict(adjointManagerNames[manageri]),
106 overrideUseSolverName
117 if (!solveri.useSolverNameForFields())
120 <<
"Multiple primal solvers are present but " 121 <<
"useSolverNameForFields is set to false in " 122 <<
"primal solver " << solveri.solverName() <<
nl 123 <<
"This is considered fatal." 129 if (nAdjointSolvers > 1)
133 const PtrList<adjointSolver>& adjointSolvers = amI.adjointSolvers();
134 for (
const adjointSolver& asI : adjointSolvers)
136 if (!asI.useSolverNameForFields())
139 <<
"Multiple adjoint solvers are present but " 140 <<
"useSolverNameForFields is set to false in " 141 <<
"adjoint solver " << asI.solverName() <<
nl 142 <<
"This is considered fatal." 158 const IOdictionary
dict 171 const word modelType(
dict.
get<word>(
"optimisationManager"));
173 Info<<
"optimisationManager type : " << modelType <<
endl;
175 auto* ctorPtr = dictionaryConstructorTable(modelType);
182 "optimisationManager",
184 *dictionaryConstructorTablePtr_
199 const dictionary& primalSolversDict = subDict(
"primalSolvers");
202 sol.readDict(primalSolversDict.
subDict(sol.solverName()));
205 const dictionary& adjointManagersDict = subDict(
"adjointManagers");
208 man.readDict(adjointManagersDict.
subDict(man.managerName()));
220 return primalSolvers_;
227 return adjointSolverManagers_;
236 primalSolvers_[psI].solve();
246 adjointSolverManagers_[amI].solveAdjointEquations();
256 adjointSolverManagers_[amI].computeAllSensitivities();
263 forAll(adjointSolverManagers_, amI)
265 PtrList<adjointSolver>& adjointSolvers =
266 adjointSolverManagers_[amI].adjointSolvers();
268 forAll(adjointSolvers, asI)
270 adjointSolvers[asI].updatePrimalBasedQuantities();
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
static autoPtr< optimisationManager > New(fvMesh &mesh)
Return a reference to the selected turbulence model.
void size(const label n)
Older name for setAddressableSize.
PtrList< adjointSolverManager > adjointSolverManagers_
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual void updatePrimalBasedQuantities()
Solve all primal equations.
virtual bool read()
Read object.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Base class for primal solvers.
Abstract base class for optimisation methods.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Ignore writing from objectRegistry::writeObject()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const Time & time() const
Return the top-level database.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
PtrList< primalSolver > primalSolvers_
wordList toc() const
Return the table of contents.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
virtual PtrList< adjointSolverManager > & adjointSolverManagers()
dictionary()
Default construct, a top-level empty dictionary.
A class for handling words, derived from Foam::string.
const word & system() const noexcept
Return system name.
virtual void computeSensitivities()
Compute all adjoint sensitivities.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
virtual void solveAdjointEquations()
Solve all adjoint equations.
List< word > wordList
List of word.
Class for managing adjoint solvers, which may be more than one per operating point.
Mesh data needed to do the Finite Volume discretisation.
static autoPtr< primalSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict)
Return a reference to the selected primal solver.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
Defines the attributes of an object for which implicit objectRegistry management is supported...
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
virtual bool read()
Read object.
Do not request registration (bool: false)
virtual void solvePrimalEquations()
Solve all primal equations.
virtual PtrList< primalSolver > & primalSolvers()
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...