DAInput.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v4
5 
6 \*---------------------------------------------------------------------------*/
7 
8 #include "DAInput.H"
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16 
17 defineTypeNameAndDebug(DAInput, 0);
18 defineRunTimeSelectionTable(DAInput, dictionary);
19 
20 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
21 
22 DAInput::DAInput(
23  const word inputName,
24  const word inputType,
25  fvMesh& mesh,
26  const DAOption& daOption,
27  const DAModel& daModel,
28  const DAIndex& daIndex)
29  : inputName_(inputName),
30  inputType_(inputType),
31  mesh_(mesh),
32  daOption_(daOption),
33  daModel_(daModel),
34  daIndex_(daIndex)
35 {
36  // initialize stateInfo_
37  word solverName = daOption_.getOption<word>("solverName");
38  autoPtr<DAStateInfo> daStateInfo(DAStateInfo::New(solverName, mesh, daOption, daModel));
39  stateInfo_ = daStateInfo->getStateInfo();
40 }
41 
42 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
43 
44 autoPtr<DAInput> DAInput::New(
45  const word inputName,
46  const word inputType,
47  fvMesh& mesh,
48  const DAOption& daOption,
49  const DAModel& daModel,
50  const DAIndex& daIndex)
51 {
52  // standard setup for runtime selectable classes
53 
54  if (daOption.getAllOptions().lookupOrDefault<label>("debug", 0))
55  {
56  Info << "Selecting input: " << inputType << " for DAInput." << endl;
57  }
58 
59  dictionaryConstructorTable::iterator cstrIter =
60  dictionaryConstructorTablePtr_->find(inputType);
61 
62  // if the solver name is not found in any child class, print an error
63  if (cstrIter == dictionaryConstructorTablePtr_->end())
64  {
65  FatalErrorIn(
66  "DAInput::New"
67  "("
68  " const word,"
69  " fvMesh&,"
70  " const DAOption&,"
71  " const DAModel&,"
72  " const DAIndex&"
73  ")")
74  << "Unknown DAInput type "
75  << inputType << nl << nl
76  << "Valid DAInput types:" << endl
77  << dictionaryConstructorTablePtr_->sortedToc()
78  << exit(FatalError);
79  }
80 
81  // child class found
82  return autoPtr<DAInput>(
83  cstrIter()(inputName,
84  inputType,
85  mesh,
86  daOption,
87  daModel,
88  daIndex));
89 }
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 } // End namespace Foam
96 
97 // ************************************************************************* //
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
Foam::DAInput::New
static autoPtr< DAInput > New(const word inputName, const word inputType, fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex)
Definition: DAInput.C:44
Foam::DAOption::getOption
classType getOption(const word key) const
get an option from subDict and key
Definition: DAOption.H:92
solverName
word solverName
Definition: createAdjoint.H:14
Foam::DAOption::getAllOptions
const dictionary & getAllOptions() const
return a reference of allOptions_ dictionary
Definition: DAOption.H:56
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAIndex
Definition: DAIndex.H:32
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(DAFunction, dictionary)
DAInput.H
Foam::DAInput::stateInfo_
HashTable< wordList > stateInfo_
the stateInfo_ list from DAStateInfo object
Definition: DAInput.H:60
Foam::DAInput::daOption_
const DAOption & daOption_
DAOption object.
Definition: DAInput.H:51
Foam::DAModel
Definition: DAModel.H:57
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFunction, 0)
Foam
Definition: checkGeometry.C:32