Skip to content

Commit

Permalink
element
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Oct 9, 2024
1 parent 3256ecc commit 9b22f46
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions src/semidiscretization/semidiscretization_euler_gravity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,37 @@ function rhs!(du_ode, u_ode, semi::SemidiscretizationEulerGravity, t)
n_elements = size(u_euler)[end]
# add gravitational source source_terms to the Euler part
if ndims(semi_euler) == 1
@threaded for i in 1:n_elements
@views @. du_euler[2, .., i] -= u_euler[1, .., i] * u_gravity[2, .., i]
@views @. du_euler[3, .., i] -= u_euler[2, .., i] * u_gravity[2, .., i]
@threaded for element in 1:n_elements
@views @. du_euler[2, .., element] -= u_euler[1, .., element] *
u_gravity[2, .., element]
@views @. du_euler[3, .., element] -= u_euler[2, .., element] *
u_gravity[2, .., element]
end
elseif ndims(semi_euler) == 2
@threaded for i in 1:n_elements
@views @. du_euler[2, .., i] -= u_euler[1, .., i] * u_gravity[2, .., i]
@views @. du_euler[3, .., i] -= u_euler[1, .., i] * u_gravity[3, .., i]
@views @. du_euler[4, .., i] -= (u_euler[2, .., i] * u_gravity[2, .., i] +
u_euler[3, .., i] * u_gravity[3, .., i])
@threaded for element in 1:n_elements
@views @. du_euler[2, .., element] -= u_euler[1, .., element] *
u_gravity[2, .., element]
@views @. du_euler[3, .., element] -= u_euler[1, .., element] *
u_gravity[3, .., element]
@views @. du_euler[4, .., element] -= (u_euler[2, .., element] *
u_gravity[2, .., element] +
u_euler[3, .., element] *
u_gravity[3, .., element])
end
elseif ndims(semi_euler) == 3
@threaded for i in 1:n_elements
@views @. du_euler[2, .., i] -= u_euler[1, .., i] * u_gravity[2, .., i]
@views @. du_euler[3, .., i] -= u_euler[1, .., i] * u_gravity[3, .., i]
@views @. du_euler[4, .., i] -= u_euler[1, .., i] * u_gravity[4, .., i]
@views @. du_euler[5, .., i] -= (u_euler[2, .., i] * u_gravity[2, .., i] +
u_euler[3, .., i] * u_gravity[3, .., i] +
u_euler[4, .., i] * u_gravity[4, .., i])
@threaded for element in 1:n_elements
@views @. du_euler[2, .., element] -= u_euler[1, .., element] *
u_gravity[2, .., element]
@views @. du_euler[3, .., element] -= u_euler[1, .., element] *
u_gravity[3, .., element]
@views @. du_euler[4, .., element] -= u_euler[1, .., element] *
u_gravity[4, .., element]
@views @. du_euler[5, .., element] -= (u_euler[2, .., element] *
u_gravity[2, .., element] +
u_euler[3, .., element] *
u_gravity[3, .., element] +
u_euler[4, .., element] *
u_gravity[4, .., element])
end
else
error("Number of dimensions $(ndims(semi_euler)) not supported.")
Expand Down Expand Up @@ -343,8 +355,9 @@ function timestep_gravity_2N!(cache, u_euler, t, dt, gravity_parameters, semi_gr
# put in gravity source term proportional to Euler density
# OBS! subtract off the background density ρ_0 (spatial mean value)
n_elements = size(u_euler)[end]
@threaded for i in 1:n_elements
@views @. du_gravity[1, .., i] += grav_scale * (u_euler[1, .., i] - rho0)
@threaded for element in 1:n_elements
@views @. du_gravity[1, .., element] += grav_scale *
(u_euler[1, .., element] - rho0)
end

a_stage = a[stage]
Expand Down Expand Up @@ -401,8 +414,9 @@ function timestep_gravity_3Sstar!(cache, u_euler, t, dt, gravity_parameters,
# put in gravity source term proportional to Euler density
# OBS! subtract off the background density ρ_0 around which the Jeans instability is perturbed
n_elements = size(u_euler)[end]
@threaded for i in 1:n_elements
@views @. du_gravity[1, .., i] += grav_scale * (u_euler[1, .., i] - rho0)
@threaded for element in 1:n_elements
@views @. du_gravity[1, .., element] += grav_scale *
(u_euler[1, .., element] - rho0)
end

delta_stage = delta[stage]
Expand Down

0 comments on commit 9b22f46

Please sign in to comment.