Loading...
Searching...
No Matches
DMD.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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::functionObjects::DMD
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Computes a dynamic mode decomposition model on a specified field.
34
35 Dynamic mode decomposition (i.e. DMD) is a data-driven
36 dimensionality reduction method. DMD is being used as a mathematical
37 processing tool to reveal dominant modes out of a given field (or dataset)
38 each of which is associated with a constant frequency and decay rate,
39 so that dynamic features of a given flow may become interpretable,
40 tractable, and even reproducible without computing simulations.
41 DMD only relies on input data, therefore it is an equation-free approach.
42
43 References:
44 \verbatim
45 DMD characteristics:
46 Brunton S. L. (2018).
47 Dynamic mode decomposition overview.
48 Seattle, Washington: University of Washington.
49 youtu.be/sQvrK8AGCAo (Retrieved:24-04-20)
50 \endverbatim
51
52 Operands:
53 \table
54 Operand | Type | Location
55 input | {vol,surface}<Type>Field(s) | <time>/inputField(s)
56 output file | dat | postProcessing/<FO>/<time>/files
57 output field | volVectorField(s) | <time>/outputField(s)
58 \endtable
59
60 where \c Type can be one of:
61 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
62
63 Output fields:
64 \verbatim
65 modeRe_<modeIndex>_<field>_<FO> | Real part of a mode field
66 modeIm_<modeIndex>_<field>_<FO> | Imaginary part of a mode field
67 \endverbatim
68
69 Output files:
70 \verbatim
71 dynamics_<field>.dat | Dynamics data for each mode
72 filtered_dynamics_<field>.dat | Filtered dynamics data for each mode
73 \endverbatim
74
75 wherein for each mode, the following quantities are output into files:
76 \vartable
77 freq | Frequency
78 mag | Magnitude
79 ampRe | Amplitude coefficients (real part)
80 ampIm | Amplitude coefficients (imaginary part)
81 evalRe | Eigenvalue (real part)
82 evalIm | Eigenvalue (imaginary part)
83 \endvartable
84
85Usage
86 Minimal example by using \c system/controlDict.functions:
87 \verbatim
88 DMDFO
89 {
90 // Mandatory entries
91 type DMD;
92 libs (fieldFunctionObjects);
93 DMDModel <DMDModel>;
94 field <word>;
95
96 // Optional entries
97
98 // Option-1
99 patch <word>;
100
101 // Option-2
102 patches (<wordRes>);
103
104 // Inherited entries
105 ...
106 }
107 \endverbatim
108
109 where the entries mean:
110 \table
111 Property | Description | Type | Reqd | Deflt
112 type | Type name: DMD | word | yes | -
113 libs | Library name: fieldFunctionObjects | word | yes | -
114 DMDModel | Name of specified DMD model | word | yes | -
115 field | Name of operand field | word | yes | -
116 patch | Name of operand patch | word | no | null
117 patches | Names of operand patches | wordRes | no | null
118 \endtable
119
120 Options for the \c DMDModel entry:
121 \verbatim
122 STDMD | Streaming total dynamic mode decomposition
123 \endverbatim
124
125 The inherited entries are elaborated in:
126 - \link functionObject.H \endlink
127 - \link writeFile.H \endlink
128
129Note
130 - Warning: DMD is an active research area at the time of writing;
131 therefore, there could be cases whereat oddities can be seen.
132
133SourceFiles
134 DMD.C
135 DMDTemplates.C
136
137\*---------------------------------------------------------------------------*/
138
139#ifndef Foam_functionObjects_DMD_H
140#define Foam_functionObjects_DMD_H
141
142#include "fvMeshFunctionObject.H"
143#include "RectangularMatrix.H"
144
145// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146
147namespace Foam
148{
149
150// Forward Declarations
151class DMDModel;
152
153namespace functionObjects
154{
155
156/*---------------------------------------------------------------------------*\
157 Class DMD Declaration
158\*---------------------------------------------------------------------------*/
159
160class DMD
161:
163{
164 typedef RectangularMatrix<scalar> RMatrix;
165
166 // Private Data
167
168 //- Dynamic mode decomposition model
169 autoPtr<DMDModel> DMDModelPtr_;
170
171 //- Augmented snapshot matrix (effectively a column vector)
172 // Upper half = current-time snapshot slot
173 // Lower half = previous-time snapshot slot
174 // A snapshot is an input dataset to be processed per execution step
175 // A single snapshot is usually referred to as the snapshot of a single
176 // time step, an augmented snapshot is constructed of two snapshots
177 RMatrix z_;
178
179 //- Names of operand patches
180 const wordRes patches_;
181
182 //- Name of operand field
183 const word fieldName_;
184
185 //- Number of elements in a snapshot
186 label nSnap_;
187
188 //- Current execution-step index of DMD,
189 //- not necessarily that of the simulation
190 label step_;
191
192
193 // Private Member Functions
194
195 // Evaluation
196
197 //- Initialise snapshot at the first-execution step
198 // Initialisation at the ctor or read level is not possible
199 // since the operand field is not available in the database
200 void initialise();
201
202 //- Create operand snapshot by using
203 //- current-time and previous-time operand fields
204 void snapshot();
205
206 //- Get operand field based on its base type
207 template<class Type>
208 bool getSnapshot();
209
210 //- Store operand field based on its geometric
211 //- field type after few manipulations
212 // Move previous-time field into previous-time slot in snapshot
213 // copy new current-time field into current-time slot in snapshot
214 template<class GeoFieldType>
215 bool storeSnapshot();
216
217
218 // Access
219
220 //- Return number of components of the base type of a given field
221 label nComponents(const word& fieldName) const;
222
223 //- Get the number of components of the base type of a given field
224 template<class Type>
225 bool nComponents(const word& fieldName, label& nComps) const;
226
227
228public:
229
230 //- Runtime type information
231 TypeName("DMD");
232
233
234 // Constructors
235
236 //- Construct from name, Time and dictionary
238 (
239 const word& name,
240 const Time& runTime,
241 const dictionary& dict
242 );
243
244 //- No copy construct
245 DMD(const DMD&) = delete;
246
247 //- No copy assignment
248 void operator=(const DMD&) = delete;
249
250
251 //- Destructor
252 virtual ~DMD() = default;
253
254
255 // Member Functions
256
257 //- Read the function-object dictionary
258 virtual bool read(const dictionary& dict);
259
260 //- Execute the function-object operations
261 virtual bool execute();
262
263 //- Write the function-object results
264 virtual bool write();
265
266 //- Write DMD results
267 virtual bool end();
268};
269
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273} // End namespace functionObjects
274} // End namespace Foam
275
276// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277
278#ifdef NoRepository
279 #include "DMDTemplates.C"
280#endif
281
282// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283
284#endif
285
286// ************************************************************************* //
Abstract base class for DMD models to handle DMD characteristics for the DMD function object.
Definition DMDModel.H:65
A templated (M x N) rectangular matrix of objects of <Type>, containing M*N elements,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Computes a dynamic mode decomposition model on a specified field.
Definition DMD.H:240
TypeName("DMD")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition DMD.C:170
virtual ~DMD()=default
Destructor.
DMD(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition DMD.C:127
DMD(const DMD &)=delete
No copy construct.
void operator=(const DMD &)=delete
No copy assignment.
virtual bool execute()
Execute the function-object operations.
Definition DMD.C:183
virtual bool write()
Write the function-object results.
Definition DMD.C:208
virtual bool end()
Write DMD results.
Definition DMD.C:219
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68