Repository navigation
[BUGFIX] Kernel tests, bug fixes, dead-code removal - #537
Merged
Merged
Conversation
This reverts commit 3f2f430.
Contributor
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
albert-de-montserrat
approved these changes
Sep 25, 2026
Collaborator
Author
|
@albert-de-montserrat gpu still needs fixing |
# Conflicts: # src/stokes/StressKernels.jl # src/variational_stokes/MiniKernels.jl # src/variational_stokes/Stokes3D.jl # src/variational_stokes/StressKernels.jl # src/variational_stokes/VelocityKernels.jl # test/test_dyrel_kernels_3D.jl # test/test_phase_ratios3D.jl # test/test_rockratio.jl
In the strain-increment stress updates, the nested broadcast
`@muladd @. dτij - 2.0 * ηij * dt * εij_pl * dτ_r` infers as
Tuple{Vararg{Float64}} under GPU compilation, making the following
broadcasts dynamic and failing CUDA compilation with InvalidIRError.
Computing the scalar coefficient first keeps the tuple length inferred.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
0.16.1 fails to precompile JustRelax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
albert-de-montserrat
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the purpose of this PR?
Describe it in more detail below:
This PR adds kernel-level tests for code paths that had no coverage. Writing them turned up a number of bugs, which are fixed here. It also removes code that is never loaded or never called.
Bug fixes
Edge-to-edge averaging in 3D stress kernels (
src/stokes/StressKernels.jl, used bysrc/stokes,src/variational_stokesandsrc/DYREL)The six
av_clamped_{yz,xz,xy}_{x,y,z}helpers move a shear component from one edge family to another. For example,εxylives at (x vertex, y vertex, z center) and is needed on a yz edge at (x center, y vertex, z vertex). Along each axis the source-to-target step is one of three kinds, and only one of them can meet a missing neighbor:(i0, ic)(i, i+1)ini + 1is a real node of both arraysAll indices came from
clamped_indices, which clamps to the number of cells,ni. That is right for the center → vertex step, but the two other kinds index arrays withni + 1entries along that axis:i + 1was clamped tonx. Ati = nxthe stencil averagedA[nx]with itself, so the value came from x_v(nx) instead of x_c(nx), half a cell off.jcwas clamped tony. On the last vertex plane (j = ny + 1) the stencil read the plane one step inside the domain.The helpers now take the unclamped target index
Ias well asIc. They use the raw index for the vertex → center and same-location axes, and the clamped/wrapped cell pair only for the center → vertex axis. Callers already guardIby the size of the target edge array, so every raw access is in range. In a periodic direction, vertex planes1andni + 1are the same physical point, so these axes never have to cross the seam; only the center pair wraps.clamped_indicesno longer returns the unusedi1, j1, k1.Principal stresses (
src/stokes/PrincipalStresses.jl)(τxx - τyy)^2 / 2instead of/ 4. The angle usedatan(y / x), which loses the quadrant, and now usesatan(y, x).eigen_symmetric_3x3). It converges quadratically, including for degenerate spectra, and throws if it hasn't converged aftermax_sweepssweeps instead of returning an unconverged result.Viscosity (
src/rheology/Viscosity.jl)Axyat the cell index. It now averages the four surrounding vertices, as the 3D kernel does.compute_viscosity_τIIwithout phase ratios now uses the stress tensor (select_tensor) instead of always using the strain rate.update_viscosity!passed an extra positional argument to the dispatched function.3D solver for a single
MaterialParams(src/stokes/Stokes3D.jl)errwas never initialized (a bare1.0line), and the loop called phase-ratio methods even though no phase ratios exist in this call form. The pressure update now receivesG,η_vepis used in the stress update, and the vertex shear stresses come fromcenter2vertex!. Vorticity uses the velocity spacings (grid._di.velocity).Buoyancy (
src/rheology/BuoyancyForces.jl)compute_ρg!calledfirst(rheology), which fails for a singleMaterialParams.gravity_ofnow handles both a singleMaterialParamsand a tuple of them.Stress rotation (
src/stress_rotation/stress_rotation_particles.jl,src/ext/*/3D.jl)GeoParams.rotate_elastic_stress3Dexpects the curl of the velocity, which is twice the stored vorticity components.τxx, and its kernel was declared(I)instead of(I...).rotate_stress_particles!dispatched to the 2D-only rotation-matrix and Jaumann kernels. It now always uses the GeoParams rotation and errors on any othermethod.Thermal diffusion (
src/thermal_diffusion/)_di.center). At a physical boundary,thermal_bcs!reflects the ghost temperature about the boundary, so the ghost-to-center distance is the boundary cell width (_di.vertex). The flux kernels now receive the completegrid._diobject, select the appropriate staggered spacing at each face, and use@dx/@dy/@dzfor uniform and non-uniform grids.update_T!/check_res!divide the flux divergence by the cell width_di.vertex, not_di.center._di.centerhas one entry fewer, and on a non-uniform grid this threw aBoundsError.PhaseRatios.Vx/Vy/Vz) are now read at the face, and cell-centered ones at the two neighboring cells (phase_at_face). Any other size throws aDimensionMismatch.compute_phaseandcompute_radioactive_heatingfor an integer phase now indexrheology[phase].Variational Stokes 3D (
src/variational_stokes/)_d_xi/_d_yi/_d_zistencils are corrected.dt.compute_V!is corrected.compute_viscosity!is called withair_phaseas a keyword.Removed code
Nothing removed is exported, documented, or used by a miniapp or test.
src/thermal_diffusion/DiffusionExplicit.jl(ThermalDiffusion1D/2D/3D)included, so never loadedsrc/thermal_diffusion/Rheology.jlincluded; duplicates ofDiffusionPT_GeoParams.jlsrc/stress_rotation/stress_rotation_grid.jlincludedsrc/types/constructors/phases.jl(PhaseRatio)included; superseded by JustPIC'sPhaseRatios_solve!takingKwithoutG(and itsdiwrapper)compute_P!with 10 arguments andcompute_V!with 13; no such methods exist, so it could not runupdate_τ_o!τxyupdate_stress!(dispatcher and both trait methods)compute_τ_nonlinear!in an order matching neither of its methodscompute_viscosity!/_compute_viscosity!withair_phasebut nophase_ratioscompute_vorticity!(…, _di)compute_buoyancy(::MaterialParams, args, phase_ratios)Tests
New files:
test_stokes_kernels2D.jl,test_stokes_kernels3D.jl: divergence, strain rate, stress (visco-elastic, nonlinear, center/vertex), momentum residual, principal stresses, and allsolve!call forms. They include affine-field checks of the 3D edge-to-edge averages at every edge except the one-sided center → boundary-vertex planes, plus boundary-plane checks of the stress update.test_variational_stokes3D.jl: masked stencils, strain rate, stress and velocity kernels, and the 3D variational solver (CPU only).test_thermal_kernels2D.jl,test_thermal_kernels3D.jl: flux against a hand-written stencil on non-uniform T, K and θ, including physical boundary faces; the energy residual; the pseudo-transient update; Dirichlet pinning; rheology-based flux; and phase ratios of mismatched size.test_rheology_kernels2D.jl,test_rheology_kernels3D.jl: viscosity from the strain-rate and stress invariants (relaxation, cutoff), harmonic phase averaging without the air phase, vertex arguments, and buoyancy.test_stress_rotation2D.jl,test_stress_rotation3D.jl: vorticity of a rigid rotation, and the per-particle rotation kernels.test_bc_kernels2D.jl,test_bc_kernels3D.jl: no-slip velocity boundaries on every face, and pure/simple-shear background fields.test_weno5_kernels.jl: WENO5 weights and convergence order.Extended:
test_diffusion2D/3D.jl(non-uniform grid),test_types.jl,test_rheology.jl,test_rockratio.jl,test_mask.jl,test_phase_ratios3D.jl.The full CPU
Pkg.test()suite passes, including the MPI tests. CUDA and AMDGPU were not run locally.Checklist
[BUGFIX],[ADDITION],[DOC], etc.🤖 Generated with Claude Code