Skip to content

Add Eshelby memo, caching and lazy fields - #129

Merged
chemiskyy merged 3 commits into
masterfrom
feature/add-lazy
Oct 6, 2026
Merged

chemiskyy merged 3 commits into
masterfrom
feature/add-lazy

Conversation

@chemiskyy

Copy link
Copy Markdown
Member

Introduce eshelby_memo to memoize Eshelby tensors for identical inclusion geometry/medium and reuse them within a homogenization pass (bitwise key). Integrate the memo into ellipsoid_multi: add S_loc_memo, eshelby_memoized(), and extend fillT/fillT_iso/fillT_mec_in to accept an optional memo; implement find/store/clear in C++ and use memcmp for exact-medium keys. Create a per-pass memo in various micromechanics schemes so identical integrations are shared, improving performance.

Python-side optimizations: make SolverResults compute expensive derived field 'LogStrain' lazily (pending derivations, _materialize, and persistent behavior on save/load/to_dataframe). In tensor.py add Basis pickling support that drops cached handles, add cached rotation handles and optional C++ rotation handles propagation to rotation paths to avoid re-creating C++ rotation objects in single-tensor rotations.

Other changes: rows_to_arr now moves the Armadillo matrix into the numpy conversion to avoid an extra copy; add required includes (vector, cstring, utility). Add tests (test_lazy_derivations.py and Teshelby test update) covering memo behavior, Basis cache/pickling, and lazy LogStrain materialization. Overall the changes reduce redundant recomputation and improve performance while preserving numerical results.

Introduce eshelby_memo to memoize Eshelby tensors for identical inclusion geometry/medium and reuse them within a homogenization pass (bitwise key). Integrate the memo into ellipsoid_multi: add S_loc_memo, eshelby_memoized(), and extend fillT/fillT_iso/fillT_mec_in to accept an optional memo; implement find/store/clear in C++ and use memcmp for exact-medium keys. Create a per-pass memo in various micromechanics schemes so identical integrations are shared, improving performance.

Python-side optimizations: make SolverResults compute expensive derived field 'LogStrain' lazily (pending derivations, _materialize, and persistent behavior on save/load/to_dataframe). In tensor.py add Basis pickling support that drops cached handles, add cached rotation handles and optional C++ rotation handles propagation to rotation paths to avoid re-creating C++ rotation objects in single-tensor rotations.

Other changes: rows_to_arr now moves the Armadillo matrix into the numpy conversion to avoid an extra copy; add required includes (vector, cstring, utility). Add tests (test_lazy_derivations.py and Teshelby test update) covering memo behavior, Basis cache/pickling, and lazy LogStrain materialization. Overall the changes reduce redundant recomputation and improve performance while preserving numerical results.
@chemiskyy
chemiskyy merged commit 144d488 into master Oct 6, 2026
7 checks passed
@chemiskyy
chemiskyy deleted the feature/add-lazy branch October 6, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant