Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
Original file line number Diff line number Diff line change
Expand Up @@ -923,25 +923,8 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
/*--- Interpolate the solution down to the coarse multigrid levels ---*/

for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {

SU2_OMP_FOR_STAT(omp_chunk_size)
for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
const su2double Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
su2double Solution_Coarse[MAXNVAR] = {0.0};

for (auto iChildren = 0ul; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
const auto Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
const su2double Area_Children = geometry[iMesh - 1]->nodes->GetVolume(Point_Fine);
const su2double* Solution_Fine = solver[iMesh - 1][FLOW_SOL]->GetNodes()->GetSolution(Point_Fine);

for (auto iVar = 0u; iVar < nVar; iVar++) {
Solution_Coarse[iVar] += Solution_Fine[iVar] * Area_Children / Area_Parent;
}
}
solver[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution_Coarse);
}
END_SU2_OMP_FOR

MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][FLOW_SOL]->GetNodes()->GetSolution(),
*geometry[iMesh], solver[iMesh][FLOW_SOL]->GetNodes()->GetSolution());
solver[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
solver[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);

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

const auto& thermal_conductivity_tr = nodes->GetThermalConductivity(iPoint);
const auto& thermal_conductivity_ve = nodes->GetThermalConductivity_ve(iPoint);

const su2double dTvedn = -GeometryToolbox::DotProduct(nDim, Grad_Temp_ve, UnitNormal);

/*--- Surface energy balance: trans-rot heat flux, vib-el heat flux ---*/
HeatFlux[iMarker][iVertex] = -(thermal_conductivity_tr*dTdn + thermal_conductivity_ve*dTvedn);

Expand Down
29 changes: 29 additions & 0 deletions SU2_CFD/include/solvers/CSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4333,6 +4333,35 @@ class CSolver {
*/
void SavelibROM(CGeometry *geometry, CConfig *config, bool converged);

/*!
* \brief Interpolate variables to a coarser grid level.
* \note Halo values are not communicated in this function.
* \param[in] geoFine - Fine grid.
* \param[in] varsFine - Matrix of variables on the fine grid.
* \param[in] geoCoarse - Coarse grid.
* \param[in] varsCoarse - Matrix of variables interpolated to the coarse grid.
*/
inline static void MultigridRestriction(const CGeometry& geoFine, const su2activematrix& varsFine,
const CGeometry& geoCoarse, su2activematrix& varsCoarse) {
SU2_OMP_FOR_STAT(roundUpDiv(geoCoarse.GetnPointDomain(), omp_get_num_threads()))
for (auto iPointCoarse = 0ul; iPointCoarse < geoCoarse.GetnPointDomain(); ++iPointCoarse) {

for (auto iVar = 0ul; iVar < varsCoarse.cols(); iVar++) {
varsCoarse(iPointCoarse, iVar) = 0.0;
}
const su2double scale = 1 / geoCoarse.nodes->GetVolume(iPointCoarse);

for (auto iChildren = 0ul; iChildren < geoCoarse.nodes->GetnChildren_CV(iPointCoarse); ++iChildren) {
const auto iPointFine = geoCoarse.nodes->GetChildren_CV(iPointCoarse, iChildren);
const su2double w = geoFine.nodes->GetVolume(iPointFine) * scale;
for (auto iVar = 0ul; iVar < varsCoarse.cols(); ++iVar) {
varsCoarse(iPointCoarse, iVar) += w * varsFine(iPointFine, iVar);
}
}
}
END_SU2_OMP_FOR
}

protected:
/*!
* \brief Allocate the memory for the verification solution, if necessary.
Expand Down
9 changes: 5 additions & 4 deletions SU2_CFD/include/variables/CVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ class CVariable {
* \brief Get the entire solution of the problem.
* \return Reference to the solution matrix.
*/
inline const MatrixType& GetSolution(void) const { return Solution; }
inline const MatrixType& GetSolution() const { return Solution; }
inline MatrixType& GetSolution() { return Solution; }

/*!
* \brief Get the solution of the problem.
Expand Down Expand Up @@ -1674,9 +1675,9 @@ class CVariable {
* \return the value of the separation intermittency.
*/
inline virtual su2double GetIntermittencySep(unsigned long iPoint) const { return 0.0; }

/*!
* \brief Set the separation intermittency(gamma).
* \brief Set the separation intermittency(gamma).
* \param[in] val_dist - Value of the separation intermittency(gamma).
*/
inline virtual void SetIntermittencySep(unsigned long iPoint, su2double val_Intermittency_sep) {}
Expand All @@ -1688,7 +1689,7 @@ class CVariable {
inline virtual su2double GetIntermittencyEff(unsigned long iPoint) const { return 0.0; }

/*!
* \brief Set the effective intermittency(gamma).
* \brief Set the effective intermittency(gamma).
* \param[in] Value of the effective intermittency(gamma).
*/
inline virtual void SetIntermittencyEff(unsigned long iPoint, su2double val_Intermittency_eff) {}
Expand Down
41 changes: 6 additions & 35 deletions SU2_CFD/src/integration/CMultiGridIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,59 +560,30 @@ void CMultiGridIntegration::SetResidual_Term(CGeometry *geometry, CSolver *solve
void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse,
CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) {

unsigned long iVertex, Point_Fine, Point_Coarse;
unsigned short iMarker, iVar, iChildren;
su2double Area_Parent, Area_Children;
const su2double *Solution_Fine = nullptr, *Grid_Vel = nullptr;

const unsigned short Solver_Position = config->GetContainerPosition(RunTime_EqSystem);
const unsigned short nVar = sol_coarse->GetnVar();
const bool grid_movement = config->GetGrid_Movement();

su2double *Solution = new su2double[nVar];

/*--- Compute coarse solution from fine solution ---*/

SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads()))
for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) {

Area_Parent = geo_coarse->nodes->GetVolume(Point_Coarse);

for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0;

for (iChildren = 0; iChildren < geo_coarse->nodes->GetnChildren_CV(Point_Coarse); iChildren++) {

Point_Fine = geo_coarse->nodes->GetChildren_CV(Point_Coarse, iChildren);
Area_Children = geo_fine->nodes->GetVolume(Point_Fine);
Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine);
for (iVar = 0; iVar < nVar; iVar++) {
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
}
}

sol_coarse->GetNodes()->SetSolution(Point_Coarse, Solution);

}
END_SU2_OMP_FOR

