diff --git a/src/summary.jl b/src/summary.jl index 5ed86c1..492dce3 100644 --- a/src/summary.jl +++ b/src/summary.jl @@ -1,6 +1,7 @@ module Summary using ..UltraDark +using ..UltraDark: AbstractGrids import Dates import MPI using Statistics @@ -340,4 +341,48 @@ function pool_summarystat(S1::RmsDensityContrast, S2::RmsDensityContrast)::RmsDe RmsDensityContrast(δx_rms, n) end +""" + TotalMass + +Total mass on a grid + +# Examples + +```jldoctest +julia> using UltraDark + +julia> g = Grids(1.0, 16); + +julia> g.ρx .= 0.; + +julia> g.ρx[1, 1, 1] = 1.; + +julia> getfield(Summary.TotalMass(g), 1) == 1.0 * (1.0/16)^3 +true + +``` +""" +struct TotalMass + mass::Float64 +end + +function TotalMass(grids, rho) + mass = sum(rho * dV(grids)) + + TotalMass(mass) +end + +function TotalMass(grids::AbstractGrids) + TotalMass(grids, grids.ρx) +end + +function TotalMass(sim_time, a, Δt, grids, constants) + ToalMass(grids) +end + +function pool_summarystat(S1::TotalMass, S2::TotalMass)::TotalMass + mass = S1.mass + S2.mass + TotalMass(mass) +end + end # module