Skip to content

Commit d524cf5

Browse files
committed
common function for multigrid interpolation
1 parent 9a4cf77 commit d524cf5

11 files changed

Lines changed: 72 additions & 245 deletions

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -923,25 +923,8 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
923923
/*--- Interpolate the solution down to the coarse multigrid levels ---*/
924924

925925
for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {
926-
927-
SU2_OMP_FOR_STAT(omp_chunk_size)
928-
for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
929-
const su2double Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
930-
su2double Solution_Coarse[MAXNVAR] = {0.0};
931-
932-
for (auto iChildren = 0ul; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
933-
const auto Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
934-
const su2double Area_Children = geometry[iMesh - 1]->nodes->GetVolume(Point_Fine);
935-
const su2double* Solution_Fine = solver[iMesh - 1][FLOW_SOL]->GetNodes()->GetSolution(Point_Fine);
936-
937-
for (auto iVar = 0u; iVar < nVar; iVar++) {
938-
Solution_Coarse[iVar] += Solution_Fine[iVar] * Area_Children / Area_Parent;
939-
}
940-
}
941-
solver[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution_Coarse);
942-
}
943-
END_SU2_OMP_FOR
944-
926+
MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][FLOW_SOL]->GetNodes()->GetSolution(),
927+
*geometry[iMesh], solver[iMesh][FLOW_SOL]->GetNodes()->GetSolution());
945928
solver[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
946929
solver[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);
947930

@@ -2610,9 +2593,9 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
26102593

26112594
const auto& thermal_conductivity_tr = nodes->GetThermalConductivity(iPoint);
26122595
const auto& thermal_conductivity_ve = nodes->GetThermalConductivity_ve(iPoint);
2613-
2596+
26142597
const su2double dTvedn = -GeometryToolbox::DotProduct(nDim, Grad_Temp_ve, UnitNormal);
2615-
2598+
26162599
/*--- Surface energy balance: trans-rot heat flux, vib-el heat flux ---*/
26172600
HeatFlux[iMarker][iVertex] = -(thermal_conductivity_tr*dTdn + thermal_conductivity_ve*dTvedn);
26182601

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4333,6 +4333,35 @@ class CSolver {
43334333
*/
43344334
void SavelibROM(CGeometry *geometry, CConfig *config, bool converged);
43354335

4336+
/*!
4337+
* \brief Interpolate variables to a coarser grid level.
4338+
* \note Halo values are not communicated in this function.
4339+
* \param[in] geoFine - Fine grid.
4340+
* \param[in] varsFine - Matrix of variables on the fine grid.
4341+
* \param[in] geoCoarse - Coarse grid.
4342+
* \param[in] varsCoarse - Matrix of variables interpolated to the coarse grid.
4343+
*/
4344+
inline static void MultigridRestriction(const CGeometry& geoFine, const su2activematrix& varsFine,
4345+
const CGeometry& geoCoarse, su2activematrix& varsCoarse) {
4346+
SU2_OMP_FOR_STAT(roundUpDiv(geoCoarse.GetnPointDomain(), omp_get_num_threads()))
4347+
for (auto iPointCoarse = 0ul; iPointCoarse < geoCoarse.GetnPointDomain(); ++iPointCoarse) {
4348+
4349+
for (auto iVar = 0ul; iVar < varsCoarse.cols(); iVar++) {
4350+
varsCoarse(iPointCoarse, iVar) = 0.0;
4351+
}
4352+
const su2double scale = 1 / geoCoarse.nodes->GetVolume(iPointCoarse);
4353+
4354+
for (auto iChildren = 0ul; iChildren < geoCoarse.nodes->GetnChildren_CV(iPointCoarse); ++iChildren) {
4355+
const auto iPointFine = geoCoarse.nodes->GetChildren_CV(iPointCoarse, iChildren);
4356+
const su2double w = geoFine.nodes->GetVolume(iPointFine) * scale;
4357+
for (auto iVar = 0ul; iVar < varsCoarse.cols(); ++iVar) {
4358+
varsCoarse(iPointCoarse, iVar) += w * varsFine(iPointFine, iVar);
4359+
}
4360+
}
4361+
}
4362+
END_SU2_OMP_FOR
4363+
}
4364+
43364365
protected:
43374366
/*!
43384367
* \brief Allocate the memory for the verification solution, if necessary.

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ class CVariable {
461461
* \brief Get the entire solution of the problem.
462462
* \return Reference to the solution matrix.
463463
*/
464-
inline const MatrixType& GetSolution(void) const { return Solution; }
464+
inline const MatrixType& GetSolution() const { return Solution; }
465+
inline MatrixType& GetSolution() { return Solution; }
465466

466467
/*!
467468
* \brief Get the solution of the problem.
@@ -1674,9 +1675,9 @@ class CVariable {
16741675
* \return the value of the separation intermittency.
16751676
*/
16761677
inline virtual su2double GetIntermittencySep(unsigned long iPoint) const { return 0.0; }
1677-
1678+
16781679
/*!
1679-
* \brief Set the separation intermittency(gamma).
1680+
* \brief Set the separation intermittency(gamma).
16801681
* \param[in] val_dist - Value of the separation intermittency(gamma).
16811682
*/
16821683
inline virtual void SetIntermittencySep(unsigned long iPoint, su2double val_Intermittency_sep) {}
@@ -1688,7 +1689,7 @@ class CVariable {
16881689
inline virtual su2double GetIntermittencyEff(unsigned long iPoint) const { return 0.0; }
16891690

16901691
/*!
1691-
* \brief Set the effective intermittency(gamma).
1692+
* \brief Set the effective intermittency(gamma).
16921693
* \param[in] Value of the effective intermittency(gamma).
16931694
*/
16941695
inline virtual void SetIntermittencyEff(unsigned long iPoint, su2double val_Intermittency_eff) {}

SU2_CFD/src/integration/CMultiGridIntegration.cpp

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -560,59 +560,30 @@ void CMultiGridIntegration::SetResidual_Term(CGeometry *geometry, CSolver *solve
560560
void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse,
561561
CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) {
562562

563-
unsigned long iVertex, Point_Fine, Point_Coarse;
564-
unsigned short iMarker, iVar, iChildren;
565-
su2double Area_Parent, Area_Children;
566-
const su2double *Solution_Fine = nullptr, *Grid_Vel = nullptr;
567-
568563
const unsigned short Solver_Position = config->GetContainerPosition(RunTime_EqSystem);
569-
const unsigned short nVar = sol_coarse->GetnVar();
570564
const bool grid_movement = config->GetGrid_Movement();
571565

572-
su2double *Solution = new su2double[nVar];
573-
574566
/*--- Compute coarse solution from fine solution ---*/
575567

576-
SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads()))
577-
for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) {
578-
579-
Area_Parent = geo_coarse->nodes->GetVolume(Point_Coarse);
580-
581-
for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0;
582-
583-
for (iChildren = 0; iChildren < geo_coarse->nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
584-
585-
Point_Fine = geo_coarse->nodes->GetChildren_CV(Point_Coarse, iChildren);
586-
Area_Children = geo_fine->nodes->GetVolume(Point_Fine);
587-
Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine);
588-
for (iVar = 0; iVar < nVar; iVar++) {
589-
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
590-
}
591-
}
592-
593-
sol_coarse->GetNodes()->SetSolution(Point_Coarse, Solution);
594-
595-
}
596-
END_SU2_OMP_FOR
597-
598-
delete [] Solution;
568+
CSolver::MultigridRestriction(*geo_fine, sol_fine->GetNodes()->GetSolution(),
569+
*geo_coarse, sol_coarse->GetNodes()->GetSolution());
599570

