Skip to content

Stress output is a zero array in linear elasticity calculation #477

@lechanm

Description

@lechanm

Description

The stress output array for linear elasticity (lElas) calculations is consistently a zero array, regardless of non-zero displacement or strain.
The array S (Array<double> S(nsd, nsd)) is not updated within the if (cPhys == EquationType::phys_lElas) block.
The following code is from post.cpp.

        case OutputNameType::outGrp_stress:
        case OutputNameType::outGrp_cauchy: 
        case OutputNameType::outGrp_mises:
          Array<double> sigma(nsd,nsd);
          Array<double> S(nsd,nsd);

          if (cPhys == EquationType::phys_lElas) {
            if (nsd == 3) {
              double detF = lambda*(ed(0) + ed(1) + ed(2));
              sigma(0,0) = detF + 2.0*mu*ed(0);
              sigma(1,1) = detF + 2.0*mu*ed(1);
              sigma(2,2) = detF + 2.0*mu*ed(2);

              sigma(0,1) = mu*ed(3);
              sigma(1,2) = mu*ed(4);
              sigma(2,0) = mu*ed(5);

              sigma(1,0) = sigma(0,1);
              sigma(2,1) = sigma(1,2);
              sigma(0,2) = sigma(2,0);
            } else {  
              double detF = lambda*(ed(0) + ed(1));
              sigma(0,0) = detF + 2.0*mu*ed(0);
              sigma(1,1) = detF + 2.0*mu*ed(1);
              sigma(0,1) = mu*ed(2);
              sigma(1,0) = sigma(0,1);
            }
          } else if (cPhys == EquationType::phys_ustruct) { 
          } else if (cPhys == EquationType::phys_struct) {
          }
          // 2nd Piola-Kirchhoff stress tensor
          if (outGrp == OutputNameType::outGrp_stress) {
            if (nsd == 3) {
              resl(0) = S(0,0);
              resl(1) = S(1,1);
              resl(2) = S(2,2);
              resl(3) = S(0,1);
              resl(4) = S(1,2);
              resl(5) = S(2,0);
            } else { 
              resl(0) = S(0,0);
              resl(1) = S(1,1);
              resl(2) = S(0,1);
            }

Reproduction

The bug can be reproduced by running the test case for linear elasticity.

Expected behavior

If the strain is non-zero, the stress must also be non-zero.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions