Skip to content

Stress based plasticity#407

Merged
MuGdxy merged 2 commits intospiriMirror:mainfrom
Roushelfy:stress-based-plasticity
Mar 26, 2026
Merged

Stress based plasticity#407
MuGdxy merged 2 commits intospiriMirror:mainfrom
Roushelfy:stress-based-plasticity

Conversation

@Roushelfy
Copy link
Copy Markdown
Collaborator

Summary

This PR clarifies the existing shell plastic bending model as strain-based plasticity and adds a parallel stress-based plastic shell bending constitution.

The old PlasticDiscreteShellBending naming was ambiguous once both yield criteria were supported. This change renames the existing model to StrainPlasticDiscreteShellBending and introduces StressPlasticDiscreteShellBending as a separate constitution.

Changes

  • rename PlasticDiscreteShellBending to StrainPlasticDiscreteShellBending
  • add StressPlasticDiscreteShellBending as a new finite-element extra constitution
  • expose both constitutions through C++ headers and Python bindings
  • add CUDA backend support for the stress-based model
  • update constitution docs and index entries:
    • UID 31: StrainPlasticDiscreteShellBending
    • UID 32: StressPlasticDiscreteShellBending
  • rename the existing strain-plastic demo and add a new stress-plastic demo
  • extend core attribute tests to cover both strain- and stress-based plastic bending
  • add CUDA and sim-case coverage for the new stress-based model

API impact

  • PlasticDiscreteShellBending is replaced by StrainPlasticDiscreteShellBending
  • the strain-based model keeps the existing parameter semantics:
    • apply_to(sc, bending_stiffness, yield_threshold, hardening_modulus=0.0)
  • the new stress-based model uses:
    • apply_to(sc, bending_stiffness, yield_stress, hardening_modulus=0.0)

Notes

  • this is a naming cleanup plus a feature addition
  • the rename is intentional and improves the distinction between strain-threshold plasticity and stress-based ECI plasticity
  • Python examples and tests are updated accordingly

Rename PlasticDiscreteShellBending to StrainPlasticDiscreteShellBending and add
StressPlasticDiscreteShellBending across the C++ API, CUDA backend, Python
bindings, docs, demos, and tests.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the shell bending simulation capabilities by introducing a novel stress-based plasticity model and refining the existing strain-based approach. The changes provide users with more accurate and stable options for simulating elastoplastic bending behavior in thin shell structures, particularly for scenarios involving residual creases and spring-back effects. The update also improves the overall clarity and structure of the bending constitution models.

Highlights

  • Model Clarification and Renaming: The existing PlasticDiscreteShellBending model has been renamed to StrainPlasticDiscreteShellBending to explicitly denote its strain-based plasticity, improving clarity and distinction from the newly introduced stress-based model.
  • New Stress-Based Plasticity Model: A new StressPlasticDiscreteShellBending constitution has been added, implementing stress-based Energy-based Consistent Integration (ECI) plasticity for shell bending. This model defines yield conditions based on generalized bending stress rather than strain.
  • Comprehensive Integration: Both the renamed strain-based and the new stress-based models are fully integrated across the codebase, including updates to C++ headers, Python bindings, CUDA backend support, and documentation. New demos and extended core attribute tests have been added to cover the functionality of both plasticity types.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the existing PlasticDiscreteShellBending constitution by renaming it to StrainPlasticDiscreteShellBending to accurately reflect its strain-threshold based yielding mechanism. It then introduces a new StressPlasticDiscreteShellBending constitution, which implements a stress-based Energy-based Consistent Integration (ECI) model for elastoplastic bending in thin shell structures. The changes include updates to CUDA backend implementations, C++ and Python bindings, documentation, and the addition of comprehensive test cases and Python examples for both the renamed strain-based model and the newly introduced stress-based model. A review comment suggests refactoring duplicated ClothPatch and load_center_patch utility code in test files into a shared header for better maintainability.

Comment on lines +10 to +82
namespace
{
using namespace uipc;
using namespace uipc::core;
using namespace uipc::geometry;
using namespace uipc::constitution;

constexpr SizeT SheetResolution = 21;
constexpr Float SheetSize = 1.0;

struct ClothPatch
{
SimplicialComplex mesh;
vector<Vector3> rest_positions;
SizeT v00 = 0;
SizeT v10 = 0;
SizeT v11 = 0;
SizeT v01 = 0;
Float cell_span = 0.0;
};

ClothPatch load_center_patch()
{
vector<Vector3> Vs;
vector<Vector3i> Fs;
Vs.reserve(SheetResolution * SheetResolution);
Fs.reserve((SheetResolution - 1) * (SheetResolution - 1) * 2);

const Float half_size = 0.5 * SheetSize;
const Float step = SheetSize / static_cast<Float>(SheetResolution - 1);

for(SizeT j = 0; j < SheetResolution; ++j)
{
const Float z = -half_size + step * static_cast<Float>(j);
for(SizeT i = 0; i < SheetResolution; ++i)
{
const Float x = -half_size + step * static_cast<Float>(i);
Vs.emplace_back(x, 0.0, z);
}
}

for(SizeT j = 0; j + 1 < SheetResolution; ++j)
{
for(SizeT i = 0; i + 1 < SheetResolution; ++i)
{
const SizeT v00 = j * SheetResolution + i;
const SizeT v10 = v00 + 1;
const SizeT v01 = v00 + SheetResolution;
const SizeT v11 = v01 + 1;
Fs.emplace_back(v00, v11, v10);
Fs.emplace_back(v00, v01, v11);
}
}

auto mesh = trimesh(Vs, Fs);
label_surface(mesh);

const SizeT cell_i = SheetResolution / 2 - 1;
const SizeT cell_j = SheetResolution / 2 - 1;
const SizeT v00 = cell_j * SheetResolution + cell_i;
const SizeT v10 = v00 + 1;
const SizeT v01 = v00 + SheetResolution;
const SizeT v11 = v01 + 1;

return ClothPatch{std::move(mesh),
std::move(Vs),
v00,
v10,
v11,
v01,
step};
}
} // namespace
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ClothPatch struct and load_center_patch function are duplicated across several new test files (81_..., 82_..., 83_...) and also exist in older, renamed test files (76_..., 77_..., 78_...). This significant code duplication can make future maintenance more difficult.

To improve code reuse and maintainability, consider refactoring this common setup code into a shared test utility header file.

@MuGdxy MuGdxy merged commit de910fe into spiriMirror:main Mar 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants