7 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) {
8 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> grad(2,2);
9 const double F00 =
F(0, 0);
10 const double F01 =
F(0, 1);
11 const double F10 =
F(1, 0);
12 const double F11 =
F(1, 1);
13 std::array<double, 4> result_0;
14 const auto helper_0 = F01*F10;
15const auto helper_1 = 0.5*k*(1.0*F00*F11 - 1.0*helper_0 - 1/(F00*F11 - helper_0));
16result_0[0] = F11*helper_1;
17result_0[1] = -F10*helper_1;
18result_0[2] = -F01*helper_1;
19result_0[3] = F00*helper_1;;
20 grad(0, 0) = result_0[0];
21 grad(0, 1) = result_0[1];
22 grad(1, 0) = result_0[2];
23 grad(1, 1) = result_0[3];
27 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) {
28 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9> hess(4,4);
29 std::array<double, 16> result_0;
30 const double F00 =
F(0, 0);
31 const double F01 =
F(0, 1);
32 const double F10 =
F(1, 0);
33 const double F11 =
F(1, 1);
34 const auto helper_0 = F00*F11;
35const auto helper_1 = F01*F10;
36const auto helper_2 = helper_0 - helper_1;
37const auto helper_3 = pow(helper_2, -2);
38const auto helper_4 = 0.5*k;
39const auto helper_5 = helper_4*(helper_3 + 1.0);
40const auto helper_6 = F11*helper_5;
41const auto helper_7 = -F10*helper_6;
42const auto helper_8 = -F01*helper_6;
43const auto helper_9 = 1.0/helper_2;
44const auto helper_10 = helper_4*(helper_0*helper_3 + 2.0*helper_0 - 1.0*helper_1 - helper_9);
45const auto helper_11 = helper_4*(-1.0*helper_0 + helper_1*helper_3 + 2.0*helper_1 + helper_9);
46const auto helper_12 = F00*helper_5;
47const auto helper_13 = -F10*helper_12;
48const auto helper_14 = -F01*helper_12;
49result_0[0] = pow(F11, 2)*helper_5;
50result_0[1] = helper_7;
51result_0[2] = helper_8;
52result_0[3] = helper_10;
53result_0[4] = helper_7;
54result_0[5] = pow(F10, 2)*helper_5;
55result_0[6] = helper_11;
56result_0[7] = helper_13;
57result_0[8] = helper_8;
58result_0[9] = helper_11;
59result_0[10] = pow(F01, 2)*helper_5;
60result_0[11] = helper_14;
61result_0[12] = helper_10;
62result_0[13] = helper_13;
63result_0[14] = helper_14;
64result_0[15] = pow(F00, 2)*helper_5;;
65 hess(0, 0) = result_0[0];
66 hess(0, 1) = result_0[1];
67 hess(0, 2) = result_0[2];
68 hess(0, 3) = result_0[3];
69 hess(1, 0) = result_0[4];
70 hess(1, 1) = result_0[5];
71 hess(1, 2) = result_0[6];
72 hess(1, 3) = result_0[7];
73 hess(2, 0) = result_0[8];
74 hess(2, 1) = result_0[9];
75 hess(2, 2) = result_0[10];
76 hess(2, 3) = result_0[11];
77 hess(3, 0) = result_0[12];
78 hess(3, 1) = result_0[13];
79 hess(3, 2) = result_0[14];
80 hess(3, 3) = result_0[15];
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)