Skip to content

More DMStag stuff: locations by axis, stencils from Julia indices, stencil assembly - #295

Merged
filoferra merged 1 commit into
JuliaParallel:mainfrom
filoferra:dmstag-stencils
Sep 25, 2026
Merged

filoferra merged 1 commit into
JuliaParallel:mainfrom
filoferra:dmstag-stencils

Conversation

@filoferra

Copy link
Copy Markdown
Collaborator

DMStag code that assembles its own Jacobian (MAGE, for example) still goes through LibPETSc for every stencil. This PR adds the high-level pieces for that.

  • Locations by axis: vertex_location(dm), edge_location(dm, a, b), face_location(dm, axis) and element_location(dm). DMSTAG_DOWN is the second axis, so its meaning shifts with the dimension; these functions mean the same thing in 2D and 3D.
  • stencil(dm, loc, I; dof = 0) builds a DMStagStencil from the 1-based element index that corners returns. It doesn't allocate, and ghost indices work. dof is PETSc's 0-based component, as in dof_slot.
  • Assembly with stencils: set_values!(J, dm, rows, cols, vals, mode), the Vec version set_values!(v, dm, positions, vals, mode), and zero_rows_local!(J, dm, rows, diag). They take any AbstractVector.
  • LibPETSc.IS(dm, loc => dof, ...) builds the index set of whole fields, for set_fieldsplit_is!. It takes location/component pairs, because PETSc ignores i, j, k here.

Fix: on an Int32 build, DMStagStencil, MatStencil and the other C structs had Int64 fields, so PETSc read them wrong. They now use the integer width of the loaded library. Checked on an Int32 build: the new tests pass there too.

…mbly

face_location, edge_location, vertex_location and element_location name DMStag locations by axis, the same in 2D and 3D.

stencil(dm, loc, I; dof) builds a DMStagStencil from a 1-based element index without allocating.

set_values! (Mat and Vec), zero_rows_local! and LibPETSc.IS(dm, loc => dof) take stencils.

C structs now use the loaded PetscInt width, so stencils work on Int32 builds.
@filoferra
filoferra merged commit 0561413 into JuliaParallel:main Sep 25, 2026
6 checks passed
@filoferra
filoferra deleted the dmstag-stencils branch September 25, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant