Skip to content

Commit 35aa605

Browse files
authored
Merge pull request #1194 from su2code/fix_IncMultigridGridvel
Fix Multigrid for Incompressible NS with moving walls, and for NEMO NS in general
2 parents 25f4f0c + f19af6d commit 35aa605

9 files changed

Lines changed: 112 additions & 53 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ TestData
7979
# Ignore output files if tests are run locally
8080
*.vtk
8181
*.vtu
82+
*.vtm
83+
*.pvsm
8284
*.ref
85+
*.plt
86+
*.szplt
8387

8488
Mercurial
8589
.hg*

SU2_CFD/include/variables/CAdjEulerVariable.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,32 @@ class CAdjEulerVariable : public CVariable {
102102
for (unsigned long iVar = 0; iVar < nVar; iVar++) IntBoundary_Jump(iPoint,iVar) = val_IntBoundary_Jump[iVar];
103103
}
104104

105+
/*!
106+
* \brief Set the velocity vector from the old solution.
107+
* \param[in] val_velocity - Pointer to the velocity.
108+
*/
109+
inline void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final {
110+
for (unsigned long iDim = 0; iDim < nDim; iDim++)
111+
Solution_Old(iPoint,iDim+1) = val_velocity[iDim]*Solution(iPoint,0);
112+
}
113+
114+
/*!
115+
* \brief Set the momentum part of the truncation error to zero.
116+
* \param[in] iPoint - Point index.
117+
*/
118+
inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
119+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
120+
}
121+
122+
/*!
123+
* \brief Specify a vector to set the velocity components of the solution. Multiplied by density for compressible cases.
124+
* \param[in] iPoint - Point index.
125+
* \param[in] val_vector - Pointer to the vector.
126+
*/
127+
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
128+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = GetDensity(iPoint) * val_vector[iDim];
129+
}
130+
105131
/*!
106132
* \brief Get the value of the force projection vector.
107133
* \return Pointer to the force projection vector.

SU2_CFD/include/variables/CEulerVariable.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,14 @@ class CEulerVariable : public CVariable {
428428
Solution_Old(iPoint,iDim+1) = val_velocity[iDim]*Solution(iPoint,0);
429429
}
430430

431+
/*!
432+
* \brief Set the momentum part of the truncation error to zero.
433+
* \param[in] iPoint - Point index.
434+
*/
435+
inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
436+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
437+
}
438+
431439
/*!
432440
* \brief Set the harmonic balance source term.
433441
* \param[in] iVar - Index of the variable.
@@ -487,4 +495,13 @@ class CEulerVariable : public CVariable {
487495
inline su2double GetStrainMag(unsigned long iPoint) const final { return StrainMag(iPoint); }
488496
inline su2activevector& GetStrainMag() { return StrainMag; }
489497

498+
/*!
499+
* \brief Specify a vector to set the velocity components of the solution. Multiplied by density for compressible cases.
500+
* \param[in] iPoint - Point index.
501+
* \param[in] val_vector - Pointer to the vector.
502+
*/
503+
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
504+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = GetDensity(iPoint) * val_vector[iDim];
505+
}
506+
490507
};

SU2_CFD/include/variables/CIncEulerVariable.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ class CIncEulerVariable : public CVariable {
326326
Solution_Old(iPoint,iDim+1) = val_velocity[iDim];
327327
}
328328

329+
/*!
330+
* \brief Set the momentum part of the truncation error to zero.
331+
* \param[in] iPoint - Point index.
332+
*/
333+
inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
334+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
335+
}
336+
329337
/*!
330338
* \brief Set all the primitive variables for incompressible flows.
331339
*/
@@ -366,4 +374,13 @@ class CIncEulerVariable : public CVariable {
366374
inline su2double GetStrainMag(unsigned long iPoint) const final { return StrainMag(iPoint); }
367375
inline su2activevector& GetStrainMag() { return StrainMag; }
368376

377+
/*!
378+
* \brief Specify a vector to set the velocity components of the solution.
379+
* \param[in] iPoint - Point index.
380+
* \param[in] val_vector - Pointer to the vector.
381+
*/
382+
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
383+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim];
384+
}
385+
369386
};

