Skip to content

Commit 621f58b

Browse files
committed
fix the "velocity to zero" part for NEMO
1 parent d92c0cf commit 621f58b

5 files changed

Lines changed: 33 additions & 33 deletions

File tree

SU2_CFD/include/variables/CEulerVariable.hpp

Lines changed: 8 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.

SU2_CFD/include/variables/CIncEulerVariable.hpp

Lines changed: 8 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
*/

SU2_CFD/include/variables/CNEMOEulerVariable.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,16 @@ class CNEMOEulerVariable : public CVariable {
582582
* \param[in] val_vector - Pointer to the vector.
583583
*/
584584
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
585-
SU2_MPI::Error("Please add the correct <Density> for `multigrid` + `moving grid` and Solution-Position for momentum below!", CURRENT_FUNCTION);
586-
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, nSpecies+iDim) = GetDensity(iPoint) * val_vector[iDim];
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;
587595
}
588596

589597
};

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,6 @@ class CVariable {
287287
Solution_time_n1(iPoint,iVar) = val_sol;
288288
}
289289

290-
/*!
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-
298290
/*!
299291
* \brief Virtual Member. Specify a vector to set the velocity components of the solution.
300292
* Multiplied by density for compressible cases.
@@ -303,14 +295,6 @@ class CVariable {
303295
*/
304296
inline virtual void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) { }
305297

306-
/*!
307-
* \brief Set to zero velocity components of the solution.
308-
* \param[in] iPoint - Point index.
309-
*/
310-
inline void SetVelSolutionOldZero(unsigned long iPoint) {
311-
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution_Old(iPoint, iDim+1) = 0.0;
312-
}
313-
314298
/*!
315299
* \brief Add a value to the solution.
316300
* \param[in] iPoint - Point index.
@@ -510,12 +494,6 @@ class CVariable {
510494
for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Sum(iPoint,iVar) = 0.0;
511495
}
512496

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

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

671647
/*!
672648
* \brief Set the velocity of the truncation error to zero.

SU2_CFD/src/integration/CMultiGridIntegration.cpp

Lines changed: 5 additions & 5 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+
unsigned short iMarker, iVar, iChildren;
546547
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];
@@ -598,8 +598,8 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst
598598
}
599599
else {
600600
/*--- For stationary no-slip walls, set the velocity to zero. ---*/
601-
602-
sol_coarse->GetNodes()->SetVelSolutionZero(Point_Coarse);
601+
su2double zero[3] = {0.0};
602+
sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, zero);
603603
}
604604

605605
}

0 commit comments

Comments
 (0)