PTsolvers / JustRelax.jl

Pseudo-transient accelerated iterative solvers
https://ptsolvers.github.io/JustRelax.jl/dev/
MIT License
26 stars 6 forks source link

Rheology traits #144

Closed albert-de-montserrat closed 4 months ago

albert-de-montserrat commented 4 months ago

Uses the rheology traits from GeoParams to dispatch on specialized methods. This makes it trivial to avoid, e.g., updating the buoyancy forces or the viscosity within the PT iterations when any of those are constant through the pseudo-time steps.

Example in a 64 x 64 grid with three phases of constant density and viscosity:

julia> @b compute_ρg!($(ρg[2], phase_ratios, rheology, args)...) # old
7.125 μs (21 allocs: 8.328 KiB)

julia> @b JustRelax.JustRelax2D.update_ρg!($(ρg[2], phase_ratios, rheology, args)...) # this branch

0.850 ns

julia> @b compute_viscosity!(
              $(stokes,
              phase_ratios,
              args,
              rheology,
              viscosity_cutoff)...;
              relaxation=1e0,
          ) # old
22.875 μs (21 allocs: 6.516 KiB)

julia> @b JustRelax.JustRelax2D.update_viscosity!(
              $(stokes,
              phase_ratios,
              args,
              rheology,
              viscosity_cutoff)...;
              relaxation=1e0,
          ) # new
0.850 ns
codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 22.82609% with 71 lines in your changes are missing coverage. Please review.

Files Patch % Lines
src/stokes/StressKernels.jl 0.00% 48 Missing :warning:
src/rheology/Viscosity.jl 47.05% 9 Missing :warning:
src/rheology/BuoyancyForces.jl 37.50% 5 Missing :warning:
src/stokes/Stokes2D.jl 50.00% 4 Missing :warning:
src/stokes/Stokes3D.jl 50.00% 4 Missing :warning:
src/types/traits.jl 0.00% 1 Missing :warning:
Additional details and impacted files

:loudspeaker: Thoughts on this report? Let us know!