Loading...
Searching...
No Matches
DEIM.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12License
13 This file is part of ITHACA-FV
14 ITHACA-FV is free software: you can redistribute it and/or modify
15 it under the terms of the GNU Lesser General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18 ITHACA-FV is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
24Class
25 DEIM
26Description
27 Implementation of the discrete empirical interpolation method
28SourceFiles
29 DEIM.C
30\*---------------------------------------------------------------------------*/
31#include "fvCFD.H"
32#include "ITHACAPOD.H"
33#include "Foam2Eigen.H"
34#include "EigenFunctions.H"
35#include "ITHACAutilities.H"
36#include "fvMeshSubset.H"
37
38
39template<typename T>
40class DEIM
41{
42 public:
43
44 //----------------------------------------------------------------------
52 DEIM (PtrList<T>& SnapShotsMatrix, label MaxModes, word FunctionName,
53 word FieldName);
54
55 //----------------------------------------------------------------------
63 DEIM (PtrList<T>& SnapShotsMatrix, label MaxModesA, label MaxModesB,
64 word MatrixName);
65
67 PtrList<T> SnapShotsMatrix;
68
70 PtrList<T> modes;
71
73 std::tuple<List<Eigen::SparseMatrix<double>>, List<Eigen::VectorXd>>
75
77 label MaxModes;
78 label MaxModesA;
79 label MaxModesB;
80
83
85 double tolerance;
86
89 Eigen::VectorXd theta;
90 Eigen::VectorXd thetaA;
91 Eigen::VectorXd thetaB;
93
95 label Ncells;
96
98 bool source;
99
102
104 Eigen::MatrixXd MatrixModes;
105
108 Eigen::MatrixXd MatrixOnline;
109 List<Eigen::SparseMatrix<double>> MatrixOnlineA;
110 Eigen::MatrixXd MatrixOnlineB;
112
115 Eigen::MatrixXd U;
116 List<Eigen::SparseMatrix<double>> UA;
117 Eigen::MatrixXd UB;
119
121 autoPtr<IOList<label>> magicPoints;
123 autoPtr<IOList<label>> magicPointsArow;
125 autoPtr<IOList<label>> magicPointsAcol;
127 autoPtr<IOList<label>> magicPointsB;
128
131 autoPtr<IOList<labelList>> totalMagicPoints;
132 autoPtr<IOList<labelList>> totalMagicPointsA;
133 autoPtr<IOList<labelList>> totalMagicPointsB;
135
138 autoPtr<IOList<label>> uniqueMagicPoints;
139 autoPtr<IOList<label>> uniqueMagicPointsA;
140 autoPtr<IOList<label>> uniqueMagicPointsB;
142
144 word Folder;
147
151 autoPtr<IOList<label>> xyz;
152 autoPtr<IOList<label>> xyz_Arow;
153 autoPtr<IOList<label>> xyz_Acol;
154 autoPtr<IOList<label>> xyz_B;
156
159 List<label> localMagicPoints;
162 List<label> localMagicPointsB;
164
167 Eigen::SparseMatrix<double> P;
168 List<Eigen::SparseMatrix<double>> PA;
169 Eigen::SparseMatrix<double> PB;
171
174 autoPtr<fvMeshSubset> submesh;
175 autoPtr<fvMeshSubset> submeshA;
176 autoPtr<fvMeshSubset> submeshB;
178
185
186 //----------------------------------------------------------------------
198 template <class S>
199 S generateSubmesh(label layers, const fvMesh& mesh, S field,
200 label secondTime = 0);
201
202 //----------------------------------------------------------------------
214 template <class S>
215 S generateSubmeshMatrix(label layers, const fvMesh& mesh, S field,
216 label secondTime = 0);
217
218 //----------------------------------------------------------------------
229 template <class S>
230 S generateSubmeshVector(label layers, const fvMesh& mesh, S field,
231 label secondTime = 0);
232
233 //----------------------------------------------------------------------
242 template <class F>
243 F generateSubField(F& field);
244
245 //----------------------------------------------------------------------
254 template <class F>
255 F generateSubFieldMatrix(F& field);
256
257 //----------------------------------------------------------------------
266 template <class F>
267 F generateSubFieldVector(F& field);
268
269 //----------------------------------------------------------------------
273
274 //----------------------------------------------------------------------
282 List<label> global2local(List<label>& points,
283 fvMeshSubset& submesh);
284
285 //----------------------------------------------------------------------
293 void check3DIndices(label& ind_rowA, label& ind_colA, label& xyz_rowA,
294 label& xyz_colA);
295
296 //----------------------------------------------------------------------
302 void check3DIndices(label& ind_rowA, label& xyz_rowA);
303
304 //----------------------------------------------------------------------
311 label getNcells(label sizeM);
312
313 //----------------------------------------------------------------------
319 void setMagicPoints(labelList& newMagicPoints, labelList& newxyz);
320
321};
Header file of the EigenFunctions class.
Header file of the Foam2Eigen class.
Header file of the ITHACAPOD class.
Foam::fvMesh & mesh
Definition createMesh.H:47
Header file of the ITHACAutilities namespace.
Definition DEIM.H:41
autoPtr< fvMeshSubset > submeshA
Submesh of the DEIM method.
Definition DEIM.H:175
Eigen::VectorXd theta
Online vector.
Definition DEIM.H:89
autoPtr< IOList< label > > magicPointsAcol
Magic points in the case of the a matrix function (cols indices)
Definition DEIM.H:125
Eigen::VectorXd thetaA
Online vector.
Definition DEIM.H:90
autoPtr< fvMeshSubset > submesh
Submesh of the DEIM method.
Definition DEIM.H:174
autoPtr< IOList< label > > xyz
Definition of the x, y, z coordinate of the identified element in the matrix or source term 0 for x,...
Definition DEIM.H:151
label MaxModes
The maximum number of modes to be considered.
Definition DEIM.H:77
Eigen::VectorXd thetaB
Online vector.
Definition DEIM.H:91
List< label > localMagicPointsAcol
Indices of the local magic points in the subMesh.
Definition DEIM.H:161
S generateSubmesh(label layers, const fvMesh &mesh, S field, label secondTime=0)
Function to generate the submesh for the nonlinear function case.
Definition DEIM.C:357
S generateSubmeshMatrix(label layers, const fvMesh &mesh, S field, label secondTime=0)
Function to generate the submesh for the nonlinear matrix function case (RHS)
Definition DEIM.C:450
Eigen::MatrixXd MatrixOnlineB
Online Matrices.
Definition DEIM.H:110
autoPtr< IOList< label > > uniqueMagicPointsA
List of unique indices that define the submesh.
Definition DEIM.H:139
List< label > localMagicPointsB
Indices of the local magic points in the subMesh.
Definition DEIM.H:162
S generateSubmeshVector(label layers, const fvMesh &mesh, S field, label secondTime=0)
Function to generate the submesh for the nonlinear matrix function case (LHS)
Definition DEIM.C:543
bool source
source
Definition DEIM.H:98
autoPtr< IOList< label > > magicPoints
Magic points in the case of the a nonlinear function.
Definition DEIM.H:121
List< Eigen::SparseMatrix< double > > UA
The U matrix of the DEIM method.
Definition DEIM.H:116
autoPtr< IOList< label > > xyz_Acol
Definition of the x, y, z coordinate of the identified element in the matrix or source term 0 for x,...
Definition DEIM.H:153
word MatrixName
The name of the matrix.
Definition DEIM.H:101
Eigen::MatrixXd U
The U matrix of the DEIM method.
Definition DEIM.H:115
DEIM(PtrList< T > &SnapShotsMatrix, label MaxModes, word FunctionName, word FieldName)
Construct DEIM for non-linear function.
Definition DEIM.C:34
autoPtr< IOList< labelList > > totalMagicPointsA
Magic points and indices of the surrounding layers.
Definition DEIM.H:132
List< label > localMagicPoints
Indices of the local magic points in the subMesh.
Definition DEIM.H:159
F generateSubFieldVector(F &field)
Function to generate a a subfield in the location of the magic points computed for the Matrix (RHS)
Definition DEIM.C:734
autoPtr< IOList< labelList > > totalMagicPointsB
Magic points and indices of the surrounding layers.
Definition DEIM.H:133
label MaxModesA
Definition DEIM.H:78
Eigen::MatrixXd MatrixModes
The matrix containing the modes.
Definition DEIM.H:104
List< label > localMagicPointsArow
Indices of the local magic points in the subMesh.
Definition DEIM.H:160
autoPtr< IOList< label > > magicPointsArow
Magic points in the case of the a matrix function (rows indices)
Definition DEIM.H:123
word Folder
Folder for nonlinear functions.
Definition DEIM.H:144
std::tuple< List< Eigen::SparseMatrix< double > >, List< Eigen::VectorXd > > Matrix_Modes
Matrix Modes.
Definition DEIM.H:74
PtrList< T > modes
The POD modes of the DEIM procedure that can be.
Definition DEIM.H:70
word FolderM
Folder in the matrix case.
Definition DEIM.H:146
void check3DIndices(label &ind_rowA, label &ind_colA, label &xyz_rowA, label &xyz_colA)
check3DIndices in case of three dimensional fields
Definition DEIM.C:659
Eigen::SparseMatrix< double > P
The P matrix of the DEIM method.
Definition DEIM.H:167
autoPtr< IOList< label > > uniqueMagicPoints
List of unique indices that define the submesh.
Definition DEIM.H:138
F generateSubField(F &field)
Function to generate a a subfield in the location of the magic points.
Definition DEIM.C:714
autoPtr< IOList< label > > xyz_Arow
Definition of the x, y, z coordinate of the identified element in the matrix or source term 0 for x,...
Definition DEIM.H:152
Eigen::MatrixXd MatrixOnline
Online Matrices.
Definition DEIM.H:108
autoPtr< IOList< label > > uniqueMagicPointsB
List of unique indices that define the submesh.
Definition DEIM.H:140
bool runSubMesh
Bool variable to check if the SubMesh is available.
Definition DEIM.H:181
autoPtr< fvMeshSubset > submeshB
Submesh of the DEIM method.
Definition DEIM.H:176
List< Eigen::SparseMatrix< double > > MatrixOnlineA
Online Matrices.
Definition DEIM.H:109
label MaxModesB
Definition DEIM.H:79
label getNcells(label sizeM)
get the number of cells from the dimension of a LHS matrix
void onlineCoeffs()
Function to get the onlineCoeffs of the DEIM approx.
autoPtr< IOList< label > > xyz_B
Definition of the x, y, z coordinate of the identified element in the matrix or source term 0 for x,...
Definition DEIM.H:154
F generateSubFieldMatrix(F &field)
Function to generate a a subfield in the location of the magic points computed for the Matrix (LHS)
Definition DEIM.C:724
autoPtr< IOList< label > > magicPointsB
Magic points in the case of the a matrix function, right hand side.
Definition DEIM.H:127
double tolerance
A given tolerance.
Definition DEIM.H:85
Eigen::SparseMatrix< double > PB
The P matrix of the DEIM method.
Definition DEIM.H:169
void setMagicPoints(labelList &newMagicPoints, labelList &newxyz)
Function to set the magic points externally.
Definition DEIM.C:756
PtrList< T > SnapShotsMatrix
The snapshots matrix containing the nonlinear function or operator.
Definition DEIM.H:67
autoPtr< IOList< labelList > > totalMagicPoints
Magic points and indices of the surrounding layers.
Definition DEIM.H:131
label Ncells
Int Number of Cells;.
Definition DEIM.H:95
Eigen::MatrixXd UB
The U matrix of the DEIM method.
Definition DEIM.H:117
word FunctionName
The name of the non-linear function.
Definition DEIM.H:82
List< Eigen::SparseMatrix< double > > PA
The P matrix of the DEIM method.
Definition DEIM.H:168
List< label > global2local(List< label > &points, fvMeshSubset &submesh)
Get local indices in the submeshe from indices in the global ones.
Definition DEIM.C:638
bool runSubMeshA
Bool variable to check if the SubMesh is available.
Definition DEIM.H:182
bool runSubMeshB
Bool variable to check if the SubMesh is available.
Definition DEIM.H:183
volScalarField S(IOobject("S", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), T.mesh(), dimensionedScalar("zero", dimensionSet(0, 0, -1, 1, 0, 0, 0), 0))