v0.14.0
EshelbianOperators.cpp
Go to the documentation of this file.
1 /**
2  * \file EshelbianOperators.cpp
3  * \example EshelbianOperators.cpp
4  *
5  * \brief Implementation of operators
6  */
7 
8 #include <MoFEM.hpp>
9 using namespace MoFEM;
10 
11 #include <EshelbianPlasticity.hpp>
12 
13 #include <boost/math/constants/constants.hpp>
14 
15 #include <EshelbianAux.hpp>
16 
17 #include <lapack_wrap.h>
18 
19 #include <Lie.hpp>
20 #include <MatrixFunction.hpp>
21 
22 namespace EshelbianPlasticity {
23 
25  EntData &data) {
30 
31  int nb_integration_pts = getGaussPts().size2();
32 
33  auto t_P = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(dataAtPts->approxPAtPts);
34  auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(dataAtPts->hAtPts);
35  auto t_energy = getFTensor0FromVec(dataAtPts->energyAtPts);
36 
37  dataAtPts->SigmaAtPts.resize(SPACE_DIM * SPACE_DIM, nb_integration_pts,
38  false);
39  auto t_eshelby_stress =
40  getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(dataAtPts->SigmaAtPts);
41 
43 
44  for (auto gg = 0; gg != nb_integration_pts; ++gg) {
45  t_eshelby_stress(i, j) = t_energy * t_kd(i, j) - t_F(m, i) * t_P(m, j);
46  ++t_energy;
47  ++t_P;
48  ++t_F;
49  ++t_eshelby_stress;
50  }
51 
53 }
54 
56  EntityType type,
57  EntData &data) {
59 
60  auto ts_ctx = getTSCtx();
61  int nb_integration_pts = getGaussPts().size2();
62 
63  // space size indices
71 
72  // sym size indices
74 
75  auto t_L = symm_L_tensor();
76 
77  dataAtPts->hAtPts.resize(9, nb_integration_pts, false);
78  dataAtPts->hdOmegaAtPts.resize(9 * 3, nb_integration_pts, false);
79  dataAtPts->hdLogStretchAtPts.resize(9 * 6, nb_integration_pts, false);
80 
81  dataAtPts->leviKirchhoffAtPts.resize(3, nb_integration_pts, false);
82  dataAtPts->leviKirchhoffdOmegaAtPts.resize(9, nb_integration_pts, false);
83  dataAtPts->leviKirchhoffdLogStreatchAtPts.resize(3 * size_symm,
84  nb_integration_pts, false);
85  dataAtPts->leviKirchhoffPAtPts.resize(9 * 3, nb_integration_pts, false);
86 
87  dataAtPts->adjointPdstretchAtPts.resize(9, nb_integration_pts, false);
88  dataAtPts->adjointPdUAtPts.resize(size_symm, nb_integration_pts, false);
89  dataAtPts->adjointPdUdPAtPts.resize(9 * size_symm, nb_integration_pts, false);
90  dataAtPts->adjointPdUdOmegaAtPts.resize(3 * size_symm, nb_integration_pts,
91  false);
92  dataAtPts->rotMatAtPts.resize(9, nb_integration_pts, false);
93  dataAtPts->stretchTensorAtPts.resize(6, nb_integration_pts, false);
94  dataAtPts->diffStretchTensorAtPts.resize(36, nb_integration_pts, false);
95  dataAtPts->eigenVals.resize(3, nb_integration_pts, false);
96  dataAtPts->eigenVecs.resize(9, nb_integration_pts, false);
97  dataAtPts->nbUniq.resize(nb_integration_pts, false);
98 
99  dataAtPts->logStretch2H1AtPts.resize(6, nb_integration_pts, false);
100  dataAtPts->logStretchTotalTensorAtPts.resize(6, nb_integration_pts, false);
101 
102  // Calculated values
103  auto t_h = getFTensor2FromMat<3, 3>(dataAtPts->hAtPts);
104  auto t_h_domega = getFTensor3FromMat<3, 3, 3>(dataAtPts->hdOmegaAtPts);
105  auto t_h_dlog_u =
106  getFTensor3FromMat<3, 3, size_symm>(dataAtPts->hdLogStretchAtPts);
107  auto t_levi_kirchhoff = getFTensor1FromMat<3>(dataAtPts->leviKirchhoffAtPts);
108  auto t_levi_kirchhoff_domega =
109  getFTensor2FromMat<3, 3>(dataAtPts->leviKirchhoffdOmegaAtPts);
110  auto t_levi_kirchhoff_dstreach = getFTensor2FromMat<3, size_symm>(
111  dataAtPts->leviKirchhoffdLogStreatchAtPts);
112  auto t_levi_kirchhoff_dP =
113  getFTensor3FromMat<3, 3, 3>(dataAtPts->leviKirchhoffPAtPts);
114  auto t_approx_P_adjoint_dstretch =
115  getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
116  auto t_approx_P_adjoint_log_du =
117  getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
118  auto t_approx_P_adjoint_log_du_dP =
119  getFTensor3FromMat<3, 3, size_symm>(dataAtPts->adjointPdUdPAtPts);
120  auto t_approx_P_adjoint_log_du_domega =
121  getFTensor2FromMat<3, size_symm>(dataAtPts->adjointPdUdOmegaAtPts);
122  auto t_R = getFTensor2FromMat<3, 3>(dataAtPts->rotMatAtPts);
123  auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
124  auto t_diff_u =
125  getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
126  auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
127  auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
128  auto t_log_stretch_total =
129  getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
130  auto t_log_u2_h1 =
131  getFTensor2SymmetricFromMat<3>(dataAtPts->logStretch2H1AtPts);
132  auto &nbUniq = dataAtPts->nbUniq;
133  auto t_nb_uniq =
134  FTensor::Tensor0<FTensor::PackPtr<int *, 1>>(nbUniq.data().data());
135 
136  // Field values
137  auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
138  auto t_omega = getFTensor1FromMat<3>(dataAtPts->rotAxisAtPts);
139  auto t_approx_P = getFTensor2FromMat<3, 3>(dataAtPts->approxPAtPts);
140  auto t_log_u =
141  getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTensorAtPts);
142 
143  auto next = [&]() {
144  // calculated values
145  ++t_h;
146  ++t_h_domega;
147  ++t_h_dlog_u;
148  ++t_levi_kirchhoff;
149  ++t_levi_kirchhoff_domega;
150  ++t_levi_kirchhoff_dstreach;
151  ++t_levi_kirchhoff_dP;
152  ++t_approx_P_adjoint_dstretch;
153  ++t_approx_P_adjoint_log_du;
154  ++t_approx_P_adjoint_log_du_dP;
155  ++t_approx_P_adjoint_log_du_domega;
156  ++t_R;
157  ++t_u;
158  ++t_diff_u;
159  ++t_eigen_vals;
160  ++t_eigen_vecs;
161  ++t_nb_uniq;
162  ++t_log_u2_h1;
163  ++t_log_stretch_total;
164  // field values
165  ++t_omega;
166  ++t_grad_h1;
167  ++t_approx_P;
168  ++t_log_u;
169  };
170 
173 
174  auto bound_eig = [&](auto &eig) {
176  const auto zero = std::exp(std::numeric_limits<double>::min_exponent);
177  const auto large = std::exp(std::numeric_limits<double>::max_exponent);
178  for (int ii = 0; ii != 3; ++ii) {
179  eig(ii) = std::min(std::max(zero, eig(ii)), large);
180  }
182  };
183 
184  auto calculate_log_stretch = [&]() {
187  eigen_vec(i, j) = t_log_u(i, j);
188  if (computeEigenValuesSymmetric(eigen_vec, eig) != MB_SUCCESS) {
189  MOFEM_LOG("SELF", Sev::error) << "Failed to compute eigen values";
190  }
191  // CHKERR bound_eig(eig);
192  // rare case when two eigen values are equal
193  t_nb_uniq = get_uniq_nb<3>(&eig(0));
194  if (t_nb_uniq < 3) {
195  sort_eigen_vals(eig, eigen_vec);
196  }
197  t_eigen_vals(i) = eig(i);
198  t_eigen_vecs(i, j) = eigen_vec(i, j);
199  t_u(i, j) =
200  EigenMatrix::getMat(t_eigen_vals, t_eigen_vecs, EshelbianCore::f)(i, j);
201  auto get_t_diff_u = [&]() {
202  return EigenMatrix::getDiffMat(t_eigen_vals, t_eigen_vecs,
204  t_nb_uniq);
205  };
206  t_diff_u(i, j, k, l) = get_t_diff_u()(i, j, k, l);
208  t_Ldiff_u(i, j, L) = t_diff_u(i, j, m, n) * t_L(m, n, L);
209  return t_Ldiff_u;
210  };
211 
212  auto calculate_total_stretch = [&](auto &t_h1) {
214 
215  t_log_u2_h1(i, j) = 0;
216  t_log_stretch_total(i, j) = t_log_u(i, j);
217 
220  t_R_h1(i, j) = t_kd(i, j);
221  t_inv_u_h1(i, j) = t_symm_kd(i, j);
222 
223  return std::make_pair(t_R_h1, t_inv_u_h1);
224 
225  } else {
226 
229 
231  t_C_h1(i, j) = t_h1(k, i) * t_h1(k, j);
232  eigen_vec(i, j) = t_C_h1(i, j);
233  if (computeEigenValuesSymmetric(eigen_vec, eig) != MB_SUCCESS) {
234  MOFEM_LOG("SELF", Sev::error) << "Failed to compute eigen values";
235  }
236 
238  CHKERR bound_eig(eig);
239  }
240 
241  t_log_u2_h1(i, j) =
242  EigenMatrix::getMat(eig, eigen_vec, EshelbianCore::inv_f)(i, j);
243  t_log_stretch_total(i, j) = t_log_u2_h1(i, j) / 2 + t_log_u(i, j);
244 
245  auto f_inv_sqrt = [](auto e) { return 1. / std::sqrt(e); };
247  t_inv_u_h1(i, j) = EigenMatrix::getMat(eig, eigen_vec, f_inv_sqrt)(i, j);
249  t_R_h1(i, j) = t_h1(i, o) * t_inv_u_h1(o, j);
250 
251  return std::make_pair(t_R_h1, t_inv_u_h1);
252  }
253  };
254 
255  auto no_h1_loop = [&]() {
257 
258  switch (EshelbianCore::rotSelector) {
259  case LARGE_ROT:
260  break;
261  case SMALL_ROT:
262  break;
263  default:
264  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
265  "rotSelector should be large");
266  };
267 
268  for (int gg = 0; gg != nb_integration_pts; ++gg) {
269 
271 
273  t_h1(i, j) = t_kd(i, j);
274 
275  // calculate streach
276  auto t_Ldiff_u = calculate_log_stretch();
277 
278  // calculate total stretch
279  auto [t_R_h1, t_inv_u_h1] = calculate_total_stretch(t_h1);
280 
285 
287 
288  // rotation
289  switch (EshelbianCore::rotSelector) {
290  case LARGE_ROT:
291  t_R(i, j) = LieGroups::SO3::exp(t_omega, t_omega.l2())(i, j);
292  t_diff_R(i, j, k) =
293  LieGroups::SO3::diffExp(t_omega, t_omega.l2())(i, j, k);
294  // left
295  t_diff_Rr(i, j, l) = t_R(i, k) * levi_civita(k, j, l);
296  t_diff_diff_Rr(i, j, l, m) = t_diff_R(i, k, m) * levi_civita(k, j, l);
297  // right
298  t_diff_Rl(i, j, l) = levi_civita(i, k, l) * t_R(k, j);
299  t_diff_diff_Rl(i, j, l, m) = levi_civita(i, k, l) * t_diff_R(k, j, m);
300  break;
301 
302  default:
303  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
304  "rotationSelector not handled");
305  }
306 
307  constexpr double half_r = 1 / 2.;
308  constexpr double half_l = 1 / 2.;
309 
310  // calculate gradient
311  t_h(i, k) = t_R(i, l) * t_u(l, k);
312 
313  // Adjoint stress
314  t_approx_P_adjoint_dstretch(l, k) =
315  (t_R(i, l) * t_approx_P(i, k) + t_R(i, k) * t_approx_P(i, l));
316  t_approx_P_adjoint_dstretch(l, k) /= 2.;
317 
318  t_approx_P_adjoint_log_du(L) =
319  t_approx_P_adjoint_dstretch(l, k) * t_Ldiff_u(l, k, L);
320 
321  // Kirchhoff stress
322  t_levi_kirchhoff(m) =
323 
324  half_r * (t_diff_Rr(i, l, m) * (t_u(l, k) * t_approx_P(i, k)) +
325  t_diff_Rr(i, k, m) * (t_u(l, k) * t_approx_P(i, l)))
326 
327  +
328 
329  half_l * (t_diff_Rl(i, l, m) * (t_u(l, k) * t_approx_P(i, k)) +
330  t_diff_Rl(i, k, m) * (t_u(l, k) * t_approx_P(i, l)));
331  t_levi_kirchhoff(m) /= 2.;
332 
334 
336  t_h_domega(i, k, m) = half_r * (t_diff_Rr(i, l, m) * t_u(l, k))
337 
338  +
339 
340  half_l * (t_diff_Rl(i, l, m) * t_u(l, k));
341  } else {
342  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
343  "symmetrySelector not handled");
344  }
345 
346  t_h_dlog_u(i, k, L) = t_R(i, l) * t_Ldiff_u(l, k, L);
347 
348  t_approx_P_adjoint_log_du_dP(i, k, L) = t_R(i, l) * t_Ldiff_u(l, k, L);
349 
351  t_A(k, l, m) = t_diff_Rr(i, l, m) * t_approx_P(i, k) +
352  t_diff_Rr(i, k, m) * t_approx_P(i, l);
353  t_A(k, l, m) /= 2.;
355  t_B(k, l, m) = t_diff_Rl(i, l, m) * t_approx_P(i, k) +
356  t_diff_Rl(i, k, m) * t_approx_P(i, l);
357  t_B(k, l, m) /= 2.;
358 
359  t_approx_P_adjoint_log_du_domega(m, L) =
360  half_r * (t_A(k, l, m) * t_Ldiff_u(k, l, L)) +
361  half_l * (t_B(k, l, m) * t_Ldiff_u(k, l, L));
362 
363  t_levi_kirchhoff_domega(m, n) =
364  half_r *
365  (t_diff_diff_Rr(i, l, m, n) * (t_u(l, k) * t_approx_P(i, k)) +
366  t_diff_diff_Rr(i, k, m, n) * (t_u(l, k) * t_approx_P(i, l)))
367 
368  +
369 
370  half_l *
371  (t_diff_diff_Rl(i, l, m, n) * (t_u(l, k) * t_approx_P(i, k)) +
372  t_diff_diff_Rl(i, k, m, n) * (t_u(l, k) * t_approx_P(i, l)));
373  t_levi_kirchhoff_domega(m, n) /= 2.;
374  }
375 
376  next();
377  }
378 
380  };
381 
382  auto large_loop = [&]() {
384 
385  switch (EshelbianCore::rotSelector) {
386  case LARGE_ROT:
387  break;
388  case SMALL_ROT:
389  break;
390  default:
391  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
392  "rotSelector should be large");
393  };
394 
395  for (int gg = 0; gg != nb_integration_pts; ++gg) {
396 
398 
401  case NO_H1_CONFIGURATION:
402  t_h1(i, j) = t_kd(i, j);
403  break;
404  case LARGE_ROT:
405  t_h1(i, j) = t_grad_h1(i, j) + t_kd(i, j);
406  break;
407  default:
408  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
409  "gradApproximator not handled");
410  };
411 
412  // calculate streach
413  auto t_Ldiff_u = calculate_log_stretch();
414  // calculate total stretch
415  auto [t_R_h1, t_inv_u_h1] = calculate_total_stretch(t_h1);
416 
418  t_h_u(l, k) = t_u(l, o) * t_h1(o, k);
420  t_Ldiff_h_u(l, k, L) = t_Ldiff_u(l, o, L) * t_h1(o, k);
421 
426 
428 
429  // rotation
430  switch (EshelbianCore::rotSelector) {
431  case LARGE_ROT:
432  t_R(i, j) = LieGroups::SO3::exp(t_omega, t_omega.l2())(i, j);
433  t_diff_R(i, j, k) =
434  LieGroups::SO3::diffExp(t_omega, t_omega.l2())(i, j, k);
435  // left
436  t_diff_Rr(i, j, l) = t_R(i, k) * levi_civita(k, j, l);
437  t_diff_diff_Rr(i, j, l, m) = t_diff_R(i, k, m) * levi_civita(k, j, l);
438  // right
439  t_diff_Rl(i, j, l) = levi_civita(i, k, l) * t_R(k, j);
440  t_diff_diff_Rl(i, j, l, m) = levi_civita(i, k, l) * t_diff_R(k, j, m);
441  break;
442  case SMALL_ROT:
443  t_R(i, k) = t_kd(i, k) + levi_civita(i, k, l) * t_omega(l);
444  t_diff_R(i, j, k) = levi_civita(i, j, k);
445  // left
446  t_diff_Rr(i, j, l) = levi_civita(i, j, l);
447  t_diff_diff_Rr(i, j, l, m) = 0;
448  // right
449  t_diff_Rl(i, j, l) = levi_civita(i, j, l);
450  t_diff_diff_Rl(i, j, l, m) = 0;
451  break;
452 
453  default:
454  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
455  "rotationSelector not handled");
456  }
457 
458  constexpr double half_r = 1 / 2.;
459  constexpr double half_l = 1 / 2.;
460 
461  // calculate gradient
462  t_h(i, k) = t_R(i, l) * t_h_u(l, k);
463 
464  // Adjoint stress
465  t_approx_P_adjoint_dstretch(l, o) =
466  (t_R(i, l) * t_approx_P(i, k)) * t_h1(o, k);
467  t_approx_P_adjoint_log_du(L) =
468  t_approx_P_adjoint_dstretch(l, o) * t_Ldiff_u(l, o, L);
469 
470  // Kirchhoff stress
471  t_levi_kirchhoff(m) =
472 
473  half_r * ((t_diff_Rr(i, l, m) * (t_h_u(l, k))*t_approx_P(i, k)))
474 
475  +
476 
477  half_l * ((t_diff_Rl(i, l, m) * (t_h_u(l, k))*t_approx_P(i, k)));
478 
480 
482  t_h_domega(i, k, m) = half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
483 
484  +
485 
486  half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
487  } else {
488  t_h_domega(i, k, m) = t_diff_R(i, l, m) * t_h_u(l, k);
489  }
490 
491  t_h_dlog_u(i, k, L) = t_R(i, l) * t_Ldiff_h_u(l, k, L);
492 
493  t_approx_P_adjoint_log_du_dP(i, k, L) =
494  t_R(i, l) * t_Ldiff_h_u(l, k, L);
495 
498  t_A(m, L, i, k) = t_diff_Rr(i, l, m) * t_Ldiff_h_u(l, k, L);
500  t_B(m, L, i, k) = t_diff_Rl(i, l, m) * t_Ldiff_h_u(l, k, L);
501 
502  t_approx_P_adjoint_log_du_domega(m, L) =
503  half_r * (t_A(m, L, i, k) * t_approx_P(i, k))
504 
505  +
506 
507  half_l * (t_B(m, L, i, k) * t_approx_P(i, k));
508  } else {
510  t_A(m, L, i, k) = t_diff_R(i, l, m) * t_Ldiff_h_u(l, k, L);
511  t_approx_P_adjoint_log_du_domega(m, L) =
512  t_A(m, L, i, k) * t_approx_P(i, k);
513  }
514 
515  t_levi_kirchhoff_dstreach(m, L) =
516  half_r *
517  (t_diff_Rr(i, l, m) * (t_Ldiff_h_u(l, k, L) * t_approx_P(i, k)))
518 
519  +
520 
521  half_l * (t_diff_Rl(i, l, m) *
522  (t_Ldiff_h_u(l, k, L) * t_approx_P(i, k)));
523 
524  t_levi_kirchhoff_dP(m, i, k) =
525 
526  half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
527 
528  +
529 
530  half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
531 
532  t_levi_kirchhoff_domega(m, n) =
533  half_r *
534  (t_diff_diff_Rr(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)))
535 
536  +
537 
538  half_l *
539  (t_diff_diff_Rl(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)));
540  }
541 
542  next();
543  }
544 
546  };
547 
548  auto moderate_loop = [&]() {
550 
551  switch (EshelbianCore::rotSelector) {
552  case LARGE_ROT:
553  break;
554  case SMALL_ROT:
555  break;
556  default:
557  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
558  "rotSelector should be large");
559  };
560 
561  for (int gg = 0; gg != nb_integration_pts; ++gg) {
562 
564 
567  case MODERATE_ROT:
568  t_h1(i, j) = t_grad_h1(i, j) + t_kd(i, j);
569  break;
570  default:
571  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
572  "gradApproximator not handled");
573  };
574 
575  // calculate streach
576  auto t_Ldiff_u = calculate_log_stretch();
577  // calculate total stretch
578  auto [t_R_h1, t_inv_u_h1] = calculate_total_stretch(t_h1);
579 
581  t_h_u(l, k) = (t_symm_kd(l, o) + t_log_u(l, o)) * t_h1(o, k);
583  t_L_h(l, k, L) = t_L(l, o, L) * t_h1(o, k);
584 
589 
591 
592  // rotation
593  switch (EshelbianCore::rotSelector) {
594  case LARGE_ROT:
595  t_R(i, j) = LieGroups::SO3::exp(t_omega, t_omega.l2())(i, j);
596  t_diff_R(i, j, k) =
597  LieGroups::SO3::diffExp(t_omega, t_omega.l2())(i, j, k);
598  // left
599  t_diff_Rr(i, j, l) = t_R(i, k) * levi_civita(k, j, l);
600  t_diff_diff_Rr(i, j, l, m) = t_diff_R(i, k, m) * levi_civita(k, j, l);
601  // right
602  t_diff_Rl(i, j, l) = levi_civita(i, k, l) * t_R(k, j);
603  t_diff_diff_Rl(i, j, l, m) = levi_civita(i, k, l) * t_diff_R(k, j, m);
604  break;
605  case SMALL_ROT:
606  t_R(i, k) = t_kd(i, k) + levi_civita(i, k, l) * t_omega(l);
607  t_diff_R(i, j, l) = levi_civita(i, j, l);
608  // left
609  t_diff_Rr(i, j, l) = levi_civita(i, j, l);
610  t_diff_diff_Rr(i, j, l, m) = 0;
611  // right
612  t_diff_Rl(i, j, l) = levi_civita(i, j, l);
613  t_diff_diff_Rl(i, j, l, m) = 0;
614  break;
615 
616  default:
617  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
618  "rotationSelector not handled");
619  }
620 
621  constexpr double half_r = 1 / 2.;
622  constexpr double half_l = 1 / 2.;
623 
624  // calculate gradient
625  t_h(i, k) = t_R(i, l) * t_h_u(l, k);
626 
627  // Adjoint stress
628  t_approx_P_adjoint_dstretch(l, o) =
629  (t_R(i, l) * t_approx_P(i, k)) * t_h1(o, k);
630 
631  t_approx_P_adjoint_log_du(L) =
632  t_approx_P_adjoint_dstretch(l, o) * t_L(l, o, L);
633 
634  // Kirchhoff stress
635  t_levi_kirchhoff(m) =
636 
637  half_r * ((t_diff_Rr(i, l, m) * (t_h_u(l, k))*t_approx_P(i, k)))
638 
639  +
640 
641  half_l * ((t_diff_Rl(i, l, m) * (t_h_u(l, k))*t_approx_P(i, k)));
642 
644 
646  t_h_domega(i, k, m) = half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
647 
648  +
649 
650  half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
651  } else {
652  t_h_domega(i, k, m) = t_diff_R(i, l, m) * t_h_u(l, k);
653  }
654 
655  t_h_dlog_u(i, k, L) = t_R(i, l) * t_L_h(l, k, L);
656 
657  t_approx_P_adjoint_log_du_dP(i, k, L) = t_R(i, l) * t_L_h(l, k, L);
658 
661  t_A(m, L, i, k) = t_diff_Rr(i, l, m) * t_L_h(l, k, L);
663  t_B(m, L, i, k) = t_diff_Rl(i, l, m) * t_L_h(l, k, L);
664  t_approx_P_adjoint_log_du_domega(m, L) =
665  half_r * (t_A(m, L, i, k) * t_approx_P(i, k))
666 
667  +
668 
669  half_l * (t_B(m, L, i, k) * t_approx_P(i, k));
670  } else {
672  t_A(m, L, i, k) = t_diff_R(i, l, m) * t_L_h(l, k, L);
673  t_approx_P_adjoint_log_du_domega(m, L) =
674  t_A(m, L, i, k) * t_approx_P(i, k);
675  }
676 
677  t_levi_kirchhoff_dstreach(m, L) =
678  half_r * (t_diff_Rr(i, l, m) * (t_L_h(l, k, L) * t_approx_P(i, k)))
679 
680  +
681 
682  half_l * (t_diff_Rl(i, l, m) * (t_L_h(l, k, L) * t_approx_P(i, k)));
683 
684  t_levi_kirchhoff_dP(m, i, k) =
685 
686  half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
687 
688  +
689 
690  half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
691 
692  t_levi_kirchhoff_domega(m, n) =
693  half_r *
694  (t_diff_diff_Rr(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)))
695 
696  +
697 
698  half_l *
699  (t_diff_diff_Rl(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)));
700  }
701 
702  next();
703  }
704 
706  };
707 
708  auto small_loop = [&]() {
710  switch (EshelbianCore::rotSelector) {
711  case SMALL_ROT:
712  break;
713  default:
714  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
715  "rotSelector should be small");
716  };
717 
718  for (int gg = 0; gg != nb_integration_pts; ++gg) {
719 
722  case SMALL_ROT:
723  t_h1(i, j) = t_kd(i, j);
724  break;
725  default:
726  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
727  "gradApproximator not handled");
728  };
729 
730  // calculate streach
732 
734  t_Ldiff_u(i, j, L) = calculate_log_stretch()(i, j, L);
735  } else {
736  t_u(i, j) = t_symm_kd(i, j) + t_log_u(i, j);
737  t_Ldiff_u(i, j, L) = t_L(i, j, L);
738  }
739  t_log_u2_h1(i, j) = 0;
740  t_log_stretch_total(i, j) = t_log_u(i, j);
741 
742 
744  t_h(i, j) = levi_civita(i, j, k) * t_omega(k) + t_u(i, j);
745 
746  t_h_domega(i, j, k) = levi_civita(i, j, k);
747  t_h_dlog_u(i, j, L) = t_Ldiff_u(i, j, L);
748 
749  // Adjoint stress
750  t_approx_P_adjoint_dstretch(i, j) = t_approx_P(i, j);
751  t_approx_P_adjoint_log_du(L) =
752  t_approx_P_adjoint_dstretch(i, j) * t_Ldiff_u(i, j, L);
753  t_approx_P_adjoint_log_du_dP(i, j, L) = t_Ldiff_u(i, j, L);
754  t_approx_P_adjoint_log_du_domega(m, L) = 0;
755 
756  // Kirchhoff stress
757  t_levi_kirchhoff(k) = levi_civita(i, j, k) * t_approx_P(i, j);
758  t_levi_kirchhoff_dstreach(m, L) = 0;
759  t_levi_kirchhoff_dP(k, i, j) = levi_civita(i, j, k);
760  t_levi_kirchhoff_domega(m, n) = 0;
761 
762  next();
763  }
764 
766  };
767 
769  case NO_H1_CONFIGURATION:
770  CHKERR no_h1_loop();
771  break;
772  case LARGE_ROT:
773  CHKERR large_loop();
775  break;
776  case MODERATE_ROT:
777  CHKERR moderate_loop();
779  break;
780  case SMALL_ROT:
781  CHKERR small_loop();
783  break;
784  default:
785  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
786  "gradApproximator not handled");
787  break;
788  };
789 
791 }
792 
794  EntData &data) {
798 
799  auto n_total_side_eles = getLoopSize();
800  auto N_InLoop = getNinTheLoop();
801  auto sensee = getSkeletonSense();
802  auto nb_gauss_pts = getGaussPts().size2();
803  auto t_normal = getFTensor1NormalsAtGaussPts();
804 
805  auto t_sigma_ptr =
806  getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(dataAtPts->approxPAtPts);
807  if (N_InLoop == 0) {
808  dataAtPts->tractionAtPts.resize(SPACE_DIM, nb_gauss_pts, false);
809  dataAtPts->tractionAtPts.clear();
810  }
811  auto t_traction = getFTensor1FromMat<SPACE_DIM>(dataAtPts->tractionAtPts);
812 
813  for (int gg = 0; gg != nb_gauss_pts; gg++) {
814  t_traction(i) = t_sigma_ptr(i, j) * sensee * (t_normal(j) / t_normal.l2());
815  ++t_traction;
816  ++t_sigma_ptr;
817  ++t_normal;
818  }
819 
821 }
822 
824  EntData &data) {
826  if (blockEntities.find(getFEEntityHandle()) == blockEntities.end()) {
828  };
832  int nb_integration_pts = getGaussPts().size2();
833  auto t_w = getFTensor0IntegrationWeight();
834  auto t_traction = getFTensor1FromMat<SPACE_DIM>(dataAtPts->tractionAtPts);
835  auto t_coords = getFTensor1CoordsAtGaussPts();
836  auto t_spatial_disp = getFTensor1FromMat<SPACE_DIM>(dataAtPts->wL2AtPts);
837 
838  FTensor::Tensor1<double, 3> t_coords_spatial{0., 0., 0.};
839  // Offset for center of mass. Can be added in the future.
840  FTensor::Tensor1<double, 3> t_off{0.0, 0.0, 0.0};
841  FTensor::Tensor1<double, 3> loc_reaction_forces{0., 0., 0.};
842  FTensor::Tensor1<double, 3> loc_moment_forces{0., 0., 0.};
843 
844  for (auto gg = 0; gg != nb_integration_pts; ++gg) {
845  loc_reaction_forces(i) += (t_traction(i))*t_w * getMeasure();
846  t_coords_spatial(i) = t_coords(i) + t_spatial_disp(i);
847  // t_coords_spatial(i) -= t_off(i);
848  loc_moment_forces(i) +=
849  (FTensor::levi_civita<double>(i, j, k) * t_coords_spatial(j)) *
850  t_traction(k) * t_w * getMeasure();
851  ++t_coords;
852  ++t_spatial_disp;
853  ++t_w;
854  ++t_traction;
855  }
856 
857  reactionVec[0] += loc_reaction_forces(0);
858  reactionVec[1] += loc_reaction_forces(1);
859  reactionVec[2] += loc_reaction_forces(2);
860  reactionVec[3] += loc_moment_forces(0);
861  reactionVec[4] += loc_moment_forces(1);
862  reactionVec[5] += loc_moment_forces(2);
863 
865 }
866 
869  int nb_dofs = data.getIndices().size();
870  int nb_integration_pts = data.getN().size1();
871  auto v = getVolume();
872  auto t_w = getFTensor0IntegrationWeight();
873  auto t_div_P = getFTensor1FromMat<3>(dataAtPts->divPAtPts);
874  auto t_s_dot_w = getFTensor1FromMat<3>(dataAtPts->wL2DotAtPts);
875  if (dataAtPts->wL2DotDotAtPts.size1() == 0 &&
876  dataAtPts->wL2DotDotAtPts.size2() != nb_integration_pts) {
877  dataAtPts->wL2DotDotAtPts.resize(3, nb_integration_pts);
878  dataAtPts->wL2DotDotAtPts.clear();
879  }
880  auto t_s_dot_dot_w = getFTensor1FromMat<3>(dataAtPts->wL2DotDotAtPts);
881 
882  auto piola_scale = dataAtPts->piolaScale;
883  auto alpha_w = alphaW / piola_scale;
884  auto alpha_rho = alphaRho / piola_scale;
885 
886  int nb_base_functions = data.getN().size2();
887  auto t_row_base_fun = data.getFTensor0N();
888 
890  auto get_ftensor1 = [](auto &v) {
892  &v[2]);
893  };
894 
895  for (int gg = 0; gg != nb_integration_pts; ++gg) {
896  double a = v * t_w;
897  auto t_nf = get_ftensor1(nF);
898  int bb = 0;
899  for (; bb != nb_dofs / 3; ++bb) {
900  t_nf(i) -= a * t_row_base_fun * t_div_P(i);
901  t_nf(i) += a * t_row_base_fun * alpha_w * t_s_dot_w(i);
902  t_nf(i) += a * t_row_base_fun * alpha_rho * t_s_dot_dot_w(i);
903  ++t_nf;
904  ++t_row_base_fun;
905  }
906  for (; bb != nb_base_functions; ++bb)
907  ++t_row_base_fun;
908  ++t_w;
909  ++t_div_P;
910  ++t_s_dot_w;
911  ++t_s_dot_dot_w;
912  }
913 
915 }
916 
919  int nb_dofs = data.getIndices().size();
920  int nb_integration_pts = getGaussPts().size2();
921  auto v = getVolume();
922  auto t_w = getFTensor0IntegrationWeight();
923  auto t_levi_kirchhoff = getFTensor1FromMat<3>(dataAtPts->leviKirchhoffAtPts);
924  auto t_omega_grad_dot =
925  getFTensor2FromMat<3, 3>(dataAtPts->rotAxisGradDotAtPts);
926  int nb_base_functions = data.getN().size2();
927  auto t_row_base_fun = data.getFTensor0N();
928  auto t_row_grad_fun = data.getFTensor1DiffN<3>();
932  auto get_ftensor1 = [](auto &v) {
934  &v[2]);
935  };
936  for (int gg = 0; gg != nb_integration_pts; ++gg) {
937  double a = v * t_w;
938  auto t_nf = get_ftensor1(nF);
939  int bb = 0;
940  for (; bb != nb_dofs / 3; ++bb) {
941  t_nf(k) -= (a * t_row_base_fun) * t_levi_kirchhoff(k);
942  t_nf(k) +=
943  (a * alphaOmega) * (t_row_grad_fun(i) * t_omega_grad_dot(k, i));
944  ++t_nf;
945  ++t_row_base_fun;
946  ++t_row_grad_fun;
947  }
948  for (; bb != nb_base_functions; ++bb) {
949  ++t_row_base_fun;
950  ++t_row_grad_fun;
951  }
952  ++t_w;
953  ++t_levi_kirchhoff;
954  ++t_omega_grad_dot;
955  }
957 }
958 
961  int nb_dofs = data.getIndices().size();
962  int nb_integration_pts = data.getN().size1();
963  auto v = getVolume();
964  auto t_w = getFTensor0IntegrationWeight();
965 
966  int nb_base_functions = data.getN().size2() / 3;
967  auto t_row_base_fun = data.getFTensor1N<3>();
968  FTENSOR_INDEX(3, i);
969  FTENSOR_INDEX(3, j);
970  FTENSOR_INDEX(3, k);
971  FTENSOR_INDEX(3, m);
972  FTENSOR_INDEX(3, l);
973 
974  auto get_ftensor1 = [](auto &v) {
976  &v[2]);
977  };
978 
980 
981  auto t_R = getFTensor2FromMat<3, 3>(dataAtPts->rotMatAtPts);
982  auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
983 
984  for (int gg = 0; gg != nb_integration_pts; ++gg) {
985  double a = v * t_w;
986  auto t_nf = get_ftensor1(nF);
987 
988  constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
989 
990  int bb = 0;
991  for (; bb != nb_dofs / 3; ++bb) {
992  t_nf(i) -= a * (t_row_base_fun(k) * (t_R(i, l) * t_u(l, k)) / 2);
993  t_nf(i) -= a * (t_row_base_fun(l) * (t_R(i, k) * t_u(l, k)) / 2);
994  t_nf(i) += a * (t_row_base_fun(j) * t_kd(i, j));
995  ++t_nf;
996  ++t_row_base_fun;
997  }
998 
999  for (; bb != nb_base_functions; ++bb)
1000  ++t_row_base_fun;
1001 
1002  ++t_w;
1003  ++t_R;
1004  ++t_u;
1005  }
1006 
1007  } else {
1008 
1009  auto t_h = getFTensor2FromMat<3, 3>(dataAtPts->hAtPts);
1010 
1011  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1012  double a = v * t_w;
1013  auto t_nf = get_ftensor1(nF);
1014 
1015  constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
1016  FTensor::Tensor2<double, 3, 3> t_residuum;
1017 
1018  t_residuum(i, j) = t_h(i, j) - t_kd(i, j);
1019 
1020  int bb = 0;
1021  for (; bb != nb_dofs / 3; ++bb) {
1022  t_nf(i) -= a * t_row_base_fun(j) * t_residuum(i, j);
1023  ++t_nf;
1024  ++t_row_base_fun;
1025  }
1026 
1027  for (; bb != nb_base_functions; ++bb)
1028  ++t_row_base_fun;
1029 
1030  ++t_w;
1031  ++t_h;
1032  }
1033  }
1034 
1036 }
1037 
1040  int nb_dofs = data.getIndices().size();
1041  int nb_integration_pts = data.getN().size1();
1042  auto v = getVolume();
1043  auto t_w = getFTensor0IntegrationWeight();
1044 
1045  int nb_base_functions = data.getN().size2() / 9;
1046  auto t_row_base_fun = data.getFTensor2N<3, 3>();
1047  FTENSOR_INDEX(3, i);
1048  FTENSOR_INDEX(3, j);
1049  FTENSOR_INDEX(3, k);
1050  FTENSOR_INDEX(3, m);
1051  FTENSOR_INDEX(3, l);
1052 
1053  auto get_ftensor0 = [](auto &v) {
1055  };
1056 
1058 
1059  auto t_R = getFTensor2FromMat<3, 3>(dataAtPts->rotMatAtPts);
1060  auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
1061 
1062  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1063  double a = v * t_w;
1064  auto t_nf = get_ftensor0(nF);
1065 
1066  constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
1067 
1068  int bb = 0;
1069  for (; bb != nb_dofs; ++bb) {
1070  t_nf -= a * t_row_base_fun(i, k) * (t_R(i, l) * t_u(l, k)) / 2;
1071  t_nf -= a * t_row_base_fun(i, l) * (t_R(i, k) * t_u(l, k)) / 2;
1072  ++t_nf;
1073  ++t_row_base_fun;
1074  }
1075  for (; bb != nb_base_functions; ++bb) {
1076  ++t_row_base_fun;
1077  }
1078  ++t_w;
1079  ++t_R;
1080  ++t_u;
1081  }
1082 
1083  } else {
1084 
1085  auto t_h = getFTensor2FromMat<3, 3>(dataAtPts->hAtPts);
1086 
1087  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1088  double a = v * t_w;
1089  auto t_nf = get_ftensor0(nF);
1090 
1091  constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
1092  FTensor::Tensor2<double, 3, 3> t_residuum;
1093  t_residuum(i, j) = t_h(i, j);
1094 
1095  int bb = 0;
1096  for (; bb != nb_dofs; ++bb) {
1097  t_nf -= a * t_row_base_fun(i, j) * t_residuum(i, j);
1098  ++t_nf;
1099  ++t_row_base_fun;
1100  }
1101  for (; bb != nb_base_functions; ++bb) {
1102  ++t_row_base_fun;
1103  }
1104  ++t_w;
1105  ++t_h;
1106  }
1107  }
1108 
1110 }
1111 
1114  int nb_dofs = data.getIndices().size();
1115  int nb_integration_pts = data.getN().size1();
1116  auto v = getVolume();
1117  auto t_w = getFTensor0IntegrationWeight();
1118  auto t_w_l2 = getFTensor1FromMat<3>(dataAtPts->wL2AtPts);
1119  int nb_base_functions = data.getN().size2() / 3;
1120  auto t_row_diff_base_fun = data.getFTensor2DiffN<3, 3>();
1122  auto get_ftensor1 = [](auto &v) {
1124  &v[2]);
1125  };
1126 
1127  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1128  double a = v * t_w;
1129  auto t_nf = get_ftensor1(nF);
1130  int bb = 0;
1131  for (; bb != nb_dofs / 3; ++bb) {
1132  double div_row_base = t_row_diff_base_fun(i, i);
1133  t_nf(i) -= a * div_row_base * t_w_l2(i);
1134  ++t_nf;
1135  ++t_row_diff_base_fun;
1136  }
1137  for (; bb != nb_base_functions; ++bb) {
1138  ++t_row_diff_base_fun;
1139  }
1140  ++t_w;
1141  ++t_w_l2;
1142  }
1143 
1145 }
1146 
1147 template <AssemblyType A>
1150  // get entity of face
1151  EntityHandle fe_ent = OP::getFEEntityHandle();
1152  // iterate over all boundary data
1153  for (auto &bc : (*bcDispPtr)) {
1154  // check if finite element entity is part of boundary condition
1155  if (bc.faces.find(fe_ent) != bc.faces.end()) {
1156  int nb_dofs = data.getIndices().size();
1157  int nb_integration_pts = OP::getGaussPts().size2();
1158  auto t_normal = OP::getFTensor1NormalsAtGaussPts();
1159  auto t_w = OP::getFTensor0IntegrationWeight();
1160  int nb_base_functions = data.getN().size2() / 3;
1161  auto t_row_base_fun = data.getFTensor1N<3>();
1162 
1165 
1166  double scale = 1;
1167  for (auto &sm : scalingMethodsVec) {
1169  scale *= sm->getScale(EshelbianCore::dynamicTime);
1170  } else {
1171  scale *= sm->getScale(OP::getFEMethod()->ts_t);
1172  }
1173  }
1174 
1175  // get bc data
1176  FTensor::Tensor1<double, 3> t_bc_disp(bc.vals[0], bc.vals[1], bc.vals[2]);
1177  t_bc_disp(i) *= scale;
1178 
1179  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1180  auto t_nf = getFTensor1FromPtr<3>(&*OP::locF.begin());
1181  int bb = 0;
1182  for (; bb != nb_dofs / SPACE_DIM; ++bb) {
1183  t_nf(i) +=
1184  t_w * (t_row_base_fun(j) * t_normal(j)) * t_bc_disp(i) * 0.5;
1185  ++t_nf;
1186  ++t_row_base_fun;
1187  }
1188  for (; bb != nb_base_functions; ++bb)
1189  ++t_row_base_fun;
1190 
1191  ++t_w;
1192  ++t_normal;
1193  }
1194  }
1195  }
1197 }
1198 
1200  return OP::iNtegrate(data);
1201 }
1202 
1203 template <AssemblyType A>
1206 
1207  FTENSOR_INDEX(3, i);
1208  FTENSOR_INDEX(3, j);
1209  FTENSOR_INDEX(3, k);
1210 
1211  // get entity of face
1212  EntityHandle fe_ent = OP::getFEEntityHandle();
1213  // interate over all boundary data
1214  for (auto &bc : (*bcRotPtr)) {
1215  // check if finite element entity is part of boundary condition
1216  if (bc.faces.find(fe_ent) != bc.faces.end()) {
1217  int nb_dofs = data.getIndices().size();
1218  int nb_integration_pts = OP::getGaussPts().size2();
1219  auto t_normal = OP::getFTensor1NormalsAtGaussPts();
1220  auto t_w = OP::getFTensor0IntegrationWeight();
1221 
1222  int nb_base_functions = data.getN().size2() / 3;
1223  auto t_row_base_fun = data.getFTensor1N<3>();
1224 
1225  auto get_ftensor1 = [](auto &v) {
1227  &v[2]);
1228  };
1229 
1230  // get bc data
1231  FTensor::Tensor1<double, 3> t_center(bc.vals[0], bc.vals[1], bc.vals[2]);
1232 
1233  double theta = bc.theta;
1235  theta *= EshelbianCore::dynamicTime;
1236  } else {
1237  theta *= OP::getFEMethod()->ts_t;
1238  }
1239 
1241  const double a = sqrt(t_normal(i) * t_normal(i));
1242  t_omega(i) = t_normal(i) * (theta / a);
1243  auto t_R = LieGroups::SO3::exp(t_omega, EshelbianCore::rotSelector ==
1245  ? 0.
1246  : t_omega.l2());
1247  auto t_coords = OP::getFTensor1CoordsAtGaussPts();
1248 
1249  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1251  t_delta(i) = t_center(i) - t_coords(i);
1253  t_disp(i) = t_delta(i) - t_R(i, j) * t_delta(j);
1254 
1255  auto t_nf = getFTensor1FromPtr<3>(&*OP::locF.begin());
1256  int bb = 0;
1257  for (; bb != nb_dofs / 3; ++bb) {
1258  t_nf(i) += t_w * (t_row_base_fun(j) * t_normal(j)) * t_disp(i) * 0.5;
1259  ++t_nf;
1260  ++t_row_base_fun;
1261  }
1262  for (; bb != nb_base_functions; ++bb)
1263  ++t_row_base_fun;
1264 
1265  ++t_w;
1266  ++t_normal;
1267  ++t_coords;
1268  }
1269  }
1270  }
1272 }
1273 
1275  return OP::iNtegrate(data);
1276 }
1277 
1280 
1281  FTENSOR_INDEX(3, i);
1282 
1283  int nb_dofs = data.getFieldData().size();
1284  int nb_integration_pts = getGaussPts().size2();
1285  int nb_base_functions = data.getN().size2();
1286 
1287  double ts_t = getFEMethod()->ts_t;
1290  }
1291 
1292  double time_scale = 1;
1293  for (auto &sm : scalingMethodsVec) {
1294  time_scale *= sm->getScale(ts_t);
1295  }
1296 
1297 #ifndef NDEBUG
1298  if (this->locF.size() != nb_dofs)
1299  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
1300  "Size of locF %d != nb_dofs %d", this->locF.size(), nb_dofs);
1301 #endif // NDEBUG
1302 
1303  auto integrate_rhs = [&](auto &bc, auto calc_tau) {
1305 
1306  auto t_val = getFTensor1FromPtr<3>(&*bc.vals.begin());
1307  auto t_row_base = data.getFTensor0N();
1308  auto t_w = getFTensor0IntegrationWeight();
1309  auto t_coords = getFTensor1CoordsAtGaussPts();
1310 
1311  double scale = (piolaScalePtr) ? 1. / (*piolaScalePtr) : 1.0;
1312 
1313  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1314 
1315  const auto tau = calc_tau(t_coords(0), t_coords(1), t_coords(2));
1316  auto t_f = getFTensor1FromPtr<3>(&*this->locF.begin());
1317  int rr = 0;
1318  for (; rr != nb_dofs / SPACE_DIM; ++rr) {
1319  t_f(i) -= time_scale * t_w * t_row_base * tau * (t_val(i) * scale);
1320  ++t_row_base;
1321  ++t_f;
1322  }
1323 
1324  for (; rr != nb_base_functions; ++rr)
1325  ++t_row_base;
1326  ++t_w;
1327  ++t_coords;
1328  }
1329  // Multiply by 2 since we integrate on triangle, and hybrid constrain is
1330  // multiplied by norm.
1331  this->locF *= 2. * getMeasure();
1333  };
1334 
1335  // get entity of face
1336  EntityHandle fe_ent = getFEEntityHandle();
1337  for (auto &bc : *(bcData)) {
1338  if (bc.faces.find(fe_ent) != bc.faces.end()) {
1339 
1340  int nb_dofs = data.getFieldData().size();
1341  if (nb_dofs) {
1342 
1343  if (std::regex_match(bc.blockName, std::regex(".*COOK.*"))) {
1344  auto calc_tau = [](double, double y, double) {
1345  y -= 44;
1346  y /= (60 - 44);
1347  return -y * (y - 1) / 0.25;
1348  };
1349  CHKERR integrate_rhs(bc, calc_tau);
1350  } else {
1351  CHKERR integrate_rhs(bc, [](double, double, double) { return 1; });
1352  }
1353  }
1354  }
1355  }
1357 }
1358 
1360  EntData &col_data) {
1362  int nb_integration_pts = row_data.getN().size1();
1363  int row_nb_dofs = row_data.getIndices().size();
1364  int col_nb_dofs = col_data.getIndices().size();
1365  auto get_ftensor1 = [](MatrixDouble &m, const int r, const int c) {
1367  &m(r + 0, c + 0), &m(r + 1, c + 1), &m(r + 2, c + 2));
1368  };
1370  auto v = getVolume();
1371  auto t_w = getFTensor0IntegrationWeight();
1372  int row_nb_base_functions = row_data.getN().size2();
1373  auto t_row_base_fun = row_data.getFTensor0N();
1374  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1375  double a = v * t_w;
1376  int rr = 0;
1377  for (; rr != row_nb_dofs / 3; ++rr) {
1378  auto t_col_diff_base_fun = col_data.getFTensor2DiffN<3, 3>(gg, 0);
1379  auto t_m = get_ftensor1(K, 3 * rr, 0);
1380  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
1381  double div_col_base = t_col_diff_base_fun(i, i);
1382  t_m(i) -= a * t_row_base_fun * div_col_base;
1383  ++t_m;
1384  ++t_col_diff_base_fun;
1385  }
1386  ++t_row_base_fun;
1387  }
1388  for (; rr != row_nb_base_functions; ++rr)
1389  ++t_row_base_fun;
1390  ++t_w;
1391  }
1393 }
1394 
1396  EntData &col_data) {
1398 
1399  if (alphaW < std::numeric_limits<double>::epsilon() &&
1400  alphaRho < std::numeric_limits<double>::epsilon())
1402 
1403  const int nb_integration_pts = row_data.getN().size1();
1404  const int row_nb_dofs = row_data.getIndices().size();
1405  auto get_ftensor1 = [](MatrixDouble &m, const int r, const int c) {
1407  &m(r + 0, c + 0), &m(r + 1, c + 1), &m(r + 2, c + 2)
1408 
1409  );
1410  };
1412 
1413  auto v = getVolume();
1414  auto t_w = getFTensor0IntegrationWeight();
1415 
1416  auto piola_scale = dataAtPts->piolaScale;
1417  auto alpha_w = alphaW / piola_scale;
1418  auto alpha_rho = alphaRho / piola_scale;
1419 
1420  int row_nb_base_functions = row_data.getN().size2();
1421  auto t_row_base_fun = row_data.getFTensor0N();
1422 
1423  double ts_scale = alpha_w * getTSa();
1424  if (std::abs(alphaRho) > std::numeric_limits<double>::epsilon())
1425  ts_scale += alpha_rho * getTSaa();
1426 
1427  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1428  double a = v * t_w * ts_scale;
1429 
1430  int rr = 0;
1431  for (; rr != row_nb_dofs / 3; ++rr) {
1432 
1433  auto t_col_base_fun = row_data.getFTensor0N(gg, 0);
1434  auto t_m = get_ftensor1(K, 3 * rr, 0);
1435  for (int cc = 0; cc != row_nb_dofs / 3; ++cc) {
1436  const double b = a * t_row_base_fun * t_col_base_fun;
1437  t_m(i) += b;
1438  ++t_m;
1439  ++t_col_base_fun;
1440  }
1441 
1442  ++t_row_base_fun;
1443  }
1444 
1445  for (; rr != row_nb_base_functions; ++rr)
1446  ++t_row_base_fun;
1447 
1448  ++t_w;
1449  }
1450 
1452 }
1453 
1455  EntData &col_data) {
1457 
1463 
1464  int nb_integration_pts = row_data.getN().size1();
1465  int row_nb_dofs = row_data.getIndices().size();
1466  int col_nb_dofs = col_data.getIndices().size();
1467  auto get_ftensor3 = [](MatrixDouble &m, const int r, const int c) {
1469 
1470  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
1471 
1472  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
1473 
1474  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2),
1475 
1476  &m(r + 3, c + 0), &m(r + 3, c + 1), &m(r + 3, c + 2),
1477 
1478  &m(r + 4, c + 0), &m(r + 4, c + 1), &m(r + 4, c + 2),
1479 
1480  &m(r + 5, c + 0), &m(r + 5, c + 1), &m(r + 5, c + 2));
1481  };
1482 
1483  auto v = getVolume();
1484  auto t_w = getFTensor0IntegrationWeight();
1485 
1486  int row_nb_base_functions = row_data.getN().size2();
1487  auto t_row_base_fun = row_data.getFTensor0N();
1488 
1489  auto t_approx_P_adjoint_log_du_dP =
1490  getFTensor3FromMat<3, 3, size_symm>(dataAtPts->adjointPdUdPAtPts);
1491 
1492  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1493  double a = v * t_w;
1494  int rr = 0;
1495  for (; rr != row_nb_dofs / 6; ++rr) {
1496 
1497  auto t_col_base_fun = col_data.getFTensor1N<3>(gg, 0);
1498  auto t_m = get_ftensor3(K, 6 * rr, 0);
1499 
1500  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
1501  t_m(L, i) -=
1502  a * (t_approx_P_adjoint_log_du_dP(i, j, L) * t_col_base_fun(j)) *
1503  t_row_base_fun;
1504  ++t_col_base_fun;
1505  ++t_m;
1506  }
1507 
1508  ++t_row_base_fun;
1509  }
1510  for (; rr != row_nb_base_functions; ++rr)
1511  ++t_row_base_fun;
1512  ++t_w;
1513  ++t_approx_P_adjoint_log_du_dP;
1514  }
1515 
1517 }
1518 
1520  EntData &col_data) {
1522 
1528 
1529  int nb_integration_pts = row_data.getN().size1();
1530  int row_nb_dofs = row_data.getIndices().size();
1531  int col_nb_dofs = col_data.getIndices().size();
1532  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
1534  &m(r + 0, c), &m(r + 1, c), &m(r + 2, c), &m(r + 3, c), &m(r + 4, c),
1535  &m(r + 5, c));
1536  };
1537 
1538  auto v = getVolume();
1539  auto t_w = getFTensor0IntegrationWeight();
1540  auto t_row_base_fun = row_data.getFTensor0N();
1541 
1542  int row_nb_base_functions = row_data.getN().size2();
1543 
1544  auto t_approx_P_adjoint_log_du_dP =
1545  getFTensor3FromMat<3, 3, size_symm>(dataAtPts->adjointPdUdPAtPts);
1546 
1547  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1548  double a = v * t_w;
1549  int rr = 0;
1550  for (; rr != row_nb_dofs / 6; ++rr) {
1551  auto t_m = get_ftensor2(K, 6 * rr, 0);
1552  auto t_col_base_fun = col_data.getFTensor2N<3, 3>(gg, 0);
1553  for (int cc = 0; cc != col_nb_dofs; ++cc) {
1554  t_m(L) -=
1555  a * (t_approx_P_adjoint_log_du_dP(i, j, L) * t_col_base_fun(i, j)) *
1556  t_row_base_fun;
1557  ++t_m;
1558  ++t_col_base_fun;
1559  }
1560  ++t_row_base_fun;
1561  }
1562  for (; rr != row_nb_base_functions; ++rr)
1563  ++t_row_base_fun;
1564  ++t_w;
1565  ++t_approx_P_adjoint_log_du_dP;
1566  }
1568 }
1569 
1571  EntData &col_data) {
1573 
1575  auto t_L = symm_L_tensor();
1576 
1577  int row_nb_dofs = row_data.getIndices().size();
1578  int col_nb_dofs = col_data.getIndices().size();
1579  auto get_ftensor3 = [](MatrixDouble &m, const int r, const int c) {
1581 
1582  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
1583 
1584  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
1585 
1586  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2),
1587 
1588  &m(r + 3, c + 0), &m(r + 3, c + 1), &m(r + 3, c + 2),
1589 
1590  &m(r + 4, c + 0), &m(r + 4, c + 1), &m(r + 4, c + 2),
1591 
1592  &m(r + 5, c + 0), &m(r + 5, c + 1), &m(r + 5, c + 2)
1593 
1594  );
1595  };
1601 
1602  auto v = getVolume();
1603  auto t_w = getFTensor0IntegrationWeight();
1604  auto t_approx_P_adjoint_log_du_domega =
1605  getFTensor2FromMat<3, size_symm>(dataAtPts->adjointPdUdOmegaAtPts);
1606 
1607  int row_nb_base_functions = row_data.getN().size2();
1608  auto t_row_base_fun = row_data.getFTensor0N();
1609 
1610  int nb_integration_pts = row_data.getN().size1();
1611 
1612  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1613  double a = v * t_w;
1614 
1615  int rr = 0;
1616  for (; rr != row_nb_dofs / 6; ++rr) {
1617  auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
1618  auto t_m = get_ftensor3(K, 6 * rr, 0);
1619  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
1620  double v = a * t_row_base_fun * t_col_base_fun;
1621  t_m(L, k) -= v * t_approx_P_adjoint_log_du_domega(k, L);
1622  ++t_m;
1623  ++t_col_base_fun;
1624  }
1625  ++t_row_base_fun;
1626  }
1627 
1628  for (; rr != row_nb_base_functions; ++rr)
1629  ++t_row_base_fun;
1630 
1631  ++t_w;
1632  ++t_approx_P_adjoint_log_du_domega;
1633  }
1634 
1636 }
1637 
1639  EntData &col_data) {
1641  int nb_integration_pts = getGaussPts().size2();
1642  int row_nb_dofs = row_data.getIndices().size();
1643  int col_nb_dofs = col_data.getIndices().size();
1644  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
1646  size_symm>{
1647 
1648  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2), &m(r + 0, c + 3),
1649  &m(r + 0, c + 4), &m(r + 0, c + 5),
1650 
1651  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2), &m(r + 1, c + 3),
1652  &m(r + 1, c + 4), &m(r + 1, c + 5),
1653 
1654  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2), &m(r + 2, c + 3),
1655  &m(r + 2, c + 4), &m(r + 2, c + 5)
1656 
1657  };
1658  };
1659 
1662 
1663  auto v = getVolume();
1664  auto t_w = getFTensor0IntegrationWeight();
1665  auto t_levi_kirchhoff_du = getFTensor2FromMat<3, size_symm>(
1666  dataAtPts->leviKirchhoffdLogStreatchAtPts);
1667  int row_nb_base_functions = row_data.getN().size2();
1668  auto t_row_base_fun = row_data.getFTensor0N();
1669  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1670  double a = v * t_w;
1671  int rr = 0;
1672  for (; rr != row_nb_dofs / 3; ++rr) {
1673  auto t_m = get_ftensor2(K, 3 * rr, 0);
1674  const double b = a * t_row_base_fun;
1675  auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
1676  for (int cc = 0; cc != col_nb_dofs / size_symm; ++cc) {
1677  t_m(k, L) -= (b * t_col_base_fun) * t_levi_kirchhoff_du(k, L);
1678  ++t_m;
1679  ++t_col_base_fun;
1680  }
1681  ++t_row_base_fun;
1682  }
1683  for (; rr != row_nb_base_functions; ++rr) {
1684  ++t_row_base_fun;
1685  }
1686  ++t_w;
1687  ++t_levi_kirchhoff_du;
1688  }
1690 }
1691 
1693  EntData &col_data) {
1695 
1702 
1703  int nb_integration_pts = getGaussPts().size2();
1704  int row_nb_dofs = row_data.getIndices().size();
1705  int col_nb_dofs = col_data.getIndices().size();
1706  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
1708 
1709  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
1710 
1711  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
1712 
1713  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2)
1714 
1715  );
1716  };
1717 
1718  auto v = getVolume();
1719  auto t_w = getFTensor0IntegrationWeight();
1720 
1721  int row_nb_base_functions = row_data.getN().size2();
1722  auto t_row_base_fun = row_data.getFTensor0N();
1723  auto t_levi_kirchhoff_dP =
1724  getFTensor3FromMat<3, 3, 3>(dataAtPts->leviKirchhoffPAtPts);
1725 
1726  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1727  double a = v * t_w;
1728  int rr = 0;
1729  for (; rr != row_nb_dofs / 3; ++rr) {
1730  double b = a * t_row_base_fun;
1731  auto t_col_base_fun = col_data.getFTensor1N<3>(gg, 0);
1732  auto t_m = get_ftensor2(K, 3 * rr, 0);
1733  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
1734  t_m(m, i) -= b * (t_levi_kirchhoff_dP(m, i, k) * t_col_base_fun(k));
1735  ++t_m;
1736  ++t_col_base_fun;
1737  }
1738  ++t_row_base_fun;
1739  }
1740  for (; rr != row_nb_base_functions; ++rr) {
1741  ++t_row_base_fun;
1742  }
1743 
1744  ++t_w;
1745  ++t_levi_kirchhoff_dP;
1746  }
1748 }
1749 
1751  EntData &col_data) {
1753  int nb_integration_pts = getGaussPts().size2();
1754  int row_nb_dofs = row_data.getIndices().size();
1755  int col_nb_dofs = col_data.getIndices().size();
1756 
1757  auto get_ftensor1 = [](MatrixDouble &m, const int r, const int c) {
1759  &m(r + 0, c), &m(r + 1, c), &m(r + 2, c));
1760  };
1761 
1762  FTENSOR_INDEX(3, i);
1763  FTENSOR_INDEX(3, k);
1764  FTENSOR_INDEX(3, m);
1765 
1766  auto v = getVolume();
1767  auto t_w = getFTensor0IntegrationWeight();
1768  auto t_levi_kirchoff_dP =
1769  getFTensor3FromMat<3, 3, 3>(dataAtPts->leviKirchhoffPAtPts);
1770 
1771  int row_nb_base_functions = row_data.getN().size2();
1772  auto t_row_base_fun = row_data.getFTensor0N();
1773 
1774  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1775  double a = v * t_w;
1776  int rr = 0;
1777  for (; rr != row_nb_dofs / 3; ++rr) {
1778  double b = a * t_row_base_fun;
1779  auto t_col_base_fun = col_data.getFTensor2N<3, 3>(gg, 0);
1780  auto t_m = get_ftensor1(K, 3 * rr, 0);
1781  for (int cc = 0; cc != col_nb_dofs; ++cc) {
1782  t_m(m) -= b * (t_levi_kirchoff_dP(m, i, k) * t_col_base_fun(i, k));
1783  ++t_m;
1784  ++t_col_base_fun;
1785  }
1786  ++t_row_base_fun;
1787  }
1788 
1789  for (; rr != row_nb_base_functions; ++rr) {
1790  ++t_row_base_fun;
1791  }
1792  ++t_w;
1793  ++t_levi_kirchoff_dP;
1794  }
1796 }
1797 
1799  EntData &col_data) {
1801  int nb_integration_pts = getGaussPts().size2();
1802  int row_nb_dofs = row_data.getIndices().size();
1803  int col_nb_dofs = col_data.getIndices().size();
1804  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
1806 
1807  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
1808 
1809  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
1810 
1811  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2)
1812 
1813  );
1814  };
1821 
1823 
1824  auto v = getVolume();
1825  auto ts_a = getTSa();
1826  auto t_w = getFTensor0IntegrationWeight();
1827  auto t_levi_kirchhoff_domega =
1828  getFTensor2FromMat<3, 3>(dataAtPts->leviKirchhoffdOmegaAtPts);
1829  int row_nb_base_functions = row_data.getN().size2();
1830  auto t_row_base_fun = row_data.getFTensor0N();
1831  auto t_row_grad_fun = row_data.getFTensor1DiffN<3>();
1832  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1833  double a = v * t_w;
1834  double c = a * alphaOmega * ts_a;
1835  int rr = 0;
1836  for (; rr != row_nb_dofs / 3; ++rr) {
1837  auto t_m = get_ftensor2(K, 3 * rr, 0);
1838  const double b = a * t_row_base_fun;
1839  auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
1840  auto t_col_grad_fun = col_data.getFTensor1DiffN<3>(gg, 0);
1841  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
1842  t_m(k, l) -= (b * t_col_base_fun) * t_levi_kirchhoff_domega(k, l);
1843  t_m(k, l) += t_kd(k, l) * (c * (t_row_grad_fun(i) * t_col_grad_fun(i)));
1844  ++t_m;
1845  ++t_col_base_fun;
1846  ++t_col_grad_fun;
1847  }
1848  ++t_row_base_fun;
1849  ++t_row_grad_fun;
1850  }
1851  for (; rr != row_nb_base_functions; ++rr) {
1852  ++t_row_base_fun;
1853  ++t_row_grad_fun;
1854  }
1855  ++t_w;
1856  ++t_levi_kirchhoff_domega;
1857  }
1859 }
1860 
1862  EntData &col_data) {
1864  if (dataAtPts->matInvD.size1() == size_symm &&
1865  dataAtPts->matInvD.size2() == size_symm) {
1866  return integrateImpl<0>(row_data, col_data);
1867  } else {
1868  return integrateImpl<size_symm>(row_data, col_data);
1869  }
1871 };
1872 
1873 template <int S>
1875  EntData &col_data) {
1877 
1878  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
1880 
1881  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
1882 
1883  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
1884 
1885  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2)
1886 
1887  );
1888  };
1889 
1890  int nb_integration_pts = getGaussPts().size2();
1891  int row_nb_dofs = row_data.getIndices().size();
1892  int col_nb_dofs = col_data.getIndices().size();
1893 
1894  auto v = getVolume();
1895  auto t_w = getFTensor0IntegrationWeight();
1896  int row_nb_base_functions = row_data.getN().size2() / 3;
1897 
1902 
1903  auto t_inv_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, S>(
1904  &*dataAtPts->matInvD.data().begin());
1905 
1906  auto t_row_base = row_data.getFTensor1N<3>();
1907  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1908  double a = v * t_w;
1909 
1910  int rr = 0;
1911  for (; rr != row_nb_dofs / 3; ++rr) {
1912  auto t_col_base = col_data.getFTensor1N<3>(gg, 0);
1913  auto t_m = get_ftensor2(K, 3 * rr, 0);
1914  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
1915  t_m(i, k) -= a * t_row_base(j) * (t_inv_D(i, j, k, l) * t_col_base(l));
1916  ++t_m;
1917  ++t_col_base;
1918  }
1919 
1920  ++t_row_base;
1921  }
1922 
1923  for (; rr != row_nb_base_functions; ++rr)
1924  ++t_row_base;
1925 
1926  ++t_w;
1927  ++t_inv_D;
1928  }
1930 }
1931 
1934  EntData &col_data) {
1936  if (dataAtPts->matInvD.size1() == size_symm &&
1937  dataAtPts->matInvD.size2() == size_symm) {
1938  return integrateImpl<0>(row_data, col_data);
1939  } else {
1940  return integrateImpl<size_symm>(row_data, col_data);
1941  }
1943 };
1944 
1945 template <int S>
1948  EntData &col_data) {
1950 
1951  int nb_integration_pts = getGaussPts().size2();
1952  int row_nb_dofs = row_data.getIndices().size();
1953  int col_nb_dofs = col_data.getIndices().size();
1954 
1955  auto v = getVolume();
1956  auto t_w = getFTensor0IntegrationWeight();
1957  int row_nb_base_functions = row_data.getN().size2() / 9;
1958 
1963 
1964  auto t_inv_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, S>(
1965  &*dataAtPts->matInvD.data().begin());
1966 
1967  auto t_row_base = row_data.getFTensor2N<3, 3>();
1968  for (int gg = 0; gg != nb_integration_pts; ++gg) {
1969  double a = v * t_w;
1970 
1971  int rr = 0;
1972  for (; rr != row_nb_dofs; ++rr) {
1973  auto t_col_base = col_data.getFTensor2N<3, 3>(gg, 0);
1974  for (int cc = 0; cc != col_nb_dofs; ++cc) {
1975  K(rr, cc) -=
1976  a * (t_row_base(i, j) * (t_inv_D(i, j, k, l) * t_col_base(k, l)));
1977  ++t_col_base;
1978  }
1979 
1980  ++t_row_base;
1981  }
1982 
1983  for (; rr != row_nb_base_functions; ++rr)
1984  ++t_row_base;
1985  ++t_w;
1986  ++t_inv_D;
1987  }
1989 }
1990 
1992  EntData &col_data) {
1994  if (dataAtPts->matInvD.size1() == size_symm &&
1995  dataAtPts->matInvD.size2() == size_symm) {
1996  return integrateImpl<0>(row_data, col_data);
1997  } else {
1998  return integrateImpl<size_symm>(row_data, col_data);
1999  }
2001 };
2002 
2003 template <int S>
2006  EntData &col_data) {
2008 
2009  auto get_ftensor1 = [](MatrixDouble &m, const int r, const int c) {
2011 
2012  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2)
2013 
2014  );
2015  };
2016 
2017  int nb_integration_pts = getGaussPts().size2();
2018  int row_nb_dofs = row_data.getIndices().size();
2019  int col_nb_dofs = col_data.getIndices().size();
2020 
2021  auto v = getVolume();
2022  auto t_w = getFTensor0IntegrationWeight();
2023  int row_nb_base_functions = row_data.getN().size2() / 9;
2024 
2031 
2032  auto t_inv_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, S>(
2033  &*dataAtPts->matInvD.data().begin());
2034 
2035  auto t_row_base = row_data.getFTensor2N<3, 3>();
2036  for (int gg = 0; gg != nb_integration_pts; ++gg) {
2037  double a = v * t_w;
2038 
2039  auto t_m = get_ftensor1(K, 0, 0);
2040 
2041  int rr = 0;
2042  for (; rr != row_nb_dofs; ++rr) {
2043  auto t_col_base = col_data.getFTensor1N<3>(gg, 0);
2044  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
2045  t_m(k) -= a * (t_row_base(i, j) * t_inv_D(i, j, k, l)) * t_col_base(l);
2046  ++t_col_base;
2047  ++t_m;
2048  }
2049 
2050  ++t_row_base;
2051  }
2052 
2053  for (; rr != row_nb_base_functions; ++rr)
2054  ++t_row_base;
2055  ++t_w;
2056  ++t_inv_D;
2057  }
2059 }
2060 
2062  EntData &col_data) {
2064 
2071 
2072  int nb_integration_pts = row_data.getN().size1();
2073  int row_nb_dofs = row_data.getIndices().size();
2074  int col_nb_dofs = col_data.getIndices().size();
2075 
2076  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
2078 
2079  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
2080 
2081  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
2082 
2083  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2)
2084 
2085  );
2086  };
2087 
2088  auto v = getVolume();
2089  auto t_w = getFTensor0IntegrationWeight();
2090  int row_nb_base_functions = row_data.getN().size2() / 3;
2091  auto t_row_base_fun = row_data.getFTensor1N<3>();
2092 
2093  const double ts_a = getTSa();
2094 
2095  auto t_h_domega = getFTensor3FromMat<3, 3, 3>(dataAtPts->hdOmegaAtPts);
2096  for (int gg = 0; gg != nb_integration_pts; ++gg) {
2097  double a = v * t_w;
2098 
2099  int rr = 0;
2100  for (; rr != row_nb_dofs / 3; ++rr) {
2101 
2103  t_PRT(i, k) = t_row_base_fun(j) * t_h_domega(i, j, k);
2104 
2105  auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
2106  auto t_m = get_ftensor2(K, 3 * rr, 0);
2107  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
2108  t_m(i, j) -= (a * t_col_base_fun) * t_PRT(i, j);
2109  ++t_m;
2110  ++t_col_base_fun;
2111  }
2112 
2113  ++t_row_base_fun;
2114  }
2115 
2116  for (; rr != row_nb_base_functions; ++rr)
2117  ++t_row_base_fun;
2118  ++t_w;
2119  ++t_h_domega;
2120  }
2122 }
2123 
2126  EntData &col_data) {
2128 
2135 
2136  int nb_integration_pts = row_data.getN().size1();
2137  int row_nb_dofs = row_data.getIndices().size();
2138  int col_nb_dofs = col_data.getIndices().size();
2139 
2140  auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
2142  &m(r, c + 0), &m(r, c + 1), &m(r, c + 2));
2143  };
2144 
2145  auto v = getVolume();
2146  auto t_w = getFTensor0IntegrationWeight();
2147  int row_nb_base_functions = row_data.getN().size2() / 9;
2148  auto t_row_base_fun = row_data.getFTensor2N<3, 3>();
2149 
2150  const double ts_a = getTSa();
2151 
2152  auto t_h_domega = getFTensor3FromMat<3, 3, 3>(dataAtPts->hdOmegaAtPts);
2153  for (int gg = 0; gg != nb_integration_pts; ++gg) {
2154  double a = v * t_w;
2155 
2156  int rr = 0;
2157  for (; rr != row_nb_dofs; ++rr) {
2158 
2160  t_PRT(k) = t_row_base_fun(i, j) * t_h_domega(i, j, k);
2161 
2162  auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
2163  auto t_m = get_ftensor2(K, rr, 0);
2164  for (int cc = 0; cc != col_nb_dofs / 3; ++cc) {
2165  t_m(j) -= (a * t_col_base_fun) * t_PRT(j);
2166  ++t_m;
2167  ++t_col_base_fun;
2168  }
2169 
2170  ++t_row_base_fun;
2171  }
2172 
2173  for (; rr != row_nb_base_functions; ++rr)
2174  ++t_row_base_fun;
2175 
2176  ++t_w;
2177  ++t_h_domega;
2178  }
2180 }
2181 
2183  EntData &data) {
2185 
2186  if (tagSense != getSkeletonSense())
2188 
2189  auto get_tag = [&](auto name) {
2190  auto &mob = getPtrFE()->mField.get_moab();
2191  Tag tag;
2192  CHK_MOAB_THROW(mob.tag_get_handle(name, tag), "get tag");
2193  return tag;
2194  };
2195 
2196  auto get_tag_value = [&](auto &&tag, int dim) {
2197  auto &mob = getPtrFE()->mField.get_moab();
2198  auto face = getSidePtrFE()->getFEEntityHandle();
2199  std::vector<double> value(dim);
2200  CHK_MOAB_THROW(mob.tag_get_data(tag, &face, 1, value.data()), "set tag");
2201  return value;
2202  };
2203 
2204  auto create_tag = [this](const std::string tag_name, const int size) {
2205  double def_VAL[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
2206  Tag th;
2207  CHKERR postProcMesh.tag_get_handle(tag_name.c_str(), size, MB_TYPE_DOUBLE,
2208  th, MB_TAG_CREAT | MB_TAG_SPARSE,
2209  def_VAL);
2210  return th;
2211  };
2212 
2213  Tag th_cauchy_streess = create_tag("CauchyStress", 9);
2214  Tag th_detF = create_tag("detF", 1);
2215  Tag th_traction = create_tag("traction", 3);
2216  Tag th_disp_error = create_tag("DisplacementError", 1);
2217 
2218  Tag th_energy = create_tag("Energy", 1);
2219 
2220  auto t_w = getFTensor1FromMat<3>(dataAtPts->wL2AtPts);
2221  auto t_h = getFTensor2FromMat<3, 3>(dataAtPts->hAtPts);
2222  auto t_approx_P = getFTensor2FromMat<3, 3>(dataAtPts->approxPAtPts);
2223 
2224  auto t_normal = getFTensor1NormalsAtGaussPts();
2225  auto t_disp = getFTensor1FromMat<3>(dataAtPts->wH1AtPts);
2226 
2227  auto next = [&]() {
2228  ++t_w;
2229  ++t_h;
2230  ++t_approx_P;
2231  ++t_normal;
2232  ++t_disp;
2233  };
2234 
2235  if (dataAtPts->energyAtPts.size() == 0) {
2236  // that is for case that energy is not calculated
2237  dataAtPts->energyAtPts.resize(getGaussPts().size2());
2238  dataAtPts->energyAtPts.clear();
2239  }
2240  auto t_energy = getFTensor0FromVec(dataAtPts->energyAtPts);
2241 
2246 
2247  auto set_float_precision = [](const double x) {
2248  if (std::abs(x) < std::numeric_limits<float>::epsilon())
2249  return 0.;
2250  else
2251  return x;
2252  };
2253 
2254  // scalars
2255  auto save_scal_tag = [&](auto &th, auto v, const int gg) {
2257  v = set_float_precision(v);
2258  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, &v);
2260  };
2261 
2262  // vectors
2263  VectorDouble3 v(3);
2264  FTensor::Tensor1<FTensor::PackPtr<double *, 0>, 3> t_v(&v[0], &v[1], &v[2]);
2265  auto save_vec_tag = [&](auto &th, auto &t_d, const int gg) {
2267  t_v(i) = t_d(i);
2268  for (auto &a : v.data())
2269  a = set_float_precision(a);
2270  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1,
2271  &*v.data().begin());
2273  };
2274 
2275  // tensors
2276 
2277  MatrixDouble3by3 m(3, 3);
2279  &m(0, 0), &m(0, 1), &m(0, 2),
2280 
2281  &m(1, 0), &m(1, 1), &m(1, 2),
2282 
2283  &m(2, 0), &m(2, 1), &m(2, 2));
2284 
2285  auto save_mat_tag = [&](auto &th, auto &t_d, const int gg) {
2287  t_m(i, j) = t_d(i, j);
2288  for (auto &v : m.data())
2289  v = set_float_precision(v);
2290  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1,
2291  &*m.data().begin());
2293  };
2294 
2295  const auto nb_gauss_pts = getGaussPts().size2();
2296  for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
2297 
2298  FTensor::Tensor1<double, 3> t_traction;
2299  t_traction(i) = t_approx_P(i, j) * t_normal(j) / t_normal.l2();
2300  // vectors
2301  CHKERR save_vec_tag(th_traction, t_traction, gg);
2302 
2303  double u_error = sqrt((t_disp(i) - t_w(i)) * (t_disp(i) - t_w(i)));
2304  CHKERR save_scal_tag(th_disp_error, u_error, gg);
2305  CHKERR save_scal_tag(th_energy, t_energy, gg);
2306 
2307  const double jac = determinantTensor3by3(t_h);
2309  t_cauchy(i, j) = (1. / jac) * (t_approx_P(i, k) * t_h(j, k));
2310  CHKERR save_mat_tag(th_cauchy_streess, t_cauchy, gg);
2311  CHKERR postProcMesh.tag_set_data(th_detF, &mapGaussPts[gg], 1, &jac);
2312 
2313  next();
2314  }
2315 
2317 }
2318 
2320  boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
2321  std::vector<FieldSpace> spaces, std::string geom_field_name,
2322  boost::shared_ptr<Range> crack_front_edges_ptr) {
2324 
2325  constexpr bool scale_l2 = false;
2326 
2327  if (scale_l2) {
2328 
2329  struct OpGetHONormalsOnFace
2330  : public MoFEM::OpGetHONormalsOnFace<SPACE_DIM> {
2331 
2333 
2334  OpGetHONormalsOnFace(std::string &field_name,
2335  boost::shared_ptr<Range> edges_ptr)
2336  : OP(field_name), edgesPtr(edges_ptr) {}
2337 
2338  MoFEMErrorCode doWork(int side, EntityType type, EntData &data) {
2339 
2340  auto ent = data.getFieldEntities().size()
2341  ? data.getFieldEntities()[0]->getEnt()
2342  : 0;
2343 
2344  if (type == MBEDGE && edgesPtr->find(ent) != edgesPtr->end()) {
2345  return 0;
2346  } else {
2347  return OP::doWork(side, type, data);
2348  }
2349  };
2350 
2351  private:
2352  boost::shared_ptr<Range> edgesPtr;
2353  };
2354 
2355  auto jac = boost::make_shared<MatrixDouble>();
2356  auto det = boost::make_shared<VectorDouble>();
2357  pipeline.push_back(new OpGetHONormalsOnFace(
2358  geom_field_name, EshelbianCore::setSingularity
2359  ? crack_front_edges_ptr
2360  : boost::make_shared<Range>()));
2361  pipeline.push_back(new OpCalculateHOJacForFaceEmbeddedIn3DSpace(jac));
2362  pipeline.push_back(new OpInvertMatrix<3>(jac, det, nullptr));
2363  pipeline.push_back(new OpScaleBaseBySpaceInverseOfMeasure(
2364  L2, AINSWORTH_LEGENDRE_BASE, det));
2365  }
2366 
2367  CHKERR MoFEM::AddHOOps<2, 3, 3>::add(pipeline, spaces, geom_field_name);
2368 
2370 }
2371 
2373  boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
2374  std::vector<FieldSpace> spaces, std::string geom_field_name,
2375  boost::shared_ptr<Range> crack_front_edges_ptr) {
2377 
2379  auto jac = boost::make_shared<MatrixDouble>();
2380  auto det = boost::make_shared<VectorDouble>();
2382  geom_field_name, jac));
2383  pipeline.push_back(new OpInvertMatrix<3>(jac, det, nullptr));
2384  pipeline.push_back(
2386  }
2387 
2388  constexpr bool scale_l2_ainsworth_legendre_base = false;
2389 
2390  if (scale_l2_ainsworth_legendre_base) {
2391 
2393  : public MoFEM::OpCalculateVectorFieldGradient<SPACE_DIM, SPACE_DIM> {
2394 
2396 
2397  OpCalculateVectorFieldGradient(const std::string &field_name,
2398  boost::shared_ptr<MatrixDouble> jac,
2399  boost::shared_ptr<Range> edges_ptr)
2400  : OP(field_name, jac), edgesPtr(edges_ptr) {}
2401 
2402  MoFEMErrorCode doWork(int side, EntityType type, EntData &data) {
2403 
2404  auto ent = data.getFieldEntities().size()
2405  ? data.getFieldEntities()[0]->getEnt()
2406  : 0;
2407 
2408  if (type == MBEDGE && edgesPtr->find(ent) != edgesPtr->end()) {
2409  return 0;
2410  } else {
2411  return OP::doWork(side, type, data);
2412  }
2413  };
2414 
2415  private:
2416  boost::shared_ptr<Range> edgesPtr;
2417  };
2418 
2419  auto jac = boost::make_shared<MatrixDouble>();
2420  auto det = boost::make_shared<VectorDouble>();
2421  pipeline.push_back(new OpCalculateVectorFieldGradient(
2422  geom_field_name, jac,
2423  EshelbianCore::setSingularity ? crack_front_edges_ptr
2424  : boost::make_shared<Range>()));
2425  pipeline.push_back(new OpInvertMatrix<3>(jac, det, nullptr));
2426  pipeline.push_back(new OpScaleBaseBySpaceInverseOfMeasure(
2427  L2, AINSWORTH_LEGENDRE_BASE, det));
2428  }
2429 
2430  CHKERR MoFEM::AddHOOps<3, 3, 3>::add(pipeline, spaces, geom_field_name,
2431  nullptr, nullptr, nullptr);
2432 
2434 }
2435 
2437  EntData &data) {
2439 
2445 
2446  // sym size indices
2448  auto t_L = symm_L_tensor();
2449 
2450  const auto nb_integration_pts = getGaussPts().size2();
2451 
2452  auto t_w = getFTensor0IntegrationWeight();
2453  auto t_h = getFTensor2FromMat<3, 3>(dataAtPts->hAtPts);
2454  auto t_P = getFTensor2FromMat<3, 3>(dataAtPts->approxPAtPts);
2455 
2456  auto t_var_omega = getFTensor1FromMat<3>(dataAtPts->varRotAxis);
2457  auto t_var_log_u = getFTensor2SymmetricFromMat<3>(dataAtPts->varLogStreach);
2458  auto t_var_P = getFTensor2FromMat<3, 3>(dataAtPts->varPiola);
2459 
2460  auto t_h_domega = getFTensor3FromMat<3, 3, 3>(dataAtPts->hdOmegaAtPts);
2461  auto t_h_dlog_u =
2462  getFTensor3FromMat<3, 3, size_symm>(dataAtPts->hdLogStretchAtPts);
2463 
2464  auto t_approx_P_adjoint_log_du =
2465  getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
2466 
2467  double var_element_energy = 0.;
2468 
2469  for (auto gg = 0; gg != nb_integration_pts; ++gg) {
2470 
2472  t_var_L_u(L) = t_L(J, K, L) * t_var_log_u(J, K);
2473  auto var_energy = t_P(i, J) * (t_h_domega(i, J, j) * t_var_omega(j) +
2474  t_h_dlog_u(i, J, L) * t_var_L_u(L));
2475  var_element_energy += t_w * var_energy;
2476  auto var_complementary = t_var_P(i, J) * t_h(i, J);
2477  var_element_energy += t_w * var_complementary;
2478 
2479  ++t_w;
2480  ++t_h;
2481  ++t_P;
2482 
2483  ++t_var_omega;
2484  ++t_var_log_u;
2485  ++t_var_P;
2486 
2487  ++t_h_domega;
2488  ++t_h_dlog_u;
2489 
2490  ++t_approx_P_adjoint_log_du;
2491  }
2492 
2493  var_element_energy *= getMeasure();
2494 
2495  auto get_tag = [&]() {
2496  auto &mob = getPtrFE()->mField.get_moab();
2497  Tag tag;
2498  double def_val[] = {0.};
2499  CHK_MOAB_THROW(mob.tag_get_handle("ReleaseEnergy", 1, MB_TYPE_DOUBLE, tag,
2500  MB_TAG_CREAT | MB_TAG_SPARSE, def_val),
2501  "create tag");
2502  return tag;
2503  };
2504 
2505  auto set_tag = [&](auto &&tag, auto &energy) {
2506  auto &mob = getPtrFE()->mField.get_moab();
2507  auto tet = getPtrFE()->getFEEntityHandle();
2508  CHK_MOAB_THROW(mob.tag_set_data(tag, &tet, 1, &energy), "set tag");
2509  };
2510 
2511  set_tag(get_tag(), var_element_energy);
2512 
2513  *releaseEnergyPtr += var_element_energy;
2514 
2516 }
2517 
2518 } // namespace EshelbianPlasticity
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
CHK_MOAB_THROW
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:589
MoFEM::K
VectorDouble K
Definition: Projection10NodeCoordsOnField.cpp:125
MoFEM::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:128
OpSpatialConsistency_dBubble_dBubble::integrateImpl
MoFEMErrorCode integrateImpl(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1947
MoFEM::EntitiesFieldData::EntData::getFieldEntities
const VectorFieldEntities & getFieldEntities() const
get field entities
Definition: EntitiesFieldData.hpp:1277
EshelbianPlasticity::LINEAR
@ LINEAR
Definition: EshelbianPlasticity.hpp:46
OpRotationBc::iNtegrate
MoFEMErrorCode iNtegrate(EntData &data)
Definition: EshelbianOperators.cpp:1274
MoFEM::Types::VectorDouble3
VectorBoundedArray< double, 3 > VectorDouble3
Definition: Types.hpp:92
OpCalculateEshelbyStress::doWork
MoFEMErrorCode doWork(int row_side, EntityType row_type, EntData &row_data)
Operator for linear form, usually to calculate values on right hand side.
Definition: EshelbianOperators.cpp:24
OpDispBcImpl
Definition: EshelbianOperators.hpp:272
FTensor::Tensor1< double, 3 >
EntityHandle
MoFEM::OpCalculateHOJacForFaceEmbeddedIn3DSpace
OpCalculateHOJacForFaceImpl< 3 > OpCalculateHOJacForFaceEmbeddedIn3DSpace
Definition: HODataOperators.hpp:265
EshelbianCore::f
static boost::function< double(const double)> f
Definition: EshelbianCore.hpp:32
OpDispBc::iNtegrate
MoFEMErrorCode iNtegrate(EntData &data)
Definition: EshelbianOperators.cpp:1199
OpCalculateReactionForces::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
Definition: EshelbianOperators.cpp:823
L2
@ L2
field with C-1 continuity
Definition: definitions.h:88
EshelbianCore::stretchSelector
static enum StretchSelector stretchSelector
Definition: EshelbianCore.hpp:17
OpSpatialConsistencyP::integrate
MoFEMErrorCode integrate(EntData &data)
Definition: EshelbianOperators.cpp:959
OpSpatialConsistency_dBubble_dBubble::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1933
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
FTensor::Tensor1::l2
T l2() const
Definition: Tensor1_value.hpp:84
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
MoFEM::th
Tag th
Definition: Projection10NodeCoordsOnField.cpp:122
MoFEM::EntitiesFieldData::EntData::getFieldData
const VectorDouble & getFieldData() const
get dofs values
Definition: EntitiesFieldData.hpp:1254
FTensor::Kronecker_Delta
Kronecker Delta class.
Definition: Kronecker_Delta.hpp:15
EshelbianPlasticity
Definition: CGGTonsorialBubbleBase.hpp:11
MoFEM.hpp
OpSpatialRotation_domega_domega::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1798
J
FTensor::Index< 'J', DIM1 > J
Definition: level_set.cpp:30
MoFEM::OpScaleBaseBySpaceInverseOfMeasure
Scale base functions by inverses of measure of element.
Definition: HODataOperators.hpp:390
FTensor::Tensor2_symmetric
Definition: Tensor2_symmetric_value.hpp:13
FTENSOR_INDEX
#define FTENSOR_INDEX(DIM, I)
Definition: Templates.hpp:2013
EshelbianPlasticity::NO_H1_CONFIGURATION
@ NO_H1_CONFIGURATION
Definition: EshelbianPlasticity.hpp:45
scale
double scale
Definition: plastic.cpp:123
FTensor::levi_civita
constexpr std::enable_if<(Dim0<=2 &&Dim1<=2), Tensor2_Expr< Levi_Civita< T >, T, Dim0, Dim1, i, j > >::type levi_civita(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
levi_civita functions to make for easy adhoc use
Definition: Levi_Civita.hpp:617
ts_ctx
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1932
OpSpatialRotation_domega_dBubble::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1750
OpSpatialRotation_domega_dP::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1692
LieGroups::SO3::exp
static auto exp(A &&t_w_vee, B &&theta)
Definition: Lie.hpp:49
sdf.r
int r
Definition: sdf.py:8
FTensor::Tensor2< double, 3, 3 >
USER_BASE
@ USER_BASE
user implemented approximation base
Definition: definitions.h:68
OpSpatialConsistencyDivTerm::integrate
MoFEMErrorCode integrate(EntData &data)
Definition: EshelbianOperators.cpp:1112
OpSpatialRotation::integrate
MoFEMErrorCode integrate(EntData &data)
Definition: EshelbianOperators.cpp:917
EshelbianCore::setSingularity
static PetscBool setSingularity
Definition: EshelbianCore.hpp:19
OpSpatialConsistency_dP_dP::integrateImpl
MoFEMErrorCode integrateImpl(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1874
I
constexpr IntegrationType I
Definition: operators_tests.cpp:31
MoFEM::EntitiesFieldData::EntData::getFTensor0N
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
Definition: EntitiesFieldData.hpp:1502
EshelbianCore::gradApproximator
static enum RotSelector gradApproximator
Definition: EshelbianCore.hpp:16
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
EigenMatrix::getMat
auto getMat(A &&t_val, B &&t_vec, Fun< double > f)
Get the Mat object.
Definition: MatrixFunction.hpp:114
MoFEM::EntitiesFieldData::EntData::getFTensor2DiffN
FTensor::Tensor2< FTensor::PackPtr< double *, Tensor_Dim0 *Tensor_Dim1 >, Tensor_Dim0, Tensor_Dim1 > getFTensor2DiffN(FieldApproximationBase base)
Get derivatives of base functions for Hdiv space.
Definition: EntitiesFieldData.cpp:660
EigenMatrix::getDiffMat
auto getDiffMat(A &&t_val, B &&t_vec, Fun< double > f, Fun< double > d_f, const int nb)
Get the Diff Mat object.
Definition: MatrixFunction.hpp:166
OpSpatialPhysical_du_domega::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1570
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
FTensor::Tensor3
Definition: Tensor3_value.hpp:12
EshelbianPlasticity::SYMMETRIC
@ SYMMETRIC
Definition: EshelbianPlasticity.hpp:44
OpBrokenTractionBc::iNtegrate
MoFEMErrorCode iNtegrate(EntData &data)
Definition: EshelbianOperators.cpp:1278
OpSpatialConsistency_dBubble_domega::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:2125
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
SPACE_DIM
constexpr int SPACE_DIM
Definition: child_and_parent.cpp:16
LieGroups::SO3::diffExp
static auto diffExp(A &&t_w_vee, B &&theta)
Definition: Lie.hpp:80
a
constexpr double a
Definition: approx_sphere.cpp:30
double
convert.type
type
Definition: convert.py:64
OpRotationBcImpl
Definition: EshelbianOperators.hpp:303
MoFEM::TSMethod::CTX_TSSETIJACOBIAN
@ CTX_TSSETIJACOBIAN
Definition: LoopMethods.hpp:147
Lie.hpp
OpSpatialEquilibrium_dw_dP::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1359
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
OpCalculateRotationAndSpatialGradient::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
Operator for linear form, usually to calculate values on right hand side.
Definition: EshelbianOperators.cpp:55
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
lapack_wrap.h
OpSpatialRotation_domega_du::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1638
MatrixFunction.hpp
MoFEM::EntitiesFieldData::EntData::getFTensor2N
FTensor::Tensor2< FTensor::PackPtr< double *, Tensor_Dim0 *Tensor_Dim1 >, Tensor_Dim0, Tensor_Dim1 > getFTensor2N(FieldApproximationBase base)
Get base functions for Hdiv/Hcurl spaces.
Definition: EntitiesFieldData.cpp:762
MoFEM::L
VectorDouble L
Definition: Projection10NodeCoordsOnField.cpp:124
MoFEM::OpGetHONormalsOnFace
Calculate normals at Gauss points of triangle element.
Definition: HODataOperators.hpp:281
EshelbianPlasticity.hpp
Eshelbian plasticity interface.
OpSpatialConsistency_dP_domega::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:2061
FTensor::Tensor4
Definition: Tensor4_value.hpp:18
size_symm
constexpr auto size_symm
Definition: plastic.cpp:42
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
t_kd
constexpr auto t_kd
Definition: free_surface.cpp:139
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FTensor::Index< 'i', 3 >
EshelbianCore::symmetrySelector
static enum SymmetrySelector symmetrySelector
Definition: EshelbianCore.hpp:14
MoFEM::AddHOOps
Add operators pushing bases from local to physical configuration.
Definition: HODataOperators.hpp:417
MoFEM::OpCalculateVectorFieldGradient
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Definition: UserDataOperators.hpp:1561
convert.n
n
Definition: convert.py:82
MoFEM::determinantTensor3by3
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
Definition: Templates.hpp:1540
OpSpatialPhysical_du_dBubble::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1519
v
const double v
phase velocity of light in medium (cm/ns)
Definition: initial_diffusion.cpp:40
HenckyOps::sort_eigen_vals
auto sort_eigen_vals(FTensor::Tensor1< double, DIM > &eig, FTensor::Tensor2< double, DIM, DIM > &eigen_vec)
Definition: HenckyOps.hpp:41
EshelbianPlasticity::SMALL_ROT
@ SMALL_ROT
Definition: EshelbianPlasticity.hpp:45
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::EntitiesFieldData::EntData::getFTensor1DiffN
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
Definition: EntitiesFieldData.cpp:526
EshelbianPlasticity::LARGE_ROT
@ LARGE_ROT
Definition: EshelbianPlasticity.hpp:45
FTensor::Tensor0
Definition: Tensor0.hpp:16
EshelbianPlasticity::LOG
@ LOG
Definition: EshelbianPlasticity.hpp:46
EshelbianCore::dynamicRelaxation
static PetscBool dynamicRelaxation
Definition: EshelbianCore.hpp:20
PlasticOps::symm_L_tensor
auto symm_L_tensor(FTensor::Number< DIM >)
Definition: PlasticOpsGeneric.hpp:21
MoFEM::EntitiesFieldData::EntData::getN
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
Definition: EntitiesFieldData.hpp:1318
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
MoFEM::EntitiesFieldData::EntData::getFTensor1N
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1N(FieldApproximationBase base)
Get base functions for Hdiv/Hcurl spaces.
Definition: EntitiesFieldData.cpp:640
OpCalculateTractionFromSideEl::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
Definition: EshelbianOperators.cpp:793
OpSpatialConsistency_dBubble_dP::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1991
EshelbianCore::inv_f
static boost::function< double(const double)> inv_f
Definition: EshelbianCore.hpp:35
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
OpSpatialEquilibrium::integrate
MoFEMErrorCode integrate(EntData &data)
Definition: EshelbianOperators.cpp:867
MoFEM::OpInvertMatrix
Definition: UserDataOperators.hpp:3684
OpReleaseEnergy::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
Definition: EshelbianOperators.cpp:2436
MoFEM::Types::MatrixDouble3by3
MatrixBoundedArray< double, 9 > MatrixDouble3by3
Definition: Types.hpp:105
OpSpatialConsistency_dBubble_dP::integrateImpl
MoFEMErrorCode integrateImpl(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:2005
EshelbianAux.hpp
Auxilary functions for Eshelbian plasticity.
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
EshelbianCore::rotSelector
static enum RotSelector rotSelector
Definition: EshelbianCore.hpp:15
OpPostProcDataStructure::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
Definition: EshelbianOperators.cpp:2182
FTensor::Kronecker_Delta_symmetric
Kronecker Delta class symmetric.
Definition: Kronecker_Delta.hpp:49
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
OpSpatialPhysical_du_dP::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1454
EshelbianPlasticity::MODERATE_ROT
@ MODERATE_ROT
Definition: EshelbianPlasticity.hpp:45
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianCore::dynamicTime
static double dynamicTime
Definition: EshelbianCore.hpp:23
OpSpatialConsistencyBubble::integrate
MoFEMErrorCode integrate(EntData &data)
Definition: EshelbianOperators.cpp:1038
OP
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
OpSpatialEquilibrium_dw_dw::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1395
EshelbianCore::l2UserBaseScale
static PetscBool l2UserBaseScale
Definition: EshelbianCore.hpp:27
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
OpSpatialConsistency_dP_dP::integrate
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
Definition: EshelbianOperators.cpp:1861
MoFEM::computeEigenValuesSymmetric
MoFEMErrorCode computeEigenValuesSymmetric(const MatrixDouble &mat, VectorDouble &eig, MatrixDouble &eigen_vec)
compute eigenvalues of a symmetric matrix using lapack dsyev
Definition: Templates.hpp:1452
EshelbianCore::d_f
static boost::function< double(const double)> d_f
Definition: EshelbianCore.hpp:33