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  // Evaluation
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  // I-O
173 
174  //- Read model settings
175  virtual bool read(const dictionary& dict) = 0;
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
TypeName("DMDModel")
Runtime type information.
DMDModel(const fvMesh &mesh, const word &name, const dictionary &dict)
Construct from components.
Definition: DMDModel.C:35
virtual bool modes()=0
Compute and write modes.
virtual bool dynamics()=0
Compute and write mode dynamics.
const word name_
Name of operand function object.
Definition: DMDModel.H:82
virtual bool initialise(const RMatrix &snapshot)=0
Initialise model data members with a given snapshot.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool fit()=0
Compute and write modes and mode dynamics of model data members.
virtual bool read(const dictionary &dict)=0
Read model settings.
const fvMesh & mesh_
Reference to the mesh.
Definition: DMDModel.H:77
virtual ~DMDModel()=default
Destructor.
virtual void reconstruct(const wordList modes)
Compute and write a reconstruction of flow field based on given modes and mode dynamics (currently no...
Definition: DMDModel.H:190
virtual bool update(const RMatrix &snapshot)=0
Update model data members with a given snapshot.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Abstract base class for DMD models to handle DMD characteristics for the DMD function object...
Definition: DMDModel.H:62
Macros to ease declaration of run-time selection tables.
declareRunTimeSelectionTable(autoPtr, DMDModel, dictionary,(const fvMesh &mesh, const word &name, const dictionary &dict),(mesh, name, dict))
Base class for writing single files from the function objects.
Definition: writeFile.H:112
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
static autoPtr< DMDModel > New(const fvMesh &mesh, const word &name, const dictionary &dict)
Return a reference to the selected DMD model.
Definition: DMDModelNew.C:26
void operator=(const DMDModel &)=delete
No copy assignment.
Namespace for OpenFOAM.