agentleFS
SteadfastAsArtSteadfastAsArt/geoscience-skills/discretize/SKILL.md

discretize

Skill67 starsChanged 10 months agoMITView on GitHub

Create finite-volume meshes and discrete differential operators with discretize. Use for TensorMesh or TreeMesh geometry, cell/face/edge ordering, divergence, interpolation and meshes supporting SimPEG; use a physics solver for inversion itself.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use TensorMesh for separable rectangular grids.

    line 22
  2. Distinctive:

    Verify constants/linear fields, conservation and convergence against an independent analytic case before using a mesh in an inverse problem.

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

discretize

Construct the mesh and location-aware operators before attaching physical data. The library does not determine the CRS or the physical units of its coordinates.

Choose geometry and data locations

Use TensorMesh for separable rectangular grids; choose TreeMesh when local refinement substantially reduces cost. Finalize a tree before using its operators. Pad model boundaries and refine sources, receivers and property contrasts as required by the forward problem, then test domain and resolution sensitivity.

Record axis meanings, origin, units, cell widths and active-cell mask. In a 2D vertical section the second coordinate can mean elevation, but this is a project convention. A vector of length n_cells is not a face or edge vector.

Divergence with an independent answer

The synthetic velocity field is u = (2x, -3y) per second. Its divergence is -1 s⁻¹, including on this nonuniform mesh. Boundary fluxes are represented at their actual face locations; no zero boundary condition is imposed implicitly.

# example: nonuniform-divergence
import numpy as np
from discretize import TensorMesh

mesh = TensorMesh([[1.0, 2.0, 3.0], [2.0, 4.0]], origin=[0.0, 0.0])
face_velocity_m_s = np.r_[2 * mesh.faces_x[:, 0], -3 * mesh.faces_y[:, 1]]
divergence_s_inv = mesh.face_divergence @ face_velocity_m_s
integrated_divergence_m2_s = np.dot(mesh.cell_volumes, divergence_s_inv)

The rectangular area is 36 m², so the area-integrated divergence and outward boundary flux are both -36 m²/s. In 2D, cell_volumes are cell areas.

Handoffs and checks

  • Inspect cell_centers, faces_x, faces_y and the operator shape. Keep cell, face, node and edge quantities distinct when interpolating or plotting.
  • Cell ordering has the first coordinate varying fastest; reshape cell vectors with Fortran order when required. Test a spatially varying field, not a uniform array that could hide an ordering error.
  • Verify constants/linear fields, conservation and convergence against an independent analytic case before using a mesh in an inverse problem.
  • Preserve inactive/air masks and do not turn NaNs into zero conductivity.

See the operator tutorials and API for the chosen mesh.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.