Loading...
Searching...
No Matches
HyperReducedCompressibleUnSteadyNS.C
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-------------------------------------------------------------------------------
12
13License
14 This file is part of ITHACA-FV
15
16 ITHACA-FV is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 ITHACA-FV is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU Lesser General Public License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
28
29\*---------------------------------------------------------------------------*/
30
33
35
36// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
37
38// Constructor
42
45 :
46 problem(&FOMproblem)
47{
48 for (int i = 0; i < problem->Umodes.size(); i++)
49 {
50 Umodes.append((problem->Umodes.toPtrList()[i]).clone());
51 }
52
53 for (int i = 0; i < problem->Pmodes.size(); i++)
54 {
55 Pmodes.append((problem->Pmodes.toPtrList()[i]).clone());
56 }
57
58 for (int i = 0; i < problem->Emodes.size(); i++)
59 {
60 Emodes.append((problem->Emodes.toPtrList()[i]).clone());
61 }
62
63 //problem->restart();
64 Info << "################ HyperReduced Ctor called ##################" <<
65 endl;
66}
67
68
69
70// * * * * * * * * * * * * * * * Solve Functions * * * * * * * * * * * * * //
71
73 int NmodesPproj,
74 int NmodesEproj,
75 fileName folder)
76{
77 Time& runTime = problem->_runTime();
78 volVectorField& U = problem->_U();
79 volScalarField& p = problem->pThermo().p();
80 volScalarField& E = problem->pThermo().he();
81 pimpleControl& pimple = problem->_pimple();
82 volScalarField _nut(problem->turbulence->nut());
83 instantList Times = runTime.times();
84 runTime.setEndTime(finalTime);
85 runTime.setTime(Times[1], 1);
86 runTime.setDeltaT(timeStep);
87 nextWrite = startTime; // timeStep initialization
88 int counter = 1;
89 bool correctPhi = problem->correctPhi;
90 bool checkMeshCourantNo = problem->checkMeshCourantNo;
91 bool moveMeshOuterCorrectors = problem->moveMeshOuterCorrectors;
92 scalar cumulativeContErr = problem->cumulativeContErr;
93#include "HyperRedSolvers.H"
94}
95std::tuple<Eigen::MatrixXd, Eigen::VectorXd>
97 S,
98 Eigen::VectorXd& se,
99 List<label>& uniqueMagicPoints,
100 Eigen::MatrixXd& Modes)
101{
102 dynamicFvMesh& mesh = problem->meshPtr();
103 int s = uniqueMagicPoints.size();
104 Eigen::MatrixXd B;
105 int m = Modes.cols(); // number of modes
106 B.setZero(s, m);
107 Eigen::VectorXd b;
108 b.setZero(s);
109
110 for (int k = 0; k < uniqueMagicPoints.size(); ++k)
111 {
112 int magicPoint = uniqueMagicPoints[k];
113 Eigen::SparseVector<double> vec = S.row(magicPoint);
114 Eigen::RowVectorXd tempB = Eigen::RowVectorXd::Zero(m);
115
116 for (Eigen::SparseVector<double>::InnerIterator it(vec); it; ++it)
117 {
118 tempB += it.value() * Modes.row(it.index());
119 }
120
121 // Apply scaling by volume
122 double volume = 1.0 / mesh.V()[magicPoint];
123 B.row(k) = tempB * volume;
124 b(k) = volume * se(magicPoint);
125 }
126
127 std::tuple<Eigen::MatrixXd, Eigen::VectorXd> HRSys;
128 HRSys = std::make_tuple(B, b);
129 return HRSys;
130}
132{
133 scalar diffnow = mag(nextWrite - atof(timeObject.timeName().c_str()));
134 scalar diffnext = mag(nextWrite - atof(timeObject.timeName().c_str()) -
135 timeObject.deltaTValue());
136
137 if ( diffnow < diffnext)
138 {
139 return true;
140 }
141 else
142 {
143 return false;
144 }
145}
146
147
148// void HyperReducedCompressibleUnSteadyNS::setOnlineVelocity(Eigen::MatrixXd vel)
149// {
150// M_Assert(problem->inletIndex.rows() == vel.size(),
151// "Imposed boundary conditions dimensions do not match given values matrix dimensions into setOnlineVelocity");
152// Eigen::MatrixXd vel_scal;
153// vel_scal.resize(vel.rows(), vel.cols());
154
155// for (int k = 0; k < problem->inletIndex.rows(); k++)
156// {
157// label p = problem->inletIndex(k, 0);
158// label l = problem->inletIndex(k, 1);
159// scalar area = gSum(problem->liftfield[0].mesh().magSf().boundaryField()[p]);
160// scalar u_lf = gSum(problem->liftfield[k].mesh().magSf().boundaryField()[p] *
161// problem->liftfield[k].boundaryField()[p]).component(l) / area;
162// vel_scal(k, 0) = vel(k, 0) / u_lf;
163// }
164
165// vel_now = vel_scal;
166// }
167
168
169// void HyperReducedCompressibleUnSteadyNS::projectReducedOperators(int NmodesUproj, int NmodesPproj, int NmodesEproj)
170// {
171// PtrList<volVectorField> gradModP;
172// for (label i = 0; i < NmodesPproj; i++)
173// {
174// gradModP.append(fvc::grad(problem->Pmodes[i]));
175// }
176// projGradModP = problem->Umodes.project(gradModP, NmodesUproj);
177// }
Header file of the reducedSteadyNS class.
Implementation of a parametrized full order Compressible UnSteady Pimple and preparation of the the...
std::tuple< Eigen::MatrixXd, Eigen::VectorXd > HyperReducedSys(Eigen::SparseMatrix< double > &S, Eigen::VectorXd &se, List< label > &MagicPoints, Eigen::MatrixXd &Modes)
It assembles the reduced oeprators using the modes.
bool checkWrite(Time &timeObject)
Method to check and write solutions.
void SolveHyperReducedSys(int NmodesUproj, int NmodesPproj, int NmodesEproj, fileName folder="./ITHACAoutput/Online/")
Method to perform an online solve using a PPE stabilisation method.
CompressibleUnSteadyRhoPimple * problem
Full problem.
Implementation of a container class derived from PtrList.
Definition Modes.H:69