Loading...
Searching...
No Matches
05PODI.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-------------------------------------------------------------------------------
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 PODI Problem
26SourceFiles
27 05PODI.C
28\*---------------------------------------------------------------------------*/
29
30#include "steadyNS.H"
31#include "ITHACAstream.H"
32#include "ITHACAPOD.H"
33#include "forces.H"
34#include "IOmanip.H"
35
36#include "bspline.h"
37#include "rbfspline.h"
38
39
40class tutorial05 : public steadyNS
41{
42 public:
44 explicit tutorial05(int argc, char* argv[])
45 :
46 steadyNS(argc, argv),
47 U(_U()),
48 p(_p())
49 {}
50
52 volVectorField& U;
54 volScalarField& p;
55
58 {
59 Vector<double> inl(0, 0, 0);
60 List<scalar> mu_now(1);
61
62 // if the offline solution is already performed read the fields
63 if (offline)
64 {
65 ITHACAstream::read_fields(Ufield, U, "./ITHACAoutput/Offline/");
66 ITHACAstream::read_fields(Pfield, p, "./ITHACAoutput/Offline/");
68 ITHACAstream::readMatrix("./ITHACAoutput/Offline/mu_samples_mat.txt");
69 }
70 else
71 {
72 Vector<double> Uinl(0, 0, 0);
73
74 for (label i = 0; i < mu.cols(); i++)
75 {
76 mu_now[0] = mu(0, i);
78 assignIF(U, Uinl);
79 truthSolve(mu_now);
80 }
81 }
82 }
83
84};
85
86int main(int argc, char* argv[])
87{
88 // Construct the tutorial object
89 tutorial05 example(argc, argv);
90 // Read some parameters from file
92 example._runTime());
93 int NmodesUout = para->ITHACAdict->lookupOrDefault<int>("NmodesUout", 15);
94 int NmodesPout = para->ITHACAdict->lookupOrDefault<int>("NmodesPout", 15);
95 // Read the par file where the parameters are stored
96 word filename("./par");
97 example.mu = ITHACAstream::readMatrix(filename);
98 // Perform the offline solve
99 example.offlineSolve();
100 // Perform POD on velocity pressure and supremizers and store the first 10 modes
101 ITHACAPOD::getModes(example.Ufield, example.Umodes, example._U().name(),
102 example.podex, 0, 0,
103 NmodesUout);
104 ITHACAPOD::getModes(example.Pfield, example.Pmodes, example._p().name(),
105 example.podex, 0, 0,
106 NmodesPout);
107 exit(0);
108}
int main(int argc, char *argv[])
Definition 05PODI.C:86
Header file of the ITHACAPOD class.
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
IOdictionary * ITHACAdict
Dictionary for input objects from file.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
Eigen::MatrixXd mu_samples
Matrix of parameters to be used for PODI, where each row corresponds to a sample point....
void assignIF(T &s, G &value)
Assign internal field condition.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
Eigen::MatrixXd mu
Row matrix of parameters.
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
Implementation of a parametrized full order steady NS problem and preparation of the the reduced ma...
Definition steadyNS.H:70
void change_viscosity(double mu)
Function to change the viscosity.
Definition steadyNS.C:2014
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
Definition steadyNS.H:86
autoPtr< Time > _runTime
Time.
Definition steadyNS.H:290
volVectorModes Umodes
List of pointers used to form the velocity modes.
Definition steadyNS.H:101
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
Definition steadyNS.H:89
autoPtr< fvMesh > _mesh
Mesh.
Definition steadyNS.H:281
autoPtr< volVectorField > Uinl
Initial dummy field with all Dirichlet boundary conditions.
Definition steadyNS.H:272
autoPtr< volVectorField > _U
Velocity field.
Definition steadyNS.H:263
volScalarModes Pmodes
List of pointers used to form the pressure modes.
Definition steadyNS.H:98
autoPtr< volScalarField > _p
Pressure field.
Definition steadyNS.H:260
void offlineSolve()
Perform an Offline solve.
Definition 05PODI.C:57
volVectorField & U
Velocity field.
Definition 05PODI.C:52
volScalarField & p
Pressure field.
Definition 05PODI.C:54
tutorial05(int argc, char *argv[])
Constructor.
Definition 05PODI.C:44
void getModes(PtrList< GeometricField< Type, PatchField, GeoMesh > > &snapshots, PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, word fieldName, bool podex, bool supex, bool sup, label nmodes, bool correctBC)
Computes the bases or reads them for a field.
Definition ITHACAPOD.C:93
List< Eigen::MatrixXd > readMatrix(word folder, word mat_name)
Read a three dimensional matrix from a txt file in Eigen format.
void read_fields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, word Name, fileName casename, int first_snap, int n_snap)
Function to read a list of fields from the name of the field and casename.
label i
Definition pEqn.H:46
Header file of the steadyNS class.