18 explicit msr(
int argc,
char* argv[])
47 volScalarField&
prec1;
48 volScalarField&
prec2;
49 volScalarField&
prec3;
50 volScalarField&
prec4;
51 volScalarField&
prec5;
52 volScalarField&
prec6;
53 volScalarField&
prec7;
54 volScalarField&
prec8;
97 List<scalar> mu_now(3);
98 std::string folder = dir;
100 for (
int i = 0;
i <
mu.cols();
i++)
102 folder.append(std::to_string(
i));
116 mu_now[0] =
mu(0,
i);
117 mu_now[1] =
mu(1,
i);
118 mu_now[2] =
mu(2,
i);
135 explicit Tmlocal(
int argc,
char* argv[],
int Nsampled)
137 Tm(argc, argv, Nsampled),
147 explicit Plocal(
int argc,
char* argv[],
int Nsampled)
149 Ptot(argc, argv, Nsampled),
156int main(
int argc,
char* argv[])
159 msr prova(argc, argv);
168 double nu0 = 2.46E-06;
169 double betatot0 = 321.8E-05;
170 double dlam30 = 3.58e-04;
171 double signu = 0.1 / 3 * nu0;
172 double sigbeta = 0.1 / 3 * betatot0;
173 double sigdlam3 = 0.1 / 3 * dlam30;
176 std::string dist = {
"normal"};
184 double tstart = std::time(0);
185 Eigen::MatrixXd mu_f = prova.
mu;
196 std::string folder = {
"./ITHACAoutput/FOMoutput/"};
199 double tend = std::time(0);
200 double deltat_offline;
201 deltat_offline = difftime(tend, tstart);
205 std::ofstream diff_t(
"./ITHACAoutput/t_SA=" + name(deltat_offline));
208 std::cout <<
"Offline stage time= " << deltat_offline << std::endl;
210 int Nparameters = prova.
Pnumber;
211 int samplingPoints = prova.
Tnumber;
214 analisi.
MatX.col(0) = mu_f.row(0);
215 analisi.
MatX.col(1) = mu_f.row(1);
216 analisi.
MatX.col(2) = mu_f.row(2);
219 Tmlocal TmediaSA(argc, argv, samplingPoints);
220 Plocal PtotSA(argc, argv, samplingPoints);
225 analisi.
M = autoPtr<FofM>(&TmediaSA);
229 std::cout <<
"Mean value and variance of the output:" << std::endl;
230 std::cout << analisi.
Ey <<
"\t" << analisi.
Vy << std::endl;
231 std::cout <<
"-------------" << std::endl;
233 std::cout <<
"analisi regression coefficients:" << std::endl;
234 std::cout << analisi.
betas << std::endl;
235 std::cout <<
"-------------" << std::endl;
237 std::cout <<
"quality: " << analisi.
QI << std::endl;
238 Eigen::MatrixXd saveyout(samplingPoints, 1);
239 Eigen::MatrixXd saveymodel(samplingPoints, 1);
240 saveyout.col(0) = analisi.
y;
241 saveymodel.col(0) = analisi.
ylin;
244 Eigen::MatrixXd coeffsT(4, 3);
246 coeffsT(0, 0) = analisi.
Ey;
247 coeffsT(0, 1) = analisi.
Vy;
248 coeffsT(0, 2) = analisi.
QI;
249 coeffsT.row(1) = analisi.
EX;
250 coeffsT.row(2) = analisi.
VX;
251 coeffsT.row(3) = analisi.
betas;
254 analisi.
M = autoPtr<FofM>(&PtotSA);
258 std::cout <<
"Mean value and variance of the output:" << std::endl;
259 std::cout << analisi.
Ey <<
"\t" << analisi.
Vy << std::endl;
260 std::cout <<
"-------------" << std::endl;
262 std::cout <<
"analisi regression coefficients:" << std::endl;
263 std::cout << analisi.
betas << std::endl;
264 std::cout <<
"-------------" << std::endl;
266 std::cout <<
"quality: " << analisi.
QI << std::endl;
267 Eigen::MatrixXd saveyoutP(samplingPoints, 1);
268 Eigen::MatrixXd saveymodelP(samplingPoints, 1);
269 saveyoutP.col(0) = analisi.
y;
270 saveymodelP.col(0) = analisi.
ylin;
273 Eigen::MatrixXd coeffsP(4, 3);
275 coeffsP(0, 0) = analisi.
Ey;
276 coeffsP(0, 1) = analisi.
Vy;
277 coeffsP(0, 2) = analisi.
QI;
278 coeffsP.row(1) = analisi.
EX;
279 coeffsP.row(2) = analisi.
VX;
280 coeffsP.row(3) = analisi.
betas;
int main(int argc, char *argv[])
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.
static Eigen::VectorXd samplingMC(std::string pdftype, double &lowerE, double &upperE, double &distpara1, double &distpara2, label &Npoints)
void getYstat()
Method to compute Ey and Vy, it sets Ydone=true.
void getXstats()
Method to compute EX and VX, it sets Xdone=true.
double Vy
Variance of the output.
Eigen::VectorXd y
Vectors to store the output of the model.
double QI
double to quantify the goodness of linear regression from 0 (no linearity) to 1 (perfect linearity) a...
Eigen::MatrixXd MatX
Matrices storing the independent variables' values.
Eigen::VectorXd VX
Vector to store the variances of the parameters.
double Ey
Mean value of the output.
void getBetas()
Method to compute SRCs, it sets bdone=true.
void load_output()
Method to load the output of FOM/ROM inside member LRsensitivity member y.
Eigen::VectorXd ylin
Vector to store the result of linear approximation.
Eigen::VectorXd betas
Vector to store the standardized regression coefficient (SRC)
void assessQuality()
Method to compute the quality of linear regression approximation.
Eigen::VectorXd EX
Vector to store the meanvalues of the parameters.
autoPtr< FofM > M
Figure of merit object.
volScalarField & powerDens
Plocal(int argc, char *argv[], int Nsampled)
void buildMO(std::string dir)
Method that computes the total power at the last time instant of the simulation, output are sought in...
autoPtr< volScalarField > _powerDens
List of pointers to power density field.
void buildMO(std::string dir)
Method that computes the average temperature (integral average) at the last time instant of the simul...
autoPtr< volScalarField > _T
List of pointers to temperature field.
Tmlocal(int argc, char *argv[], int Nsampled)
autoPtr< dimensionedScalar > _betaTot
autoPtr< volScalarField > _NSF
autoPtr< volScalarField > _prec8
autoPtr< volScalarField > _dec3
autoPtr< volScalarField > _SP
autoPtr< volScalarField > _T
autoPtr< dimensionedScalar > _beta8
autoPtr< volScalarField > _dec2
autoPtr< dimensionedScalar > _beta5
autoPtr< volScalarField > _prec2
autoPtr< volScalarField > _prec4
autoPtr< dimensionedScalar > _beta2
void change_viscosity(double mu)
method to change the viscosity in UEqn
autoPtr< dimensionedScalar > _beta3
void readMSRfields()
Method to read all the fieds of the MSR problem in the offline folder, it also reads mu_samples matri...
autoPtr< volVectorField > _U
autoPtr< dimensionedScalar > _beta7
autoPtr< dimensionedScalar > _beta1
autoPtr< dimensionedScalar > _decLam3
autoPtr< volScalarField > _prec5
autoPtr< volScalarField > _v
autoPtr< dimensionedScalar > _beta4
autoPtr< volScalarField > _prec3
autoPtr< volScalarField > _prec6
autoPtr< volScalarField > _D
autoPtr< volScalarField > _prec7
autoPtr< dimensionedScalar > _nu
autoPtr< volScalarField > _TXS
autoPtr< volScalarField > _p
void restart()
method to set all fields back to values in 0 folder
autoPtr< volScalarField > _prec1
autoPtr< volScalarField > _flux
autoPtr< volScalarField > _A
autoPtr< dimensionedScalar > _beta6
autoPtr< volScalarField > _dec1
void offlineSolve(std::string dir)
msr(int argc, char *argv[])
label Pnumber
Number of parameters.
label Tnumber
Dimension of the training set (used only when gerating parameters without input)
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
Eigen::MatrixXd mu
Row matrix of parameters.
Eigen::MatrixXd mu_range
Range of the parameter spaces.
void setParameters()
Set Parameters Problems.
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
void truthSolve()
Perform a TruthSolve.
void exportMatrix(Eigen::Matrix< T, -1, dim > &matrix, word Name, word type, word folder)
Export the reduced matrices in numpy (type=python), matlab (type=matlab) and txt (type=eigen) format ...
List< Eigen::MatrixXd > readMatrix(word folder, word mat_name)
Read a three dimensional matrix from a txt file in Eigen format.