PolyFEM
Loading...
Searching...
No Matches
GenericElastic.cpp
Go to the documentation of this file.
1// Shared template implementation, included by the GenericElastic material groups.
2// This file is not compiled separately.
3#include "GenericElastic.hpp"
4
6
7namespace polyfem::assembler
8{
9
10 template <typename Derived>
11 template <int dim>
12 Eigen::Matrix<double, dim * dim, dim> GenericElastic<Derived>::compute_B_block(const Eigen::Matrix<double, 1, dim> &g) const
13 {
14 Eigen::Matrix<double, dim * dim, dim> B(size() * size(), size());
15 B.setZero();
16
17 for (int i = 0; i < dim; ++i) // displacement component
18 for (int j = 0; j < dim; ++j) // gradient direction
19 B(i * dim + j, i) = g(j);
20
21 return B;
22 }
23
24 template <typename Derived>
28
29 template <typename Derived>
31 const Eigen::Index p, const MatrixNd &displacement_grad, OutputStress &output) const
32 {
33 const auto &deformation = output.deformation();
36 const bool rest_pose = derived().real_def_grad(vals.val.row(p), data.t, data.el_id);
37 output.has_stress = rest_pose;
38 if (!rest_pose || !output.needs_stress)
39 {
40 if (output.needs_energy)
41 {
42 DefGradMatrix<double> energy_deformation = deformation;
43 if (!rest_pose)
44 energy_deformation = energy_deformation * vals.jac_it[p].inverse();
45 output.energy = derived().template elastic_energy<double>(data.local_pts.row(p), data.t, vals.element_id, energy_deformation);
46 }
47 return true;
48 }
49 Eigen::Matrix<Diff, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> def_grad(size(), size());
50 for (int d1 = 0; d1 < size(); ++d1)
51 for (int d2 = 0; d2 < size(); ++d2)
52 def_grad(d1, d2) = Diff(d1 * size() + d2, deformation(d1, d2));
53 const auto val = derived().elastic_energy(data.local_pts.row(p), data.t, vals.element_id, def_grad);
54 if (output.needs_energy)
55 output.energy = val.getValue();
56 MatrixNd stress_tensor(size(), size());
57 for (int d1 = 0; d1 < size(); ++d1)
58 for (int d2 = 0; d2 < size(); ++d2)
59 stress_tensor(d1, d2) = val.getGradient()(d1 * size() + d2);
60 output.native = 1.0 / deformation.determinant() * stress_tensor * deformation.transpose();
61 return true;
62 }
63
64 template <typename Derived>
66 {
67 return compute_energy_aux<double>(data);
68 }
69
70 template <typename Derived>
72 {
73 if (autodiff_type_ == AutodiffType::FULL)
74 return assemble_gradient_full_ad(data);
75 else if (autodiff_type_ == AutodiffType::STRESS)
76 {
77#ifndef NDEBUG
78 auto grad = assemble_gradient_stress_ad(data);
79 auto grad_full = assemble_gradient_full_ad(data);
80 assert((std::isnan(grad.norm()) && std::isnan(grad_full.norm())) || (grad - grad_full).norm() < 1e-6);
81#endif
82 return assemble_gradient_stress_ad(data);
83 }
84 else
85 {
86#ifndef NDEBUG
87 auto grad = assemble_gradient_stress_noad(data);
88 auto grad_full = assemble_gradient_stress_ad(data);
89 assert((std::isnan(grad.norm()) && std::isnan(grad_full.norm())) || (grad - grad_full).norm() < 1e-6);
90#endif
91 return assemble_gradient_stress_noad(data);
92 }
93 }
94
95 template <typename Derived>
97 {
98 const int n_bases = data.vals.basis_values.size();
100 size(), n_bases, data,
101 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 6, 1>>>(data); },
102 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 8, 1>>>(data); },
103 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 12, 1>>>(data); },
104 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 18, 1>>>(data); },
105 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 24, 1>>>(data); },
106 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 30, 1>>>(data); },
107 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 60, 1>>>(data); },
108 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, 81, 1>>>(data); },
109 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, SMALL_N, 1>>>(data); },
110 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, BIG_N, 1>>>(data); },
111 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar1<double, Eigen::VectorXd>>(data); });
112 }
113
114 template <typename Derived>
116 {
117 Eigen::Matrix<double, Eigen::Dynamic, 1> gradient;
118
119 if (size() == 2)
120 {
121 switch (data.vals.basis_values.size())
122 {
123 case 3:
124 {
125 gradient.resize(6);
126 compute_gradient_from_stress<3, 2>(data, gradient);
127 break;
128 }
129 case 6:
130 {
131 gradient.resize(12);
132 compute_gradient_from_stress<6, 2>(data, gradient);
133 break;
134 }
135 case 10:
136 {
137 gradient.resize(20);
138 compute_gradient_from_stress<10, 2>(data, gradient);
139 break;
140 }
141 default:
142 {
143 gradient.resize(data.vals.basis_values.size() * 2);
144 compute_gradient_from_stress<Eigen::Dynamic, 2>(data, gradient);
145 break;
146 }
147 }
148 }
149 else // if (size() == 3)
150 {
151 assert(size() == 3);
152 switch (data.vals.basis_values.size())
153 {
154 case 4:
155 {
156 gradient.resize(12);
157 compute_gradient_from_stress<4, 3>(data, gradient);
158 break;
159 }
160 case 10:
161 {
162 gradient.resize(30);
163 compute_gradient_from_stress<10, 3>(data, gradient);
164 break;
165 }
166 case 20:
167 {
168 gradient.resize(60);
169 compute_gradient_from_stress<20, 3>(data, gradient);
170 break;
172 default:
173 {
174 gradient.resize(data.vals.basis_values.size() * 3);
175 compute_gradient_from_stress<Eigen::Dynamic, 3>(data, gradient);
176 break;
177 }
178 }
179 }
180
181 return gradient;
182 }
183
184 template <typename Derived>
186 {
187 Eigen::Matrix<double, Eigen::Dynamic, 1> gradient;
188
189 if (size() == 2)
190 {
191 switch (data.vals.basis_values.size())
192 {
193 case 3:
194 {
195 gradient.resize(6);
196 compute_gradient_from_stress_noad<3, 2>(data, gradient);
197 break;
198 }
199 case 6:
200 {
201 gradient.resize(12);
202 compute_gradient_from_stress_noad<6, 2>(data, gradient);
203 break;
204 }
205 case 10:
206 {
207 gradient.resize(20);
208 compute_gradient_from_stress_noad<10, 2>(data, gradient);
209 break;
210 }
211 default:
212 {
213 gradient.resize(data.vals.basis_values.size() * 2);
214 compute_gradient_from_stress_noad<Eigen::Dynamic, 2>(data, gradient);
215 break;
216 }
217 }
218 }
219 else // if (size() == 3)
220 {
221 assert(size() == 3);
222 switch (data.vals.basis_values.size())
223 {
224 case 4:
225 {
226 gradient.resize(12);
227 compute_gradient_from_stress_noad<4, 3>(data, gradient);
228 break;
229 }
230 case 10:
231 {
232 gradient.resize(30);
233 compute_gradient_from_stress_noad<10, 3>(data, gradient);
234 break;
235 }
236 case 20:
237 {
238 gradient.resize(60);
239 compute_gradient_from_stress_noad<20, 3>(data, gradient);
240 break;
241 }
242 default:
243 {
244 gradient.resize(data.vals.basis_values.size() * 3);
245 compute_gradient_from_stress_noad<Eigen::Dynamic, 3>(data, gradient);
246 break;
247 }
248 }
249 }
250
251 return gradient;
252 }
253
254 template <typename Derived>
256 {
257 if (autodiff_type_ == AutodiffType::FULL)
258 assemble_hessian_full_ad(data, hessian);
259 else
260 {
261 if (autodiff_type_ == AutodiffType::STRESS)
262 assemble_hessian_stress_ad(data, hessian);
263 else
264 assemble_hessian_stress_noad(data, hessian);
265#ifndef NDEBUG
266 LocalHessian reference;
267 if (autodiff_type_ == AutodiffType::STRESS)
268 assemble_hessian_full_ad(data, reference);
269 else
270 assemble_hessian_stress_ad(data, reference);
271 hessian.visit([&](const auto &H) {
272 reference.visit([&](const auto &R) {
273 assert((std::isnan(H.norm()) && std::isnan(R.norm())) || (H - R).norm() < 1e-5);
274 });
275 });
276#endif
277 }
278 }
279
280 template <typename Derived>
282 {
283 const int n_bases = data.vals.basis_values.size();
285 size(), n_bases, data, hessian,
286 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 6, 1>, Eigen::Matrix<double, 6, 6>>>(data); },
287 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 8, 1>, Eigen::Matrix<double, 8, 8>>>(data); },
288 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 12, 1>, Eigen::Matrix<double, 12, 12>>>(data); },
289 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 18, 1>, Eigen::Matrix<double, 18, 18>>>(data); },
290 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 24, 1>, Eigen::Matrix<double, 24, 24>>>(data); },
291 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 30, 1>, Eigen::Matrix<double, 30, 30>>>(data); },
292 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 60, 1>, Eigen::Matrix<double, 60, 60>>>(data); },
293 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, 81, 1>, Eigen::Matrix<double, 81, 81>>>(data); },
294 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, SMALL_N, 1>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, SMALL_N, SMALL_N>>>(data); },
295 [&](const NonLinearAssemblerData &data) { return compute_energy_aux<DScalar2<double, Eigen::VectorXd, Eigen::MatrixXd>>(data); });
296 }
297
298 template <typename Derived>
300 {
301 result.resize(data.vals.basis_values.size() * size(), data.vals.basis_values.size() * size());
302 result.visit([&](auto &hessian) {
303 hessian.setZero();
304 if (size() == 2)
305 {
306 switch (data.vals.basis_values.size())
307 {
308 case 3:
309 {
310 compute_hessian_from_stress<3, 2>(data, hessian);
311 break;
312 }
313 case 6:
314 {
315 compute_hessian_from_stress<6, 2>(data, hessian);
316 break;
317 }
318 case 10:
319 {
320 compute_hessian_from_stress<10, 2>(data, hessian);
321 break;
322 }
323 default:
324 {
325 compute_hessian_from_stress<Eigen::Dynamic, 2>(data, hessian);
326 break;
327 }
328 }
329 }
330 else // if (size() == 3)
331 {
332 assert(size() == 3);
333 switch (data.vals.basis_values.size())
334 {
335 case 4:
336 {
337 compute_hessian_from_stress<4, 3>(data, hessian);
338 break;
339 }
340 case 10:
341 {
342 compute_hessian_from_stress<10, 3>(data, hessian);
343 break;
344 }
345 case 20:
346 {
347 compute_hessian_from_stress<20, 3>(data, hessian);
348 break;
349 }
350 default:
351 {
352 compute_hessian_from_stress<Eigen::Dynamic, 3>(data, hessian);
353 break;
354 }
355 }
356 }
357 });
358 }
359
360 template <typename Derived>
362 {
363 result.resize(data.vals.basis_values.size() * size(), data.vals.basis_values.size() * size());
364 result.visit([&](auto &hessian) {
365 hessian.setZero();
366 if (size() == 2)
367 {
368 switch (data.vals.basis_values.size())
369 {
370 case 3:
371 {
372 compute_hessian_from_stress_noad<3, 2>(data, hessian);
373 break;
374 }
375 case 6:
376 {
377 compute_hessian_from_stress_noad<6, 2>(data, hessian);
378 break;
379 }
380 case 10:
381 {
382 compute_hessian_from_stress_noad<10, 2>(data, hessian);
383 break;
384 }
385 default:
386 {
387 compute_hessian_from_stress_noad<Eigen::Dynamic, 2>(data, hessian);
388 break;
389 }
390 }
391 }
392 else // if (size() == 3)
393 {
394 assert(size() == 3);
395 switch (data.vals.basis_values.size())
396 {
397 case 4:
398 {
399 compute_hessian_from_stress_noad<4, 3>(data, hessian);
400 break;
401 }
402 case 10:
403 {
404 compute_hessian_from_stress_noad<10, 3>(data, hessian);
405 break;
406 }
407 case 20:
408 {
409 compute_hessian_from_stress_noad<20, 3>(data, hessian);
410 break;
411 }
412 default:
413 {
414 compute_hessian_from_stress_noad<Eigen::Dynamic, 3>(data, hessian);
415 break;
416 }
417 }
418 }
419 });
420 }
421
422 template <typename Derived>
424 const OptAssemblerData &data,
425 const Eigen::MatrixXd &mat,
426 Eigen::MatrixXd &stress,
427 Eigen::MatrixXd &result) const
428 {
429 typedef DScalar2<double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, 9, 1>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9>> Diff;
430
431 const double t = data.t;
432 const int el_id = data.el_id;
433 if (!derived().real_def_grad(data.global_pts, t, el_id))
434 log_and_throw_error("Stress derivatives are not available in absolute mode (use_rest_pose false)");
435 const Eigen::MatrixXd &local_pts = data.local_pts;
436 const Eigen::MatrixXd &global_pts = data.global_pts;
437 const Eigen::MatrixXd &grad_u_i = data.grad_u_i;
438
439 DiffScalarBase::setVariableCount(size() * size());
440 Eigen::Matrix<Diff, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> def_grad(size(), size());
441
442 Eigen::MatrixXd F = grad_u_i;
443 for (int d = 0; d < size(); ++d)
444 F(d, d) += 1.;
445
446 assert(local_pts.rows() == 1);
447 for (int i = 0; i < size(); ++i)
448 for (int j = 0; j < size(); ++j)
449 def_grad(i, j) = Diff(i + j * size(), F(i, j));
450
451 auto energy = derived().elastic_energy(global_pts, t, el_id, def_grad);
452
453 // Grad is ∂W(F)/∂F_ij
454 Eigen::MatrixXd grad = energy.getGradient().reshaped(size(), size());
455 // Hessian is ∂W(F)/(∂F_ij*∂F_kl)
456 Eigen::MatrixXd hess = energy.getHessian();
457
458 // Stress is S_ij = ∂W(F)/∂F_ij
459 stress = grad;
460 // Compute ∂S_ij/∂F_kl * M_kl, same as M_ij * ∂S_ij/∂F_kl since the hessian is symmetric
461 result = (hess * mat.reshaped(size() * size(), 1)).reshaped(size(), size());
462 }
463
464 template <typename Derived>
466 const OptAssemblerData &data,
467 Eigen::MatrixXd &stress,
468 Eigen::MatrixXd &result) const
469 {
470 typedef DScalar2<double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, 9, 1>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9>> Diff;
471
472 const double t = data.t;
473 const int el_id = data.el_id;
474 if (!derived().real_def_grad(data.global_pts, t, el_id))
475 log_and_throw_error("Stress derivatives are not available in absolute mode (use_rest_pose false)");
476 const Eigen::MatrixXd &local_pts = data.local_pts;
477 const Eigen::MatrixXd &global_pts = data.global_pts;
478 const Eigen::MatrixXd &grad_u_i = data.grad_u_i;
479
480 DiffScalarBase::setVariableCount(size() * size());
481 Eigen::Matrix<Diff, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> def_grad(size(), size());
482
483 Eigen::MatrixXd F = grad_u_i;
484 for (int d = 0; d < size(); ++d)
485 F(d, d) += 1.;
486
487 assert(local_pts.rows() == 1);
488 for (int i = 0; i < size(); ++i)
489 for (int j = 0; j < size(); ++j)
490 def_grad(i, j) = Diff(i + j * size(), F(i, j));
491
492 auto energy = derived().elastic_energy(global_pts, t, el_id, def_grad);
493
494 // Grad is ∂W(F)/∂F_ij
495 Eigen::MatrixXd grad = energy.getGradient().reshaped(size(), size());
496 // Hessian is ∂W(F)/(∂F_ij*∂F_kl)
497 Eigen::MatrixXd hess = energy.getHessian();
498
499 // Stress is S_ij = ∂W(F)/∂F_ij
500 stress = grad;
501 // Compute ∂S_ij/∂F_kl * S_kl, same as S_ij * ∂S_ij/∂F_kl since the hessian is symmetric
502 result = (hess * stress.reshaped(size() * size(), 1)).reshaped(size(), size());
503 }
504
505 template <typename Derived>
507 const OptAssemblerData &data,
508 const Eigen::MatrixXd &vect,
509 Eigen::MatrixXd &stress,
510 Eigen::MatrixXd &result) const
511 {
512 typedef DScalar2<double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, 9, 1>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9>> Diff;
513
514 const double t = data.t;
515 const int el_id = data.el_id;
516 if (!derived().real_def_grad(data.global_pts, t, el_id))
517 log_and_throw_error("Stress derivatives are not available in absolute mode (use_rest_pose false)");
518 const Eigen::MatrixXd &local_pts = data.local_pts;
519 const Eigen::MatrixXd &global_pts = data.global_pts;
520 const Eigen::MatrixXd &grad_u_i = data.grad_u_i;
521
522 DiffScalarBase::setVariableCount(size() * size());
523 Eigen::Matrix<Diff, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> def_grad(size(), size());
524
525 Eigen::MatrixXd F = grad_u_i;
526 for (int d = 0; d < size(); ++d)
527 F(d, d) += 1.;
528
529 assert(local_pts.rows() == 1);
530 for (int i = 0; i < size(); ++i)
531 for (int j = 0; j < size(); ++j)
532 def_grad(i, j) = Diff(i + j * size(), F(i, j));
533
534 auto energy = derived().elastic_energy(global_pts, t, el_id, def_grad);
535
536 // Grad is ∂W(F)/∂F_ij
537 Eigen::MatrixXd grad = energy.getGradient().reshaped(size(), size());
538 // Hessian is ∂W(F)/(∂F_ij*∂F_kl)
539 Eigen::MatrixXd hess = energy.getHessian();
540
541 // Stress is S_ij = ∂W(F)/∂F_ij
542 stress = grad;
543 result.resize(hess.rows(), vect.size());
544 for (int i = 0; i < hess.rows(); ++i)
545 if (vect.rows() == 1)
546 // Compute ∂S_ij/∂F_kl * v_k, same as ∂S_ij/∂F_kl * v_i since the hessian is symmetric
547 result.row(i) = vect * hess.row(i).reshaped(size(), size());
548 else
549 // Compute ∂S_ij/∂F_kl * v_l, same as ∂S_ij/∂F_kl * v_j since the hessian is symmetric
550 result.row(i) = (hess.row(i).reshaped(size(), size()) * vect).transpose();
551 }
552
553} // namespace polyfem::assembler
LocalHessian hessian
double val
ElementAssemblyValues vals
Eigen::MatrixXd F
Scratch for one output point. All tensor storage has a fixed 3x3 capacity.
stores per element basis values at given quadrature points and geometric mapping
std::vector< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > > jac_it
Eigen::Matrix< double, dim *dim, dim > compute_B_block(const Eigen::Matrix< double, 1, dim > &g) const
Eigen::VectorXd assemble_gradient_full_ad(const NonLinearAssemblerData &data) const
void assemble_hessian_stress_ad(const NonLinearAssemblerData &data, LocalHessian &hessian) const
void assemble_hessian(const NonLinearAssemblerData &data, LocalHessian &hessian) const override
Eigen::VectorXd assemble_gradient_stress_noad(const NonLinearAssemblerData &data) const
bool compute_output_stress(const OutputData &data, const ElementAssemblyValues &vals, Eigen::Index point, const MatrixNd &displacement_gradient, OutputStress &stress) const override
Return false to use a material's legacy assign_stress_tensor implementation.
Eigen::VectorXd assemble_gradient(const NonLinearAssemblerData &data) const override
Eigen::VectorXd assemble_gradient_stress_ad(const NonLinearAssemblerData &data) const
double compute_energy(const NonLinearAssemblerData &data) const override
void assemble_hessian_full_ad(const NonLinearAssemblerData &data, LocalHessian &hessian) const
Reusable element matrix with inline storage for small blocks and a dynamic fallback for high-order el...
void resize(const Eigen::Index rows, const Eigen::Index cols)
const Eigen::MatrixXd & local_pts
Used for test only.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > DefGradMatrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor, 3, 3 > MatrixNd
Definition Types.hpp:14
void hessian_from_energy(const int size, const int n_bases, const assembler::NonLinearAssemblerData &data, assembler::LocalHessian &hessian, const std::function< DScalar2< double, Eigen::Matrix< double, 6, 1 >, Eigen::Matrix< double, 6, 6 > >(const assembler::NonLinearAssemblerData &)> &fun6, const std::function< DScalar2< double, Eigen::Matrix< double, 8, 1 >, Eigen::Matrix< double, 8, 8 > >(const assembler::NonLinearAssemblerData &)> &fun8, const std::function< DScalar2< double, Eigen::Matrix< double, 12, 1 >, Eigen::Matrix< double, 12, 12 > >(const assembler::NonLinearAssemblerData &)> &fun12, const std::function< DScalar2< double, Eigen::Matrix< double, 18, 1 >, Eigen::Matrix< double, 18, 18 > >(const assembler::NonLinearAssemblerData &)> &fun18, const std::function< DScalar2< double, Eigen::Matrix< double, 24, 1 >, Eigen::Matrix< double, 24, 24 > >(const assembler::NonLinearAssemblerData &)> &fun24, const std::function< DScalar2< double, Eigen::Matrix< double, 30, 1 >, Eigen::Matrix< double, 30, 30 > >(const assembler::NonLinearAssemblerData &)> &fun30, const std::function< DScalar2< double, Eigen::Matrix< double, 60, 1 >, Eigen::Matrix< double, 60, 60 > >(const assembler::NonLinearAssemblerData &)> &fun60, const std::function< DScalar2< double, Eigen::Matrix< double, 81, 1 >, Eigen::Matrix< double, 81, 81 > >(const assembler::NonLinearAssemblerData &)> &fun81, const std::function< DScalar2< double, Eigen::Matrix< double, Eigen::Dynamic, 1, 0, SMALL_N, 1 >, Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, SMALL_N, SMALL_N > >(const assembler::NonLinearAssemblerData &)> &funN, const std::function< DScalar2< double, Eigen::VectorXd, Eigen::MatrixXd >(const assembler::NonLinearAssemblerData &)> &funn)
Eigen::VectorXd gradient_from_energy(const int size, const int n_bases, const assembler::NonLinearAssemblerData &data, const std::function< DScalar1< double, Eigen::Matrix< double, 6, 1 > >(const assembler::NonLinearAssemblerData &)> &fun6, const std::function< DScalar1< double, Eigen::Matrix< double, 8, 1 > >(const assembler::NonLinearAssemblerData &)> &fun8, const std::function< DScalar1< double, Eigen::Matrix< double, 12, 1 > >(const assembler::NonLinearAssemblerData &)> &fun12, const std::function< DScalar1< double, Eigen::Matrix< double, 18, 1 > >(const assembler::NonLinearAssemblerData &)> &fun18, const std::function< DScalar1< double, Eigen::Matrix< double, 24, 1 > >(const assembler::NonLinearAssemblerData &)> &fun24, const std::function< DScalar1< double, Eigen::Matrix< double, 30, 1 > >(const assembler::NonLinearAssemblerData &)> &fun30, const std::function< DScalar1< double, Eigen::Matrix< double, 60, 1 > >(const assembler::NonLinearAssemblerData &)> &fun60, const std::function< DScalar1< double, Eigen::Matrix< double, 81, 1 > >(const assembler::NonLinearAssemblerData &)> &fun81, const std::function< DScalar1< double, Eigen::Matrix< double, Eigen::Dynamic, 1, 0, SMALL_N, 1 > >(const assembler::NonLinearAssemblerData &)> &funN, const std::function< DScalar1< double, Eigen::Matrix< double, Eigen::Dynamic, 1, 0, BIG_N, 1 > >(const assembler::NonLinearAssemblerData &)> &funBigN, const std::function< DScalar1< double, Eigen::VectorXd >(const assembler::NonLinearAssemblerData &)> &funn)
void log_and_throw_error(const std::string &msg)
Definition Logger.cpp:73
Automatic differentiation scalar with first-order derivatives.
Definition autodiff.h:112
Automatic differentiation scalar with first- and second-order derivatives.
Definition autodiff.h:493
static void setVariableCount(size_t value)
Set the independent variable count used by the automatic differentiation layer.
Definition autodiff.h:54