Skip to content

Commit

Permalink
semi
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyuxie committed Aug 26, 2024
1 parent e5f8a5d commit 7707c61
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/callbacks_step/glm_speed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function update_cleaning_speed!(semi, glm_speed_callback, dt)
c_h_deltat = calc_dt_for_cleaning_speed(cfl, mesh, equations, solver, cache)

# c_h is proportional to its own time step divided by the complete MHD time step
@reset equations.c_h = glm_scale * c_h_deltat / dt
@reset semi.equations.c_h = glm_scale * c_h_deltat / dt

return semi
end
Expand Down
5 changes: 5 additions & 0 deletions src/equations/ideal_glm_mhd_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ struct IdealGlmMhdEquations2D{RealT <: Real} <:
γ, inv_gamma_minus_one, c_h = promote(gamma, inv(gamma - 1), c_h)
new{typeof(γ)}(γ, inv_gamma_minus_one, c_h)
end

function IdealGlmMhdEquations2D(gamma, inv_gamma_minus_one, c_h)
γ, inv_gamma_minus_one, c_h = promote(gamma, inv_gamma_minus_one, c_h)
new{typeof(γ)}(γ, inv_gamma_minus_one, c_h)
end
end

function IdealGlmMhdEquations2D(gamma; initial_c_h = convert(typeof(gamma), NaN))
Expand Down
5 changes: 5 additions & 0 deletions src/equations/ideal_glm_mhd_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ struct IdealGlmMhdEquations3D{RealT <: Real} <:
γ, inv_gamma_minus_one, c_h = promote(gamma, inv(gamma - 1), c_h)
new{typeof(γ)}(γ, inv_gamma_minus_one, c_h)
end

function IdealGlmMhdEquations3D(gamma, inv_gamma_minus_one, c_h)
γ, inv_gamma_minus_one, c_h = promote(gamma, inv_gamma_minus_one, c_h)
new{typeof(γ)}(γ, inv_gamma_minus_one, c_h)
end
end

function IdealGlmMhdEquations3D(gamma; initial_c_h = convert(typeof(gamma), NaN))
Expand Down
2 changes: 1 addition & 1 deletion src/semidiscretization/semidiscretization_coupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function update_cleaning_speed!(semi_coupled::SemidiscretizationCoupled,
c_h_deltat = calc_dt_for_cleaning_speed(cfl, mesh, equations, solver, cache)

# c_h is proportional to its own time step divided by the complete MHD time step
@reset equations.c_h = glm_scale * c_h_deltat / dt
equations.c_h = glm_scale * c_h_deltat / dt
end

return semi_coupled
Expand Down
33 changes: 33 additions & 0 deletions src/semidiscretization/semidiscretization_hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ struct SemidiscretizationHyperbolic{Mesh, Equations, InitialCondition,
new(mesh, equations, initial_condition, boundary_conditions, source_terms,
solver, cache, performance_counter)
end

function SemidiscretizationHyperbolic{Mesh, Equations, InitialCondition,
BoundaryConditions, SourceTerms, Solver,
Cache}(mesh::Mesh, equations::Equations,
initial_condition::InitialCondition,
boundary_conditions::BoundaryConditions,
source_terms::SourceTerms,
solver::Solver,
cache::Cache,
performance_counter) where {Mesh,
Equations,
InitialCondition,
BoundaryConditions,
SourceTerms,
Solver,
Cache}
new(mesh, equations, initial_condition, boundary_conditions, source_terms,
solver, cache, performance_counter)
end
end

"""
Expand Down Expand Up @@ -84,6 +103,20 @@ function SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver
cache)
end

function SemidiscretizationHyperbolic(mesh, equations, initial_condition,
boundary_conditions,
source_terms, solver, cache, performance_counter)
SemidiscretizationHyperbolic{typeof(mesh), typeof(equations),
typeof(initial_condition),
typeof(boundary_conditions), typeof(source_terms),
typeof(solver), typeof(cache)}(mesh, equations,
initial_condition,
boundary_conditions,
source_terms,
solver, cache,
performance_counter)
end

# Create a new semidiscretization but change some parameters compared to the input.
# `Base.similar` follows a related concept but would require us to `copy` the `mesh`,
# which would impact the performance. Instead, `SciMLBase.remake` has exactly the
Expand Down

0 comments on commit 7707c61

Please sign in to comment.