Skip to content

Commit 788dea4

Browse files
committed
Fixed Coord_j for boundary viscous numerics
The visc_numerics' coordinates were often set to the coordinates of the boundary vertex and its closest normal neighbour. Setting them to the boundary vertex and the reflection of the closest normal neighbour at the vertex is more systematic however. Normally this should not change much, because the boundary numerics do not apply gradient correction, so they only depend on the distance between Coord_i, Coord_j.
1 parent ff6091a commit 788dea4

9 files changed

Lines changed: 156 additions & 47 deletions

File tree

Common/include/toolboxes/geometry_toolbox.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ inline void Distance(Int nDim, const T* a, const T* b, T* d) {
5050
for(Int i = 0; i < nDim; i++) d[i] = a[i] - b[i];
5151
}
5252

53+
/*! \brief Reflect a at b: c = 2*b - a
54+
*/
55+
template<class T, typename Int>
56+
inline void PointPointReflect(Int nDim, const T* a, const T* b, T* d){
57+
for(Int i = 0; i < nDim; i++) d[i] = 2 * b[i] - a[i];
58+
}
59+
5360
/*! \return a.b */
5461
template<class T, typename Int>
5562
inline T DotProduct(Int nDim, const T* a, const T* b) {

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,10 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Fluid_Interface(CGeometry* geometry,
15161516
/*--- Set the normal vector and the coordinates ---*/
15171517

15181518
visc_numerics->SetNormal(Normal);
1519-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
1519+
su2double Coord_Reflected[MAXNDIM];
1520+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
1521+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
1522+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
15201523

15211524
/*--- Primitive variables, and gradient ---*/
15221525

SU2_CFD/src/solvers/CAdjEulerSolver.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,8 +3387,10 @@ void CAdjEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
33873387
if (config->GetViscous()) {
33883388

33893389
/*--- Points in edge, coordinates and normal vector---*/
3390-
3391-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
3390+
su2double Coord_Reflected[3];
3391+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
3392+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
3393+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
33923394
visc_numerics->SetNormal(Normal);
33933395

33943396
/*--- Conservative variables w/o reconstruction and adjoint variables w/o reconstruction---*/
@@ -3501,7 +3503,10 @@ void CAdjEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_
35013503

35023504
/*--- Points in edge, coordinates and normal vector---*/
35033505

3504-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
3506+
su2double Coord_Reflected[3];
3507+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
3508+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
3509+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
35053510
visc_numerics->SetNormal(Normal);
35063511

35073512
/*--- Conservative variables w/o reconstruction and adjoint variables w/o reconstruction---*/
@@ -3616,7 +3621,10 @@ void CAdjEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver
36163621

36173622
/*--- Points in edge, coordinates and normal vector---*/
36183623

3619-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
3624+
su2double Coord_Reflected[3];
3625+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
3626+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
3627+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
36203628
visc_numerics->SetNormal(Normal);
36213629

36223630
/*--- Conservative variables w/o reconstruction and adjoint variables w/o reconstruction---*/
@@ -3788,7 +3796,10 @@ void CAdjEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
37883796

37893797
/*--- Points in edge, coordinates and normal vector---*/
37903798

3791-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
3799+
su2double Coord_Reflected[3];
3800+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
3801+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
3802+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
37923803
visc_numerics->SetNormal(Normal);
37933804

37943805
/*--- Conservative variables w/o reconstruction and adjoint variables w/o reconstruction---*/
@@ -3878,7 +3889,10 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
38783889

38793890
Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();
38803891

3881-
conv_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
3892+
su2double Coord_Reflected[3];
3893+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
3894+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
3895+
conv_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
38823896

38833897
/*--- Allocate the value at the outlet ---*/
38843898

@@ -4068,7 +4082,10 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
40684082

40694083
/*--- Points in edge, coordinates and normal vector---*/
40704084
visc_numerics->SetNormal(Normal);
4071-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
4085+
su2double Coord_Reflected[3];
4086+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
4087+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
4088+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
40724089

40734090
/*--- Conservative variables w/o reconstruction and adjoint variables w/o reconstruction---*/
40744091

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5155,8 +5155,10 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container,
51555155
/*--- Set the normal vector and the coordinates ---*/
51565156

51575157
visc_numerics->SetNormal(Normal);
5158-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint),
5159-
geometry->nodes->GetCoord(Point_Normal));
5158+
su2double Coord_Reflected[MAXNDIM];
5159+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
5160+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
5161+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
51605162

51615163
/*--- Primitive variables, and gradient ---*/
51625164

@@ -5623,7 +5625,10 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container,
56235625
/*--- Set the normal vector and the coordinates ---*/
56245626

56255627
visc_numerics->SetNormal(Normal);
5626-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
5628+
su2double Coord_Reflected[MAXNDIM];
5629+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
5630+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
5631+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
56275632

56285633
/*--- Primitive variables, and gradient ---*/
56295634

@@ -6137,7 +6142,10 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain
61376142
/*--- Set the normal vector and the coordinates ---*/
61386143

61396144
visc_numerics->SetNormal(Normal);
6140-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
6145+
su2double Coord_Reflected[MAXNDIM];
6146+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
6147+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
6148+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
61416149

61426150
/*--- Primitive variables, and gradient ---*/
61436151

@@ -7037,7 +7045,10 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu
70377045
/*--- Set the normal vector and the coordinates ---*/
70387046

70397047
visc_numerics->SetNormal(Normal);
7040-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
7048+
su2double Coord_Reflected[MAXNDIM];
7049+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
7050+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7051+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
70417052

70427053
/*--- Primitive variables, and gradient ---*/
70437054

@@ -7377,7 +7388,10 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
73777388
// /*--- Set the normal vector and the coordinates ---*/
73787389
//
73797390
// visc_numerics->SetNormal(Normal);
7380-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
7391+
// su2double Coord_Reflected[MAXNDIM];
7392+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
7393+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7394+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
73817395
//
73827396
// /*--- Primitive variables, and gradient ---*/
73837397
//
@@ -7551,7 +7565,10 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
75517565
// /*--- Set the normal vector and the coordinates ---*/
75527566
//
75537567
// visc_numerics->SetNormal(Normal);
7554-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
7568+
// su2double Coord_Reflected[MAXNDIM];
7569+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
7570+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7571+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
75557572
//
75567573
// /*--- Primitive variables, and gradient ---*/
75577574
//
@@ -7695,7 +7712,10 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con
76957712
// /*--- Set the normal vector and the coordinates ---*/
76967713
//
76977714
// visc_numerics->SetNormal(Normal);
7698-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
7715+
// su2double Coord_Reflected[MAXNDIM];
7716+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
7717+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7718+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
76997719
//
77007720
// /*--- Primitive variables, and gradient ---*/
77017721
//
@@ -7817,7 +7837,10 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co
78177837
// /*--- Set the normal vector and the coordinates ---*/
78187838
//
78197839
// visc_numerics->SetNormal(Normal);
7820-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
7840+
// su2double Coord_Reflected[MAXNDIM];
7841+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
7842+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7843+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
78217844
//
78227845
// /*--- Primitive variables, and gradient ---*/
78237846
//
@@ -8037,7 +8060,10 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai
80378060
// /*--- Set the normal vector and the coordinates ---*/
80388061
//
80398062
// visc_numerics->SetNormal(Normal);
8040-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
8063+
// su2double Coord_Reflected[MAXNDIM];
8064+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
8065+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
8066+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
80418067
//
80428068
// /*--- Primitive variables, and gradient ---*/
80438069
//
@@ -8288,7 +8314,10 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta
82888314
// /*--- Set the normal vector and the coordinates ---*/
82898315
//
82908316
// visc_numerics->SetNormal(Normal);
8291-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
8317+
// su2double Coord_Reflected[MAXNDIM];
8318+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
8319+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
8320+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
82928321
//
82938322
// /*--- Primitive variables, and gradient ---*/
82948323
//
@@ -8848,7 +8877,10 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C
88488877
// /*--- Set the normal vector and the coordinates ---*/
88498878
//
88508879
// visc_numerics->SetNormal(Normal);
8851-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->node[iPoint_Normal]->GetCoord());
8880+
// su2double Coord_Reflected[MAXNDIM];
8881+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
8882+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
8883+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
88528884
//
88538885
// /*--- Primitive variables, and gradient ---*/
88548886
//

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,10 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
18781878
/*--- Set the normal vector and the coordinates ---*/
18791879

