Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench/bench_legacy_vs_modular.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def bench_family(key, results_dir, repeats):
out_l, out_m = f"b_{key}_l.txt", f"b_{key}_m.txt"
for _ in range(repeats):
t0 = time.perf_counter()
sim.solver(name, props, nstatev, 0., 0., 0., 0, 1,
sim._core.solver(name, props, nstatev, 0., 0., 0., 0, 1,
"../data", results_dir, path_file, out_l)
t_leg.append(time.perf_counter() - t0)
t0 = time.perf_counter()
sim.solver("MODUL", mat.props, mat.nstatev, 0., 0., 0., 0, 1,
sim._core.solver("MODUL", mat.props, mat.nstatev, 0., 0., 0., 0, 1,
"../data", results_dir, path_file, out_m)
t_mod.append(time.perf_counter() - t0)
# discard the first (warmup) pair; min = least-noise estimator
Expand Down
15 changes: 6 additions & 9 deletions docs/cpp_api/continuum_mechanics_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ User Material subroutines (UMAT) for finite element analysis, organized by strai
- Isotropic, Orthotropic, Transversely Isotropic

**Plasticity:**
- `plastic_isotropic_ccp` - J2 plasticity with isotropic hardening
- `plastic_kin_iso_ccp` - Combined kinematic-isotropic hardening
- `plastic_chaboche_ccp` - Chaboche multi-kinematic hardening model
- `Hill_isoh` - Hill anisotropic plasticity with isotropic hardening
- `Hill_isoh_Nfast` - Hill plasticity with multiple hardening mechanisms
- `Hill_chaboche_ccp` - Hill plasticity with Chaboche hardening
- `Ani_chaboche_ccp` - General anisotropic plasticity with Chaboche hardening
- `DFA_chaboche_ccp` - Distortion-based anisotropy with Chaboche hardening
- `Generic_chaboche_ccp` - Generic anisotropic plasticity framework
- `plastic_isotropic_ccp` - J2 plasticity with isotropic hardening (kept as a readable reference implementation)
- `plastic_chaboche_ccp` - Chaboche multi-kinematic hardening model (kept as a readable reference implementation)
- All other plasticity variants (kinematic-isotropic `EPKCP`, Hill `EPHIL`/`EPTRI`/`EPHIN`,
Hill-Chaboche `EPHAC`, anisotropic Chaboche `EPANI`/`EPDFA`/`EPCHG`) are served since 2.0
by the **modular UMAT engine** through `umat_legacy_modular` name adapters — legacy names
and props ABI preserved. See the UMAT catalog (`docs/simulation/umat_catalog.rst`).

**Viscoelasticity:**
- `Zener_fast` - Single Zener (Standard Linear Solid) element
Expand Down
9 changes: 6 additions & 3 deletions docs/simulation/umat_catalog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ names — **the calling convention is identical for all of them** (same
- **modular (native)**: the composable ``MODUL`` engine, configured from a
props stream (see :mod:`simcoon.modular` for the Python builder).
- **modular (adapter)**: a legacy name whose dedicated kernel was removed
after its equivalence with a ``MODUL`` configuration was proven
(bit-identical results, dedicated tests in ``test_modular.py``); a
translator maps the legacy props to the modular configuration at each call.
after its equivalence with a ``MODUL`` configuration was proven against the
retained reference kernels — bit-identical for the elastic, power-law and
Hill families; within 2e-3 relative for the Voce/Chaboche families, whose
legacy incremental ``Hp`` update differs from the modular closed form
(tests in ``test_modular.py`` and ``Treference_umats``); a translator maps
the legacy props to the modular configuration at each call.
- **legacy (kept)**: a dedicated, self-contained implementation kept either
for pedagogy (readable single-file reference of the CCP return mapping) or
because no modular equivalent exists.
Expand Down
243 changes: 0 additions & 243 deletions examples/umat_prototype_tensor.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions examples/umat_tutorial/umat_tutorial_J2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ void umat_tutorial_J2(const std::string & /*umat_name*/, const vec &Etot,
if (start) {
T_init = T;
p = 0.;
EP = tensor2::zeros(VoigtType::strain);
EP = tensor2::zeros(Tensor2Type::strain);
sigma = zeros(6);
Wm = 0.; Wm_r = 0.; Wm_ir = 0.; Wm_d = 0.;
}

// Objectivity: the stored plastic strain co-rotates with the material
// frame. The typed rotate() picks the strain rotation kernel (factor-2
// shear convention) from the tensor's own VoigtType.
// shear convention) from the tensor's own Tensor2Type.
EP = EP.rotate(Rotation::from_matrix(DR));

const vec sigma_start = sigma;
Expand All @@ -100,7 +100,7 @@ void umat_tutorial_J2(const std::string & /*umat_name*/, const vec &Etot,
const double f_trial = Mises(sig_trial) - (sigma_Y + H * p);

double Dp = 0.;
tensor2 Lam = tensor2::zeros(VoigtType::strain);
tensor2 Lam = tensor2::zeros(Tensor2Type::strain);

if (f_trial > 0.) {
// -------------------------------------------------------------- 6.
Expand Down
12 changes: 6 additions & 6 deletions examples/umats/external/umat_plugin_ext_EPICP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* ``L - dyadic(kappa, kappa/Bhat)`` L - (kappa (x) kappa) / Bhat
*
* Overhead: the typed objects are fixed-size (stack, no heap). Construction uses
* the ``VoigtType`` *enum* (no per-call string parsing), and the only Voigt->tensor
* the ``Tensor2Type`` *enum* (no per-call string parsing), and the only Voigt->tensor
* conversion sits *before* the Newton loop — the hot loop never touches a string
* tag or rebuilds a tensor from a raw vector.
*
Expand Down Expand Up @@ -101,15 +101,15 @@ class LIB_EXPORT umat_epicp_tensor : public umat_plugin_ext_api {
L_out = L.mat();

// ---- Wrap incoming state as tensors (the only Voigt->tensor conversions) ----
tensor2 sig = tensor2::from_voigt(sigma, VoigtType::stress);
tensor2 EP = tensor2::from_voigt(vec(statev.subvec(2, 7)), VoigtType::strain);
tensor2 sig = tensor2::from_voigt(sigma, Tensor2Type::stress);
tensor2 EP = tensor2::from_voigt(vec(statev.subvec(2, 7)), Tensor2Type::strain);
tensor2 sig_start = sig;
tensor2 EP_start = EP;

// ---- Trial mechanical strain (built once, reused every iteration) ----
vec alpha_v = {alpha, alpha, alpha, 0., 0., 0.};
tensor2 eps_tot = tensor2::from_voigt(
vec(Etot + DEtot - alpha_v * (T + DT - T_init)), VoigtType::strain);
vec(Etot + DEtot - alpha_v * (T + DT - T_init)), Tensor2Type::strain);

// ---- Hardening at the start of the step ----
double Hp = 0., dHpdp = 0.;
Expand All @@ -123,7 +123,7 @@ class LIB_EXPORT umat_epicp_tensor : public umat_plugin_ext_api {
sig = L.contract(eps_tot - EP);

// ---- Return mapping (CCP) — scalars stay primitive, tensors stay typed ----
tensor2 N(VoigtType::strain), kappa(VoigtType::stress);
tensor2 N(Tensor2Type::strain), kappa(Tensor2Type::stress);
double error = 1.;
for (int iter = 0;
iter < simcoon::maxiter_umat && error > simcoon::precision_umat;
Expand Down Expand Up @@ -165,7 +165,7 @@ class LIB_EXPORT umat_epicp_tensor : public umat_plugin_ext_api {
// ---- Work (typed double contractions sigma : d_eps) ----
tensor2 sig_sum = sig_start + sig;
tensor2 DEP = EP - EP_start;
tensor2 DEtot_t = tensor2::from_voigt(DEtot, VoigtType::strain);
tensor2 DEtot_t = tensor2::from_voigt(DEtot, Tensor2Type::strain);
double Dp = p - p_old;
double A_p = -Hp;

Expand Down
4 changes: 2 additions & 2 deletions examples/umats/external/umat_plugin_ext_NEOHC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class LIB_EXPORT umat_neohookean_tensor : public umat_plugin_ext_api {
mat invC_mat = inv(C_mat);

// ---- PKII stress using Tensor2 (enum tags: no string parsing in the UMAT hot path) ----
tensor2 invC_t = tensor2::from_voigt(t2v_stress(invC_mat), VoigtType::stress);
tensor2 I_t = tensor2::identity(VoigtType::stress);
tensor2 invC_t = tensor2::from_voigt(t2v_stress(invC_mat), Tensor2Type::stress);
tensor2 I_t = tensor2::identity(Tensor2Type::stress);
tensor2 S = mu * (I_t - invC_t) + lambda * lnJ * invC_t;

// ---- Cauchy stress via push-forward ----
Expand Down
6 changes: 6 additions & 0 deletions include/simcoon/Continuum_mechanics/Functions/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
#include <optional>
#include <Fastor/Fastor.h>

/**
* @file tensor.hpp
* @brief Typed 2nd- and 4th-order tensor API: type-tagged Voigt/Mandel conversions,
* convention-aware contractions and rotations (Voigt order [11,22,33,12,13,23], units MPa).
*/

namespace simcoon {

// Forward declarations
Expand Down
Loading
Loading