Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
amrueda committed Nov 7, 2023
1 parent 84966be commit 1dd114d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
27 changes: 11 additions & 16 deletions src/equations/ideal_mhd_multiion_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ mutable struct IdealMhdMultiIonEquations1D{NVARS, NCOMP, RealT <: Real} <:
gammas :: SVector{NCOMP, RealT} # Heat capacity ratios
charge_to_mass :: SVector{NCOMP, RealT} # Charge to mass ratios

function IdealMhdMultiIonEquations1D{NVARS, NCOMP, RealT}(gammas::SVector{NCOMP,
RealT},
charge_to_mass::SVector{
NCOMP,
RealT
}) where {
NVARS,
NCOMP,
RealT <:
Real
}
function IdealMhdMultiIonEquations1D{NVARS, NCOMP,
RealT}(gammas
::SVector{NCOMP, RealT},
charge_to_mass
::SVector{NCOMP, RealT}) where
{NVARS, NCOMP, RealT <: Real}
NCOMP >= 1 ||
throw(DimensionMismatch("`gammas` and `charge_to_mass` have to be filled with at least one value"))

Expand Down Expand Up @@ -310,7 +305,7 @@ The term is composed of three parts

# Compute charge ratio of u_ll
charge_ratio_ll = zero(MVector{ncomponents(equations), eltype(u_ll)})
total_electron_charge = zero(eltype(u_ll))
total_electron_charge = zero(real(equations))
for k in eachcomponent(equations)
rho_k = u_ll[3 + (k - 1) * 5 + 1]
charge_ratio_ll[k] = rho_k * charge_to_mass[k]
Expand Down Expand Up @@ -504,7 +499,7 @@ end
end

@inline function max_abs_speeds(u, equations::IdealMhdMultiIonEquations1D)
v1 = zero(eltype(u))
v1 = zero(real(equations))
for k in eachcomponent(equations)
rho, rho_v1, _ = get_component(k, u, equations)
v1 = max(v1, abs(rho_v1 / rho))
Expand Down Expand Up @@ -610,7 +605,7 @@ Compute the fastest wave speed for ideal MHD equations: c_f, the fast magnetoaco
equations::IdealMhdMultiIonEquations1D)
B1, B2, B3 = magnetic_field(cons, equations)

c_f = zero(cons[1])
c_f = zero(real(equations))
for k in eachcomponent(equations)
rho, rho_v1, rho_v2, rho_v3, rho_e = get_component(k, cons, equations)

Expand Down Expand Up @@ -642,7 +637,7 @@ Routine to compute the charge-averaged velocities:
* vk*_plus: Contribution of each species to the charge-averaged velocity
"""
@inline function charge_averaged_velocities(u, equations::IdealMhdMultiIonEquations1D)
total_electron_charge = zero(eltype(u))
total_electron_charge = zero(real(equations))

vk1_plus = zero(MVector{ncomponents(equations), eltype(u)})
vk2_plus = zero(MVector{ncomponents(equations), eltype(u)})
Expand Down Expand Up @@ -696,7 +691,7 @@ end
magnetic_field(u, equations::IdealMhdMultiIonEquations1D) = SVector(u[1], u[2], u[3])

@inline function density(u, equations::IdealMhdMultiIonEquations1D)
rho = zero(eltype(u))
rho = zero(real(equations))
for k in eachcomponent(equations)
rho += u[3 + (k - 1) * 5 + 1]
end
Expand Down
23 changes: 8 additions & 15 deletions src/equations/ideal_mhd_multiion_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ mutable struct IdealMhdMultiIonEquations2D{NVARS, NCOMP, RealT <: Real, Electron
charge_to_mass::SVector{NCOMP, RealT} # Charge to mass ratios
electron_pressure::ElectronPressure # Function to compute the electron pressure

function IdealMhdMultiIonEquations2D{NVARS, NCOMP, RealT, ElectronPressure}(gammas::SVector{
NCOMP,
RealT
},
charge_to_mass::SVector{
NCOMP,
RealT
},
electron_pressure::ElectronPressure) where {
NVARS,
NCOMP,
RealT <:
Real,
ElectronPressure
}
function IdealMhdMultiIonEquations2D{NVARS, NCOMP, RealT,
ElectronPressure}(gammas
::SVector{NCOMP, RealT},
charge_to_mass
::SVector{NCOMP, RealT},
electron_pressure
::ElectronPressure) where
{NVARS, NCOMP, RealT <: Real, ElectronPressure}
NCOMP >= 1 ||
throw(DimensionMismatch("`gammas` and `charge_to_mass` have to be filled with at least one value"))

Expand Down

0 comments on commit 1dd114d

Please sign in to comment.