18801880
visc_numerics->SetNormal(Normal);
1881-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint),
1882-
geometry->nodes->GetCoord(Point_Normal));
1881+
su2double Coord_Reflected[MAXNDIM];
1882+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
1883+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
1884+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
18831885

18841886
/*--- Primitive variables, and gradient ---*/
18851887

@@ -2117,8 +2119,10 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
21172119
/*--- Set the normal vector and the coordinates ---*/
21182120

21192121
visc_numerics->SetNormal(Normal);
2120-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint),
2121-
geometry->nodes->GetCoord(Point_Normal));
2122+
su2double Coord_Reflected[MAXNDIM];
2123+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
2124+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
2125+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
21222126

21232127
/*--- Primitive variables, and gradient ---*/
21242128

@@ -2312,8 +2316,10 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
23122316
/*--- Set the normal vector and the coordinates ---*/
23132317

23142318
visc_numerics->SetNormal(Normal);
2315-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint),
2316-
geometry->nodes->GetCoord(Point_Normal));
2319+
su2double Coord_Reflected[MAXNDIM];
2320+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
2321+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
2322+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
23172323

23182324
/*--- Primitive variables, and gradient ---*/
23192325

SU2_CFD/src/solvers/CNEMOEulerSolver.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,8 +1630,10 @@ void CNEMOEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contai
16301630

