DAStateInfo.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6 \*---------------------------------------------------------------------------*/
7 
8 #include "DAStateInfo.H"
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16 
17 defineTypeNameAndDebug(DAStateInfo, 0);
18 defineRunTimeSelectionTable(DAStateInfo, dictionary);
19 
20 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
21 
22 DAStateInfo::DAStateInfo(
23  const word modelType,
24  const fvMesh& mesh,
25  const DAOption& daOption,
26  const DAModel& daModel)
27  : mesh_(mesh),
28  daOption_(daOption),
29  daModel_(daModel)
30 {
31 
32  // initialize stateInfo
33  stateInfo_.set("volScalarStates", {});
34  stateInfo_.set("volVectorStates", {});
35  stateInfo_.set("surfaceScalarStates", {});
36  stateInfo_.set("modelStates", {});
37 
38  //Info<<stateInfo_<<endl;
39 }
40 
41 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
42 
43 autoPtr<DAStateInfo> DAStateInfo::New(
44  const word modelType,
45  const fvMesh& mesh,
46  const DAOption& daOption,
47  const DAModel& daModel)
48 {
49  // standard setup for runtime selectable classes
50 
51  if (daOption.getAllOptions().lookupOrDefault<label>("debug", 0))
52  {
53  Info << "Selecting " << modelType << " for DAStateInfo" << endl;
54  }
55 
56  dictionaryConstructorTable::iterator cstrIter =
57  dictionaryConstructorTablePtr_->find(modelType);
58 
59  // if the solver name is not found in any child class, print an error
60  if (cstrIter == dictionaryConstructorTablePtr_->end())
61  {
62  FatalErrorIn(
63  "DAStateInfo::New"
64  "("
65  " const word,"
66  " const fvMesh&,"
67  " const DAOption&,"
68  " const DAModel&"
69  ")")
70  << "Unknown DAStateInfo type "
71  << modelType << nl << nl
72  << "Valid DAStateInfo types:" << endl
73  << dictionaryConstructorTablePtr_->sortedToc()
74  << exit(FatalError);
75  }
76 
77  // child class found
78  return autoPtr<DAStateInfo>(
79  cstrIter()(modelType, mesh, daOption, daModel));
80 }
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 } // End namespace Foam
87 
88 // ************************************************************************* //
Foam::DAStateInfo::New
static autoPtr< DAStateInfo > New(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel)
Definition: DAStateInfo.C:43
Foam::DAOption
Definition: DAOption.H:29
daOption
DAOption daOption(mesh, pyOptions_)
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(DAFvSource, dictionary)
Foam::DAModel
Definition: DAModel.H:59
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFvSource, 0)
DAStateInfo.H
daModel
DAModel daModel(mesh, daOption)
Foam::DAStateInfo::stateInfo_
HashTable< wordList > stateInfo_
registered states 1st hash: solverName, 2nd hash: fieldType, 3nd list, stateNames
Definition: DAStateInfo.H:51