Add DiracDelta scatter for Points on DGSEM 2D/3D models#125
Merged
Conversation
Implements pts%DiracDelta(geometry, scalar) on the Points class. Each
stored point owns one variable of the target MappedScalar2D/3D and
receives the discrete post-mass-matrix delta
scalar%interior(i,j[,k],iEl,p) = l_i(xi_p)*l_j(eta_p)[*l_k(zeta_p)]
/ ( w_i*w_j[*w_k] * J_0(p) )
for iEl = elements(p) and zero in every other element. J_0(p) is the
polynomial interpolation of the nodal Jacobian determinant at the source
location, so the conservation property
sum_{i,j[,k]} f * w_i*w_j[*w_k]*J_{ij[k]} = 1 holds algebraically
regardless of element curvature.
The form is "post mass matrix" so it can be added directly to dSdt /
the source term in a DGSEM model -- MappedDGDivergence already divides
by w_i*w_j*J_{ij}.
A HIP kernel mirrors the host path for GPU-resident scalars; the
override uses select type so non-GPU subtypes still fall through to
the inherited host implementation. The kernel reuses the per-point
Lagrange basis cache populated by LocatePoints and writes
scalar%interior_gpu directly. A pre-launch hipMemset clears the field
so unlocated points and non-owning elements remain zero.
Two new tests assert (1) discrete conservation = 1, (2) other elements
are exactly zero, and (3) on a node-coincident source the only nonzero
entry equals 1/(w*w*J_node).
Adds *.sqsh to .dockerignore to keep large local archive files out of
the Docker build context.
Fortran treats N and n as the same identifier. The two new DiracDelta specifics declared `m, n, N` (2D) and `m, n, l, N` (3D) in a single list, so n/N collided and the entire declaration was rejected under `implicit none` -- gfortran 9/10/11/12 all reported the loop indices as having no implicit type. Rename the J0-interpolation indices to mm/nn(/ll) so they are distinct from N. Also drop an unused `k` local in the 2D test and tidy a stray double-space before an inline comment that fprettify rewrote.
On GPU builds DiracDelta writes scalar%interior_gpu; the host-side scalar%interior buffer that the tests inspect remains the zero-init state from %Init, producing the spurious "conservation failure integral=0" reported on amd-mi210-coverage build 121. Call f%UpdateHost() after pts%DiracDelta in both tests. On the CPU build the call is a no-op, so behaviour is unchanged there.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Codecov flagged three uncovered branches in pts%DiracDelta_{2,3}D:
the on-the-fly Lagrange recompute (useCache=False), the nDim guard,
and the scalar%nVar /= nPoints guard.
Positive tests: extend points_dirac_delta_{2,3}d to run a second
DiracDelta against a scalar at a different polynomial degree so the
cached basis from LocatePoints no longer matches and the host
fallback path fires. Wrap in #ifndef ENABLE_GPU because the GPU
override intentionally stops on a cache-N mismatch (it has no
recompute fallback).
Negative tests: four new programs each set up a deliberate mismatch
(2D/3D x nDim/nVar), call DiracDelta, and let the guard stop 1.
Registered with CTest WILL_FAIL TRUE so a non-zero exit is the pass
criterion. The same programs exercise the GPU guards on GPU builds
(select type + nDim/nVar checks in src/gpu/SELF_Points.f90).
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.
Summary
pts%DiracDelta(geometry, scalar)to thePointsclass. Each stored point owns one variable of the targetMappedScalar2D/3Dand receives the discrete post-mass-matrix deltaf_{ij[k]} = l_i(ξ₀)·l_j(η₀)[·l_k(ζ₀)] / (w_i·w_j[·w_k]·J₀)foriEl = elements(p), zero elsewhere.J₀is the polynomial interpolation of nodalJat the source location, which makesΣ f·w·w·J = 1hold algebraically on every element (affine or curved).dSdt/ the source term in a DGSEM model becauseMappedDGDivergencealready divides byw·w·J.select typekeeps the override compatible with non-GPU subtypes (falls back to the inherited host impl). The kernel reuses the per-point Lagrange basis cache populated byLocatePointsand writesscalar%interior_gpudirectly; a pre-launchhipMemsetclears the field so unlocated points and non-owning elements remain zero.*.sqshadded to.dockerignore(mirrors the existing*.sifexclusion) so large local archive files don't bloat the Docker build context.Design notes
scalar%nVar == pts%nPoints. Each point owns its own column so contributions never overlap. Points withelements(p) == 0(not located on this rank) leave their column zero.LocatePointschose — no S/2 face split.pts%nCached == scalar%interp%N, the cached basis values fromLocatePointsare reused. Otherwise the host path recomputes; the GPU path errors out because device basis cache is mandatory there (matches the existingEvaluateScalarGPU contract).Test plan
test/points_dirac_delta_2d.f90— conservation, other-element isolation, and node-coincident valuetest/points_dirac_delta_3d.f90— 3D analoguetest/CMakeLists.txtregistration)/homepartition is at 100%, so I couldn't complete a docker/podman build. Asking CI to verify.🤖 Generated with Claude Code