delete [] Solution;
CSolver::MultigridRestriction(*geo_fine, sol_fine->GetNodes()->GetSolution(),
*geo_coarse, sol_coarse->GetNodes()->GetSolution());

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

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

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

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

if (Solver_Position == FLOW_SOL) {

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

if (grid_movement) {
Grid_Vel = geo_coarse->nodes->GetGridVel(Point_Coarse);
const auto* Grid_Vel = geo_coarse->nodes->GetGridVel(Point_Coarse);
sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, Grid_Vel);
}
else {
Expand Down
39 changes: 2 additions & 37 deletions SU2_CFD/src/integration/CSingleGridIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,45 +109,10 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve

void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse,
CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) {
unsigned long Point_Fine, Point_Coarse;
unsigned short iVar, iChildren;
su2double Area_Parent, Area_Children;
const su2double *Solution_Fine;

unsigned short nVar = sol_coarse->GetnVar();

su2double *Solution = new su2double[nVar];

/*--- Compute coarse solution from fine solution ---*/

SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads()))
for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) {

Area_Parent = geo_coarse->nodes->GetVolume(Point_Coarse);

for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0;

for (iChildren = 0; iChildren < geo_coarse->nodes->GetnChildren_CV(Point_Coarse); iChildren++) {

Point_Fine = geo_coarse->nodes->GetChildren_CV(Point_Coarse, iChildren);
Area_Children = geo_fine->nodes->GetVolume(Point_Fine);
Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine);
for (iVar = 0; iVar < nVar; iVar++)
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
}

sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution);

}
END_SU2_OMP_FOR

delete [] Solution;

/*--- MPI the new interpolated solution ---*/

CSolver::MultigridRestriction(*geo_fine, sol_fine->GetNodes()->GetSolution(),
*geo_coarse, sol_coarse->GetNodes()->GetSolution());
sol_coarse->InitiateComms(geo_coarse, config, SOLUTION);
sol_coarse->CompleteComms(geo_coarse, config, SOLUTION);

}

void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse,
Expand Down
50 changes: 11 additions & 39 deletions SU2_CFD/src/solvers/CAdjEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,41 +895,24 @@ void CAdjEulerSolver::SetForceProj_Vector(CGeometry *geometry, CSolver **solver_
}

void CAdjEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) {
unsigned long iPoint, Point_Fine;
unsigned short iMesh, iChildren, iVar;
su2double Area_Children, Area_Parent, *Solution, *Solution_Fine;

bool restart = config->GetRestart();
bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
const bool restart = config->GetRestart();
const bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));

