TrixiParticles.jl icon indicating copy to clipboard operation
TrixiParticles.jl copied to clipboard

Add `TableDataSavingCallback`

Open LasNikas opened this issue 1 year ago • 1 comments

This is to save table data only for a specific time range save_interval. The rows in the table are the function values and the columns are the evaluations.

hydrostatic_water_column_2d.jl with the following extra_callback

interpolated_density(v, u, t, system) = nothing
function interpolated_density(v, u, t, system::TrixiParticles.FluidSystem)
    n_particles_xy = round(Int, 1.0 / system.initial_condition.particle_spacing)

    values = interpolate_line([0.5, 0.0], [0.5, 1.0], n_particles_xy, semi, system,
                              v, u; endpoint=true, cut_off_bnd=true)

    return values.density
end

pos = collect(LinRange(0.0, 1.0, round(Int, 1.0 / fluid_particle_spacing)))

extra_callback = TableDataSavingCallback(; dt=0.02, save_interval=10, 
                                         start_at=0.90, # condition is `true` if `t >= start_at` 
                                         axis_ticks=Dict(interpolated_density => pos),
                                         interpolated_density=interpolated_density)

The plot shows the density evaluated at every dt starting at time t=0.9

image

LasNikas avatar Aug 14 '24 10:08 LasNikas

Codecov Report

Attention: Patch coverage is 0% with 106 lines in your changes missing coverage. Please review.

Project coverage is 68.97%. Comparing base (54fd033) to head (0bc0c1d).

Files with missing lines Patch % Lines
src/callbacks/data_saving.jl 0.00% 104 Missing :warning:
src/callbacks/post_process.jl 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #602      +/-   ##
==========================================
- Coverage   70.10%   68.97%   -1.14%     
==========================================
  Files          99      100       +1     
  Lines        6345     6449     +104     
==========================================
  Hits         4448     4448              
- Misses       1897     2001     +104     
Flag Coverage Δ
unit 68.97% <0.00%> (-1.14%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Aug 14 '24 10:08 codecov[bot]