DAStateInfoPisoFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6 \*---------------------------------------------------------------------------*/
7 
8 #include "DAStateInfoPisoFoam.H"
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 defineTypeNameAndDebug(DAStateInfoPisoFoam, 0);
16 addToRunTimeSelectionTable(DAStateInfo, DAStateInfoPisoFoam, dictionary);
17 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
18 
20  const word modelType,
21  const fvMesh& mesh,
22  const DAOption& daOption,
23  const DAModel& daModel)
24  : DAStateInfo(modelType, mesh, daOption, daModel)
25 {
26  /*
27  Description:
28  Register the names of state variables
29  NOTE:
30  For model variables, such as turbulence model, register specific names
31  For example, register "nut" to modelStates for RANS turbulence models,
32  Then, we will call correctModelStates(stateInfo_["modelStates"]) to modify
33  "nut" based on the selected turbulence model. For example, for SA model,
34  correctModelStates will just replace "nut" with "nuTilda", for SST model,
35  it will replace "nut" with "k" and append "omega" to modelStates.
36  In other words, the model variables will be modified based on the selected
37  models at runtime.
38  */
39 
40  stateInfo_["volScalarStates"].append("p");
41  stateInfo_["modelStates"].append("nut");
42  stateInfo_["volVectorStates"].append("U");
43  stateInfo_["surfaceScalarStates"].append("phi");
44 
45  // correct the names for model states based on the selected physical model at runtime
46  daModel.correctModelStates(stateInfo_["modelStates"]);
47 
48  /*
49  Description:
50  Adjoint state connectivity info, numbers denote the level of connectivity
51  N/A means this state does not connect to the corrsponding residual
52 
53  U T p nut phi
54  URes 2 2 1 1 0
55  TRes 2 2 2 1 0
56  pRes 3 2 2 2 1
57  phiRes 2 2 1 1 0
58 
59  ******************************** NOTE 1 **********************************
60  One does not need to specify connectivity for each physical model, set the
61  connectivity for original variables instead. For example, for turbulence models,
62  set nut. Then, how is nut connected to the other turbulence states will be
63  set in the DAModel class. This is done by calling correctStateResidualModelCon.
64  For example, for SA model we just replace nut with nuTilda, for SST model, we need
65  to add extract connectivity since nut depends on grad(U), k, and omega. We need
66  to do this for other pyhsical models such as radiation models.
67  **************************************************************************
68 
69  ******************************** NOTE 2 **********************************
70  Do not specify physical model connectivity here, because they will be added
71  by calling addModelResidualCon. For example, for the SA turbulence
72  model, it will add the nuTildaRes to stateResConInfo_ and setup
73  its connectivity automatically.
74  **************************************************************************
75 
76  */
77 
78  stateResConInfo_.set(
79  "URes",
80  {
81  {"U", "p", "nut", "phi"}, // lv0
82  {"U", "p", "nut"}, // lv1
83  {"U"} // lv2
84  });
85 
86  stateResConInfo_.set(
87  "pRes",
88  {
89  {"U", "p", "nut", "phi"}, // lv0
90  {"U", "p", "nut", "phi"}, // lv1
91  {"U", "p", "nut"}, // lv2
92  {"U"} // lv3
93  });
94 
95  stateResConInfo_.set(
96  "phiRes",
97  {
98  {"U", "p", "nut", "phi"}, // lv0
99  {"U", "p", "nut"}, // lv1
100  {"U"}, // lv2
101  });
102 
103  // need to correct connectivity for physical models for each residual
104  daModel.correctStateResidualModelCon(stateResConInfo_["URes"]);
105  daModel.correctStateResidualModelCon(stateResConInfo_["pRes"]);
106  daModel.correctStateResidualModelCon(stateResConInfo_["phiRes"]);
107 
108  // add physical model residual connectivity
109  daModel.addModelResidualCon(stateResConInfo_);
110 
111 }
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 } // End namespace Foam
115 
116 // ************************************************************************* //
Foam::DAOption
Definition: DAOption.H:29
daOption
DAOption daOption(mesh, pyOptions_)
Foam::DAStateInfoPisoFoam::DAStateInfoPisoFoam
DAStateInfoPisoFoam(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel)
Definition: DAStateInfoPisoFoam.C:19
DAStateInfoPisoFoam.H
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAModel
Definition: DAModel.H:59
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::DAStateInfo::stateResConInfo_
HashTable< List< List< word > > > stateResConInfo_
table to specify how the states are connected to the residuals for a given solver
Definition: DAStateInfo.H:54
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFvSource, 0)
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(DAFvSource, DAFvSourceActuatorDisk, dictionary)
daModel
DAModel daModel(mesh, daOption)
Foam::DAStateInfo
Definition: DAStateInfo.H:30
Foam::DAStateInfo::stateInfo_
HashTable< wordList > stateInfo_
registered states 1st hash: solverName, 2nd hash: fieldType, 3nd list, stateNames
Definition: DAStateInfo.H:51