@@ -4316,29 +4316,15 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) {
4316
4316
// Added by max
4317
4317
void CSolver::ReadVGConfigFile (CConfig* config) {
4318
4318
string filename, line;
4319
- unsigned short nVgs_file = 0 ;
4320
- su2double **vg_b, **vg_t , **vg_n, **vg_uhat, ***vg_coord, *Svg, *betaVg;
4321
- su2double bNorm, nNorm, tNorm;
4322
- const unsigned short p1_idx = 4 , l_idx = 0 , h_idx = 1 , nOpt = 13 , un_idx = 7 , u_idx = 10 ;
4323
- vector<string> lines_configVg;
4324
- int restart_iter;
4319
+ unsigned short nVgs = 0 ;
4320
+ vector<string> lines_vgConfig;
4321
+ bool unsteady_restart = config->GetTime_Domain () && config->GetRestart ();
4322
+ bool ts_2nd = config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_2ND;
4325
4323
4326
4324
/* --- Get the vortex generator filename. ---*/
4327
4325
4328
- if (config->GetTime_Domain () && config->GetRestart ()) {
4329
-
4330
- switch (config->GetTime_Marching ())
4331
- {
4332
- case TIME_MARCHING::DT_STEPPING_1ST:
4333
- restart_iter = config->GetRestart_Iter () - 1 ;
4334
- break ;
4335
- case TIME_MARCHING::DT_STEPPING_2ND:
4336
- restart_iter = config->GetRestart_Iter () - 2 ;
4337
- break ;
4338
- default :
4339
- break ;
4340
- }
4341
-
4326
+ if (unsteady_restart) {
4327
+ int restart_iter = config->GetRestart_Iter () - 1 - ts_2nd;
4342
4328
filename = config->GetUnsteady_FileName (config->GetVGFileName (), restart_iter, " .cfg" );
4343
4329
4344
4330
} else {
@@ -4351,87 +4337,113 @@ void CSolver::ReadVGConfigFile(CConfig* config) {
4351
4337
4352
4338
while (std::getline (file, line)) {
4353
4339
if (line.empty () || line.front () == ' #' ) continue ;
4354
- nVgs_file ++;
4355
- lines_configVg .push_back (line);
4340
+ nVgs ++;
4341
+ lines_vgConfig .push_back (line);
4356
4342
};
4357
4343
file.close ();
4358
4344
4345
+ InitializeVGVariables (nVgs, lines_vgConfig, config);
4346
+ }
4347
+
4348
+ void CSolver::InitializeVGVariables (unsigned short nVgs, std::vector<std::string>& lines_vgConfig, CConfig* config) {
4349
+ su2double l, h1, h2, beta, p1[3 ], un[3 ], u[3 ], uc[3 ];
4350
+ unsigned short iDim;
4351
+
4359
4352
/* --- Allocate and compute the required varibales for the vortex generator model ---*/
4360
4353
4361
- vg_b = new su2double*[nVgs_file];
4362
- vg_n = new su2double*[nVgs_file];
4363
- vg_t = new su2double*[nVgs_file];
4364
- vg_uhat = new su2double*[nVgs_file];
4365
- vg_coord = new su2double**[nVgs_file];
4366
- Svg = new su2double[nVgs_file];
4367
- betaVg = new su2double[nVgs_file];
4368
-
4369
- for (unsigned short iVG = 0 ; iVG < nVgs_file; iVG++) {
4370
- istringstream vg_line{lines_configVg[iVG]};
4371
- su2double opt[13 ];
4372
- su2double tmp;
4373
- unsigned short iOpt;
4374
-
4375
- for (iOpt = 0 ; iOpt < nOpt; iOpt++) {
4376
- vg_line >> tmp;
4377
- opt[iOpt] = tmp;
4354
+ su2double** vg_b = new su2double*[nVgs];
4355
+ su2double** vg_n = new su2double*[nVgs];
4356
+ su2double** vg_t = new su2double*[nVgs];
4357
+ su2double** vg_uhat = new su2double*[nVgs];
4358
+ su2double*** vg_coord = new su2double**[nVgs];
4359
+ su2double* Svg = new su2double[nVgs];
4360
+ su2double* betaVg = new su2double[nVgs];
4361
+
4362
+ for (unsigned short iVG = 0 ; iVG < nVgs; iVG++) {
4363
+ /* --- Parse variables ---*/
4364
+ istringstream vg_line{lines_vgConfig[iVG]};
4365
+
4366
+ vg_line >> l;
4367
+ vg_line >> h1;
4368
+ vg_line >> h2;
4369
+ vg_line >> beta;
4370
+
4371
+ for (iDim = 0 ; iDim < nDim; iDim++) {
4372
+ vg_line >> p1[iDim];
4378
4373
}
4379
4374
4380
- betaVg[iVG] = opt[3 ];
4381
- vg_b[iVG] = new su2double[3 ]{opt[un_idx], opt[un_idx + 1 ], opt[un_idx + 2 ]};
4382
- vg_uhat[iVG] = new su2double[3 ]{opt[u_idx], opt[u_idx + 1 ], opt[u_idx + 2 ]};
4383
- vg_n[iVG] = new su2double[3 ]{0 };
4384
- vg_t [iVG] = new su2double[3 ]{0 };
4375
+ for (iDim = 0 ; iDim < nDim; iDim++) {
4376
+ vg_line >> un[iDim];
4377
+ }
4385
4378
4386
- const auto beta = betaVg[iVG] * PI_NUMBER / 180.0 ;
4379
+ for (iDim = 0 ; iDim < nDim; iDim++) {
4380
+ vg_line >> u[iDim];
4381
+ }
4387
4382
4388
- su2double uc[3 ];
4389
- GeometryToolbox::CrossProduct (vg_b[iVG], vg_uhat[iVG], uc);
4383
+ /* --- Allocate Variable ---*/
4390
4384
4391
- for (unsigned short iDim = 0 ; iDim < 3 ; iDim++) {
4392
- vg_t [iVG][iDim] = vg_uhat[iVG][iDim] * cos (beta) + uc[iDim] * sin (beta);
4393
- vg_n[iVG][iDim] = vg_uhat[iVG][iDim] * sin (beta) + uc[iDim] * cos (beta);
4394
- }
4385
+ vg_b[iVG] = new su2double[3 ];
4386
+ vg_uhat[iVG] = new su2double[3 ];
4387
+ vg_n[iVG] = new su2double[3 ];
4388
+ vg_t [iVG] = new su2double[3 ];
4389
+
4390
+ /* --- Compute the VG variables ---*/
4395
4391
4396
- bNorm = GeometryToolbox::Norm (nDim, vg_b[iVG]);
4397
- nNorm = GeometryToolbox::Norm (nDim, vg_n[iVG]);
4398
- tNorm = GeometryToolbox::Norm (nDim, vg_t [iVG]);
4392
+ beta *= PI_NUMBER / 180.0 ;
4399
4393
4400
- for (unsigned short iDim = 0 ; iDim < 3 ; iDim++) {
4401
- vg_t [iVG][iDim] /= tNorm;
4402
- vg_b[iVG][iDim] /= bNorm;
4403
- vg_n[iVG][iDim] /= nNorm;
4394
+ GeometryToolbox::CrossProduct (un, u, uc);
4395
+
4396
+ for (iDim = 0 ; iDim < 3 ; iDim++) {
4397
+ vg_t [iVG][iDim] = u[iDim] * cos (beta) + uc[iDim] * sin (beta);
4398
+ vg_n[iVG][iDim] = u[iDim] * sin (beta) + uc[iDim] * cos (beta);
4399
+ vg_b[iVG][iDim] = un[iDim];
4400
+ vg_uhat[iVG][iDim] = u[iDim];
4404
4401
}
4402
+ betaVg[iVG] = beta;
4403
+
4404
+ GeometryToolbox::NormalizeVector (nDim, vg_t [iVG]);
4405
+ GeometryToolbox::NormalizeVector (nDim, vg_b[iVG]);
4406
+ GeometryToolbox::NormalizeVector (nDim, vg_n[iVG]);
4405
4407
4406
4408
/* --- Set variables in CConfig ---*/
4407
4409
4408
4410
vg_coord[iVG] = new su2double*[4 ];
4409
4411
4410
- vg_coord[iVG][0 ] = new su2double[3 ]{opt[p1_idx], opt[p1_idx + 1 ], opt[p1_idx + 2 ]};
4412
+ vg_coord[iVG][0 ] = new su2double[3 ]{
4413
+ p1[0 ], p1[1 ], p1[2 ]
4414
+ };
4411
4415
4412
- vg_coord[iVG][1 ] = new su2double[3 ]{opt[p1_idx] + vg_t [iVG][0 ] * opt[l_idx],
4413
- opt[p1_idx + 1 ] + vg_t [iVG][1 ] * opt[l_idx],
4414
- opt[p1_idx + 2 ] + vg_t [iVG][2 ] * opt[l_idx]};
4416
+ vg_coord[iVG][1 ] = new su2double[3 ]{
4417
+ p1[0 ] + vg_t [iVG][0 ] * l,
4418
+ p1[1 ] + vg_t [iVG][1 ] * l,
4419
+ p1[2 ] + vg_t [iVG][2 ] * l
4420
+ };
4415
4421
4416
- vg_coord[iVG][2 ] = new su2double[3 ]{vg_coord[iVG][1 ][0 ] + vg_b[iVG][0 ] * opt[h_idx],
4417
- vg_coord[iVG][1 ][1 ] + vg_b[iVG][1 ] * opt[h_idx],
4418
- vg_coord[iVG][1 ][2 ] + vg_b[iVG][2 ] * opt[h_idx]};
4422
+ su2double* p2 = vg_coord[iVG][1 ];
4419
4423
4420
- vg_coord[iVG][3 ] = new su2double[3 ]{opt[p1_idx] + vg_b[iVG][0 ] * opt[h_idx + 1 ],
4421
- opt[p1_idx + 1 ] + vg_b[iVG][1 ] * opt[h_idx + 1 ],
4422
- opt[p1_idx + 2 ] + vg_b[iVG][2 ] * opt[h_idx + 1 ]};
4423
-
4424
- Svg[iVG] = 0.5 * (opt[h_idx] + opt[h_idx + 1 ]) * opt[l_idx];
4424
+ vg_coord[iVG][2 ] = new su2double[3 ]{
4425
+ p2[0 ] + vg_b[iVG][0 ] * h2,
4426
+ p2[1 ] + vg_b[iVG][1 ] * h2,
4427
+ p2[2 ] + vg_b[iVG][2 ] * h2
4428
+ };
4429
+
4430
+ vg_coord[iVG][3 ] = new su2double[3 ]{
4431
+ p1[0 ] + vg_b[iVG][0 ] * h1,
4432
+ p1[1 ] + vg_b[iVG][1 ] * h1,
4433
+ p1[2 ] + vg_b[iVG][2 ] * h1
4434
+ };
4435
+
4436
+ Svg[iVG] = 0.5 * (h1 + h2) * l;
4425
4437
};
4426
4438
4439
+ /* --- Set the variables in CConfig ---*/
4440
+
4427
4441
config->Set_nVG (vg_n);
4428
4442
config->Set_bVG (vg_b);
4429
4443
config->Set_tVG (vg_t );
4430
4444
config->SetVGCoord (vg_coord);
4431
4445
config->Set_Svg (Svg);
4432
- config->Set_nVGs (nVgs_file );
4446
+ config->Set_nVGs (nVgs );
4433
4447
config->Set_uhatVg (vg_uhat);
4434
4448
config->Set_betaVg (betaVg);
4435
- }
4436
-
4437
- // End added by max
4449
+ } // End added by max
0 commit comments