12 #define NEOHOOKEAN_OFF_INVERSE
25 "extract block data failed");
27 #ifdef NEOHOOKEAN_SCALING
41 "Stretch selector is not equal to LOG");
45 "Exponent base is not equal to exp(1)");
52 if (b.blockEnts.find(ent) != b.blockEnts.end()) {
53 return std::make_pair(b.c10, b.K);
58 "Block not found for entity handle. If you mat set "
59 "block, set it to all elements");
65 boost::shared_ptr<PhysicalEquations> physics_ptr)
73 boost::dynamic_pointer_cast<HMHNeohookean>(
physicsPtr);
74 *(
scalePtr) = neohookean_ptr->eqScaling;
85 boost::shared_ptr<PhysicalEquations> physics_ptr) {
90 struct OpJacobian :
public EshelbianPlasticity::OpJacobian {
91 using EshelbianPlasticity::OpJacobian::OpJacobian;
96 virtual EshelbianPlasticity::OpJacobian *
98 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
99 boost::shared_ptr<PhysicalEquations> physics_ptr) {
100 return (
new OpJacobian(tag, eval_rhs, eval_lhs, data_ptr, physics_ptr));
105 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD,
"neo_hookean_",
"",
"none");
115 CHKERR PetscOptionsScalar(
"-viscosity_alpha_grad_u",
"viscosity",
"",
118 ierr = PetscOptionsEnd();
133 (boost::format(
"%s(.*)") %
"MAT_NEOHOOKEAN").str()
145 for (
auto m : meshset_vec_ptr) {
147 std::vector<double> block_data;
148 CHKERR m->getAttributes(block_data);
149 if (block_data.size() != 2) {
151 "Expected that block has two attribute");
153 auto get_block_ents = [&]() {
159 double c10 = block_data[0];
160 double K = block_data[1];
162 blockData.push_back({c10,
K, get_block_ents()});
164 MOFEM_LOG(
"EP", sev) <<
"MatBlock Neo-Hookean c10 = "
166 <<
" K = " <<
blockData.back().K <<
" nb ents. = "
180 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
181 const double alpha_u);
191 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
192 const double alpha_u) {
198 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
207 std::string row_field, std::string col_field,
208 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha) {
231 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha_u)
237 auto neohookean_ptr =
238 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
239 if (!neohookean_ptr) {
241 "Pointer to HMHNeohookean is null");
243 auto [def_c10, def_K] =
244 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
246 double c10 = def_c10 / neohookean_ptr->eqScaling;
247 double alpha_u = alphaU / neohookean_ptr->eqScaling;
248 double K = def_K / neohookean_ptr->eqScaling;
250 double alpha_grad_u = neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
259 int nb_integration_pts = data.
getN().size1();
260 auto v = getVolume();
261 auto t_w = getFTensor0IntegrationWeight();
262 auto t_approx_P_adjoint_log_du =
263 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
264 auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
265 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
267 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
269 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
271 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTensorAtPts);
273 getFTensor2FromMat<6, 3>(dataAtPts->gradLogStretchDotTensorAtPts);
275 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretch2H1AtPts);
286 auto get_ftensor2 = [](
auto &
v) {
288 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
291 int nb_base_functions = data.
getN().size2();
298 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
303 t_Ldiff_u(
i,
j,
L) = t_diff_u(
i,
j,
k,
l) * t_L(
k,
l,
L);
307 t_Sigma_u(
i,
j) = 2.0 * c10 * t_u(
i,
j);
308 const double tr = t_log_u(
i,
i);
310 const double Sigma_J = -2.0 * c10 +
K * (
J *
J -
J);
314 alpha_u * (t_dot_log_u(
i,
j) -
315 t_dot_log_u(
k,
l) * t_kd_sym(
k,
l) * t_kd_sym(
i,
j));
318 t_residual(
L) = t_approx_P_adjoint_log_du(
L);
319 t_residual(
L) -= t_Ldiff_u(
i,
j,
L) * t_Sigma_u(
i,
j);
320 t_residual(
L) -= (t_L(
i,
j,
L) *
t_kd(
i,
j)) * Sigma_J;
321 t_residual(
L) -= t_L(
i,
j,
L) * t_viscous_P(
i,
j);
325 t_grad_residual(
L,
i) = alpha_grad_u * t_grad_log_u(
L,
i);
326 t_grad_residual(
L,
i) *=
a;
328 ++t_approx_P_adjoint_log_du;
334 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
336 for (; bb != nb_dofs /
size_symm; ++bb) {
337 t_nf(
L) -= t_row_base_fun * t_residual(
L);
338 t_nf(
L) += t_grad_base_fun(
i) * t_grad_residual(
L,
i);
343 for (; bb != nb_base_functions; ++bb) {
355 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
362 t_Ldiff_u(
i,
j,
L) = (t_diff_u(
i,
m,
k,
l) * t_h1(
m,
j)) * t_L(
k,
l,
L);
367 const double tr_h1 = t_log_u2_h1(
i,
j) * t_kd_sym(
i,
j) / 2;
368 const double tr_u = t_log_u(
i,
j) * t_kd_sym(
i,
j);
369 const double tr = tr_h1 + tr_u;
373 t_total_u(
i,
j) = t_u(
i,
m) * t_h1(
m,
j);
374 #ifndef NEOHOOKEAN_OFF_INVERSE
377 #endif // NEOHOOKEAN_OFF_INVERSE
379 #ifndef NEOHOOKEAN_OFF_INVERSE
382 2.0 * c10 * t_total_u(
i,
m) *
383 (t_kd_sym(
m,
j) - t_inv_total_u(
m,
k) * t_inv_total_u(
k,
j));
385 t_Sigma_u(
i,
j) = -2.0 * c10 * t_inv_total_u(
i,
m) *
386 (t_kd_sym(
m,
j) - t_total_u(
m,
k) * t_total_u(
k,
j));
389 t_Sigma_u(
i,
j) = 2.0 * c10 * t_total_u(
i,
j);
390 #endif // NEOHOOKEAN_OFF_INVERSE
392 #ifndef NEOHOOKEAN_OFF_INVERSE
393 const double Sigma_J =
K * (
J *
J -
J);
395 const double Sigma_J = -2.0 * c10 +
K * (
J *
J -
J);
396 #endif // NEOHOOKEAN_OFF_INVERSE
400 alpha_u * (t_dot_log_u(
i,
j) -
401 t_dot_log_u(
k,
l) * t_kd_sym(
k,
l) * t_kd_sym(
i,
j));
404 t_residual(
L) = t_approx_P_adjoint_log_du(
L);
405 t_residual(
L) -= t_Ldiff_u(
i,
j,
L) * t_Sigma_u(
i,
j);
406 t_residual(
L) -= (t_L(
i,
j,
L) *
t_kd(
i,
j)) * Sigma_J;
407 t_residual(
L) -= t_L(
i,
j,
L) * t_viscous_P(
i,
j);
411 t_grad_residual(
L,
i) = alpha_grad_u * t_grad_log_u(
L,
i);
412 t_grad_residual(
L,
i) *=
a;
414 ++t_approx_P_adjoint_log_du;
421 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
423 for (; bb != nb_dofs /
size_symm; ++bb) {
424 t_nf(
L) -= t_row_base_fun * t_residual(
L);
425 t_nf(
L) += t_grad_base_fun(
i) * t_grad_residual(
L,
i);
430 for (; bb != nb_base_functions; ++bb) {
449 "gradApproximator not handled");
456 std::string row_field, std::string col_field,
457 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha)
468 auto neohookean_ptr =
469 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
470 if (!neohookean_ptr) {
472 "Pointer to HMHNeohookean is null");
474 auto [def_c10, def_K] =
475 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
477 double c10 = def_c10 / neohookean_ptr->eqScaling;
478 double alpha_u = alphaU / neohookean_ptr->eqScaling;
479 double lambda = def_K / neohookean_ptr->eqScaling;
481 double alpha_grad_u = neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
492 int nb_integration_pts = row_data.
getN().size1();
493 int row_nb_dofs = row_data.
getIndices().size();
494 int col_nb_dofs = col_data.
getIndices().size();
500 &
m(
r + 0,
c + 0), &
m(
r + 0,
c + 1), &
m(
r + 0,
c + 2), &
m(
r + 0,
c + 3),
501 &
m(
r + 0,
c + 4), &
m(
r + 0,
c + 5),
503 &
m(
r + 1,
c + 0), &
m(
r + 1,
c + 1), &
m(
r + 1,
c + 2), &
m(
r + 1,
c + 3),
504 &
m(
r + 1,
c + 4), &
m(
r + 1,
c + 5),
506 &
m(
r + 2,
c + 0), &
m(
r + 2,
c + 1), &
m(
r + 2,
c + 2), &
m(
r + 2,
c + 3),
507 &
m(
r + 2,
c + 4), &
m(
r + 2,
c + 5),
509 &
m(
r + 3,
c + 0), &
m(
r + 3,
c + 1), &
m(
r + 3,
c + 2), &
m(
r + 3,
c + 3),
510 &
m(
r + 3,
c + 4), &
m(
r + 3,
c + 5),
512 &
m(
r + 4,
c + 0), &
m(
r + 4,
c + 1), &
m(
r + 4,
c + 2), &
m(
r + 4,
c + 3),
513 &
m(
r + 4,
c + 4), &
m(
r + 4,
c + 5),
515 &
m(
r + 5,
c + 0), &
m(
r + 5,
c + 1), &
m(
r + 5,
c + 2), &
m(
r + 5,
c + 3),
516 &
m(
r + 5,
c + 4), &
m(
r + 5,
c + 5)
528 auto v = getVolume();
529 auto ts_a = getTSa();
530 auto t_w = getFTensor0IntegrationWeight();
532 int row_nb_base_functions = row_data.
getN().size2();
536 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
538 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
540 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTensorAtPts);
542 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretch2H1AtPts);
543 auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
544 auto t_approx_P_adjoint_dstretch =
545 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
546 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
547 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
548 auto &nbUniq = dataAtPts->nbUniq;
550 auto t_P = getFTensor2FromMat<3, 3>(dataAtPts->PAtPts);
551 auto r_P_du = getFTensor4FromMat<3, 3, 3, 3>(dataAtPts->P_du);
556 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
561 t_Ldiff_u(
i,
j,
L) = t_diff_u(
i,
j,
k,
l) * t_L(
k,
l,
L);
564 const double tr = t_log_u(
i,
i);
574 t_dP(
L,
J) = (-2.0 * c10) * (t_Ldiff_u(
i,
j,
L) * t_Ldiff_u(
i,
j,
J));
575 t_dP(
L,
J) -= (t_L(
i,
j,
L) *
t_kd(
i,
j)) * Sigma_J_dtr(
J);
576 t_dP(
L,
J) -= (alpha_u * ts_a) *
577 (t_L(
i,
j,
L) * (t_diff(
i,
j,
k,
l) * t_L(
k,
l,
J) -
578 (t_diff(
m,
n,
k,
l) * t_kd_sym(
m,
n)) *
579 t_kd_sym(
i,
j) * t_L(
k,
l,
J)));
582 t_Sigma_u(
i,
j) = 2.0 * c10 * t_u(
i,
j);
587 t_deltaP(
i,
j) = t_approx_P_adjoint_dstretch(
i,
j) - t_Sigma_u(
i,
j);
591 t_dP(
L,
J) += t_L(
i,
j,
L) * (t_diff2_uP(
i,
j,
k,
l) * t_L(
k,
l,
J));
593 ++t_approx_P_adjoint_dstretch;
598 for (; rr != row_nb_dofs /
size_symm; ++rr) {
602 auto t_m = get_ftensor2(
K, 6 * rr, 0);
603 for (
int cc = 0; cc != col_nb_dofs /
size_symm; ++cc) {
604 double b =
a * t_row_base_fun * t_col_base_fun;
605 double c = (
a * alpha_grad_u * ts_a) *
606 (t_row_grad_fun(
i) * t_col_grad_fun(
i));
607 t_m(
L,
J) -= b * t_dP(
L,
J);
608 t_m(
L,
J) +=
c * t_kd_sym(
L,
J);
618 for (; rr != row_nb_base_functions; ++rr) {
632 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
642 t_Ldiff_u(
i,
j,
L) = t_diff_u(
i,
j,
k,
l) * t_L(
k,
l,
L);
647 t_Ldiff_u(
i,
j,
L) = (t_diff_u(
i,
m,
k,
l) * t_h1(
m,
j)) * t_L(
k,
l,
L);
651 "gradApproximator not handled");
656 const double tr_h1 = t_log_u2_h1(
i,
j) * t_kd_sym(
i,
j) / 2;
657 const double tr_u = t_log_u(
i,
j) * t_kd_sym(
i,
j);
658 const double tr = tr_h1 + tr_u;
668 t_total_u(
i,
j) = t_u(
i,
m) * t_h1(
m,
j);
669 #ifndef NEOHOOKEAN_OFF_INVERSE
672 #endif // NEOHOOKEAN_OFF_INVERSE
676 #ifndef NEOHOOKEAN_OFF_INVERSE
678 t_Sigma_u_du(
i,
j,
J) = t_Ldiff_u(
i,
j,
J) + t_inv_total_u(
i,
k) *
681 t_dP(
L,
J) = (-2.0 * c10) * (t_Ldiff_u(
i,
j,
L) * t_Sigma_u_du(
i,
j,
J));
683 t_dP(
L,
J) = (-2.0 * c10) * (t_Ldiff_u(
i,
j,
L) * t_Ldiff_u(
i,
j,
J));
684 #endif // NEOHOOKEAN_OFF_INVERSE
686 t_dP(
L,
J) -= (t_L(
i,
j,
L) *
t_kd(
i,
j)) * Sigma_J_dtr(
J);
687 t_dP(
L,
J) -= (alpha_u * ts_a) *
688 (t_L(
i,
j,
L) * (t_diff(
i,
j,
k,
l) * t_L(
k,
l,
J) -
689 (t_diff(
m,
n,
k,
l) * t_kd_sym(
m,
n)) *
690 t_kd_sym(
i,
j) * t_L(
k,
l,
J)));
693 #ifndef NEOHOOKEAN_OFF_INVERSE
696 2.0 * c10 * t_total_u(
i,
m) *
697 (t_kd_sym(
m,
j) - t_inv_total_u(
m,
k) * t_inv_total_u(
k,
j));
699 t_Sigma_u(
i,
j) = -2.0 * c10 * t_inv_total_u(
i,
m) *
700 (t_kd_sym(
m,
j) - t_total_u(
m,
k) * t_total_u(
k,
j));
703 t_Sigma_u(
i,
j) = 2.0 * c10 * t_total_u(
i,
j);
704 #endif // NEOHOOKEAN_OFF_INVERSE
711 t_approx_P_adjoint_dstretch(
i,
j) - t_h1(
j,
n) * t_Sigma_u(
i,
n);
714 t_deltaP(
i,
j) = -t_h1(
j,
n) * t_Sigma_u(
i,
n);
718 "gradApproximator not handled");
720 ++t_approx_P_adjoint_dstretch;
724 t_deltaP_sym(
i,
j) = (t_deltaP(
i,
j) || t_deltaP(
j,
i));
725 t_deltaP_sym(
i,
j) /= 2.0;
729 t_dP(
L,
J) += t_L(
i,
j,
L) * (t_diff2_uP2(
i,
j,
k,
l) * t_L(
k,
l,
J));
735 for (; rr != row_nb_dofs /
size_symm; ++rr) {
739 auto t_m = get_ftensor2(
K, 6 * rr, 0);
740 for (
int cc = 0; cc != col_nb_dofs /
size_symm; ++cc) {
741 double b =
a * t_row_base_fun * t_col_base_fun;
742 double c = (
a * alpha_grad_u * ts_a) *
743 (t_row_grad_fun(
i) * t_col_grad_fun(
i));
744 t_m(
L,
J) -= b * t_dP(
L,
J);
745 t_m(
L,
J) +=
c * t_kd_sym(
L,
J);
755 for (; rr != row_nb_base_functions; ++rr) {
776 "gradApproximator not handled");