SU2_CFD/include/variables/CNEMOEulerVariable.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,22 @@ class CNEMOEulerVariable : public CVariable {
576576
*/
577577
inline unsigned short GetRhoCvveIndex(void) { return RHOCVVE_INDEX; }
578578

579+
/*!
580+
* \brief Specify a vector to set the velocity components of the solution. Multiplied by density for compressible cases.
581+
* \param[in] iPoint - Point index.
582+
* \param[in] val_vector - Pointer to the vector.
583+
*/
584+
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
585+
for (unsigned long iDim = 0; iDim < nDim; iDim++)
586+
Solution(iPoint, nSpecies+iDim) = Primitive(iPoint,RHO_INDEX) * val_vector[iDim];
587+
}
588+
589+
/*!
590+
* \brief Set the momentum part of the truncation error to zero.
591+
* \param[in] iPoint - Point index.
592+
*/
593+
inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
594+
for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,nSpecies+iDim) = 0.0;
595+
}
596+
579597
};

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -288,29 +288,12 @@ class CVariable {
288288
}
289289

290290
/*!
291-
* \brief Set to zero the velocity components of the solution.
292-
* \param[in] iPoint - Point index.
293-
*/
294-
inline void SetVelSolutionZero(unsigned long iPoint) {
295-
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint,iDim+1) = 0.0;
296-
}
297-
298-
/*!
299-
* \brief Specify a vector to set the velocity components of the solution.
291+
* \brief Virtual Member. Specify a vector to set the velocity components of the solution.
292+
* Multiplied by density for compressible cases.
300293
* \param[in] iPoint - Point index.
301294
* \param[in] val_vector - Pointer to the vector.
302295
*/
303-
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) {
304-
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim];
305-
}
306-
307-
/*!
308-
* \brief Set to zero velocity components of the solution.
309-
* \param[in] iPoint - Point index.
310-
*/
311-
inline void SetVelSolutionOldZero(unsigned long iPoint) {
312-
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution_Old(iPoint, iDim+1) = 0.0;
313-
}
296+
inline virtual void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) { }
314297

315298
/*!
316299
* \brief Add a value to the solution.
@@ -511,12 +494,6 @@ class CVariable {
511494
for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Sum(iPoint,iVar) = 0.0;
512495
}
513496

514-
/*!
515-
* \brief Set the velocity of the truncation error to zero.
516-
* \param[in] iPoint - Point index.
517-
*/
518-
inline virtual void SetVel_ResTruncError_Zero(unsigned long iPoint, unsigned long iSpecies) {}
519-
520497
/*!
521498
* \brief Get the value of the summed residual.
522499
* \param[in] iPoint - Point index.
@@ -662,12 +639,10 @@ class CVariable {
662639
inline void SetVal_ResTruncError_Zero(unsigned long iPoint, unsigned long iVar) {Res_TruncError(iPoint, iVar) = 0.0;}
663640

664641
/*!
665-
* \brief Set the velocity of the truncation error to zero.
642+
* \brief Set the momentum part of the truncation error to zero.
666643
* \param[in] iPoint - Point index.
667644
*/
668-
inline void SetVel_ResTruncError_Zero(unsigned long iPoint) {
669-
for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
670-
}
645+
inline virtual void SetVel_ResTruncError_Zero(unsigned long iPoint) { }
671646

672647
/*!
673648
* \brief Set the velocity of the truncation error to zero.

SU2_CFD/src/integration/CMultiGridIntegration.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS
350350
/*--- For dirichlet boundary condtions, set the correction to zero.
351351
Note that Solution_Old stores the correction not the actual value ---*/
352352

353-
sol_coarse->GetNodes()->SetVelSolutionOldZero(Point_Coarse);
353+
su2double zero[3] = {0.0};
354+
sol_coarse->GetNodes()->SetVelocity_Old(Point_Coarse, zero);
354355

355356
}
356357
}
@@ -542,13 +543,12 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst
542543
CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) {
543544

544545
unsigned long iVertex, Point_Fine, Point_Coarse;
545-
unsigned short iMarker, iVar, iChildren, iDim;
546-
su2double Area_Parent, Area_Children, Vector[3] = {0.0};
546+
unsigned short iMarker, iVar, iChildren;
547+
su2double Area_Parent, Area_Children;
547548
const su2double *Solution_Fine = nullptr, *Grid_Vel = nullptr;
548549

549550
const unsigned short Solver_Position = config->GetContainerPosition(RunTime_EqSystem);
550551
const unsigned short nVar = sol_coarse->GetnVar();
551-
const unsigned short nDim = geo_fine->GetnDim();
552552
const bool grid_movement = config->GetGrid_Movement();
553553

554554
su2double *Solution = new su2double[nVar];
@@ -594,14 +594,12 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst
594594

595595
if (grid_movement) {
596596
Grid_Vel = geo_coarse->nodes->GetGridVel(Point_Coarse);
597-
for (iDim = 0; iDim < nDim; iDim++)
598-
Vector[iDim] = sol_coarse->GetNodes()->GetSolution(Point_Coarse,0)*Grid_Vel[iDim];
599-
sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, Vector);
597+
sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, Grid_Vel);
600598
}
601599
else {
602600
/*--- For stationary no-slip walls, set the velocity to zero. ---*/
603-
604-
sol_coarse->GetNodes()->SetVelSolutionZero(Point_Coarse);
601+
su2double zero[3] = {0.0};
602+
sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, zero);
605603
}
606604