600571
/*--- Update the solution at the no-slip walls ---*/
601572

602-
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
573+
for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) {
603574
if (config->GetViscous_Wall(iMarker)) {
604575

605576
SU2_OMP_FOR_STAT(32)
606-
for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) {
577+
for (auto iVertex = 0ul; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) {
607578

608-
Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode();
579+
const auto Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode();
609580

610581
if (Solver_Position == FLOW_SOL) {
611582

612583
/*--- At moving walls, set the solution based on the new density and wall velocity ---*/
613584

614585
if (grid_movement) {
615-
Grid_Vel = geo_coarse->nodes->GetGridVel(Point_Coarse);
586+
const auto* Grid_Vel = geo_coarse->nodes->GetGridVel(Point_Coarse);
616587
sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, Grid_Vel);
617588
}
618589
else {

SU2_CFD/src/integration/CSingleGridIntegration.cpp

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -109,45 +109,10 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve
109109

110110
void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse,
111111
CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) {
112-
unsigned long Point_Fine, Point_Coarse;
113-
unsigned short iVar, iChildren;
114-
su2double Area_Parent, Area_Children;
115-
const su2double *Solution_Fine;
116-
117-
unsigned short nVar = sol_coarse->GetnVar();
118-
119-
su2double *Solution = new su2double[nVar];
120-
121-
/*--- Compute coarse solution from fine solution ---*/
122-
123-
SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads()))
124-
for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) {
125-
126-
Area_Parent = geo_coarse->nodes->GetVolume(Point_Coarse);
127-
128-
for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0;
129-
130-
for (iChildren = 0; iChildren < geo_coarse->nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
131-
132-
Point_Fine = geo_coarse->nodes->GetChildren_CV(Point_Coarse, iChildren);
133-
Area_Children = geo_fine->nodes->GetVolume(Point_Fine);
134-
Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine);
135-
for (iVar = 0; iVar < nVar; iVar++)
136-
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
137-
}
138-
139-
sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution);
140-
141-
}
142-
END_SU2_OMP_FOR
143-
144-
delete [] Solution;
145-
146-
/*--- MPI the new interpolated solution ---*/
147-
112+
CSolver::MultigridRestriction(*geo_fine, sol_fine->GetNodes()->GetSolution(),
113+
*geo_coarse, sol_coarse->GetNodes()->GetSolution());
148114
sol_coarse->InitiateComms(geo_coarse, config, SOLUTION);
149115
sol_coarse->CompleteComms(geo_coarse, config, SOLUTION);
150-
151116
}
152117

