CalculiX external-behaviour target: dlopen'd .so plugin (no ccx recompile) - #126
Closed
petlenz wants to merge 2 commits into
Closed
CalculiX external-behaviour target: dlopen'd .so plugin (no ccx recompile)#126petlenz wants to merge 2 commits into
petlenz wants to merge 2 commits into
Conversation
added 2 commits
August 1, 2026 12:24
Member
Author
|
Consolidated into a single PR against main (external .so target only). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #125. Adds
CalculiXExternalTarget(make_target("calculix_external")) — emits<Model>_ext.cppcompiling tolib<MODEL>.sothat CalculiX loads at runtime via dlopen, so adding a new material needs no ccx recompile (build ccx once with external support; select materials by name in the deck).Mechanism (verified against ccx 2.22 source)
A deck
*MATERIAL, NAME=@<LIB>_<FUNC>makes ccx (which uppercases the name)dlopen("lib<LIB>.so")anddlsym("<FUNC>")(external.c, gated on-DCALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT+-ldl). The STANDARD interface passes native quantities under Abaqus-flavored names —STRAN1 = emec(tensorial),STRESS = stre,DDSDDE = stiff(21)packed — so the sameabq_stdboundary as the compiled-in target (#125) reuses verbatim. The emitted plugin follows a per-thread lifecycle: athread_localmaterial instance built once per thread (ccx runs the element loop multithreaded), then per-call unpack → evaluate → pack.Verification
calculix_check_drivergains 3 tests that call the emittedNCG_UMATthrough the exactcalculixptrABI and checkstre/stiffagainst the isotropic oracle, plus an equivalence test proving the external entry matches the compiled-inumat_user_bit-for-bit. Full suite 272/272.examples/calculix/build_and_run_external.shbuilds ccx once with external support, compiles the codegen'd.so, and runsuniaxial_c3d8_external.inpby@-name. Confirmed S11=0.027, S22=S33=0.013 — same result as the compiled-in path, with no ccx recompile.Scope
Stateless (elastic) — same guards as #125. The
STATEVround-trip for stateful J2 (numsim-materials-backedevaluate()) is the next step; the thread_local②/per-call③scaffold is already in place for it.🤖 Generated with Claude Code