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