Skip to content

Guide: finite-difference data, samples, reconstruction and difference operators (#321) - #514

Open
berkgeveci wants to merge 1 commit into
Kitware:mainfrom
berkgeveci:docs/finite-difference-guide
Open

berkgeveci wants to merge 1 commit into
Kitware:mainfrom
berkgeveci:docs/finite-difference-guide

Conversation

@berkgeveci

Copy link
Copy Markdown
Collaborator

Step 1 of the finite-difference plan (#513, issue #321): a guide, docs/visualization/finite-difference.md, beside the finite-volume guide. It documents what Tack does today, so it stands on its own whatever the plan's review decides.

  • Opening example: the u = x² counterexample. finite_differences(derivative=2) gives exactly 2; the linear reconstruction between the same samples is the chord, h²/4 above the parabola midway.
  • Point samples and cell averages, and what H1, Constant and Values read them as. Point and cell Values are read trilinearly and as constant by any filter that needs a basis, which the page says plainly.
  • Samples at cell centres: read as Constant, or trilinearly as the points of a grid shifted by half a cell, which covers only the centres' hull.
  • finite_differences against gradients: the operator against the reconstruction, with orders 2, 4 and 6 converging on sin(x), and its rules at edges, hidden points, ghost layers and cell data.
  • Staggered components today: not held directly. A short kernel averages a MAC grid's faces to the cell centres, exact for a linear velocity.

Linked from the visualization index, the nav and the finite-volume guide's "Where to go next".

Every marked example runs, and prints what the page shows. mkdocs build --strict is clean.

This will be merged after the 0.8 release.

🤖 Generated with Claude Code

@berkgeveci berkgeveci added this to the 0.9 milestone Dec 5, 2026
dtype=tack.f64)
shifted.fields["t"] = td.Field(td.H1(shifted), tack.array(samples))

where = np.array([[0.5, 0.5, 0.0], [0.05, 0.5, 0.0]])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(0.5, 0.5) is a vertex shared by four solver cells, so the constant reading's 1.125 is whichever cell probe picks. A point inside one cell would make the comparison read cleanly.

data.fields["velocity"] = td.Field(td.Constant(data), velocity)

print(data.fields["velocity"].values.numpy()[:2])
assert np.allclose(velocity.numpy()[:, 0], np.tile(np.arange(nx) + 0.5, ny))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check v too, since the y-faces' indexing is the easier one to get wrong.

@jlee-kitware

Copy link
Copy Markdown
Collaborator

Clear, and the x² counterexample makes the point in a few lines. Two nits inline.

This branch has not been deployed

No deployments
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.

2 participants