22 boost::shared_ptr<HMHHencky> hencky_ptr)
27 "Can not get data from block");
30 MoFEMErrorCode
doWork(
int side, EntityType type,
31 EntitiesFieldData::EntData &data) {
35 if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
41 b.bulkModulusK, b.shearModulusG);
72 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
73 boost::shared_ptr<PhysicalEquations> physics_ptr) {
75 data_ptr, boost::dynamic_pointer_cast<HMHHencky>(physics_ptr)));
81 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
82 const double alpha_u);
97 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
98 const double alpha_u) {
105 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
106 boost::shared_ptr<ExternalStrainVec> &external_strain_vec_ptr,
107 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
118 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
119 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
120 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv)
123 field_name, data_ptr, external_strain_vec_ptr, smv);
129 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
143 std::string row_field, std::string col_field,
144 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha) {
164 boost::shared_ptr<double> total_energy_ptr);
165 MoFEMErrorCode
doWork(
int side, EntityType type,
EntData &data);
174 boost::shared_ptr<double> total_energy_ptr) {
180 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
181 boost::shared_ptr<MatrixDouble> strain_ptr,
182 boost::shared_ptr<MatrixDouble> stress_ptr,
183 boost::shared_ptr<HMHHencky> hencky_ptr);
184 MoFEMErrorCode
doWork(
int side, EntityType type,
EntData &data);
187 boost::shared_ptr<DataAtIntegrationPts>
195 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
196 boost::shared_ptr<PhysicalEquations> physics_ptr) {
198 data_ptr, data_ptr->getLogStretchTensorAtPts(),
199 data_ptr->getApproxPAtPts(),
200 boost::dynamic_pointer_cast<HMHHencky>(physics_ptr));
204 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
205 boost::shared_ptr<PhysicalEquations> physics_ptr) {
207 data_ptr, data_ptr->getVarLogStreachPts(), data_ptr->getVarPiolaPts(),
208 boost::dynamic_pointer_cast<HMHHencky>(physics_ptr));
211 MoFEMErrorCode
getOptions(boost::shared_ptr<DataAtIntegrationPts> data_ptr) {
213 PetscOptionsBegin(PETSC_COMM_WORLD,
"hencky_",
"",
"none");
215 CHKERR PetscOptionsScalar(
"-young_modulus",
"Young modulus",
"",
E, &
E,
217 CHKERR PetscOptionsScalar(
"-poisson_ratio",
"poisson ratio",
"",
nu, &
nu,
223 <<
"Hencky: E = " <<
E <<
" nu = " <<
nu;
236 (boost::format(
"%s(.*)") %
"MAT_ELASTIC").str()
248 for (
auto m : meshset_vec_ptr) {
250 std::vector<double> block_data;
251 CHKERR m->getAttributes(block_data);
252 if (block_data.size() < 2) {
254 "Expected that block has atleast two attributes");
256 auto get_block_ents = [&]() {
276 MoFEMErrorCode
getMatDPtr(boost::shared_ptr<MatrixDouble> mat_D_ptr,
277 boost::shared_ptr<MatrixDouble> mat_axiator_D_ptr,
278 boost::shared_ptr<MatrixDouble> mat_deviator_D_ptr,
282 auto set_material_stiffness = [&]() {
288 auto t_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, 0>(
289 &*(mat_D_ptr->data().begin()));
290 auto t_axiator_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, 0>(
291 &*mat_axiator_D_ptr->data().begin());
292 auto t_deviator_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, 0>(
293 &*mat_deviator_D_ptr->data().begin());
296 t_deviator_D(
i,
j,
k,
l) =
298 t_D(
i,
j,
k,
l) = t_axiator_D(
i,
j,
k,
l) + t_deviator_D(
i,
j,
k,
l);
305 set_material_stiffness();
314 auto set_material_compilance = [&]() {
323 auto t_inv_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, 0>(
324 &*(mat_inv_D_ptr->data().begin()));
325 t_inv_D(
i,
j,
k,
l) =
331 set_material_compilance();
338 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
339 SmartPetscObj<Vec> assemble_vec,
340 boost::shared_ptr<TopologicalData> topo_ptr,
341 const double alpha_u);
360 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
361 SmartPetscObj<Vec> assemble_vec,
362 boost::shared_ptr<TopologicalData> topo_ptr,
363 const double alpha_u) {
388 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha_u)
391 CHK_MOAB_THROW(PetscOptionsGetBool(PETSC_NULLPTR,
"",
"-poly_convex",
393 "get polyconvex option failed");
399 CHKERR integratePolyconvexHencky(data);
401 CHKERR integrateHencky(data);
413 int nb_integration_pts = data.
getN().size1();
414 auto v = getVolume();
415 auto t_w = getFTensor0IntegrationWeight();
416 auto t_approx_P_adjoint_log_du =
417 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
418 auto t_log_stretch_h1 =
419 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
421 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
423 auto t_D = getFTensor4DdgFromPtr<3, 3, 0>(&*dataAtPts->matD.data().begin());
429 auto get_ftensor2 = [](
auto &
v) {
431 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
434 int nb_base_functions = data.
getN().size2();
436 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
438 auto t_nf = get_ftensor2(nF);
442 t_D(
i,
j,
k,
l) * (t_log_stretch_h1(
k,
l) + alphaU * t_dot_log_u(
k,
l));
445 a * (t_approx_P_adjoint_log_du(L) - t_L(
i,
j, L) * t_T(
i,
j));
448 for (; bb != nb_dofs / 6; ++bb) {
449 t_nf(L) -= t_row_base_fun * t_residual(L);
453 for (; bb != nb_base_functions; ++bb)
457 ++t_approx_P_adjoint_log_du;
472 int nb_integration_pts = data.
getN().size1();
473 auto v = getVolume();
474 auto t_w = getFTensor0IntegrationWeight();
475 auto t_approx_P_adjoint_log_du =
476 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
477 auto t_log_stretch_h1 =
478 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
480 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
482 auto t_D = getFTensor4DdgFromPtr<3, 3, 0>(&*dataAtPts->matD.data().begin());
488 auto get_ftensor2 = [](
auto &
v) {
490 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
493 constexpr double nohat_k = 1. / 4;
494 constexpr double hat_k = 1. / 8;
495 double mu = dataAtPts->mu;
496 double lambda = dataAtPts->lambda;
498 constexpr double third = boost::math::constants::third<double>();
502 int nb_base_functions = data.
getN().size2();
504 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
506 auto t_nf = get_ftensor2(nF);
508 double log_det = t_log_stretch_h1(
i,
i);
509 double log_det2 = log_det * log_det;
512 double dev_norm2 = t_dev(
i,
j) * t_dev(
i,
j);
515 auto A = 2 *
mu * std::exp(nohat_k * dev_norm2);
516 auto B =
lambda * std::exp(hat_k * log_det2) * log_det;
519 A * (t_dev(
k,
l) * t_diff_deviator(
k,
l,
i,
j))
527 alphaU * t_D(
i,
j,
k,
l) * t_dot_log_u(
k,
l);
531 a * (t_approx_P_adjoint_log_du(L) - t_L(
i,
j, L) * t_T(
i,
j));
534 for (; bb != nb_dofs /
size_symm; ++bb) {
535 t_nf(L) -= t_row_base_fun * t_residual(L);
539 for (; bb != nb_base_functions; ++bb)
543 ++t_approx_P_adjoint_log_du;
551 std::string row_field, std::string col_field,
552 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha)
557 CHK_MOAB_THROW(PetscOptionsGetBool(PETSC_NULLPTR,
"",
"-poly_convex",
559 "get polyconvex option failed");
564 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
565 boost::shared_ptr<ExternalStrainVec> &external_strain_vec_ptr,
566 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv)
568 externalStrainVecPtr(external_strain_vec_ptr), scalingMethodsMap(smv) {}
584 for (
auto &ext_strain_block : (*externalStrainVecPtr)) {
586 if (ext_strain_block.ents.find(fe_ent) != ext_strain_block.ents.end()) {
589 if (scalingMethodsMap.find(ext_strain_block.blockName) !=
590 scalingMethodsMap.end()) {
592 scalingMethodsMap.at(ext_strain_block.blockName)->getScale(time);
595 <<
"No scaling method found for " << ext_strain_block.blockName;
599 int nb_integration_pts = data.
getN().size1();
600 auto v = getVolume();
601 auto t_w = getFTensor0IntegrationWeight();
604 double external_strain_val;
605 VectorDouble v_external_strain;
606 auto block_name =
"(.*)ANALYTICAL_EXTERNALSTRAIN(.*)";
607 std::regex reg_name(block_name);
608 if (std::regex_match(ext_strain_block.blockName, reg_name)) {
609 VectorDouble analytical_external_strain;
610 std::string block_name_tmp;
611 std::tie(block_name_tmp, v_external_strain) =
613 ext_strain_block.blockName);
616 external_strain_val =
scale * ext_strain_block.val;
618 v_external_strain.resize(nb_integration_pts);
619 std::fill(v_external_strain.begin(), v_external_strain.end(),
620 external_strain_val);
622 auto t_external_strain = getFTensor0FromVec(v_external_strain);
630 auto get_ftensor2 = [](
auto &
v) {
632 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
635 int nb_base_functions = data.
getN().size2();
637 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
638 auto tr = 3.0 * t_external_strain;
640 auto t_nf = get_ftensor2(nF);
647 t_residual(L) =
a * (t_L(
i,
j, L) * t_T(
i,
j));
650 for (; bb != nb_dofs / 6; ++bb) {
651 t_nf(L) += t_row_base_fun * t_residual(L);
655 for (; bb != nb_base_functions; ++bb)
672 CHKERR integratePolyconvexHencky(row_data, col_data);
674 CHKERR integrateHencky(row_data, col_data);
689 int nb_integration_pts = row_data.
getN().size1();
690 int row_nb_dofs = row_data.
getIndices().size();
691 int col_nb_dofs = col_data.
getIndices().size();
693 auto get_ftensor2 = [](MatrixDouble &
m,
const int r,
const int c) {
697 &
m(r + 0,
c + 0), &
m(r + 0,
c + 1), &
m(r + 0,
c + 2), &
m(r + 0,
c + 3),
698 &
m(r + 0,
c + 4), &
m(r + 0,
c + 5),
700 &
m(r + 1,
c + 0), &
m(r + 1,
c + 1), &
m(r + 1,
c + 2), &
m(r + 1,
c + 3),
701 &
m(r + 1,
c + 4), &
m(r + 1,
c + 5),
703 &
m(r + 2,
c + 0), &
m(r + 2,
c + 1), &
m(r + 2,
c + 2), &
m(r + 2,
c + 3),
704 &
m(r + 2,
c + 4), &
m(r + 2,
c + 5),
706 &
m(r + 3,
c + 0), &
m(r + 3,
c + 1), &
m(r + 3,
c + 2), &
m(r + 3,
c + 3),
707 &
m(r + 3,
c + 4), &
m(r + 3,
c + 5),
709 &
m(r + 4,
c + 0), &
m(r + 4,
c + 1), &
m(r + 4,
c + 2), &
m(r + 4,
c + 3),
710 &
m(r + 4,
c + 4), &
m(r + 4,
c + 5),
712 &
m(r + 5,
c + 0), &
m(r + 5,
c + 1), &
m(r + 5,
c + 2), &
m(r + 5,
c + 3),
713 &
m(r + 5,
c + 4), &
m(r + 5,
c + 5)
724 auto v = getVolume();
725 auto t_w = getFTensor0IntegrationWeight();
727 auto t_approx_P_adjoint__dstretch =
728 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
729 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
730 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
732 int row_nb_base_functions = row_data.
getN().size2();
735 auto get_dP = [&]() {
737 auto ts_a = getTSa();
739 auto t_D = getFTensor4DdgFromPtr<3, 3, 0>(&*dataAtPts->matD.data().begin());
741 t_dP_tmp(L,
J) = -(1 + alphaU * ts_a) *
743 ((t_D(
i,
j,
m,
n) * t_diff(
m,
n,
k,
l)) * t_L(
k,
l,
J)));
747 auto t_approx_P_adjoint__dstretch =
748 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
749 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
750 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
751 auto &nbUniq = dataAtPts->nbUniq;
753 auto t_dP = getFTensor2FromMat<size_symm, size_symm>(dP);
754 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
759 t_sym(
i,
j) = (t_approx_P_adjoint__dstretch(
i,
j) ||
760 t_approx_P_adjoint__dstretch(
j,
i));
765 t_dP(L,
J) = t_L(
i,
j, L) *
766 ((t_diff2_uP2(
i,
j,
k,
l) + t_diff2_uP2(
k,
l,
i,
j)) *
772 ++t_approx_P_adjoint__dstretch;
777 auto t_dP = getFTensor2FromMat<size_symm, size_symm>(dP);
778 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
779 t_dP(L,
J) = t_dP_tmp(L,
J);
784 return getFTensor2FromMat<size_symm, size_symm>(dP);
787 auto t_dP = get_dP();
788 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
792 for (; rr != row_nb_dofs / 6; ++rr) {
794 auto t_m = get_ftensor2(K, 6 * rr, 0);
795 for (
int cc = 0; cc != col_nb_dofs / 6; ++cc) {
796 const double b =
a * t_row_base_fun * t_col_base_fun;
797 t_m(L,
J) -= b * t_dP(L,
J);
804 for (; rr != row_nb_base_functions; ++rr) {
823 int nb_integration_pts = row_data.
getN().size1();
824 int row_nb_dofs = row_data.
getIndices().size();
825 int col_nb_dofs = col_data.
getIndices().size();
827 auto get_ftensor2 = [](MatrixDouble &
m,
const int r,
const int c) {
831 &
m(r + 0,
c + 0), &
m(r + 0,
c + 1), &
m(r + 0,
c + 2), &
m(r + 0,
c + 3),
832 &
m(r + 0,
c + 4), &
m(r + 0,
c + 5),
834 &
m(r + 1,
c + 0), &
m(r + 1,
c + 1), &
m(r + 1,
c + 2), &
m(r + 1,
c + 3),
835 &
m(r + 1,
c + 4), &
m(r + 1,
c + 5),
837 &
m(r + 2,
c + 0), &
m(r + 2,
c + 1), &
m(r + 2,
c + 2), &
m(r + 2,
c + 3),
838 &
m(r + 2,
c + 4), &
m(r + 2,
c + 5),
840 &
m(r + 3,
c + 0), &
m(r + 3,
c + 1), &
m(r + 3,
c + 2), &
m(r + 3,
c + 3),
841 &
m(r + 3,
c + 4), &
m(r + 3,
c + 5),
843 &
m(r + 4,
c + 0), &
m(r + 4,
c + 1), &
m(r + 4,
c + 2), &
m(r + 4,
c + 3),
844 &
m(r + 4,
c + 4), &
m(r + 4,
c + 5),
846 &
m(r + 5,
c + 0), &
m(r + 5,
c + 1), &
m(r + 5,
c + 2), &
m(r + 5,
c + 3),
847 &
m(r + 5,
c + 4), &
m(r + 5,
c + 5)
858 auto v = getVolume();
859 auto t_w = getFTensor0IntegrationWeight();
861 int row_nb_base_functions = row_data.
getN().size2();
864 auto get_dP = [&]() {
866 auto ts_a = getTSa();
868 auto t_D = getFTensor4DdgFromPtr<3, 3, 0>(&*dataAtPts->matD.data().begin());
870 constexpr double nohat_k = 1. / 4;
871 constexpr double hat_k = 1. / 8;
872 double mu = dataAtPts->mu;
873 double lambda = dataAtPts->lambda;
875 constexpr double third = boost::math::constants::third<double>();
879 auto t_approx_P_adjoint__dstretch =
880 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
881 auto t_log_stretch_h1 =
882 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
883 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
884 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
885 auto &nbUniq = dataAtPts->nbUniq;
887 auto t_dP = getFTensor2FromMat<size_symm, size_symm>(dP);
888 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
890 double log_det = t_log_stretch_h1(
i,
i);
891 double log_det2 = log_det * log_det;
894 double dev_norm2 = t_dev(
i,
j) * t_dev(
i,
j);
896 auto A = 2 *
mu * std::exp(nohat_k * dev_norm2);
897 auto B =
lambda * std::exp(hat_k * log_det2) * log_det;
901 (
A * 2 * nohat_k) * (t_dev(
k,
l) * t_diff_deviator(
k,
l,
i,
j));
902 t_B_diff(
i,
j) = (
B * 2 * hat_k) * log_det *
t_kd(
i,
j) +
906 t_A_diff(
i,
j) * (t_dev(
m,
n) * t_diff_deviator(
m,
n,
k,
l))
910 A * t_diff_deviator(
m,
n,
i,
j) * t_diff_deviator(
m,
n,
k,
l)
916 t_dP(L,
J) = -t_L(
i,
j, L) *
923 (alphaU * ts_a) * (t_D(
i,
j,
m,
n) * t_diff(
m,
n,
k,
l)
933 t_sym(
i,
j) = (t_approx_P_adjoint__dstretch(
i,
j) ||
934 t_approx_P_adjoint__dstretch(
j,
i));
939 t_dP(L,
J) += t_L(
i,
j, L) *
940 ((t_diff2_uP2(
i,
j,
k,
l) + t_diff2_uP2(
k,
l,
i,
j)) *
946 ++t_approx_P_adjoint__dstretch;
952 return getFTensor2FromMat<size_symm, size_symm>(dP);
955 auto t_dP = get_dP();
956 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
960 for (; rr != row_nb_dofs / 6; ++rr) {
962 auto t_m = get_ftensor2(K, 6 * rr, 0);
963 for (
int cc = 0; cc != col_nb_dofs / 6; ++cc) {
964 const double b =
a * t_row_base_fun * t_col_base_fun;
965 t_m(L,
J) -= b * t_dP(L,
J);
972 for (; rr != row_nb_base_functions; ++rr) {
983 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
984 boost::shared_ptr<double> total_energy_ptr)
986 totalEnergyPtr(total_energy_ptr) {
990 "dataAtPts is not allocated. Please set it before "
991 "using this operator.");
1005 int nb_integration_pts = getGaussPts().size2();
1007 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
1010 auto &mat_d = dataAtPts->matD;
1013 "wrong matD size, should be 6 by 6 but is %d by %d",
size_symm,
1017 auto t_D = getFTensor4DdgFromPtr<3, 3, 0>(mat_d.data().data());
1019 dataAtPts->energyAtPts.resize(nb_integration_pts,
false);
1020 auto t_energy = getFTensor0FromVec(dataAtPts->energyAtPts);
1022 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
1024 t_energy = 0.5 * (t_log_u(
i,
j) * (t_D(
i,
j,
k,
l) * t_log_u(
k,
l)));
1030 if (totalEnergyPtr) {
1031 auto t_w = getFTensor0IntegrationWeight();
1032 auto t_energy = getFTensor0FromVec(dataAtPts->energyAtPts);
1033 double loc_energy = 0;
1034 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
1035 loc_energy += t_energy * t_w;
1039 *totalEnergyPtr += getMeasure() * loc_energy;
1046 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
1047 boost::shared_ptr<MatrixDouble> strain_ptr,
1048 boost::shared_ptr<MatrixDouble> stress_ptr,
1049 boost::shared_ptr<HMHHencky> hencky_ptr)
1051 strainPtr(strain_ptr), stressPtr(stress_ptr), henckyPtr(hencky_ptr) {}
1065 auto nb_integration_pts = stressPtr->size2();
1067 if (nb_integration_pts != getGaussPts().size2()) {
1069 "inconsistent number of integration points");
1073 auto get_D = [&]() {
1075 for (
auto &b : henckyPtr->blockData) {
1077 if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
1078 dataAtPts->mu = b.shearModulusG;
1079 dataAtPts->lambda = b.bulkModulusK - 2 * b.shearModulusG / 3;
1080 CHKERR henckyPtr->getMatDPtr(
1081 dataAtPts->getMatDPtr(), dataAtPts->getMatAxiatorDPtr(),
1082 dataAtPts->getMatDeviatorDPtr(), b.bulkModulusK, b.shearModulusG);
1083 CHKERR henckyPtr->getInvMatDPtr(dataAtPts->getMatInvDPtr(),
1084 b.bulkModulusK, b.shearModulusG);
1089 const auto E = henckyPtr->E;
1090 const auto nu = henckyPtr->nu;
1098 CHKERR henckyPtr->getMatDPtr(
1099 dataAtPts->getMatDPtr(), dataAtPts->getMatAxiatorDPtr(),
1108 strainPtr->resize(
size_symm, nb_integration_pts,
false);
1109 auto t_strain = getFTensor2SymmetricFromMat<3>(*strainPtr);
1110 auto t_stress = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*stressPtr);
1111 auto t_inv_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, 0>(
1112 &*dataAtPts->matInvD.data().begin());
1114 auto t_D = getFTensor4DdgFromPtr<SPACE_DIM, SPACE_DIM, 0>(
1115 &*dataAtPts->matD.data().begin());
1122 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
1123 t_strain(
i,
j) = t_inv_D(
i,
j,
k,
l) * t_stress(
k,
l);
1127 t_stress_symm_debug(
i,
j) = (t_stress(
i,
j) || t_stress(
j,
i)) / 2;
1129 t_stress_symm_debug_diff(
i,
j) =
1130 t_D(
i,
j,
k,
l) * t_strain(
k,
l) - t_stress_symm_debug(
i,
j);
1132 t_stress_symm_debug_diff(
i,
j) * t_stress_symm_debug_diff(
i,
j);
1133 double nrm0 = t_stress_symm_debug(
i,
j) * t_stress_symm_debug(
i,
j) +
1134 std::numeric_limits<double>::epsilon();
1135 constexpr double eps = 1e-10;
1136 if (std::fabs(std::sqrt(nrm / nrm0)) >
eps) {
1138 <<
"Stress symmetry check failed: " << std::endl
1139 << t_stress_symm_debug_diff << std::endl
1142 "Norm is too big: " + std::to_string(nrm / nrm0));
1155template <
typename OP_PTR>
1156std::tuple<std::string, VectorDouble>
1158 const std::string block_name) {
1160 auto nb_gauss_pts = op_ptr->getGaussPts().size2();
1162 auto ts_time = op_ptr->getTStime();
1163 auto ts_time_step = op_ptr->getTStimeStep();
1169 MatrixDouble m_ref_coords = op_ptr->getCoordsAtGaussPts();
1172 ts_time_step, ts_time, nb_gauss_pts, m_ref_coords, block_name);
1175 if (v_analytical_expr.size() != nb_gauss_pts)
1177 "Wrong number of integration pts");
1180 return std::make_tuple(block_name, v_analytical_expr);
1187 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
1188 SmartPetscObj<Vec> assemble_vec,
1189 boost::shared_ptr<TopologicalData> topo_ptr,
const double alpha_u)
1191 topoDataPtr(topo_ptr), assembleVec(assemble_vec) {
1193 CHK_MOAB_THROW(PetscOptionsGetBool(PETSC_NULLPTR,
"",
"-poly_convex",
1195 "get polyconvex option failed");
1201 CHKERR integratePolyconvexHencky(data);
1203 CHKERR integrateHencky(data);
1215 int nb_integration_pts = data.
getN().size1();
1216 auto v = getVolume();
1217 auto t_w = getFTensor0IntegrationWeight();
1218 auto t_approx_P_adjoint_log_du =
1219 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
1220 auto t_log_stretch_h1 =
1221 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
1223 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
1224 auto t_var_log_u = getFTensor1FromMat<SPACE_DIM>(dataAtPts->varLogStreach);
1226 auto t_D = getFTensor4DdgFromPtr<3, 3, 0>(&*dataAtPts->matD.data().begin());
1228 auto t_det = getFTensor0FromVec(topoDataPtr->detJacobianAtPts);
1230 getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(topoDataPtr->invJacobianAtPtr);
1236 auto get_ftensor2 = [](
auto &
v) {
1238 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
1241 int nb_base_functions = data.
getN().size2();
1243 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
1247 t_cof(
i,
j) = t_det * t_inv_jac(
j,
i);
1251 auto t_nf = get_ftensor2(nF);
1255 t_D(
i,
j,
k,
l) * (t_log_stretch_h1(
k,
l) + alphaU * t_dot_log_u(
k,
l));
1258 a * (t_approx_P_adjoint_log_du(L) - t_L(
i,
j, L) * t_T(
i,
j));
1261 for (; bb != nb_dofs / 6; ++bb) {
1263 t_var_log_u(L) * t_residual(L) * t_cof(
i,
j) * t_diff_base(
j);
1267 for (; bb != nb_base_functions; ++bb)
1271 ++t_approx_P_adjoint_log_du;
1286 "Polyconvex Hencky is not implemented yet");
1292 double *vec_ptr = nF.data().data();
1293 const int nb_dofs = data.
getIndices().size();
1294 int *ind_ptr = data.
getIndices().data().data();
1295 CHKERR VecSetValues(assembleVec, nb_dofs, ind_ptr, vec_ptr, ADD_VALUES);
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define FTENSOR_INDEX(DIM, I)
static PetscErrorCode ierr
Kronecker Delta class symmetric.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
auto get_D
Create deviatoric stress tensor.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
const double n
refractive index of diffusive medium
FTensor::Index< 'J', DIM1 > J
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
auto getDiffDiffMat(A &&t_val, B &&t_vec, Fun< double > f, Fun< double > d_f, Fun< double > dd_f, C &&t_S, const int nb)
Get the Diff Diff Mat object.
VectorDouble analytical_externalstrain_function(double delta_t, double t, int nb_gauss_pts, MatrixDouble &m_ref_coords, const std::string block_name)
auto diff_deviator(FTensor::Ddg< double, 3, 3 > &&t_diff_stress)
std::tuple< std::string, VectorDouble > getAnalyticalExternalStrain(OP_PTR op_ptr, VectorDouble &analytical_expr, const std::string block_name)
ForcesAndSourcesCore::UserDataOperator UserDataOperator
static constexpr auto size_symm
constexpr auto field_name
FTensor::Index< 'm', 3 > m
static enum StretchSelector stretchSelector
static double dynamicTime
static enum RotSelector gradApproximator
static PetscBool dynamicRelaxation
static boost::function< double(const double)> f
static boost::function< double(const double)> dd_f
static boost::function< double(const double)> d_f
Calculate energy density for Hencky material model.
boost::shared_ptr< double > totalEnergyPtr
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
OpCalculateEnergy(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< double > total_energy_ptr)
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
boost::shared_ptr< MatrixDouble > strainPtr
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
data at integration pts
boost::shared_ptr< HMHHencky > henckyPtr
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
boost::shared_ptr< MatrixDouble > stressPtr
OpCalculateStretchFromStress(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< MatrixDouble > strain_ptr, boost::shared_ptr< MatrixDouble > stress_ptr, boost::shared_ptr< HMHHencky > hencky_ptr)
MoFEMErrorCode evaluateRhs(EntData &data)
boost::shared_ptr< HMHHencky > henckyPtr
MoFEMErrorCode evaluateLhs(EntData &data)
OpHenckyJacobian(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< HMHHencky > hencky_ptr)
boost::shared_ptr< DataAtIntegrationPts > dataAtGaussPts
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
std::map< std::string, boost::shared_ptr< ScalingMethod > > scalingMethodsMap
boost::shared_ptr< ExternalStrainVec > externalStrainVecPtr
OpSpatialPhysicalExternalStrain(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< ExternalStrainVec > &external_strain_vec_ptr, std::map< std::string, boost::shared_ptr< ScalingMethod > > smv)
MoFEMErrorCode integrate(EntData &data)
OpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
MoFEMErrorCode integrateHencky(EntData &row_data, EntData &col_data)
MoFEMErrorCode integratePolyconvexHencky(EntData &row_data, EntData &col_data)
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
MoFEMErrorCode integratePolyconvexHencky(EntData &data)
OpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
MoFEMErrorCode integrateHencky(EntData &data)
MoFEMErrorCode integrate(EntData &data)
OpTopoSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, SmartPetscObj< Vec > assemble_vec, boost::shared_ptr< TopologicalData > topo_ptr, const double alpha_u)
SmartPetscObj< Vec > assembleVec
boost::shared_ptr< TopologicalData > topoDataPtr
MoFEMErrorCode integratePolyconvexHencky(EntData &data)
MoFEMErrorCode integrateHencky(EntData &data)
MoFEMErrorCode assemble(EntData &data) override
MoFEMErrorCode integrate(EntData &data)
virtual VolUserDataOperator * returnOpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
VolUserDataOperator * returnOpCalculateStretchFromStress(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
MoFEMErrorCode extractBlockData(Sev sev)
Sev getOptionsSeverityLevels
std::vector< BlockData > blockData
virtual VolUserDataOperator * returnOpTopoSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, SmartPetscObj< Vec > assemble_vec, boost::shared_ptr< TopologicalData > topo_ptr, const double alpha_u)
MoFEMErrorCode extractBlockData(std::vector< const CubitMeshSets * > meshset_vec_ptr, Sev sev)
HMHHencky(MoFEM::Interface &m_field, const double E, const double nu)
VolUserDataOperator * returnOpCalculateVarStretchFromStress(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
VolUserDataOperator * returnOpCalculateEnergy(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< double > total_energy_ptr)
MoFEMErrorCode getMatDPtr(boost::shared_ptr< MatrixDouble > mat_D_ptr, boost::shared_ptr< MatrixDouble > mat_axiator_D_ptr, boost::shared_ptr< MatrixDouble > mat_deviator_D_ptr, double bulk_modulus_K, double shear_modulus_G)
MoFEMErrorCode getOptions(boost::shared_ptr< DataAtIntegrationPts > data_ptr)
virtual UserDataOperator * returnOpJacobian(const int tag, const bool eval_rhs, const bool eval_lhs, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
VolUserDataOperator * returnOpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
MoFEM::Interface & mField
virtual VolUserDataOperator * returnOpSpatialPhysicalExternalStrain(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< ExternalStrainVec > external_strain_vec_ptr, std::map< std::string, boost::shared_ptr< ScalingMethod > > smv)
MoFEMErrorCode recordTape(const int tag, DTensor2Ptr *t_h)
MoFEMErrorCode getInvMatDPtr(boost::shared_ptr< MatrixDouble > mat_inv_D_ptr, double bulk_modulus_K, double shear_modulus_G)
virtual moab::Interface & get_moab()=0
bool sYmm
If true assume that matrix is symmetric structure.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorInt & getIndices() const
Get global indices of degrees of freedom on entity.
EntityHandle getFEEntityHandle() const
Return finite element entity handle.
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
PetscReal ts_t
Current time value.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
double young_modulus
Young modulus.
double poisson_ratio
Poisson ratio.