Repository navigation
CalculiX stateless target: refuse iorien / beta, guard the extern "C" boundary #162
Description
Context
CalculiXExternalTarget (#127) emits a stateless plugin for CalculiX's native call_external_umat_user hook. #160 covers the stateful path (STATEV offset, TIME rebasing, building on numsim-materials' umat/calculix_interface.h). It deliberately keeps the stateless plugin free of numsim-materials.
This issue covers what remains for the stateless path. Three arguments of the native hook change the right answer even without state, but the emitted entry comments them out. A fourth gap is an unguarded exception boundary.
Gaps (compared with numsim-materials umat/calculix_interface.h, same ABI)
iorienis ignored. On the native hook,umat_main.fdoes not rotate into the material frame (umat_user.f:86-104): that is the material's job. An anisotropic elastic recipe used with*ORIENTATIONis evaluated in the global frame, and nothing reports it. Isotropic recipes are not affected.
Suggested: refuse it (zero the outputs, report, terminate) ascalculix_interface.hdoes, or rotate when the recipe is anisotropic.beta(initial stress,*INITIAL CONDITIONS, TYPE=STRESS) is ignored. A preloaded model is then wrong from the first increment.
Suggested: refuse a nonzerobeta.ielasis ignored. This is harmless for a purely elastic recipe. The check becomes necessary once a non-elastic recipe can reach this target, so add it with the scope check.- No exception boundary. The entry point is
extern "C"and called from C/Fortran. If anything in<Model>_computeor the linear-algebra emitter can throw, the throw terminates ccx.
Suggested: wrap the call intry { ... } catch (...), zero the outputs, and setPNEWDT(e.g. 0.25) for a cutback. Exceptions stay out of Fortran this way, asumat_dispatchdoes.
Note for #160 (STATEV)
The header comment in calculix_external.h ("STATEV0/1 = history old/new", "per-integration-point history flowing through STATEV each call") reads as if ccx passed a per-point slice. It passes the full xstate(nstate_, mi(1), *) array, so the callee must index at nstatv*((iint-1) + mi1*(iel-1)). #160 item 1 describes this; the comment should be corrected so nobody extends the stateless entry by hand from it.
On the numsim-materials side, the host-owned path the stateful mode will use is being consolidated into one material-point core (numsim-materials #184, phase 2: load_history / store_history / history_width). calculix_interface.h keeps its interface.
Validation
#128 (golden-file harness): add a case with *ORIENTATION on an anisotropic elastic recipe, and a case with an initial stress. Each should fail loudly, not give a wrong answer.
Related
- CalculiX target: dlopen'd .so material (no ccx recompile per material) #127 (stateless target), CalculiX stateful path: emit against numsim-materials' calculix_interface.h instead of hand-rolling STATEV/TIME/orientation #160 (stateful path), CalculiX material test harness: golden-file suite over tests/calculix/<material>/ #128 (harness)
- numsim-materials
include/numsim-materials/umat/calculix_interface.h
Activity