PolyFEM
Loading...
Searching...
No Matches
VolumePenalty2d.hpp
Go to the documentation of this file.
1// Auto-generated code for VolumePenalty2d energy
2#pragma once
3#include <Eigen/Dense>
4
5namespace polyfem
6{
7 namespace autogen
8 {
9 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> VolumePenalty2d_gradient(const RowVectorNd &p, const double t, const int el_id, const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> &F, const double k)
10 {
11 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> grad(2, 2);
12 const double F00 = F(0, 0);
13 const double F01 = F(0, 1);
14 const double F10 = F(1, 0);
15 const double F11 = F(1, 1);
16 std::array<double, 4> result_0;
17 const auto helper_0 = F01 * F10;
18 const auto helper_1 = 0.5 * k * (1.0 * F00 * F11 - 1.0 * helper_0 - 1 / (F00 * F11 - helper_0));
19 result_0[0] = F11 * helper_1;
20 result_0[1] = -F10 * helper_1;
21 result_0[2] = -F01 * helper_1;
22 result_0[3] = F00 * helper_1;
23 ;
24 grad(0, 0) = result_0[0];
25 grad(0, 1) = result_0[1];
26 grad(1, 0) = result_0[2];
27 grad(1, 1) = result_0[3];
28 return grad;
29 }
30
31 inline Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9> VolumePenalty2d_hessian(const RowVectorNd &p, const double t, const int el_id, const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> &F, const double k)
32 {
33 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9> hess(4, 4);
34 std::array<double, 16> result_0;
35 const double F00 = F(0, 0);
36 const double F01 = F(0, 1);
37 const double F10 = F(1, 0);
38 const double F11 = F(1, 1);
39 const auto helper_0 = F00 * F11;
40 const auto helper_1 = F01 * F10;
41 const auto helper_2 = helper_0 - helper_1;
42 const auto helper_3 = pow(helper_2, -2);
43 const auto helper_4 = 0.5 * k;
44 const auto helper_5 = helper_4 * (helper_3 + 1.0);
45 const auto helper_6 = F11 * helper_5;
46 const auto helper_7 = -F10 * helper_6;
47 const auto helper_8 = -F01 * helper_6;
48 const auto helper_9 = 1.0 / helper_2;
49 const auto helper_10 = helper_4 * (helper_0 * helper_3 + 2.0 * helper_0 - 1.0 * helper_1 - helper_9);
50 const auto helper_11 = helper_4 * (-1.0 * helper_0 + helper_1 * helper_3 + 2.0 * helper_1 + helper_9);
51 const auto helper_12 = F00 * helper_5;
52 const auto helper_13 = -F10 * helper_12;
53 const auto helper_14 = -F01 * helper_12;
54 result_0[0] = pow(F11, 2) * helper_5;
55 result_0[1] = helper_7;
56 result_0[2] = helper_8;
57 result_0[3] = helper_10;
58 result_0[4] = helper_7;
59 result_0[5] = pow(F10, 2) * helper_5;
60 result_0[6] = helper_11;
61 result_0[7] = helper_13;
62 result_0[8] = helper_8;
63 result_0[9] = helper_11;
64 result_0[10] = pow(F01, 2) * helper_5;
65 result_0[11] = helper_14;
66 result_0[12] = helper_10;
67 result_0[13] = helper_13;
68 result_0[14] = helper_14;
69 result_0[15] = pow(F00, 2) * helper_5;
70 ;
71 hess(0, 0) = result_0[0];
72 hess(0, 1) = result_0[1];
73 hess(0, 2) = result_0[2];
74 hess(0, 3) = result_0[3];
75 hess(1, 0) = result_0[4];
76 hess(1, 1) = result_0[5];
77 hess(1, 2) = result_0[6];
78 hess(1, 3) = result_0[7];
79 hess(2, 0) = result_0[8];
80 hess(2, 1) = result_0[9];
81 hess(2, 2) = result_0[10];
82 hess(2, 3) = result_0[11];
83 hess(3, 0) = result_0[12];
84 hess(3, 1) = result_0[13];
85 hess(3, 2) = result_0[14];
86 hess(3, 3) = result_0[15];
87 return hess;
88 }
89 } // namespace autogen
90} // namespace polyfem
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9 > VolumePenalty2d_hessian(const RowVectorNd &p, const double t, const int el_id, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > &F, const double k)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > VolumePenalty2d_gradient(const RowVectorNd &p, const double t, const int el_id, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > &F, const double k)
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13