DMDModel.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) 2020-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Namespace
27  Foam::DMDModels
28 
29 Description
30  A namespace for various dynamic mode
31  decomposition (DMD) model implementations.
32 
33 Class
34  Foam::DMDModel
35 
36 Description
37  Abstract base class for DMD models to handle DMD
38  characteristics for the \c DMD function object.
39 
40 SourceFiles
41  DMDModel.C
42  DMDModelNew.C
43  DMDModelTemplates.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef DMDModel_H
48 #define DMDModel_H
49 
50 #include "fvMesh.H"
51 #include "dictionary.H"
52 #include "HashSet.H"
53 #include "runTimeSelectionTables.H"
54 #include "writeFile.H"
55 #include "OFstream.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class DMDModel Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class DMDModel
67 :
69 {
72 
73 
74 protected:
75 
76  // Protected Data
77 
78  //- Reference to the mesh
79  const fvMesh& mesh_;
80 
81  //- Name of operand function object
82  const word name_;
83 
84 
85  // Protected Member Functions
86 
87  // Evaluation
88 
89  //- Compute and write mode dynamics
90  virtual bool dynamics() = 0;
91 
92  //- Compute and write modes
93  virtual bool modes() = 0;
94 
95 
96 public:
97 
98  //- Runtime type information
99  TypeName("DMDModel");
100 
101 
102  // Declare runtime constructor selection table
103 
105  (
106  autoPtr,
107  DMDModel,
108  dictionary,
109  (
110  const fvMesh& mesh,
111  const word& name,
112  const dictionary& dict
113  ),
114  (mesh, name, dict)
115  );
116 
117 
118  // Selectors
119 
120  //- Return a reference to the selected DMD model
121  static autoPtr<DMDModel> New
122  (
123  const fvMesh& mesh,
124  const word& name,
125  const dictionary& dict
126  );
127 
128 
129  // Constructors
130 
131  //- Construct from components
132  DMDModel
133  (
134  const fvMesh& mesh,
135  const word& name,
136  const dictionary& dict
137  );
138 
139  //- No copy construct
140  DMDModel(const DMDModel&) = delete;
141 
142  //- No copy assignment
143  void operator=(const DMDModel&) = delete;
144 
145 
146  //- Destructor
147  virtual ~DMDModel() = default;
148 
149 
150  // Member Functions
151 
152  // Process
153 
154  //- Initialise model data members with a given snapshot
155  virtual bool initialise(const RMatrix& snapshot) = 0;
156 
157  //- Update model data members with a given snapshot
158  virtual bool update(const RMatrix& snapshot) = 0;
159 
160  //- Compute and write modes and
161  //- mode dynamics of model data members
162  virtual bool fit() = 0;
163 
164  //- Compute and write a reconstruction of flow field
165  //- based on given modes and mode dynamics (currently no-op)
166  virtual void reconstruct(const wordList modes)
167  {
169  }
170 
171 
172  // Access
173 
174  //- Return number of components of the base type of a given field
175  label nComponents(const word& fieldName) const;
176 
177  //- Get the number of components of the base type of a given field
178  template<class Type>
179  bool nComponents(const word& fieldName, label& nComps) const;
180 
181 
182  // IO
183 
184  //- Read model settings
185  virtual bool read(const dictionary& dict) = 0;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #ifdef NoRepository
196  #include "DMDModelTemplates.C"
197 #endif
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
Foam::DMDModel::~DMDModel
virtual ~DMDModel()=default
Destructor.
Foam::DMDModel::name_
const word name_
Name of operand function object.
Definition: DMDModel.H:81
writeFile.H
Foam::DMDModel::modes
virtual bool modes()=0
Compute and write modes.
DMDModelTemplates.C
Foam::DMDModel::initialise
virtual bool initialise(const RMatrix &snapshot)=0
Initialise model data members with a given snapshot.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::DMDModel::fit
virtual bool fit()=0
Foam::DMDModel::read
virtual bool read(const dictionary &dict)=0
Read model settings.
Foam::DMDModel::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, DMDModel, dictionary,(const fvMesh &mesh, const word &name, const dictionary &dict),(mesh, name, dict))
Foam::DMDModel::New
static autoPtr< DMDModel > New(const fvMesh &mesh, const word &name, const dictionary &dict)
Return a reference to the selected DMD model.
Definition: DMDModelNew.C:33
OFstream.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::DMDModel::reconstruct
virtual void reconstruct(const wordList modes)
Definition: DMDModel.H:165
Foam::DMDModel::update
virtual bool update(const RMatrix &snapshot)=0
Update model data members with a given snapshot.
Foam::DMDModel::DMDModel
DMDModel(const fvMesh &mesh, const word &name, const dictionary &dict)
Construct from components.
Definition: DMDModel.C:42
Foam::RectangularMatrix< scalar >
HashSet.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::DMDModel::operator=
void operator=(const DMDModel &)=delete
No copy assignment.
Foam::DMDModel
Abstract base class for DMD models to handle DMD characteristics for the DMD function object.
Definition: DMDModel.H:65
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::SquareMatrix< scalar >
Foam::DMDModel::dynamics
virtual bool dynamics()=0
Compute and write mode dynamics.
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::List< word >
dictionary.H
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::DMDModel::mesh_
const fvMesh & mesh_
Reference to the mesh.
Definition: DMDModel.H:78
Foam::DMDModel::TypeName
TypeName("DMDModel")
Runtime type information.
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::DMDModel::nComponents
label nComponents(const word &fieldName) const
Return number of components of the base type of a given field.
Definition: DMDModel.C:56