16311631
/*--- Viscous contribution ---*/
16321632
if (viscous) {
1633-
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint),
1634-
geometry->nodes->GetCoord(Point_Normal) );
1633+
su2double Coord_Reflected[MAXNDIM];
1634+
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
1635+
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
1636+
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected );
16351637
visc_numerics->SetNormal(Normal);
16361638

16371639
/*--- Primitive variables, and gradient ---*/
@@ -1929,7 +1931,10 @@ void CNEMOEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solution_containe
19291931

19301932
// /*--- Set the normal vector and the coordinates ---*/
19311933
// visc_numerics->SetNormal(Normal);
1932-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(), geometry->node[Point_Normal]->GetCoord());
1934+
// su2double Coord_Reflected[MAXNDIM];
1935+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
1936+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
1937+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(), Coord_Reflected);
19331938

19341939
// /*--- Primitive variables, and gradient ---*/
19351940
// visc_numerics->SetPrimitive(V_domain, V_inlet);
@@ -2149,7 +2154,10 @@ void CNEMOEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solution_contain
21492154

21502155
// /*--- Set the normal vector and the coordinates ---*/
21512156
// visc_numerics->SetNormal(Normal);
2152-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(), geometry->node[Point_Normal]->GetCoord());
2157+
// su2double Coord_Reflected[MAXNDIM];
2158+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
2159+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
2160+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(), Coord_Reflected);
21532161

21542162
// /*--- Primitive variables, and gradient ---*/
21552163
// visc_numerics->SetPrimitive(V_domain, V_outlet);
@@ -2383,7 +2391,10 @@ SU2_MPI::Error("BC_SUPERSONIC_INLET: Not operational in NEMO.", CURRENT_FUNCTION
23832391
//
23842392
// /*--- Set the normal vector and the coordinates ---*/
23852393
// visc_numerics->SetNormal(Normal);
2386-
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(Point_Normal));
2394+
// su2double Coord_Reflected[MAXNDIM];
2395+
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
2396+
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
2397+
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
23872398
//
23882399
// /*--- Primitive variables, and gradient ---*/
23892400
// visc_numerics->SetPrimitive(V_domain, V_inlet);

0 commit comments

Comments
 (0)