Go to the documentation of this file.
28 const word objFuncName,
29 const word objFuncPart,
30 const dictionary& objFuncDict)
35 daResidual_(daResidual),
36 objFuncName_(objFuncName),
37 objFuncPart_(objFuncPart),
38 objFuncDict_(objFuncDict),
68 const word objFuncName,
69 const word objFuncPart,
70 const dictionary& objFuncDict)
76 objFuncDict.readEntry<word>(
"type", modelType);
78 if (
daOption.getAllOptions().lookupOrDefault<label>(
"debug", 0))
80 Info <<
"Selecting type: " << modelType <<
" for DAObjFunc. Name: " << objFuncName
81 <<
" part: " << objFuncPart << endl;
84 dictionaryConstructorTable::iterator cstrIter =
85 dictionaryConstructorTablePtr_->find(modelType);
88 if (cstrIter == dictionaryConstructorTablePtr_->end())
102 <<
"Unknown DAObjFunc type "
103 << modelType << nl << nl
104 <<
"Valid DAObjFunc types:" << endl
105 << dictionaryConstructorTablePtr_->sortedToc()
110 return autoPtr<DAObjFunc>(
124 labelList& faceSources,
125 labelList& cellSources)
155 if (objSource ==
"patchToFace")
158 autoPtr<topoSet> currentSet(
165 autoPtr<topoSetSource> sourceSet(
169 sourceSet().applyToSet(topoSetSource::NEW, currentSet());
172 for (
const label i : currentSet())
174 faceSources.append(i);
177 else if (objSource ==
"boxToCell")
180 autoPtr<topoSet> currentSet(
197 boxMin1[0] = boxMin[0];
198 boxMin1[1] = boxMin[1];
199 boxMin1[2] = boxMin[2];
200 boxMax1[0] = boxMax[0];
201 boxMax1[1] = boxMax[1];
202 boxMax1[2] = boxMax[2];
204 objFuncTmp.set(
"min", boxMin1);
205 objFuncTmp.set(
"max", boxMax1);
208 autoPtr<topoSetSource> sourceSet(
209 topoSetSource::New(objSource,
mesh_, objFuncTmp));
212 sourceSet().applyToSet(topoSetSource::NEW, currentSet());
215 for (
const label i : currentSet())
217 cellSources.append(i);
222 FatalErrorIn(
"calcObjFuncSources") <<
"source: " << objSource <<
" not supported!"
223 <<
"Options are: patchToFace, boxToCell!"
224 << abort(FatalError);
229 const dictionary& options,
261 label updateState = 0;
262 options.readEntry<label>(
"updateState", updateState);
264 label updateMesh = 0;
265 options.readEntry<label>(
"updateMesh", updateMesh);
279 daModel.correctBoundaryConditions();
280 daModel.updateIntermediateVariables();
virtual void correctBoundaryConditions()=0
update the boundary condition for all the states in the selected solver
const DAResidual & daResidual_
DAResidual object.
labelList objFuncCellSources_
a sorted list of all cell sources for the objective function
forAll(pseudoP.boundaryField(), patchI)
const DAModel & daModel_
DAModel object.
DAField daField_
DAField object.
virtual void updateIntermediateVariables()=0
update any intermdiate variables that are dependent on state variables and are used in calcResiduals
DAOption daOption(mesh, pyOptions_)
scalarList objFuncCellValues_
value of the obj function in the discrete cells
void calcObjFuncSources(labelList &faceSources, labelList &cellSources)
calculate DAObjFunc::objFuncFaceSources_ and DAObjFunc::objFuncCellSources_
virtual void calcObjFunc(const labelList &objFuncFaceSources, const labelList &objFuncCellSources, scalarList &objFuncFaceValues, scalarList &objFuncCellValues, scalar &objFuncValue)=0
calculate the value of objective function
scalar getObjFuncValue()
calculate the value of objective function
defineRunTimeSelectionTable(DAFvSource, dictionary)
scalar masterFunction(const dictionary &options, const Vec xvVec, const Vec wVec)
the master function to compute objective function given the state and point vectors
const fvMesh & mesh_
fvMesh
static autoPtr< DAObjFunc > New(const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex, const DAResidual &daResidual, const word objFuncName, const word objFuncPart, const dictionary &objFuncDict)
void stateVec2OFField(const Vec stateVec) const
assign the fields in OpenFOAM based on the state vector
defineTypeNameAndDebug(DAFvSource, 0)
DAModel daModel(mesh, daOption)
void pointVec2OFMesh(const Vec xvVec) const
assign the points in fvMesh of OpenFOAM based on the point vector
scalarList objFuncFaceValues_
value of the obj function on the discrete faces
DAIndex daIndex(mesh, daOption, daModel)
const dictionary & objFuncDict_
dictionary containing the information for the objective function
void specialBCTreatment()
apply special treatment for boundary conditions
scalar objFuncValue_
the value of the objective function
labelList objFuncFaceSources_
a sorted list of all face sources for the objective function