| 57 | } |
| 58 | |
| 59 | TEST_F(OrthotropicMaterialTest, Energy2D) { |
| 60 | VectorF young(2); |
| 61 | VectorF shear(1); |
| 62 | VectorF poisson(2); |
| 63 | |
| 64 | young << 1.0, 1.0; |
| 65 | shear << 2.0; |
| 66 | poisson << 0.5, 0.5; |
| 67 | |
| 68 | MaterialPtr mat = MaterialPtr(new OrthotropicMaterial<2>(m_density, young, poisson, shear)); |
| 69 | |
| 70 | MatrixF strain(2, 2); |
| 71 | strain << 1.0, 0.2, |
| 72 | 0.2, 2.0; |
| 73 | MatrixF stress = mat->strain_to_stress(strain, m_origin); |
| 74 | Float energy = (strain.array() * stress.array()).sum(); |
| 75 | |
| 76 | Float true_energy = 0.0; |
| 77 | for (size_t i=0; i<2; i++) { |
| 78 | for (size_t j=0; j<2; j++) { |
| 79 | for (size_t k=0; k<2; k++) { |
| 80 | for (size_t l=0; l<2; l++) { |
| 81 | true_energy += mat->get_material_tensor(i,j,k,l, m_origin) |
| 82 | * strain(i,j) * strain(k,l); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | ASSERT_FLOAT_EQ(true_energy, energy); |
| 89 | } |
| 90 | |
| 91 | TEST_F(OrthotropicMaterialTest, Energy3D) { |
| 92 | VectorF young(3); |
no test coverage detected