DAInputField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v4
5 
6  Description:
7  Child class for field variable input
8 
9 \*---------------------------------------------------------------------------*/
10 
11 #ifndef DAInputField_H
12 #define DAInputField_H
13 
14 #include "DAInput.H"
15 #include "addToRunTimeSelectionTable.H"
16 #include "mixedFvPatchFields.H"
17 #include "DAGlobalVar.H"
18 
19 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
20 
21 namespace Foam
22 {
23 
24 /*---------------------------------------------------------------------------*\
25  Class DAInputField Declaration
26 \*---------------------------------------------------------------------------*/
27 
29  : public DAInput
30 {
31 
32 protected:
34  word fieldName_;
35 
37  word fieldType_;
38 
40  labelList indices_;
41 
42 public:
43  TypeName("field");
44  // Constructors
45 
46  //- Construct from components
48  const word inputName,
49  const word inputType,
50  fvMesh& mesh,
51  const DAOption& daOption,
52  const DAModel& daModel,
53  const DAIndex& daIndex);
54 
55  //- Destructor
56  virtual ~DAInputField()
57  {
58  }
59 
60  virtual void run(const scalarList& input);
61 
62  virtual label size()
63  {
64  if (fieldType_ == "scalar")
65  {
66  if (this->distributed())
67  {
68  return daIndex_.nLocalCells;
69  }
70  else
71  {
72  return daIndex_.nGlobalCells;
73  }
74  }
75  else if (fieldType_ == "vector")
76  {
77  label cSize = indices_.size();
78  if (this->distributed())
79  {
80  return daIndex_.nLocalCells * cSize;
81  }
82  else
83  {
84  return daIndex_.nGlobalCells * cSize;
85  }
86  }
87  else
88  {
89  FatalErrorIn("DAInputField::size") << "fieldType not valid" << exit(FatalError);
90  return -1;
91  }
92  }
93 
94  virtual label distributed()
95  {
96  label distributed = daOption_.getAllOptions().subDict("inputInfo").subDict(inputName_).getLabel("distributed");
97  return distributed;
98  }
99 };
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 } // End namespace Foam
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 #endif
108 
109 // ************************************************************************* //
Foam::DAInputField::size
virtual label size()
Definition: DAInputField.H:62
Foam::DAInputField::TypeName
TypeName("field")
Foam::DAInput::daIndex_
const DAIndex & daIndex_
DAIndex object.
Definition: DAInput.H:57
Foam::DAInputField::fieldType_
word fieldType_
field type, can be either scalar or vector
Definition: DAInputField.H:37
Foam::DAInput::inputName_
const word inputName_
name of the input
Definition: DAInput.H:42
Foam::DAInputField::~DAInputField
virtual ~DAInputField()
Definition: DAInputField.H:56
Foam::DAOption
Definition: DAOption.H:29
DAGlobalVar.H
Foam::DAIndex::nLocalCells
label nLocalCells
local cell size
Definition: DAIndex.H:83
Foam::DAInputField::indices_
labelList indices_
if it is vector fields, we can also provide components/indices
Definition: DAInputField.H:40
Foam::DAInputField::run
virtual void run(const scalarList &input)
Definition: DAInputField.C:51
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::DAInputField::distributed
virtual label distributed()
Definition: DAInputField.H:94
Foam::DAIndex
Definition: DAIndex.H:32
DAInput.H
Foam::DAInput::daOption_
const DAOption & daOption_
DAOption object.
Definition: DAInput.H:51
Foam::DAInputField::fieldName_
word fieldName_
name of the field
Definition: DAInputField.H:34
Foam::DAIndex::nGlobalCells
label nGlobalCells
global cell size
Definition: DAIndex.H:129
Foam::DAModel
Definition: DAModel.H:57
Foam
Definition: checkGeometry.C:32
Foam::DAInput
Definition: DAInput.H:30
Foam::DAInputField::DAInputField
DAInputField(const word inputName, const word inputType, fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex)
Definition: DAInputField.C:19
Foam::DAInputField
Definition: DAInputField.H:28