zoomy_core.model.derivation.basis_cache

zoomy_core.model.derivation.basis_cache#

Manifest-based on-disk cache for basis-function matrices, plus an in-memory wrapper. Sits under the moment/Galerkin projection: consumers call get_basis_matrices instead of building a SymbolicIntegrator.

Module Contents#

Classes#

BasisMatrixCache

Hash-keyed .npz cache of the basis matrices, indexed by a JSON manifest. Stale entries are detected by comparing the stored basis fingerprint.

Functions#

get_basis_matrices

Return {phib, M, A, B, D, Dxi, Dxi2, DD, D1, DT} for (basis, level), memoized in memory and on disk.

clear_basis_matrix_cache

Drop the in-memory cache and optionally the on-disk cache.

Data#

API#

zoomy_core.model.derivation.basis_cache.CACHE_ROOT#

‘.cache/basismatrices’

zoomy_core.model.derivation.basis_cache.MANIFEST_NAME#

‘manifest.json’

zoomy_core.model.derivation.basis_cache.MATRIX_NAMES#

[‘phib’, ‘M’, ‘A’, ‘B’, ‘D’, ‘Dxi’, ‘Dxi2’, ‘DD’, ‘D1’, ‘DT’]

class zoomy_core.model.derivation.basis_cache.BasisMatrixCache(cache_root=CACHE_ROOT)#

Hash-keyed .npz cache of the basis matrices, indexed by a JSON manifest. Stale entries are detected by comparing the stored basis fingerprint.

Initialization

Set the cache directory, relative to the project root.

get_or_compute(basis, level, compute_fn)#

Return the cached matrices of a basis or compute and store them.

Args

  • basis: Basisfunction instance.

  • level: Polynomial level.

  • compute_fn: Called as compute_fn(level), returns {name: ndarray}.

Returns

Dict {name: ndarray} of basis matrices.

list_entries()#

Return the manifest dict.

clear()#

Delete the whole on-disk cache.

zoomy_core.model.derivation.basis_cache.get_basis_matrices(basis, level=None, *, cache=None)#

Return {phib, M, A, B, D, Dxi, Dxi2, DD, D1, DT} for (basis, level), memoized in memory and on disk.

Args

  • basis: Basisfunction exposing name, level, bounds(), weight(z), get(k).

  • level: Polynomial level; defaults to basis.level.

  • cache: Override of the default disk cache.

zoomy_core.model.derivation.basis_cache.clear_basis_matrix_cache(*, in_memory: bool = True, disk: bool = False)#

Drop the in-memory cache and optionally the on-disk cache.