Skip to content

CalculiX stateless target: refuse iorien / beta, guard the extern "C" boundary #162

Open

Description

@petlenz

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)

  1. iorien is ignored. On the native hook, umat_main.f does not rotate into the material frame (umat_user.f:86-104): that is the material's job. An anisotropic elastic recipe used with *ORIENTATION is evaluated in the global frame, and nothing reports it. Isotropic recipes are not affected.
    Suggested: refuse it (zero the outputs, report, terminate) as calculix_interface.h does, or rotate when the recipe is anisotropic.
  2. beta (initial stress, *INITIAL CONDITIONS, TYPE=STRESS) is ignored. A preloaded model is then wrong from the first increment.
    Suggested: refuse a nonzero beta.
  3. ielas is 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.
  4. No exception boundary. The entry point is extern "C" and called from C/Fortran. If anything in <Model>_compute or the linear-algebra emitter can throw, the throw terminates ccx.
    Suggested: wrap the call in try { ... } catch (...), zero the outputs, and set PNEWDT (e.g. 0.25) for a cutback. Exceptions stay out of Fortran this way, as umat_dispatch does.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions