@@ -4316,29 +4316,15 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) {
43164316// Added by max
43174317void CSolver::ReadVGConfigFile (CConfig* config) {
43184318 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;
43254323
43264324 /* --- Get the vortex generator filename. ---*/
43274325
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;
43424328 filename = config->GetUnsteady_FileName (config->GetVGFileName (), restart_iter, " .cfg" );
43434329
43444330 } else {
@@ -4351,87 +4337,101 @@ void CSolver::ReadVGConfigFile(CConfig* config) {
43514337
43524338 while (std::getline (file, line)) {
43534339 if (line.empty () || line.front () == ' #' ) continue ;
4354- nVgs_file ++;
4355- lines_configVg .push_back (line);
4340+ nVgs ++;
4341+ lines_vgConfig .push_back (line);
43564342 };
43574343 file.close ();
43584344
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+
43594352 /* --- Allocate and compute the required varibales for the vortex generator model ---*/
43604353
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];
43784373 }
43794374
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+ }
43854378
4386- const auto beta = betaVg[iVG] * PI_NUMBER / 180.0 ;
4379+ for (iDim = 0 ; iDim < nDim; iDim++) {
4380+ vg_line >> u[iDim];
4381+ }
43874382
4388- su2double uc[3 ];
4389- GeometryToolbox::CrossProduct (vg_b[iVG], vg_uhat[iVG], uc);
4383+ /* --- Allocate Variable ---*/
43904384
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 ---*/
43954391
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 ;
43994393
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];
44044401 }
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]);
44054407
44064408 /* --- Set variables in CConfig ---*/
44074409
44084410 vg_coord[iVG] = new su2double*[4 ];
44094411
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 ]{p1[ 0 ], p1[ 1 ], p1[ 2 ]};
44114413
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]};
4414+ vg_coord[iVG][1 ] = new su2double[3 ]{p1[0 ] + vg_t [iVG][0 ] * l, p1[1 ] + vg_t [iVG][1 ] * l, p1[2 ] + vg_t [iVG][2 ] * l};
44154415
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]};
4416+ su2double* p2 = vg_coord[iVG][1 ];
44194417
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];
4418+ vg_coord[iVG][2 ] =
4419+ new su2double[3 ]{p2[0 ] + vg_b[iVG][0 ] * h2, p2[1 ] + vg_b[iVG][1 ] * h2, p2[2 ] + vg_b[iVG][2 ] * h2};
4420+
4421+ vg_coord[iVG][3 ] =
4422+ new su2double[3 ]{p1[0 ] + vg_b[iVG][0 ] * h1, p1[1 ] + vg_b[iVG][1 ] * h1, p1[2 ] + vg_b[iVG][2 ] * h1};
4423+
4424+ Svg[iVG] = 0.5 * (h1 + h2) * l;
44254425 };
44264426
4427+ /* --- Set the variables in CConfig ---*/
4428+
44274429 config->Set_nVG (vg_n);
44284430 config->Set_bVG (vg_b);
44294431 config->Set_tVG (vg_t );
44304432 config->SetVGCoord (vg_coord);
44314433 config->Set_Svg (Svg);
4432- config->Set_nVGs (nVgs_file );
4434+ config->Set_nVGs (nVgs );
44334435 config->Set_uhatVg (vg_uhat);
44344436 config->Set_betaVg (betaVg);
4435- }
4436-
4437- // End added by max
4437+ } // End added by max
0 commit comments