serac icon indicating copy to clipboard operation
serac copied to clipboard

Test solid mechanics with patch tests

Open btalamini opened this issue 3 years ago • 2 comments

This PR was spurred by #754. The main change is to add more rigorous tests of the solid mechanics module. These are patch tests, which ensure that the numerical approximation of the PDEs are consistent. The structure should also allow generalization to manufactured solutions, which would allow us to increase our meaningful test coverage and to verify high-order convergence.

I can see that these tests could benefit from some refactoring to reduce boilerplate, to increase flexibility of options (such as geometric nonlinearity on/off, material type), and to make testing over the combinations of these options more automatic. I'm looking for help here from the code review.

Once we settle on the framework, it should be reused to check other features:

  1. Dynamics
  2. Potentially, other flavors of statics options: linear kinematics, parameterized models, and materials with state
  3. The heat conduction module

We may want to leave issue #754 open until we're satisfied with the coverage, possibly amending it with a checklist.

These tests have already caught 3 significant bugs:

  1. The residual calculation contracted the wrong index of the stress with the shape function derivatives. A stopgap solution is put in this PR that makes the residual correct, and issue #773 was opened to track a long-term fix.
  2. Several of the material models were templated on spatial dimension, but the 2D versions gave nonsensical results. The stress returned was neither plane strain nor plane stress. I removed the template parameter on the material and moved it to the constitutive output call, with the 2D version giving the plane strain response. The comments have been updated to reflect this.
  3. The geometric nonlinearity option was causing the reference configuration to sometimes be in an incorrect state. This led to issue #760 (that has since been closed, thanks @jamiebramwell).

btalamini avatar Aug 24 '22 18:08 btalamini

For reference, a visualization of the 3D patch test mesh is the red version below: patch_test_mesh

In contrast to the blue version which has a lot of symmetries, the red version has the interior nodes perturbed to break the symmetries and ensure that the element geometries are not axis-aligned.

samuelpmishLLNL avatar Aug 24 '22 20:08 samuelpmishLLNL

Codecov Report

Merging #779 (ecf8ab1) into develop (4cda7b7) will decrease coverage by 0.07%. The diff coverage is 96.58%.

@@             Coverage Diff             @@
##           develop     #779      +/-   ##
===========================================
- Coverage    94.93%   94.86%   -0.08%     
===========================================
  Files          140      140              
  Lines         8891     8970      +79     
===========================================
+ Hits          8441     8509      +68     
- Misses         450      461      +11     
Impacted Files Coverage Δ
src/serac/physics/state/finite_element_vector.hpp 97.14% <ø> (ø)
...ac/physics/tests/test_solid_functional_statics.cpp 96.03% <96.03%> (ø)
...ac/physics/materials/solid_functional_material.hpp 100.00% <100.00%> (ø)
src/serac/physics/solid_functional.hpp 98.46% <100.00%> (ø)
src/serac/physics/state/finite_element_vector.cpp 67.10% <100.00%> (+0.88%) :arrow_up:
src/serac/physics/tests/serac_solid_functional.cpp 95.91% <100.00%> (-3.52%) :arrow_down:
src/serac/numerics/functional/isotropic_tensor.hpp 100.00% <0.00%> (ø)
src/serac/numerics/functional/tensor.hpp 95.77% <0.00%> (+0.12%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Aug 25 '22 21:08 codecov-commenter