153118
void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse,

SU2_CFD/src/solvers/CAdjEulerSolver.cpp

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -895,41 +895,24 @@ void CAdjEulerSolver::SetForceProj_Vector(CGeometry *geometry, CSolver **solver_
895895
}
896896

897897
void 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);

SU2_CFD/src/solvers/CDiscAdjSolver.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -637,20 +637,7 @@ void CDiscAdjSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfi
637637
/*--- Interpolate solution on coarse grids ---*/
638638

639639
for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {
640-
641-
const auto& fineSol = solver[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution();
642-
643-
for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
644-
su2double Solution[MAXNVAR] = {0.0};
645-
const su2double Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
646-
647-
for (auto iChildren = 0u; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
648-
const auto Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
649-
const su2double weight = geometry[iMesh-1]->nodes->GetVolume(Point_Fine) / Area_Parent;
650-
651-
for (auto iVar = 0u; iVar < nVar; iVar++) Solution[iVar] += weight * fineSol(Point_Fine, iVar);
652-
}
653-
solver[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint, Solution);
654-
}
640+
MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][ADJFLOW_SOL]->GetNodes()->GetSolution(),
641+
*geometry[iMesh], solver[iMesh][ADJFLOW_SOL]->GetNodes()->GetSolution());
655642
}
656643
}

SU2_CFD/src/solvers/CHeatSolver.cpp

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -285,23 +285,8 @@ void CHeatSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *
285285
/*--- Interpolate the solution down to the coarse multigrid levels ---*/
286286

287287
for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {
288-
289-
for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
290-
const su2double Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
291-
su2double Solution_Coarse[MAXNVAR] = {0.0};
292-
293-
for (auto iChildren = 0ul; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
294-
const auto Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
295-
const su2double Area_Children = geometry[iMesh - 1]->nodes->GetVolume(Point_Fine);
296-
const su2double* Solution_Fine = solver[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(Point_Fine);
297-
298-
for (auto iVar = 0u; iVar < nVar; iVar++) {
299-
Solution_Coarse[iVar] += Solution_Fine[iVar] * Area_Children / Area_Parent;
300-
}
301-
}
302-
solver[iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint,Solution_Coarse);
303-
}
304-
288+
MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(),
289+
*geometry[iMesh], solver[iMesh][HEAT_SOL]->GetNodes()->GetSolution());
305290
solver[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
306291
solver[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);
307292

@@ -1356,9 +1341,6 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_
13561341

13571342
void CHeatSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) {
13581343

1359-
unsigned long Point_Fine;
1360-
su2double Area_Children, Area_Parent, *Solution_Fine;
1361-
13621344
const bool restart = (config->GetRestart() || config->GetRestart_Flow());
13631345
const bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
13641346
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
@@ -1368,21 +1350,9 @@ void CHeatSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_co
13681350

13691351
if (restart && (TimeIter == 0)) {
13701352

1371-
su2double Solution[MAXNVAR];
13721353
for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {
1373-
for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
1374-
Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
1375-
for (auto iVar = 0u; iVar < nVar; iVar++) Solution[iVar] = 0.0;
1376-
for (auto iChildren = 0ul; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
1377-
Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
1378-
Area_Children = geometry[iMesh-1]->nodes->GetVolume(Point_Fine);
1379-
Solution_Fine = solver_container[iMesh-1][HEAT_SOL]->GetNodes()->GetSolution(Point_Fine);
1380-
for (auto iVar = 0u; iVar < nVar; iVar++) {
1381-
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
1382-
}
1383-
}
1384-
solver_container[iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint,Solution);
1385-
}
1354+
MultigridRestriction(*geometry[iMesh - 1], solver_container[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(),
1355+
*geometry[iMesh], solver_container[iMesh][HEAT_SOL]->GetNodes()->GetSolution());
13861356
solver_container[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
13871357
solver_container[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);
13881358
}

0 commit comments

Comments
 (0)