fvOptionAdjointList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2007-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 
29 Class
30  Foam::fv::optionAdjointList
31 
32 DescriptionAdjoint
33  List of finite volume optionAdjoints
34 
35 SourceFile
36  optionAdjointList.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef optionAdjointList_H
41 #define optionAdjointList_H
42 
43 #include "PtrList.H"
44 #include "GeometricField.H"
45 #include "fvPatchField.H"
46 #include "fvOptionAdjoint.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 namespace fv
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class optionAdjointList Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public PtrList<optionAdjoint>
63 {
64 private:
65 
66  // Private Member Functions
67 
68  //- No copy construct
69  optionAdjointList(const optionAdjointList&) = delete;
70 
71  //- No copy assignment
72  void operator=(const optionAdjointList&) = delete;
73 
74 
75 protected:
76 
77  // Protected data
78 
79  //- Reference to the mesh database
80  const fvMesh& mesh_;
81 
82  //- Time index to check that all defined sources have been applied
83  label checkTimeIndex_;
84 
85 
86  // Protected Member Functions
87 
88  //- Return the "optionAdjoints" sub-dictionary if present otherwise
89  //- return dict
90  const dictionary& optionAdjointsDict(const dictionary& dict) const;
91 
92  //- Read optionAdjoints dictionary
93  bool readOptionAdjoints(const dictionary& dict);
94 
95  //- Check that all sources have been applied
96  void checkApplied() const;
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("optionAdjointList");
103 
104 
105  // Constructors
106 
107  //- Construct null
108  optionAdjointList(const fvMesh& mesh);
109 
110  //- Construct from mesh and dictionary
111  optionAdjointList(const fvMesh& mesh, const dictionary& dict);
112 
113 
114  //- Destructor
115  virtual ~optionAdjointList() = default;
116 
117 
118  // Member Functions
119 
120  //- Reset the source list
121  void reset(const dictionary& dict);
122 
123  //- Correct
124  template<class Type>
126 
127 
128  // Sources
129 
130  //- Return source for equation
131  template<class Type>
132  tmp<fvMatrix<Type>> operator()
133  (
135  );
136 
137  //- Return source for equation with specified name
138  template<class Type>
139  tmp<fvMatrix<Type>> operator()
140  (
142  const word& fieldName
143  );
144 
145  //- Return source for equation
146  template<class Type>
147  tmp<fvMatrix<Type>> operator()
148  (
149  const volScalarField& rho,
151  );
152 
153  //- Return source for equation with specified name
154  template<class Type>
155  tmp<fvMatrix<Type>> operator()
156  (
157  const volScalarField& rho,
159  const word& fieldName
160  );
161 
162  //- Return source for equation
163  template<class Type>
164  tmp<fvMatrix<Type>> operator()
165  (
166  const volScalarField& alpha,
167  const volScalarField& rho,
169  );
170 
171  //- Return source for equation with specified name
172  template<class Type>
173  tmp<fvMatrix<Type>> operator()
174  (
175  const volScalarField& alpha,
176  const volScalarField& rho,
178  const word& fieldName
179  );
180 
181 
182  // Constraints
183 
184  //- Apply constraints to equation
185  template<class Type>
186  void constrain(fvMatrix<Type>& eqn);
187 
188 
189  // I-O
190 
191  //- Read dictionary
192  virtual bool read(const dictionary& dict);
193 
194  //- Write data to Ostream
195  virtual bool writeData(Ostream& os) const;
196 
197  //- Ostream operator
198  friend Ostream& operator<<
199  (
200  Ostream& os,
201  const optionAdjointList& optionAdjoints
202  );
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace fv
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #ifdef NoRepository
215 #endif
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
Foam::fv::optionAdjointList::optionAdjointsDict
const dictionary & optionAdjointsDict(const dictionary &dict) const
Definition: fvOptionAdjointList.C:47
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::fv::optionAdjointList::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOptionAdjointList.H:79
Foam::fv::optionAdjointList::correct
void correct(GeometricField< Type, fvPatchField, volMesh > &fld)
Correct.
Definition: fvOptionAdjointListTemplates.C:34
rho
rho
Definition: readInitialConditions.H:88
Foam::fv::optionAdjointList
Definition: fvOptionAdjointList.H:59
Foam::fv::optionAdjointList::~optionAdjointList
virtual ~optionAdjointList()=default
Destructor.
Foam::fv::optionAdjointList::checkApplied
void checkApplied() const
Check that all sources have been applied.
Definition: fvOptionAdjointList.C:77
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
dict
dictionary dict
Definition: searchingEngine.H:14
fvOptionAdjoint.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::optionAdjointList::readOptionAdjoints
bool readOptionAdjoints(const dictionary &dict)
Read optionAdjoints dictionary.
Definition: fvOptionAdjointList.C:62
GeometricField.H
fv
labelList fv(nPoints)
Foam::fv::optionAdjointList::reset
void reset(const dictionary &dict)
Reset the source list.
Definition: fvOptionAdjointList.C:116
Foam::fv::optionAdjointList::TypeName
TypeName("optionAdjointList")
Runtime type information.
fvOptionAdjointListTemplates.C
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
PtrList.H
Foam::fv::optionAdjointList::writeData
virtual bool writeData(Ostream &os) const
Write data to Ostream.
Definition: fvOptionAdjointList.C:153
Foam::fv::optionAdjointList::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: fvOptionAdjointList.C:147
Foam::fv::optionAdjointList::checkTimeIndex_
label checkTimeIndex_
Time index to check that all defined sources have been applied.
Definition: fvOptionAdjointList.H:82
Foam::fv::optionAdjointList::constrain
void constrain(fvMatrix< Type > &eqn)
Apply constraints to equation.
Definition: fvOptionAdjointListTemplates.C:226
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< Type, fvPatchField, volMesh >
fvPatchField.H