DAFvSource.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6  Description:
7  Compute the source term (e.g., actuator disk) for the primal
8  governing equations
9 
10 \*---------------------------------------------------------------------------*/
11 
12 #ifndef DAFvSource_H
13 #define DAFvSource_H
14 
15 #include "runTimeSelectionTables.H"
16 #include "fvOptions.H"
17 #include "surfaceFields.H"
18 #include "DAOption.H"
19 #include "DAModel.H"
20 #include "DAIndex.H"
21 #include "topoSetSource.H"
22 #include "topoSet.H"
23 #include "regIOobject.H"
24 
25 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
26 
27 namespace Foam
28 {
29 
30 /*---------------------------------------------------------------------------*\
31  Class DAFvSource Declaration
32 \*---------------------------------------------------------------------------*/
33 
35  : public regIOobject
36 {
37 
38 private:
40  DAFvSource(const DAFvSource&);
41 
43  void operator=(const DAFvSource&);
44 
45 protected:
47  const word& modelType_;
48 
50  const fvMesh& mesh_;
51 
54 
56  const DAModel& daModel_;
57 
59  const DAIndex& daIndex_;
60 
62  HashTable<List<scalar>> actuatorDiskDVs_;
63 
64 public:
66  TypeName("DAFvSource");
67 
68  // Declare run-time constructor selection table
70  autoPtr,
71  DAFvSource,
72  dictionary,
73  (const word modelType,
74  const fvMesh& mesh,
75  const DAOption& daOption,
76  const DAModel& daModel,
77  const DAIndex& daIndex),
78  (modelType, mesh, daOption, daModel, daIndex));
79 
80  // Constructors
81 
82  //- Construct from components
83  DAFvSource(
84  const word modelType,
85  const fvMesh& mesh,
86  const DAOption& daOption,
87  const DAModel& daModel,
88  const DAIndex& daIndex);
89 
90  // Selectors
91 
92  //- Return a reference to the selected model
93  static autoPtr<DAFvSource> New(
94  const word modelType,
95  const fvMesh& mesh,
96  const DAOption& daOption,
97  const DAModel& daModel,
98  const DAIndex& daIndex);
99 
100  //- Destructor
101  virtual ~DAFvSource()
102  {
103  }
104 
106  virtual void calcFvSource(volVectorField& fvSource);
107 
110  const word diskName,
111  const label dvI,
112  const scalar val)
113  {
114  actuatorDiskDVs_[diskName][dvI] = val;
115  }
116 
119  const word diskName,
120  const label dvI)
121  {
122  return actuatorDiskDVs_[diskName][dvI];
123  }
124 
127  {
128  volVectorField& fvSource = const_cast<volVectorField&>(
129  mesh_.thisDb().lookupObject<volVectorField>("fvSource"));
130  this->calcFvSource(fvSource);
131  }
132 
135 
137  bool writeData(Ostream& os) const;
138 };
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace Foam
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
Foam::DAFvSource::writeData
bool writeData(Ostream &os) const
virtual function for regIOobject
Definition: DAFvSource.C:103
Foam::DAFvSource
Definition: DAFvSource.H:34
DAOption.H
Foam::DAFvSource::actuatorDiskDVs_
HashTable< List< scalar > > actuatorDiskDVs_
the list of design variables for all the actuator disks
Definition: DAFvSource.H:62
Foam::DAFvSource::syncDAOptionToActuatorDVs
void syncDAOptionToActuatorDVs()
synchronize the values in DAOption and actuatorDiskDVs_
Definition: DAFvSource.C:113
Foam::DAFvSource::daOption_
const DAOption & daOption_
DAOption object.
Definition: DAFvSource.H:53
DAIndex.H
Foam::DAOption
Definition: DAOption.H:29
daOption
DAOption daOption(mesh, pyOptions_)
Foam::DAFvSource::calcFvSource
virtual void calcFvSource(volVectorField &fvSource)
compute the FvSource term
Definition: DAFvSource.C:90
Foam::DAFvSource::daIndex_
const DAIndex & daIndex_
DAIndex object.
Definition: DAFvSource.H:59
Foam::DAFvSource::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, DAFvSource, dictionary,(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex),(modelType, mesh, daOption, daModel, daIndex))
fvSource
volScalarField & fvSource
Definition: createRefsHeatTransfer.H:7
DAModel.H
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAIndex
Definition: DAIndex.H:32
Foam::DAFvSource::updateFvSource
void updateFvSource()
calculate fvSource based on the latest actuatorDVs
Definition: DAFvSource.H:126
Foam::DAFvSource::TypeName
TypeName("DAFvSource")
Runtime type information.
Foam::DAFvSource::~DAFvSource
virtual ~DAFvSource()
Definition: DAFvSource.H:101
Foam::DAFvSource::New
static autoPtr< DAFvSource > New(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex)
Definition: DAFvSource.C:47
Foam::DAModel
Definition: DAModel.H:59
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::DAFvSource::modelType_
const word & modelType_
model name
Definition: DAFvSource.H:47
Foam::DAFvSource::getActuatorDVs
scalar getActuatorDVs(const word diskName, const label dvI)
get the value from the actuator disk design variable
Definition: DAFvSource.H:118
Foam::DAFvSource::setActuatorDVs
void setActuatorDVs(const word diskName, const label dvI, const scalar val)
set a new value to the actuator disk design variable
Definition: DAFvSource.H:109
Foam::DAFvSource::mesh_
const fvMesh & mesh_
fvMesh
Definition: DAFvSource.H:50
daModel
DAModel daModel(mesh, daOption)
daIndex
DAIndex daIndex(mesh, daOption, daModel)
Foam::DAFvSource::daModel_
const DAModel & daModel_
DAModel object.
Definition: DAFvSource.H:56