Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpit-Babbar committed Feb 10, 2024
1 parent 8d9302e commit 1a704d6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 65 deletions.
53 changes: 27 additions & 26 deletions examples/p4est_2d_dgsem/elixir_euler_NACA0012airfoil_mach08.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ equations = CompressibleEulerEquations2D(1.4)
pre_inf() = 1.0
rho_inf() = pre_inf() / (1.0 * 287.87) # pre_inf = 1.0, T = 1, R = 287.87
mach_inf() = 0.85
aoa() = pi/180.0
c_inf(equations) = sqrt( equations.gamma * pre_inf() / rho_inf() )
aoa() = pi / 180.0
c_inf(equations) = sqrt(equations.gamma * pre_inf() / rho_inf())
U_inf(equations) = mach_inf() * c_inf(equations)

@inline function initial_condition_mach085_flow(x, t, equations::CompressibleEulerEquations2D)
# set the freestream flow parameters
gasGam = equations.gamma
@inline function initial_condition_mach085_flow(x, t,
equations::CompressibleEulerEquations2D)
# set the freestream flow parameters
gasGam = equations.gamma

v1 = U_inf(equations) * cos(aoa())
v2 = U_inf(equations) * sin(aoa())
v1 = U_inf(equations) * cos(aoa())
v2 = U_inf(equations) * sin(aoa())

prim = SVector(rho_inf(), v1, v2, pre_inf())
return prim2cons(prim, equations)
prim = SVector(rho_inf(), v1, v2, pre_inf())
return prim2cons(prim, equations)
end

initial_condition = initial_condition_mach085_flow
Expand Down Expand Up @@ -66,14 +67,12 @@ mesh = P4estMesh{2}(mesh_file)
return Trixi.flux_hll(u_inner, u_boundary, normal_direction, equations)
end


boundary_conditions = Dict(
:Left => boundary_condition_subsonic_constant,
:Right => boundary_condition_subsonic_constant,
:Top => boundary_condition_subsonic_constant,
:Bottom => boundary_condition_subsonic_constant,
:AirfoilBottom => boundary_condition_slip_wall,
:AirfoilTop => boundary_condition_slip_wall)
boundary_conditions = Dict(:Left => boundary_condition_subsonic_constant,
:Right => boundary_condition_subsonic_constant,
:Top => boundary_condition_subsonic_constant,
:Bottom => boundary_condition_subsonic_constant,
:AirfoilBottom => boundary_condition_slip_wall,
:AirfoilTop => boundary_condition_slip_wall)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)
Expand All @@ -94,10 +93,12 @@ analysis_interval = 2000
linf = 1.0 # Length of airfoil

drag_coefficient = AnalysisSurfaceIntegral(semi, boundary_condition_slip_wall,
DragCoefficient(aoa(), rho_inf(), U_inf(equations), linf))
DragCoefficient(aoa(), rho_inf(),
U_inf(equations), linf))

lift_coefficient = AnalysisSurfaceIntegral(semi, boundary_condition_slip_wall,
LiftCoefficient(aoa(), rho_inf(), U_inf(equations), linf))
LiftCoefficient(aoa(), rho_inf(),
U_inf(equations), linf))

analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
output_directory = "analysis_results",
Expand All @@ -115,17 +116,17 @@ save_solution = SaveSolutionCallback(interval = 500,
# Small time step should be used to reach steady state
stepsize_callback = StepsizeCallback(cfl = 0.25)

amr_indicator = IndicatorLöhner(semi, variable=Trixi.density)
amr_indicator = IndicatorLöhner(semi, variable = Trixi.density)

amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level=1,
med_level=3, med_threshold=0.05,
max_level=4, max_threshold=0.1)
base_level = 1,
med_level = 3, med_threshold = 0.05,
max_level = 4, max_threshold = 0.1)

amr_callback = AMRCallback(semi, amr_controller,
interval=100,
adapt_initial_condition=true,
adapt_initial_condition_only_refine=true)
interval = 100,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)

callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution,
stepsize_callback, amr_callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ sw_linf() = 1.0
sw_mach_inf() = 0.8
sw_U_inf(equations) = sw_mach_inf() * sqrt(equations.gamma * sw_pre_inf() / sw_rho_inf())
@inline function initial_condition_mach08_flow(x, t, equations)
# set the freestream flow parameters
gasGam = equations.gamma
mach_inf = sw_mach_inf()
aoa = sw_aoa()
rho_inf = sw_rho_inf()
pre_inf = sw_pre_inf()
U_inf = mach_inf * sqrt(gasGam * pre_inf / rho_inf)

v1 = U_inf * cos(aoa)
v2 = U_inf * sin(aoa)

prim = SVector(rho_inf, v1, v2, pre_inf)
return prim2cons(prim, equations)
# set the freestream flow parameters
gasGam = equations.gamma
mach_inf = sw_mach_inf()
aoa = sw_aoa()
rho_inf = sw_rho_inf()
pre_inf = sw_pre_inf()
U_inf = mach_inf * sqrt(gasGam * pre_inf / rho_inf)

v1 = U_inf * cos(aoa)
v2 = U_inf * sin(aoa)

prim = SVector(rho_inf, v1, v2, pre_inf)
return prim2cons(prim, equations)
end

initial_condition = initial_condition_mach08_flow
Expand Down Expand Up @@ -65,34 +65,32 @@ mesh = P4estMesh{2}(mesh_file, initial_refinement_level = 1)
return Trixi.flux_hll(u_inner, u_boundary, normal_direction, equations)
end

boundary_conditions = Dict(:Left => boundary_condition_subsonic_constant,
:Right => boundary_condition_subsonic_constant,
:Top => boundary_condition_subsonic_constant,
:Bottom => boundary_condition_subsonic_constant,
:AirfoilBottom => boundary_condition_slip_wall,
:AirfoilTop => boundary_condition_slip_wall)

boundary_conditions = Dict(
:Left => boundary_condition_subsonic_constant,
:Right => boundary_condition_subsonic_constant,
:Top => boundary_condition_subsonic_constant,
:Bottom => boundary_condition_subsonic_constant,
:AirfoilBottom => boundary_condition_slip_wall,
:AirfoilTop => boundary_condition_slip_wall)

velocity_airfoil = NoSlip(
(x, t, equations) -> SVector(0.0, 0.0))
velocity_airfoil = NoSlip((x, t, equations) -> SVector(0.0, 0.0))

heat_airfoil = Adiabatic((x, t, equations) -> 0.0)

boundary_conditions_airfoil = BoundaryConditionNavierStokesWall(
velocity_airfoil, heat_airfoil)
boundary_conditions_airfoil = BoundaryConditionNavierStokesWall(velocity_airfoil,
heat_airfoil)

velocity_bc_square = NoSlip((x, t, equations) -> initial_condition_mach08_flow(x, t, equations)[2:3])
velocity_bc_square = NoSlip((x, t, equations) -> initial_condition_mach08_flow(x, t,
equations)[2:3])
heat_bc_square = Adiabatic((x, t, equations) -> 0.0)
boundary_condition_square = BoundaryConditionNavierStokesWall(velocity_bc_square, heat_bc_square)
boundary_condition_square = BoundaryConditionNavierStokesWall(velocity_bc_square,
heat_bc_square)

boundary_conditions_parabolic = Dict(
:Left => boundary_condition_square,
:Right => boundary_condition_square,
:Top => boundary_condition_square,
:Bottom => boundary_condition_square,
:AirfoilBottom => boundary_conditions_airfoil,
:AirfoilTop => boundary_conditions_airfoil)
boundary_conditions_parabolic = Dict(:Left => boundary_condition_square,
:Right => boundary_condition_square,
:Top => boundary_condition_square,
:Bottom => boundary_condition_square,
:AirfoilBottom => boundary_conditions_airfoil,
:AirfoilTop => boundary_conditions_airfoil)

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, solver;
Expand All @@ -113,10 +111,12 @@ summary_callback = SummaryCallback()
analysis_interval = 2000

drag_coefficient = AnalysisSurfaceIntegral(semi, boundary_condition_slip_wall,
DragCoefficient(sw_aoa(), sw_rho_inf(), sw_U_inf(equations), sw_linf()))
DragCoefficient(sw_aoa(), sw_rho_inf(),
sw_U_inf(equations), sw_linf()))

lift_coefficient = AnalysisSurfaceIntegral(semi, boundary_condition_slip_wall,
LiftCoefficient(sw_aoa(), sw_rho_inf(), sw_U_inf(equations), sw_linf()))
LiftCoefficient(sw_aoa(), sw_rho_inf(),
sw_U_inf(equations), sw_linf()))

analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
output_directory = "analysis_results",
Expand All @@ -131,15 +131,12 @@ save_solution = SaveSolutionCallback(interval = 500,
save_final_solution = true,
solution_variables = cons2prim)


callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)

###############################################################################
# run the simulation


time_int_tol = 1e-11
sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol,
ode_default_options()..., callback = callbacks)
summary_callback() # print the timer summary

0 comments on commit 1a704d6

Please sign in to comment.