56 <<
"Inconsistent dimensions for lowerBounds ("
58 <<
") and design variables ("
64 else if (
dict_.found(
"lowerBound"))
66 scalar lowerBound(
dict_.get<scalar>(
"lowerBound"));
69 else if (lowerBoundPtr)
75 if (
dict_.found(
"upperBounds"))
81 <<
"Inconsistent dimensions for upperBounds ("
83 <<
") and design variables ("
89 else if (
dict_.found(
"upperBound"))
91 scalar upperBound(
dict_.get<scalar>(
"upperBound"));
94 else if (upperBoundPtr)
103Foam::designVariables::designVariables
112 activeDesignVariables_(0),
113 oldDesignVariables_(nullptr),
114 maxInitChange_(nullptr),
115 lowerBounds_(nullptr),
116 upperBounds_(nullptr)
119 if (
dict.found(
"maxInitChange"))
121 maxInitChange_.reset(new scalar(dict_.get<scalar>(
"maxInitChange")));
126Foam::designVariables::designVariables
136 activeDesignVariables_(0),
137 oldDesignVariables_(nullptr),
138 maxInitChange_(nullptr),
139 lowerBounds_(nullptr),
140 upperBounds_(nullptr)
143 if (
dict.found(
"maxInitChange"))
145 maxInitChange_.reset(new scalar(dict_.get<scalar>(
"maxInitChange")));
158 if (!
dict.found(
"type"))
163 const word modelType(
dict.get<word>(
"type"));
165 Info<<
"designVariables type : " << modelType <<
endl;
167 auto* ctorPtr = designVariablesConstructorTable(modelType);
175 *designVariablesConstructorTablePtr_
189 if (
dict.found(
"maxInitChange"))
212 if (!oldDesignVariables_)
217 oldDesignVariables_.ref() = getVars();
224 <<
"Reseting design variables" <<
endl;
233 const wordList& adjointSolversNames,
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label size() const noexcept
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Abstract base class for defining design variables.
autoPtr< scalarField > oldDesignVariables_
Copy of old design variables. Useful when performing line-search.
virtual void evolveNumber()
For design variables with a dynamic character (i.e. changing number), perform the evolution.
static autoPtr< designVariables > New(fvMesh &mesh, const dictionary &dict)
Return a reference to the selected design variables.
autoPtr< scalarField > upperBounds_
Upper bounds of the design variables.
autoPtr< scalar > maxInitChange_
Maximum design variables' change in the first optimisation cycle.
const autoPtr< scalarField > & upperBounds() const
Get max bounds for the design variables.
virtual void resetDesignVariables()
Reset to the starting point of line search.
virtual PtrList< scalarField > constraintDerivatives()
virtual void addFvOptions(const PtrList< primalSolver > &primalSolver, const PtrList< adjointSolverManager > &adjointSolverManagers)
Add fvOptions depending on the design variables.
void readBounds(autoPtr< scalar > lowerBoundPtr=nullptr, autoPtr< scalar > upperBoundPtr=nullptr)
Read bounds for design variables, if present.
virtual const scalarField & getVars() const
Get the design variables.
virtual tmp< scalarField > constraintValues()
Design variables might add constraints related to themselves (e.g. linear combinations of the design ...
autoPtr< scalarField > lowerBounds_
Lower bounds of the design variables.
virtual bool readDict(const dictionary &dict)
Read dictionary if changed.
virtual void setInitialValues()
Set initial values of the design variables.
const autoPtr< scalarField > & lowerBounds() const
Get min bounds for the design variables.
labelList activeDesignVariables_
Which of the design variables will be updated.
virtual void storeDesignVariables()
Store design variables, as the starting point for line search.
virtual void postProcessSens(scalarField &objectiveSens, PtrList< scalarField > &constraintSens, const wordList &adjointSolversNames, bool isMaster)
Post process sensitivities if needed.
virtual void writeDesignVars()
Write useful quantities to files.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Mesh data needed to do the Finite Volume discretisation.
Base class for primal solvers.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
List< word > wordList
List of word.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
PtrList< adjointSolverManager > & adjointSolverManagers