Skip to content

Commit

Permalink
major fix - apply slip wall condition when use wall models
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqishen committed Jun 22, 2019
1 parent 049e8ac commit ad897f1
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 27 deletions.
138 changes: 115 additions & 23 deletions src/bdy_inters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,24 +666,80 @@ void bdy_inters::set_boundary_conditions(int sol_spec, int bc_id, double *u_l, d
// extrapolate density
rho_r = rho_l;

// no-slip
if(sol_spec==0)//inviscid solution
if (run_input.bc_list(bc_id).use_wm)//wall model on
{
for (int i=0; i<n_dims; i++)
v_r[i] = 2 * run_input.bc_list(bc_id).velocity(i) - v_l[i];
if (sol_spec == 0) //inverse slip inviscid solution
{
// Compute normal velocity on left side
vn_l = 0.;
for (int i = 0; i < n_dims; i++)
vn_l += v_l[i] * norm[i];

//inverse normal velocity
for (int i = 0; i < n_dims; i++)
v_r[i] = v_l[i] - 2 * vn_l * norm[i];

// energy extraploate temperature
v_sq = 0.;
for (int i = 0; i < n_dims; i++)
v_sq += (v_r[i] * v_r[i]);

e_r = p_l / (gamma - 1.0) + 0.5 * rho_r * v_sq;
}
else if (sol_spec == 1) //slip viscous solution
{
// Compute normal velocity on left side
vn_l = 0.;
for (int i = 0; i < n_dims; i++)
vn_l += v_l[i] * norm[i];

//substract normal velocity
for (int i = 0; i < n_dims; i++)
v_r[i] = v_l[i] - vn_l * norm[i];

// energy extrapolate temperature
v_sq = 0.;
for (int i = 0; i < n_dims; i++)
v_sq += (v_r[i] * v_r[i]);

e_r = p_l / (gamma - 1.0) + 0.5 * rho_r * v_sq;
}
else if (sol_spec == 2) //no-slip viscous solution
{
for (int i = 0; i < n_dims; i++)
v_r[i] = run_input.bc_list(bc_id).velocity(i);

// energy use wall temperature
v_sq = 0.;
for (int i = 0; i < n_dims; i++)
v_sq += (v_r[i] * v_r[i]);

e_r = rho_r * (R_ref / (gamma - 1.0) * T_r) + 0.5 * rho_r * v_sq;
}
}
else//viscous solution
else //wall model off
{
if (sol_spec == 0) //inverse no-slip inviscid solution
{
for (int i = 0; i < n_dims; i++)
v_r[i] = 2 * run_input.bc_list(bc_id).velocity(i) - v_l[i];
}
else if (sol_spec == 1) // no-slip viscous solution
{
for (int i = 0; i < n_dims; i++)
v_r[i] = run_input.bc_list(bc_id).velocity(i);
}
else
{
FatalError("Unrecognized flux type");
}
// energy use wall temperature
v_sq = 0.;
for (int i = 0; i < n_dims; i++)
v_r[i] = run_input.bc_list(bc_id).velocity(i);
}
v_sq += (v_r[i] * v_r[i]);

// energy
v_sq = 0.;
for (int i=0; i<n_dims; i++)
v_sq += (v_r[i]*v_r[i]);

e_r = rho_r * (R_ref / (gamma - 1.0) * T_r) + 0.5 * rho_r * v_sq;
e_r = rho_r * (R_ref / (gamma - 1.0) * T_r) + 0.5 * rho_r * v_sq;
}

// SA model
if (run_input.RANS == 1)
Expand All @@ -693,25 +749,61 @@ void bdy_inters::set_boundary_conditions(int sol_spec, int bc_id, double *u_l, d
}
}

// Adiabatic, no-slip wall (fixed)
// Adiabatic, no-slip wall
else if(bc_flag == ADIABAT_WALL)
{
// extrapolate density
rho_r = rho_l; // only useful part

// no-slip
if (sol_spec == 0) //inviscid solution
if (run_input.bc_list(bc_id).use_wm)//wall model on
{
for (int i = 0; i < n_dims; i++)
v_r[i] = 2 * run_input.bc_list(bc_id).velocity(i) - v_l[i];
if (sol_spec == 0) //inverse slip inviscid solution
{
// Compute normal velocity on left side
vn_l = 0.;
for (int i = 0; i < n_dims; i++)
vn_l += v_l[i] * norm[i];

//inverse normal velocity
for (int i = 0; i < n_dims; i++)
v_r[i] = v_l[i] - 2 * vn_l * norm[i];
}
else if (sol_spec == 1) //slip viscous solution
{
// Compute normal velocity on left side
vn_l = 0.;
for (int i = 0; i < n_dims; i++)
vn_l += v_l[i] * norm[i];

//subtract normal velocity
for (int i = 0; i < n_dims; i++)
v_r[i] = v_l[i] - vn_l * norm[i];
}
else if (sol_spec == 2) //no-slip viscous solution
{
for (int i = 0; i < n_dims; i++)
v_r[i] = run_input.bc_list(bc_id).velocity(i);
}
}
else //viscous solution
else //wall model off
{
for (int i = 0; i < n_dims; i++)
v_r[i] = run_input.bc_list(bc_id).velocity(i);
if (sol_spec == 0) //inverse no-slip inviscid solution
{
for (int i = 0; i < n_dims; i++)
v_r[i] = 2 * run_input.bc_list(bc_id).velocity(i) - v_l[i];
}
else if (sol_spec == 1) // no-slip viscous solution
{
for (int i = 0; i < n_dims; i++)
v_r[i] = run_input.bc_list(bc_id).velocity(i);
}
else
{
FatalError("Unrecognized flux type");
}
}

// energy
// energy extrapolate temperature
v_sq = 0.;
for (int i=0; i<n_dims; i++)
v_sq += (v_r[i]*v_r[i]);
Expand Down Expand Up @@ -962,7 +1054,7 @@ void bdy_inters::evaluate_boundaryConditions_viscFlux(double time_bound)
temp_loc(m) = *pos_fpts(j, i, m);
}
//calculate viscous boundary solution
set_boundary_conditions(1, boundary_id(i), temp_u_l.get_ptr_cpu(), temp_u_r.get_ptr_cpu(),
set_boundary_conditions(2, boundary_id(i), temp_u_l.get_ptr_cpu(), temp_u_r.get_ptr_cpu(),
norm.get_ptr_cpu(), temp_loc.get_ptr_cpu(), run_input.gamma, run_input.R_ref, time_bound, run_input.equation);

/*! obtain wall model input solutions */
Expand Down
2 changes: 1 addition & 1 deletion src/eles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@ void eles::evaluate_viscFlux(void)
void eles::calc_sgsf_upts(hf_array<double>& temp_u, hf_array<double>& temp_grad_u, double& detjac, int ele, int upt, hf_array<double>& temp_sgsf)
{
int i,j,k;
int eddy, sim, wall;
int eddy, sim;
double C_s=run_input.C_s;
double diag;
double ke;
Expand Down
8 changes: 5 additions & 3 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ void input::read_input_file(string fileName, int rank)
if (SGS_model == 3 || SGS_model == 2 || SGS_model == 4)
opts.getScalarValue("filter_type", filter_type);
opts.getScalarValue("filter_ratio", filter_ratio);
opts.getScalarValue("wall_model", wall_model, 0); //0: no wall model;1: werner-wengle; 2: Breuer-Rodi
}
opts.getScalarValue("wall_model", wall_model, 0); //0: no wall model;1: werner-wengle; 2: Breuer-Rodi

/* ---- Gas Parameters ---- */

Expand Down Expand Up @@ -388,7 +388,7 @@ void input::read_boundary_param(void)
bdy_r.getScalarValue(bc_paramS + "u", bc_list(i).velocity(0), 0.);
bdy_r.getScalarValue(bc_paramS + "v", bc_list(i).velocity(1), 0.);
bdy_r.getScalarValue(bc_paramS + "w", bc_list(i).velocity(2), 0.);
if (LES && wall_model)
if (wall_model)
bdy_r.getScalarValue(bc_paramS + "use_wm", bc_list(i).use_wm, 0);
}
else if (bc_list(i).get_bc_flag() == CHAR)
Expand All @@ -408,7 +408,7 @@ void input::read_boundary_param(void)
bdy_r.getScalarValue(bc_paramS + "u", bc_list(i).velocity(0), 0.);
bdy_r.getScalarValue(bc_paramS + "v", bc_list(i).velocity(1), 0.);
bdy_r.getScalarValue(bc_paramS + "w", bc_list(i).velocity(2), 0.);
if (LES && wall_model)
if (wall_model)
bdy_r.getScalarValue(bc_paramS + "use_wm", bc_list(i).use_wm, 0);
}
}
Expand Down Expand Up @@ -542,6 +542,8 @@ void input::setup_params(int rank)
FatalError("turbulent model not supported with inviscid flow");
if (LES)
FatalError("Cannot turn on RANS and LES at same time");
if (wall_model)
FatalError("Cannot use wall model with RANS");
}

if (LES && !viscous)
Expand Down

0 comments on commit ad897f1

Please sign in to comment.