607605
}

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i
376376
/*--- Get the freestream energy. Only useful if energy equation is active. ---*/
377377

378378
Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream;
379+
if (tkeNeeded) { Energy_FreeStream += Tke_FreeStream; };
379380
config->SetEnergy_FreeStream(Energy_FreeStream);
380-
if (tkeNeeded) { Energy_FreeStream += Tke_FreeStream; }; config->SetEnergy_FreeStream(Energy_FreeStream);
381381

382382
/*--- Compute Mach number ---*/
383383

@@ -390,17 +390,17 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i
390390

391391
/*--- Divide by reference values, to compute the non-dimensional free-stream values ---*/
392392

393-
Pressure_FreeStreamND = Pressure_FreeStream/config->GetPressure_Ref(); config->SetPressure_FreeStreamND(Pressure_FreeStreamND);
393+
Pressure_FreeStreamND = Pressure_FreeStream/config->GetPressure_Ref(); config->SetPressure_FreeStreamND(Pressure_FreeStreamND);
394394
Pressure_ThermodynamicND = Pressure_Thermodynamic/config->GetPressure_Ref(); config->SetPressure_ThermodynamicND(Pressure_ThermodynamicND);
395-
Density_FreeStreamND = Density_FreeStream/config->GetDensity_Ref(); config->SetDensity_FreeStreamND(Density_FreeStreamND);
395+
Density_FreeStreamND = Density_FreeStream/config->GetDensity_Ref(); config->SetDensity_FreeStreamND(Density_FreeStreamND);
396396

397397
for (iDim = 0; iDim < nDim; iDim++) {
398398
Velocity_FreeStreamND[iDim] = config->GetVelocity_FreeStream()[iDim]/Velocity_Ref; config->SetVelocity_FreeStreamND(Velocity_FreeStreamND[iDim], iDim);
399399
}
400400

401401
Temperature_FreeStreamND = Temperature_FreeStream/config->GetTemperature_Ref(); config->SetTemperature_FreeStreamND(Temperature_FreeStreamND);
402-
Gas_ConstantND = config->GetGas_Constant()/Gas_Constant_Ref; config->SetGas_ConstantND(Gas_ConstantND);
403-
Specific_Heat_CpND = config->GetSpecific_Heat_Cp()/Gas_Constant_Ref; config->SetSpecific_Heat_CpND(Specific_Heat_CpND);
402+
Gas_ConstantND = config->GetGas_Constant()/Gas_Constant_Ref; config->SetGas_ConstantND(Gas_ConstantND);
403+
Specific_Heat_CpND = config->GetSpecific_Heat_Cp()/Gas_Constant_Ref; config->SetSpecific_Heat_CpND(Specific_Heat_CpND);
404404

405405
/*--- We assume that Cp = Cv for our incompressible fluids. ---*/
406406
Specific_Heat_CvND = config->GetSpecific_Heat_Cp()/Gas_Constant_Ref; config->SetSpecific_Heat_CvND(Specific_Heat_CvND);

TestCases/.gitignore

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@
99
# changes to the meshes/solutions/restarts.
1010

1111
# Things appearing in TestCases/ repo to ignore:
12+
# mesh files
1213
*.su2
14+
*.cgns
15+
*.pw
16+
17+
# binary/ascii restart/solution files. Note that .csv can be a history, of_grad, etc file as well.
1318
*.dat
14-
*.vtk
1519
*.csv
16-
*.plt
17-
*.szplt
18-
*.pw
20+
21+
# auto-generated files by regression tests
22+
*.autotest
23+
config_*.cfg
24+
25+
# flip the pickle
26+
*.pkl
27+
1928
*.IGS
20-
*.cgns
2129
*.tgz
2230
COPYING
23-
README.md
24-
*.autotest
25-
config_*.cfg
2631
*.eqn
27-
*.pkl

0 commit comments

Comments
 (0)