Skip to content

Commit

Permalink
Merge pull request #1568 from CEED/jrwrigh/fix_blasius_state
Browse files Browse the repository at this point in the history
fix: Correct P0 deprecation
  • Loading branch information
jrwrigh committed Apr 29, 2024
2 parents 1863db2 + 2249ac9 commit 7dc3a04
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
5 changes: 5 additions & 0 deletions examples/fluids/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,11 @@ For the Density Current, Channel, and Blasius problems, the following common com
- `0`
- `m`

* - `-idl_pressure`
- Pressure used for IDL reference pressure
- `-reference_pressure`
- `Pa`

* - `-sgs_model_type`
- Type of subgrid stress model to use. Currently only `data_driven` is available
- `none`
Expand Down
15 changes: 6 additions & 9 deletions examples/fluids/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -855,20 +855,17 @@ numerous terms in the STG formulation.

#### Internal Damping Layer (IDL)
The STG inflow boundary condition creates large amplitude acoustic waves.
We use an internal damping layer (IDL) to damp them out without disrupting the synthetic structures developing into natural turbulent structures. This implementation was inspired from
{cite}`shurSTG2014`, but is implemented here as a ramped volumetric forcing
term, similar to a sponge layer (see 8.4.2.4 in {cite}`colonius2023turbBC` for example). It takes the following form:
We use an internal damping layer (IDL) to damp them out without disrupting the synthetic structures developing into natural turbulent structures.
This implementation was inspired by {cite}`shurSTG2014`, but is implemented here as a ramped volumetric forcing term, similar to a sponge layer (see 8.4.2.4 in {cite}`colonius2023turbBC` for example).
It takes the following form:

$$
S(\bm{q}) = -\sigma(\bm{x})\left.\frac{\partial \bm{q}}{\partial \bm{Y}}\right\rvert_{\bm{q}} \bm{Y}'
$$

where $\bm{Y}' = [P - P_\mathrm{ref}, \bm{0}, 0]^T$, and $\sigma(\bm{x})$ is a
linear ramp starting at `-idl_start` with length `-idl_length` and an amplitude
of inverse `-idl_decay_rate`. The damping is defined in terms of a pressure-primitive
anomaly $\bm Y'$ converted to conservative source using $\partial
\bm{q}/\partial \bm{Y}\rvert_{\bm{q}}$, which is linearized about the current
flow state. $P_\mathrm{ref}$ is defined via the `-reference_pressure` flag.
where $\bm{Y}' = [P - P_\mathrm{ref}, \bm{0}, 0]^T$, and $\sigma(\bm{x})$ is a linear ramp starting at `-idl_start` with length `-idl_length` and an amplitude of inverse `-idl_decay_rate`.
The damping is defined in terms of a pressure-primitive anomaly $\bm Y'$ converted to conservative source using $\partial \bm{q}/\partial \bm{Y}\rvert_{\bm{q}}$, which is linearized about the current flow state.
$P_\mathrm{ref}$ has a default value equal to `-reference_pressure` flag, with an optional flag `-idl_pressure` to set it to a different value.

