Skip to content

Conversation

@ayush4874
Copy link

Issue:
As reported in Issue #2603, the 2D implementation of the Von Mises stress calculation in CFEAElasticity::VonMisesStress was mathematically incorrect.

The previous code implemented:
$$\sigma_{vm} = \sqrt{S_1^2 + S_2^2 - 2S_1S_2} = \sqrt{(S_1 - S_2)^2} = |S_1 - S_2|$$

This formula corresponds to the Tresca equivalent stress (twice the maximum shear stress), not the Von Mises stress.

Fix:
Updated the formula to the correct 2D Plane Stress Von Mises definition:
$$\sigma_{vm} = \sqrt{S_1^2 + S_2^2 - S_1S_2}$$

Verification:
Verified that the term -2*S1*S2 was the source of the discrepancy. The updated implementation now aligns with standard continuum mechanics definitions for plane stress.

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

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

Thanks. Can you look into the plain strain case too?

@pcarruscag pcarruscag changed the base branch from master to develop December 28, 2025 21:28
@ayush4874
Copy link
Author

@pcarruscag I have added support for Plane Strain as requested.

Implementation Details:

  1. Updated VonMisesStress (CFEAElasticity.hpp):

    • Modified the function signature to accept Nu (Poisson's Ratio) and isPlaneStrain.
    • Used default arguments (Nu=0.0, isPlaneStrain=false) to ensure backward compatibility with other classes (like CFEALinearElasticity) that do not need these inputs.
    • Math: For Plane Strain, we now calculate the out-of-plane stress $S_{zz}$ before the Von Mises calculation:
    /*--- In Plane Strain, Szz is not zero. It is determined by Poisson's ratio. ---*/
    su2double Szz = 0.0;
    if (isPlaneStrain) {
      Szz = Nu * (Sxx + Syy);
    }
    // ... followed by general 3D Von Mises formula using Szz
  2. Updated CFEASolver.cpp:

    • Now fetches the Poisson Ratio from the config (GetPoissonRatio(0)).
    • Checks the 2D formulation kind via GetElas2D_Formulation() to set the isPlaneStrain flag correctly.

@ayush4874
Copy link
Author

@pcarruscag I have applied the requested changes:

  1. Removed default arguments from VonMisesStress to enforce explicit handling of material properties everywhere.
  2. Updated CFEALinearElasticity.cpp (and CFEANonlinearElasticity.cpp) to:
    • Retrieve the Poisson Ratio (Nu) and 2D Formulation from the config.
    • Calculate and store the 4th stress component ($S_{zz}$) for Plane Strain inside the element loop, as suggested.
    • Pass the explicit values to the Von Mises utility.
  3. Added myself to AUTHORS.md.

Builds are passing locally. Ready for final review!

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

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

I'll approve the tests to run, but there will be plenty of segmentation faults.

Comment on lines 186 to 188
static su2double VonMisesStress(unsigned short nDim, const T& stress, su2double Nu, bool isPlaneStrain) {
if (nDim == 2) {
su2double Sxx = stress[0], Syy = stress[1], Sxy = stress[2];
Copy link
Member

Choose a reason for hiding this comment

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

If the 4th element of "stress" is Szz you don't need to pass Nu and isPlainStrain to this function.

@ayush4874
Copy link
Author

@pcarruscag Done. I have refactored the implementation as requested to ensure memory safety.

  1. Utility (CFEAElasticity.hpp): VonMisesStress is now a pure math function. It no longer accepts physics parameters (Nu, isPlaneStrain) and strictly expects a 4-component vector for 2D inputs (Sxx, Syy, Sxy, Szz).
  2. Solvers (CFEALinearElasticity, CFEANonlinearElasticity, CFEASolver): The logic for calculating Szz (based on Plane Strain vs Plane Stress) has been moved explicitly to the caller side.

I updated all 3 call sites to pack the stress vector correctly before passing it to the utility, preventing any potential segfaults.

@pcarruscag pcarruscag changed the base branch from develop to tmp_develop December 30, 2025 18:08
@pcarruscag pcarruscag merged commit 4f81d27 into su2code:tmp_develop Dec 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants