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