15 #include <boost/math/constants/constants.hpp>
17 constexpr
double third = boost::math::constants::third<double>();
24 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
41 int nb_integration_pts = data.
getN().size1();
43 auto t_w = getFTensor0IntegrationWeight();
44 auto t_approx_P_adjont_log_du =
45 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
46 auto t_P = getFTensor2FromMat<3, 3>(dataAtPts->PAtPts);
48 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
50 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
56 auto get_ftensor2 = [](
auto &
v) {
58 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
61 int nb_base_functions = data.
getN().size2();
63 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
65 auto t_nf = get_ftensor2(nF);
68 t_Ldiff_u(
i,
j,
L) = t_diff_u(
i,
j,
k,
l) * t_L(
k,
l,
L);
78 a * (t_approx_P_adjont_log_du(
L) - t_Ldiff_u(
i,
j,
L) * t_P(
i,
j) -
79 t_L(
i,
j,
L) * t_viscous_P(
i,
j));
82 for (; bb != nb_dofs / 6; ++bb) {
83 t_nf(
L) += t_row_base_fun * t_residual(
L);
87 for (; bb != nb_base_functions; ++bb)
91 ++t_approx_P_adjont_log_du;
101 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha_u) {
107 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
124 return integratePiola(row_data, col_data);
136 int nb_integration_pts = row_data.
getN().size1();
137 int row_nb_dofs = row_data.
getIndices().size();
138 int col_nb_dofs = col_data.
getIndices().size();
144 &
m(
r + 0,
c + 0), &
m(
r + 0,
c + 1), &
m(
r + 0,
c + 2), &
m(
r + 0,
c + 3),
145 &
m(
r + 0,
c + 4), &
m(
r + 0,
c + 5),
147 &
m(
r + 1,
c + 0), &
m(
r + 1,
c + 1), &
m(
r + 1,
c + 2), &
m(
r + 1,
c + 3),
148 &
m(
r + 1,
c + 4), &
m(
r + 1,
c + 5),
150 &
m(
r + 2,
c + 0), &
m(
r + 2,
c + 1), &
m(
r + 2,
c + 2), &
m(
r + 2,
c + 3),
151 &
m(
r + 2,
c + 4), &
m(
r + 2,
c + 5),
153 &
m(
r + 3,
c + 0), &
m(
r + 3,
c + 1), &
m(
r + 3,
c + 2), &
m(
r + 3,
c + 3),
154 &
m(
r + 3,
c + 4), &
m(
r + 3,
c + 5),
156 &
m(
r + 4,
c + 0), &
m(
r + 4,
c + 1), &
m(
r + 4,
c + 2), &
m(
r + 4,
c + 3),
157 &
m(
r + 4,
c + 4), &
m(
r + 4,
c + 5),
159 &
m(
r + 5,
c + 0), &
m(
r + 5,
c + 1), &
m(
r + 5,
c + 2), &
m(
r + 5,
c + 3),
160 &
m(
r + 5,
c + 4), &
m(
r + 5,
c + 5)
171 auto v = getVolume();
172 auto t_w = getFTensor0IntegrationWeight();
174 auto get_dP = [&]() {
176 auto ts_a = getTSa();
178 auto t_P = getFTensor2FromMat<3, 3>(dataAtPts->PAtPts);
179 auto r_P_du = getFTensor4FromMat<3, 3, 3, 3>(dataAtPts->P_du);
180 auto t_approx_P_adjont_dstretch =
181 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
183 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
184 auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
186 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
187 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
188 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
189 auto &nbUniq = dataAtPts->nbUniq;
191 auto t_dP = getFTensor2FromMat<size_symm, size_symm>(dP);
192 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
195 t_deltaP(
i,
j) = t_approx_P_adjont_dstretch(
i,
j) - t_P(
i,
j);
198 t_Ldiff_u(
i,
j,
L) = t_diff_u(
i,
j,
m,
n) * t_L(
m,
n,
L);
200 -t_Ldiff_u(
i,
j,
L) * (r_P_du(
i,
j,
k,
l) * t_Ldiff_u(
k,
l,
J));
202 t_dP(
L,
J) -= (alphaU * ts_a) *
203 (t_L(
i,
j,
L) * (t_diff(
i,
j,
k,
l) * t_L(
k,
l,
J)));
205 if (EshelbianCore::stretchSelector >
LINEAR) {
207 t_deltaP_sym(
i,
j) = (t_deltaP(
i,
j) || t_deltaP(
j,
i));
208 t_deltaP_sym(
i,
j) /= 2.0;
212 t_dP(
L,
J) += t_L(
i,
j,
L) * (t_diff2_uP2(
i,
j,
k,
l) * t_L(
k,
l,
J));
218 ++t_approx_P_adjont_dstretch;
226 return getFTensor2FromMat<size_symm, size_symm>(dP);
229 int row_nb_base_functions = row_data.
getN().size2();
232 auto t_dP = get_dP();
233 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
237 for (; rr != row_nb_dofs / 6; ++rr) {
239 auto t_m = get_ftensor2(
K, 6 * rr, 0);
240 for (
int cc = 0; cc != col_nb_dofs / 6; ++cc) {
241 const double b =
a * t_row_base_fun * t_col_base_fun;
242 t_m(
L,
J) += b * t_dP(
L,
J);
249 for (; rr != row_nb_base_functions; ++rr) {
260 std::string row_field, std::string col_field,
261 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha) {
266 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
267 boost::shared_ptr<double> total_energy_ptr) {
272 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
273 boost::shared_ptr<PhysicalEquations> physics_ptr) {
278 OpHMHH(
const int tag,
const bool eval_rhs,
const bool eval_lhs,
279 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
280 boost::shared_ptr<PhysicalEquations> physics_ptr)
281 :
OpJacobian(tag, eval_rhs, eval_lhs, data_ptr, physics_ptr) {}
296 const auto nb_integration_pts = getGaussPts().size2();
297 auto iu = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
298 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
300 auto create_data_vec = [nb_integration_pts](
auto &
v) {
301 v.resize(nb_integration_pts,
false);
303 auto create_data_mat = [nb_integration_pts](
auto &
m) {
304 m.resize(9, nb_integration_pts,
false);
307 create_data_mat(dataAtPts->PAtPts);
310 auto r_P = getFTensor2FromMat<3, 3>(dataAtPts->PAtPts);
311 for (
unsigned int gg = 0; gg != nb_integration_pts; ++gg) {
315 switch (EshelbianCore::gradApproximator) {
318 physicsPtr->get_h()(
i,
j) = iu(
i,
j);
323 physicsPtr->get_h()(
i,
j) = iu(
i,
k) * t_h1(
k,
j);
326 physicsPtr->get_h()(
i,
j) = iu(
i,
j);
330 int r = ::function(tAg, physicsPtr->dependentVariablesPiola.size(),
331 physicsPtr->activeVariables.size(),
332 &physicsPtr->activeVariables[0],
333 &physicsPtr->dependentVariablesPiola[0]);
336 "ADOL-C function evaluation with error r = %d",
r);
339 switch (EshelbianCore::gradApproximator) {
341 r_P(
i,
j) = physicsPtr->get_P()(
i,
j);
347 r_P(
k,
l) = physicsPtr->get_P()(
i,
j) * t_h1_du(
i,
j,
k,
l);
350 r_P(
i,
j) = physicsPtr->get_P()(
i,
j);
372 const int number_of_active_variables = physicsPtr->activeVariables.size();
373 const int number_of_dependent_variables =
374 physicsPtr->dependentVariablesPiola.size();
375 std::vector<double *> jac_ptr(number_of_dependent_variables);
376 for (
unsigned int n = 0;
n != number_of_dependent_variables; ++
n) {
379 ->dependentVariablesPiolaDirevatives[
n *
380 number_of_active_variables]);
383 const auto nb_integration_pts = getGaussPts().size2();
385 auto create_data_mat = [nb_integration_pts](
auto &
m) {
386 m.resize(9, nb_integration_pts,
false);
389 dataAtPts->P_du.resize(81, nb_integration_pts,
false);
391 auto iu = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
392 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
393 auto r_P_du = getFTensor4FromMat<3, 3, 3, 3>(dataAtPts->P_du);
401 for (
unsigned int gg = 0; gg != nb_integration_pts; ++gg) {
405 switch (EshelbianCore::gradApproximator) {
408 physicsPtr->get_h()(
i,
j) = iu(
i,
k) * t_h1(
k,
j);
413 physicsPtr->get_h()(
i,
j) = iu(
i,
k) * t_h1(
k,
j);
416 physicsPtr->get_h()(
i,
j) = iu(
i,
j);
421 int r = ::jacobian(tAg, number_of_dependent_variables,
422 number_of_active_variables,
423 &physicsPtr->activeVariables[0], &jac_ptr[0]);
426 "ADOL-C function evaluation with error");
430 t_P_dh_tmp(
i,
j, N0,
k) = physicsPtr->get_P_dh0()(
i,
j,
k);
431 t_P_dh_tmp(
i,
j, N1,
k) = physicsPtr->get_P_dh1()(
i,
j,
k);
432 t_P_dh_tmp(
i,
j, N2,
k) = physicsPtr->get_P_dh2()(
i,
j,
k);
434 switch (EshelbianCore::gradApproximator) {
441 (t_P_dh_tmp(
i,
j, o, p) * t_h1_du(o, p,
m,
n)) * t_h1_du(
i,
j,
k,
l);
444 r_P_du(
i,
j,
m,
n) = t_P_dh_tmp(
i,
j,
m,
n);
465 const int tape,
const double lambda,
const double mu,
466 const double sigma_y) {
468 physicalEquations = boost::make_shared<HMHStVenantKirchhoff>(
lambda,
mu);
469 CHKERR physicalEquations->recordTape(tape,
nullptr);
474 const int tape,
const double alpha,
const double beta,
const double lambda,
475 const double sigma_y) {
478 boost::make_shared<HMHPMooneyRivlinWriggersEq63>(alpha, beta,
lambda);
479 CHKERR physicalEquations->recordTape(tape,
nullptr);
486 physicalEquations = boost::make_shared<HMHNeohookean>(c10,
K);
487 CHKERR physicalEquations->recordTape(tape,
nullptr);
493 physicalEquations = boost::make_shared<HMHHencky>(mField,
E, nu);