Loading...
Searching...
No Matches
27Online.H
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/>.
24Description
25 Example of the hyperreduction of the Smagorinsky term in a ROM
26SourceFiles
27 27SmagorinskyHyperreduction.C
28\*---------------------------------------------------------------------------*/
29
30#include "ITHACAutilities.H"
31#include "ITHACAstream.H"
32#include <Eigen/Eigen>
34
35
36class tutorial27_online
37{
38 public:
39
40 StoredParameters* m_parameters;
41 UnsteadyNSTurb* m_UnsteadyNSTurb;
42
43 Foam::Time runTime2;
44
45 volVectorField* meanU;
46 label nModesU;
47 PtrList<volVectorField> spatialModesU;
48 Eigen::MatrixXd massMatrixInv;
49
50 Eigen::MatrixXd temporalModesUSimulation;
51
52 word interpolatedField;
53 label nModesHR;
54 label nMagicPoints;
55 List<int> magicPoints;
56 labelList localMagicPoints;
57 Eigen::VectorXd weightAtMg;
58 std::vector<volTensorField> defTensorOfModesAtMg;
59
60 int d = 0;
61 float Ck;
62 float Ce;
63
64 volScalarField* nut0=nullptr;
65 volScalarField* delta=nullptr;
66 volScalarField* aaa=nullptr;
67 volScalarField* inv2aaa=nullptr;
68 volTensorField* fullDefField=nullptr;
69 volScalarField* bbb=nullptr;
70 volScalarField* ccc=nullptr;
71 volScalarField* sqrtk=nullptr;
72 volScalarField* nut=nullptr;
73 volVectorField* stressField=nullptr;
74 volVectorField* meanSmagOnMagicNeighborhoods=nullptr;
75 volScalarField* meanNutOnMagicPoints=nullptr;
76
77
78 tutorial27_online(StoredParameters* parameters);
79
80 // Evaluate nut at the magic points
81 void evaluateApproxNut(const Eigen::VectorXd& reducedCoeffs);
82
83 // Compute Smagorinsky term at the magic points
84 Eigen::VectorXd computeApproxSmagMg(const Eigen::VectorXd& reducedCoeffs);
85
86 // Reshape output for nut at the magic points
87 Eigen::VectorXd computeApproxNutMg(const Eigen::VectorXd& reducedCoeffs);
88
89 // Compute the hyperreduction prediction for Smagorinsky
90 Eigen::VectorXd predictSmagROMCoeffs(const Eigen::VectorXd& reducedCoeffs);
91
92 // Compute a vector field onto velocity modes from its reduced temporal modes. Homogenize to a stress if specified.
93 volVectorField computeROMproj_fromCoeffs(const Eigen::VectorXd& reducedCoeffs, bool stressUnit=false);
94
95 // Compute the coefficients of a vector field in the velocity basis (V^T f)
96 Eigen::VectorXd computeROMcoeffs_fromFullDim(volVectorField& f_full);
97
98 // Compute the reference Smagorinsky term (from reduced velocity)
99 volVectorField computeSmagTerm_fromChronos(const Eigen::VectorXd& reducedCoeffs);
100
101 // Perfom the prediction on the test time steps and compare the results to the reference
102 void prediction();
103
104};
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...
Header file of the ITHACAutilities namespace.
Header file of the TurbDiffusionHyperreduction class.
Class that contains all parameters of the stochastic POD.
Implementation of a parametrized full order unsteady NS problem and preparation of the reduced matr...