/*--- If restart solution, then interpolate the flow solution to
all the multigrid levels, this is important with the dual time strategy ---*/
if (restart) {
Solution = new su2double[nVar];
for (iMesh = 1; iMesh <= config->GetnMGLevels(); iMesh++) {
for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0;
for (iChildren = 0; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
Area_Children = geometry[iMesh-1]->nodes->GetVolume(Point_Fine);
Solution_Fine = solver_container[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution(Point_Fine);
for (iVar = 0; iVar < nVar; iVar++) {
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
}
}
solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint, Solution);

}
for (auto iMesh = 1ul; iMesh <= config->GetnMGLevels(); iMesh++) {
MultigridRestriction(*geometry[iMesh - 1], solver_container[iMesh - 1][ADJFLOW_SOL]->GetNodes()->GetSolution(),
*geometry[iMesh], solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->GetSolution());
solver_container[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
solver_container[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);
}
delete [] Solution;
}

/*--- The value of the solution for the first iteration of the dual time ---*/
for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) {
for (auto iMesh = 0ul; iMesh <= config->GetnMGLevels(); iMesh++) {
if ((TimeIter == 0) && (dual_time)) {
solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->Set_Solution_time_n();
solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->Set_Solution_time_n1();
Expand Down Expand Up @@ -3841,8 +3824,8 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf

/*--- Restart the solution from file information ---*/
unsigned short iDim, iVar, iMesh;
unsigned long iPoint, index, iChildren, Point_Fine;
su2double Area_Children, Area_Parent, *Coord, *Solution_Fine;
unsigned long index;
su2double *Coord;
string filename, restart_filename;

/*--- Restart the solution from file information ---*/
Expand Down Expand Up @@ -3922,19 +3905,8 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf
/*--- Interpolate the solution down to the coarse multigrid levels ---*/

for (iMesh = 1; iMesh <= config->GetnMGLevels(); iMesh++) {
for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0;
for (iChildren = 0; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
Area_Children = geometry[iMesh-1]->nodes->GetVolume(Point_Fine);
Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution(Point_Fine);
for (iVar = 0; iVar < nVar; iVar++) {
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
}
}
solver[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution);
}
MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][ADJFLOW_SOL]->GetNodes()->GetSolution(),
*geometry[iMesh], solver[iMesh][ADJFLOW_SOL]->GetNodes()->GetSolution());
solver[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
solver[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);
solver[iMesh][ADJFLOW_SOL]->Preprocessing(geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, false);
Expand Down
17 changes: 2 additions & 15 deletions SU2_CFD/src/solvers/CDiscAdjSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,20 +637,7 @@ void CDiscAdjSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfi
/*--- Interpolate solution on coarse grids ---*/

for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {

const auto& fineSol = solver[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution();

for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
su2double Solution[MAXNVAR] = {0.0};
const su2double Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);

for (auto iChildren = 0u; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
const auto Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
const su2double weight = geometry[iMesh-1]->nodes->GetVolume(Point_Fine) / Area_Parent;

for (auto iVar = 0u; iVar < nVar; iVar++) Solution[iVar] += weight * fineSol(Point_Fine, iVar);
}
solver[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint, Solution);
}
MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][ADJFLOW_SOL]->GetNodes()->GetSolution(),
*geometry[iMesh], solver[iMesh][ADJFLOW_SOL]->GetNodes()->GetSolution());
}
}
38 changes: 4 additions & 34 deletions SU2_CFD/src/solvers/CHeatSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,8 @@ void CHeatSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *
/*--- Interpolate the solution down to the coarse multigrid levels ---*/

for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {

for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
const su2double Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
su2double Solution_Coarse[MAXNVAR] = {0.0};

for (auto iChildren = 0ul; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
const auto Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
const su2double Area_Children = geometry[iMesh - 1]->nodes->GetVolume(Point_Fine);
const su2double* Solution_Fine = solver[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(Point_Fine);

for (auto iVar = 0u; iVar < nVar; iVar++) {
Solution_Coarse[iVar] += Solution_Fine[iVar] * Area_Children / Area_Parent;
}
}
solver[iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint,Solution_Coarse);
}

MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(),
*geometry[iMesh], solver[iMesh][HEAT_SOL]->GetNodes()->GetSolution());
solver[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
solver[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);

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

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

unsigned long Point_Fine;
su2double Area_Children, Area_Parent, *Solution_Fine;

const bool restart = (config->GetRestart() || config->GetRestart_Flow());
const bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
Expand All @@ -1368,21 +1350,9 @@ void CHeatSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_co

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

su2double Solution[MAXNVAR];
for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) {
for (auto iPoint = 0ul; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) {
Area_Parent = geometry[iMesh]->nodes->GetVolume(iPoint);
for (auto iVar = 0u; iVar < nVar; iVar++) Solution[iVar] = 0.0;
for (auto iChildren = 0ul; iChildren < geometry[iMesh]->nodes->GetnChildren_CV(iPoint); iChildren++) {
Point_Fine = geometry[iMesh]->nodes->GetChildren_CV(iPoint, iChildren);
Area_Children = geometry[iMesh-1]->nodes->GetVolume(Point_Fine);
Solution_Fine = solver_container[iMesh-1][HEAT_SOL]->GetNodes()->GetSolution(Point_Fine);
for (auto iVar = 0u; iVar < nVar; iVar++) {
Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
}
}
solver_container[iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint,Solution);
}
MultigridRestriction(*geometry[iMesh - 1], solver_container[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(),
*geometry[iMesh], solver_container[iMesh][HEAT_SOL]->GetNodes()->GetSolution());
solver_container[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION);
solver_container[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION);
}
Expand Down
Loading