Conversation
Rename PlasticDiscreteShellBending to StrainPlasticDiscreteShellBending and add StressPlasticDiscreteShellBending across the C++ API, CUDA backend, Python bindings, docs, demos, and tests.
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
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
PlasticDiscreteShellBendingnaming was ambiguous once both yield criteria were supported. This change renames the existing model toStrainPlasticDiscreteShellBendingand introducesStressPlasticDiscreteShellBendingas a separate constitution.Changes
PlasticDiscreteShellBendingtoStrainPlasticDiscreteShellBendingStressPlasticDiscreteShellBendingas a new finite-element extra constitutionStrainPlasticDiscreteShellBendingStressPlasticDiscreteShellBendingAPI impact
PlasticDiscreteShellBendingis replaced byStrainPlasticDiscreteShellBendingapply_to(sc, bending_stiffness, yield_threshold, hardening_modulus=0.0)apply_to(sc, bending_stiffness, yield_stress, hardening_modulus=0.0)Notes