### Meshing

Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/navierstokes.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//TESTARGS(name="Blasius, SGS DataDriven Fused") -ceed {ceed_resource} -options_file examples/fluids/tests-output/blasius_stgtest.yaml -sgs_model_type data_driven -sgs_model_dd_leakyrelu_alpha 0.3 -sgs_model_dd_parameter_dir examples/fluids/dd_sgs_data -ts_dt 2e-9 -state_var primitive -ksp_rtol 1e-12 -snes_rtol 1e-12 -stg_mean_only -stg_fluctuating_IC -test_type solver -compare_final_state_atol 1e-10 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-blasius-sgs-data-driven.bin
//TESTARGS(name="Blasius, Anisotropic Differential Filter") -ceed {ceed_resource} -test_type diff_filter -options_file examples/fluids/tests-output/blasius_test.yaml -compare_final_state_atol 5e-10 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-blasius_diff_filter_aniso_vandriest.bin -diff_filter_monitor -ts_max_steps 0 -state_var primitive -diff_filter_friction_length 1e-5 -diff_filter_wall_damping_function van_driest -diff_filter_ksp_rtol 1e-8 -diff_filter_grid_based_width -diff_filter_width_scaling 1,0.7,1
//TESTARGS(name="Blasius, Isotropic Differential Filter") -ceed {ceed_resource} -test_type diff_filter -options_file examples/fluids/tests-output/blasius_test.yaml -compare_final_state_atol 2e-12 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-blasius_diff_filter_iso.bin -diff_filter_monitor -ts_max_steps 0 -diff_filter_width_scaling 4.2e-5,4.2e-5,4.2e-5 -diff_filter_ksp_atol 1e-14 -diff_filter_ksp_rtol 1e-16
//TESTARGS(name="Gaussian Wave, with IDL") -ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_final_state_atol 2e-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-gaussianwave-IDL.bin -dm_plex_box_faces 5,5,1 -ts_max_steps 5 -idl_decay_time 2e-3 -idl_length 0.25 -idl_start 0 -ts_alpha_radius 0.5
//TESTARGS(name="Gaussian Wave, with IDL") -ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_final_state_atol 2e-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-gaussianwave-IDL.bin -dm_plex_box_faces 5,5,1 -ts_max_steps 5 -idl_decay_time 2e-3 -idl_length 0.25 -idl_start 0 -ts_alpha_radius 0.5 -idl_pressure 70
//TESTARGS(name="Spanwise Turbulence Statistics") -ceed {ceed_resource} -test_type turb_spanstats -options_file examples/fluids/tests-output/stats_test.yaml -compare_final_state_atol 1E-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-turb-spanstats-stats.bin
//TESTARGS(name="Blasius") -ceed {ceed_resource} -test_type solver -options_file examples/fluids/tests-output/blasius_test.yaml -compare_final_state_atol 2E-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-blasius.bin
//TESTARGS(name="Blasius, STG Inflow") -ceed {ceed_resource} -test_type solver -options_file examples/fluids/tests-output/blasius_stgtest.yaml -compare_final_state_atol 2E-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-blasius_STG.bin
Expand Down
26 changes: 14 additions & 12 deletions examples/fluids/problems/blasius.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,17 @@ PetscErrorCode NS_BLASIUS(ProblemData problem, DM dm, void *ctx, SimpleBC bc) {
PetscInt mesh_Ndelta = 45; // [-]
PetscReal mesh_top_angle = 5; // degrees
char mesh_ynodes_path[PETSC_MAX_PATH_LEN] = "";
PetscBool flg;
PetscBool P0_set;

PetscOptionsBegin(comm, NULL, "Options for BLASIUS problem", NULL);
PetscCall(PetscOptionsBool("-weakT", "Change from rho weak to T weak at inflow", NULL, weakT, &weakT, NULL));
PetscCall(PetscOptionsScalar("-velocity_infinity", "Velocity at boundary layer edge", NULL, U_inf, &U_inf, NULL));
PetscCall(PetscOptionsScalar("-temperature_infinity", "Temperature at boundary layer edge", NULL, T_inf, &T_inf, NULL));
PetscCall(PetscOptionsScalar("-pressure_infinity", "Pressure at boundary layer edge", NULL, P_inf, &P_inf, &flg));
PetscCall(PetscOptionsDeprecated("-P0", "-pressure_infinity", "libCEED 0.12.0", "Use -pressure_infinity to set pressure at boundary layer edge"));
if (!flg) PetscCall(PetscOptionsScalar("-P0", "Pressure at boundary layer edge", NULL, P_inf, &P_inf, &flg));
PetscCall(PetscOptionsHasName(NULL, NULL, "-P0", &P0_set)); // For maintaining behavior of -P0 flag (which is deprecated)
PetscCall(
PetscOptionsDeprecated("-P0", "-pressure_infinity", "libCEED 0.12.0",
"Use -pressure_infinity to set pressure at boundary layer edge and -idl_pressure to set the IDL reference pressure"));
PetscCall(PetscOptionsScalar("-pressure_infinity", "Pressure at boundary layer edge", NULL, P_inf, &P_inf, NULL));
PetscCall(PetscOptionsScalar("-temperature_wall", "Temperature at wall", NULL, T_wall, &T_wall, NULL));
PetscCall(PetscOptionsScalar("-delta0", "Boundary layer height at inflow", NULL, delta0, &delta0, NULL));
PetscCall(PetscOptionsInt("-n_chebyshev", "Number of Chebyshev terms", NULL, N, &N, NULL));
Expand Down Expand Up @@ -319,14 +321,14 @@ PetscErrorCode NS_BLASIUS(ProblemData problem, DM dm, void *ctx, SimpleBC bc) {
};
State S_infty = StateFromPrimitive(newtonian_ig_ctx, Y_inf);

blasius_ctx->weakT = weakT;
blasius_ctx->T_wall = T_wall;
blasius_ctx->delta0 = delta0;
blasius_ctx->S_infty = S_infty;
blasius_ctx->n_cheb = N;
newtonian_ig_ctx->idl_pressure = P_inf;
blasius_ctx->implicit = user->phys->implicit;
blasius_ctx->newtonian_ctx = *newtonian_ig_ctx;
blasius_ctx->weakT = weakT;
blasius_ctx->T_wall = T_wall;
blasius_ctx->delta0 = delta0;
blasius_ctx->S_infty = S_infty;
blasius_ctx->n_cheb = N;
blasius_ctx->implicit = user->phys->implicit;
if (P0_set) newtonian_ig_ctx->idl_pressure = P_inf; // For maintaining behavior of -P0 flag (which is deprecated)
blasius_ctx->newtonian_ctx = *newtonian_ig_ctx;

{
PetscReal domain_min[3], domain_max[3];
Expand Down
9 changes: 5 additions & 4 deletions examples/fluids/problems/newtonian.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData problem, DM dm, void *ctx, SimpleBC b
for (PetscInt i = 0; i < 3; i++) domain_size[i] = domain_max[i] - domain_min[i];

StatePrimitive reference = {.pressure = 1.01e5, .velocity = {0}, .temperature = 288.15};
CeedScalar idl_decay_time = -1, idl_start = 0, idl_length = 0;
CeedScalar idl_decay_time = -1, idl_start = 0, idl_length = 0, idl_pressure = reference.pressure;
PetscBool idl_enable = PETSC_FALSE;

// ------------------------------------------------------
Expand Down Expand Up @@ -229,8 +229,6 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData problem, DM dm, void *ctx, SimpleBC b

PetscInt dim = problem->dim;
PetscCall(PetscOptionsDeprecated("-g", "-gravity", "libCEED 0.11.1", NULL));
PetscCall(PetscOptionsRealArray("-g", "Gravitational acceleration vector", NULL, g, &dim, &given_option));
dim = problem->dim;
PetscCall(PetscOptionsRealArray("-gravity", "Gravitational acceleration vector", NULL, g, &dim, &given_option));
if (given_option) PetscCheck(dim == 3, comm, PETSC_ERR_ARG_SIZ, "Gravity vector must be size 3, %" PetscInt_FMT " values given", dim);

Expand Down Expand Up @@ -269,6 +267,9 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData problem, DM dm, void *ctx, SimpleBC b
if (idl_decay_time < 0) idl_enable = PETSC_FALSE;
PetscCall(PetscOptionsScalar("-idl_start", "Start of IDL in the x direction", NULL, idl_start, &idl_start, NULL));
PetscCall(PetscOptionsScalar("-idl_length", "Length of IDL in the positive x direction", NULL, idl_length, &idl_length, NULL));
idl_pressure = reference.pressure;
PetscCall(PetscOptionsScalar("-idl_pressure", "Pressure IDL uses as reference (default is `-reference_pressure`)", NULL, idl_pressure,
&idl_pressure, NULL));
PetscOptionsEnd();

if (stab == STAB_SUPG && !implicit) problem->create_mass_operator = CreateKSPMassOperator_NewtonianStabilized;
Expand Down Expand Up @@ -322,14 +323,14 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData problem, DM dm, void *ctx, SimpleBC b
newtonian_ig_ctx->Ctau_C = Ctau_C;
newtonian_ig_ctx->Ctau_M = Ctau_M;
newtonian_ig_ctx->Ctau_E = Ctau_E;
newtonian_ig_ctx->idl_pressure = reference.pressure;
newtonian_ig_ctx->stabilization = stab;
newtonian_ig_ctx->is_implicit = implicit;
newtonian_ig_ctx->state_var = state_var;
newtonian_ig_ctx->idl_enable = idl_enable;
newtonian_ig_ctx->idl_amplitude = 1 / (idl_decay_time * second);
newtonian_ig_ctx->idl_start = idl_start * meter;
newtonian_ig_ctx->idl_length = idl_length * meter;
newtonian_ig_ctx->idl_pressure = idl_pressure;
PetscCall(PetscArraycpy(newtonian_ig_ctx->g, g, 3));

// -- Setup Context
Expand Down
4 changes: 0 additions & 4 deletions examples/fluids/src/cloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx, SimpleBC
"Use -bc_symmetry_[x,y,z] for direct equivalency, or -bc_slip for weak, Riemann-based, direction-invariant "
"slip/no-penatration boundary conditions"));
PetscCall(PetscOptionsIntArray(flags[j], "Face IDs to apply symmetry BC", NULL, bc->symmetries[j], &bc->num_symmetry[j], &flg));
if (!flg) {
bc->num_symmetry[j] = 16;
PetscCall(PetscOptionsIntArray(deprecated[j], "Face IDs to apply slip BC", NULL, bc->symmetries[j], &bc->num_symmetry[j], &flg));
}
if (bc->num_symmetry[j] > 0) has_symmetry = PETSC_TRUE;
}

Expand Down
Binary file not shown.

0 comments on commit 7dc3a04

Please sign in to comment.