@@ -895,41 +895,24 @@ void CAdjEulerSolver::SetForceProj_Vector(CGeometry *geometry, CSolver **solver_
895895}
896896
897897void CAdjEulerSolver::SetInitialCondition (CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) {
898- unsigned long iPoint, Point_Fine;
899- unsigned short iMesh, iChildren, iVar;
900- su2double Area_Children, Area_Parent, *Solution, *Solution_Fine;
901898
902- bool restart = config->GetRestart ();
903- bool dual_time = ((config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_1ST) ||
904- (config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_2ND));
899+ const bool restart = config->GetRestart ();
900+ const bool dual_time = ((config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_1ST) ||
901+ (config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_2ND));
905902
906903 /* --- If restart solution, then interpolate the flow solution to
907904 all the multigrid levels, this is important with the dual time strategy ---*/
908905 if (restart) {
909- Solution = new su2double[nVar];
910- for (iMesh = 1 ; iMesh <= config->GetnMGLevels (); iMesh++) {
911- for (iPoint = 0 ; iPoint < geometry[iMesh]->GetnPoint (); iPoint++) {
912- Area_Parent = geometry[iMesh]->nodes ->GetVolume (iPoint);
913- for (iVar = 0 ; iVar < nVar; iVar++) Solution[iVar] = 0.0 ;
914- for (iChildren = 0 ; iChildren < geometry[iMesh]->nodes ->GetnChildren_CV (iPoint); iChildren++) {
915- Point_Fine = geometry[iMesh]->nodes ->GetChildren_CV (iPoint, iChildren);
916- Area_Children = geometry[iMesh-1 ]->nodes ->GetVolume (Point_Fine);
917- Solution_Fine = solver_container[iMesh-1 ][ADJFLOW_SOL]->GetNodes ()->GetSolution (Point_Fine);
918- for (iVar = 0 ; iVar < nVar; iVar++) {
919- Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
920- }
921- }
922- solver_container[iMesh][ADJFLOW_SOL]->GetNodes ()->SetSolution (iPoint, Solution);
923-
924- }
906+ for (auto iMesh = 1ul ; iMesh <= config->GetnMGLevels (); iMesh++) {
907+ MultigridRestriction (*geometry[iMesh - 1 ], solver_container[iMesh - 1 ][ADJFLOW_SOL]->GetNodes ()->GetSolution (),
908+ *geometry[iMesh], solver_container[iMesh][ADJFLOW_SOL]->GetNodes ()->GetSolution ());
925909 solver_container[iMesh][ADJFLOW_SOL]->InitiateComms (geometry[iMesh], config, SOLUTION);
926910 solver_container[iMesh][ADJFLOW_SOL]->CompleteComms (geometry[iMesh], config, SOLUTION);
927911 }
928- delete [] Solution;
929912 }
930913
931914 /* --- The value of the solution for the first iteration of the dual time ---*/
932- for (iMesh = 0 ; iMesh <= config->GetnMGLevels (); iMesh++) {
915+ for (auto iMesh = 0ul ; iMesh <= config->GetnMGLevels (); iMesh++) {
933916 if ((TimeIter == 0 ) && (dual_time)) {
934917 solver_container[iMesh][ADJFLOW_SOL]->GetNodes ()->Set_Solution_time_n ();
935918 solver_container[iMesh][ADJFLOW_SOL]->GetNodes ()->Set_Solution_time_n1 ();
@@ -3841,8 +3824,8 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf
38413824
38423825 /* --- Restart the solution from file information ---*/
38433826 unsigned short iDim, iVar, iMesh;
3844- unsigned long iPoint, index, iChildren, Point_Fine ;
3845- su2double Area_Children, Area_Parent, *Coord, *Solution_Fine ;
3827+ unsigned long index;
3828+ su2double *Coord;
38463829 string filename, restart_filename;
38473830
38483831 /* --- Restart the solution from file information ---*/
@@ -3922,19 +3905,8 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf
39223905 /* --- Interpolate the solution down to the coarse multigrid levels ---*/
39233906
39243907 for (iMesh = 1 ; iMesh <= config->GetnMGLevels (); iMesh++) {
3925- for (iPoint = 0 ; iPoint < geometry[iMesh]->GetnPoint (); iPoint++) {
3926- Area_Parent = geometry[iMesh]->nodes ->GetVolume (iPoint);
3927- for (iVar = 0 ; iVar < nVar; iVar++) Solution[iVar] = 0.0 ;
3928- for (iChildren = 0 ; iChildren < geometry[iMesh]->nodes ->GetnChildren_CV (iPoint); iChildren++) {
3929- Point_Fine = geometry[iMesh]->nodes ->GetChildren_CV (iPoint, iChildren);
3930- Area_Children = geometry[iMesh-1 ]->nodes ->GetVolume (Point_Fine);
3931- Solution_Fine = solver[iMesh-1 ][ADJFLOW_SOL]->GetNodes ()->GetSolution (Point_Fine);
3932- for (iVar = 0 ; iVar < nVar; iVar++) {
3933- Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
3934- }
3935- }
3936- solver[iMesh][ADJFLOW_SOL]->GetNodes ()->SetSolution (iPoint,Solution);
3937- }
3908+ MultigridRestriction (*geometry[iMesh - 1 ], solver[iMesh - 1 ][ADJFLOW_SOL]->GetNodes ()->GetSolution (),
3909+ *geometry[iMesh], solver[iMesh][ADJFLOW_SOL]->GetNodes ()->GetSolution ());
39383910 solver[iMesh][ADJFLOW_SOL]->InitiateComms (geometry[iMesh], config, SOLUTION);
39393911 solver[iMesh][ADJFLOW_SOL]->CompleteComms (geometry[iMesh], config, SOLUTION);
39403912 solver[iMesh][ADJFLOW_SOL]->Preprocessing (geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, false );
0 commit comments