74 "extract block data failed");
76#ifdef NEOHOOKEAN_SCALING
90 "Stretch selector is not equal to LOG");
94 "Exponent base is not equal to exp(1)");
101 if (b.blockEnts.find(ent) != b.blockEnts.end()) {
102 return std::make_pair(b.c10, b.K);
107 "Block not found for entity handle. If you mat set "
108 "block, set it to all elements");
113 using EshelbianPlasticity::OpJacobian::OpJacobian;
120 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
121 boost::shared_ptr<PhysicalEquations> physics_ptr) {
122 return (
new OpJacobian(eval_rhs, eval_lhs, data_ptr, physics_ptr));
127 PetscOptionsBegin(PETSC_COMM_WORLD,
"neo_hookean_",
"",
"none");
137 CHKERR PetscOptionsScalar(
"-viscosity_alpha_grad_u",
"viscosity",
"",
154 (boost::format(
"%s(.*)") %
"MAT_NEOHOOKEAN").str()
166 for (
auto m : meshset_vec_ptr) {
168 std::vector<double> block_data;
169 CHKERR m->getAttributes(block_data);
170 if (block_data.size() < 2) {
172 "Expected that block has atleast two attributes");
174 auto get_block_ents = [&]() {
180 double c10 = block_data[0];
181 double K = block_data[1];
183 blockData.push_back({c10, K, get_block_ents()});
185 MOFEM_LOG(
"EP", sev) <<
"MatBlock Neo-Hookean c10 = "
187 <<
" K = " <<
blockData.back().K <<
" nb ents. = "
196 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
197 const double alpha_u);
207 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
208 const double alpha_u) {
216 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
217 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
218 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
229 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
230 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
231 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv) {
233 external_strain_vec_ptr, smv);
238 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
249 std::string row_field, std::string col_field,
250 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha) {
272 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha_u)
277 double circumcenter[3],
double *xi,
double *
eta,
284 auto neohookean_ptr =
285 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
286 if (!neohookean_ptr) {
288 "Pointer to HMHNeohookean is null");
290 auto [def_c10, def_K] =
291 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
293 double c10 = def_c10 / neohookean_ptr->eqScaling;
294 double alpha_u = alphaU / neohookean_ptr->eqScaling;
295 double K = def_K / neohookean_ptr->eqScaling;
297 double alpha_grad_u =
298 neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
306 int nb_dofs = data.getIndices().size();
307 int nb_integration_pts = data.getN().size1();
308 auto v = getVolume();
309 auto t_w = getFTensor0IntegrationWeight();
310 auto t_approx_P_adjoint_log_du =
311 dataAtPts->getFTensorAdjointPdU(nb_integration_pts);
312 auto t_u = dataAtPts->getFTensorStretch(nb_integration_pts);
313 auto t_dot_log_u = dataAtPts->getFTensorLogStretchDot(nb_integration_pts);
314 auto t_diff_u = dataAtPts->getFTensorDiffStretch(nb_integration_pts);
315 auto t_log_u = dataAtPts->getFTensorLogStretch(nb_integration_pts);
317 dataAtPts->getFTensorGradLogStretchDot(nb_integration_pts);
318 auto t_log_u2_h1 = dataAtPts->getFTensorLogStretch2H1(nb_integration_pts);
320 auto t_eigen_vals = dataAtPts->getFTensorEigenVals(nb_integration_pts);
321 auto t_eigen_vecs = dataAtPts->getFTensorEigenVecs(nb_integration_pts);
322 auto &nbUniq = dataAtPts->nbUniq;
335 auto get_ftensor2 = [](
auto &
v) {
337 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
340 int nb_base_functions = data.getN().size2();
341 auto t_row_base_fun = data.getFTensor0N();
342 auto t_grad_base_fun = data.getFTensor1DiffN<3>();
347 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
352 auto t_neohookean_hencky =
358 const double tr = t_log_u(
i,
i);
360 t_P(L) = t_L(
i,
j, L) * (t_neohookean_hencky(
i,
j) +
363 t_viscous_P(L) = alpha_u * (t_L(
i,
j, L) * t_dot_log_u(
i,
j));
366 t_residual(L) = t_approx_P_adjoint_log_du(L) - t_P(L) - t_viscous_P(L);
370 t_grad_residual(L,
i) = alpha_grad_u * t_grad_log_u(L,
i);
371 t_grad_residual(L,
i) *=
a;
373 ++t_approx_P_adjoint_log_du;
378 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
380 for (; bb != nb_dofs /
size_symm; ++bb) {
381 t_nf(L) -= t_row_base_fun * t_residual(L);
382 t_nf(L) += t_grad_base_fun(
i) * t_grad_residual(L,
i);
387 for (; bb != nb_base_functions; ++bb) {
399 "Not implemented for Neo-Hookean (used ADOL-C)");
413 "gradApproximator not handled");
421 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
422 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
423 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv)
425 externalStrainVecPtr(external_strain_vec_ptr), scalingMethodsMap{smv} {}
431 auto neohookean_ptr =
432 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
433 if (!neohookean_ptr) {
435 "Pointer to HMHNeohookean is null");
446 for (
auto &ext_strain_block : (*externalStrainVecPtr)) {
447 auto block_name =
"(.*)ANALYTICAL_EXTERNALSTRAIN(.*)";
448 std::regex reg_name(block_name);
449 if (std::regex_match(ext_strain_block.blockName, reg_name)) {
451 "Analytical external strain not implemented for Neo-Hookean "
455 if (ext_strain_block.ents.find(fe_ent) != ext_strain_block.ents.end()) {
457 if (scalingMethodsMap.find(ext_strain_block.blockName) !=
458 scalingMethodsMap.end()) {
460 scalingMethodsMap.at(ext_strain_block.blockName)->getScale(time);
463 <<
"No scaling method found for " << ext_strain_block.blockName;
467 double external_strain_val =
scale * ext_strain_block.val;
468 double K = ext_strain_block.bulkModulusK;
474 int nb_dofs = data.getIndices().size();
475 int nb_integration_pts = data.getN().size1();
476 auto v = getVolume();
477 auto t_w = getFTensor0IntegrationWeight();
486 int nb_base_functions = data.getN().size2();
487 auto t_row_base_fun = data.getFTensor0N();
489 const double tr = 3.0 * external_strain_val;
490 const double sigma_J = K * tr;
492 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
498 t_residual(L) += (t_L(
i,
j, L) *
t_kd(
i,
j)) * sigma_J;
501 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
503 for (; bb != nb_dofs /
size_symm; ++bb) {
504 t_nf(L) -= t_row_base_fun * t_residual(L);
508 for (; bb != nb_base_functions; ++bb) {
518 std::string row_field, std::string col_field,
519 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha)
534 PetscOptionsBegin(PETSC_COMM_WORLD,
"neo_hookean_",
"",
"none");
535 CHKERR PetscOptionsScalar(
"-min_eigen_value",
"Minimum eigenvalue",
"",
536 minimEigenValue, &minimEigenValue, PETSC_NULLPTR);
546 auto neohookean_ptr =
547 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
548 if (!neohookean_ptr) {
550 "Pointer to HMHNeohookean is null");
552 auto [def_c10, def_K] =
553 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
555 double c10 = def_c10 / neohookean_ptr->eqScaling;
556 double alpha_u = alphaU / neohookean_ptr->eqScaling;
557 double lambda = def_K / neohookean_ptr->eqScaling;
559 double alpha_grad_u =
560 neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
571 int nb_integration_pts = row_data.getN().size1();
572 int row_nb_dofs = row_data.getIndices().size();
573 int col_nb_dofs = col_data.getIndices().size();
575 auto get_ftensor2 = [](MatrixDouble &
m,
const int r,
const int c) {
579 &
m(r + 0,
c + 0), &
m(r + 0,
c + 1), &
m(r + 0,
c + 2), &
m(r + 0,
c + 3),
580 &
m(r + 0,
c + 4), &
m(r + 0,
c + 5),
582 &
m(r + 1,
c + 0), &
m(r + 1,
c + 1), &
m(r + 1,
c + 2), &
m(r + 1,
c + 3),
583 &
m(r + 1,
c + 4), &
m(r + 1,
c + 5),
585 &
m(r + 2,
c + 0), &
m(r + 2,
c + 1), &
m(r + 2,
c + 2), &
m(r + 2,
c + 3),
586 &
m(r + 2,
c + 4), &
m(r + 2,
c + 5),
588 &
m(r + 3,
c + 0), &
m(r + 3,
c + 1), &
m(r + 3,
c + 2), &
m(r + 3,
c + 3),
589 &
m(r + 3,
c + 4), &
m(r + 3,
c + 5),
591 &
m(r + 4,
c + 0), &
m(r + 4,
c + 1), &
m(r + 4,
c + 2), &
m(r + 4,
c + 3),
592 &
m(r + 4,
c + 4), &
m(r + 4,
c + 5),
594 &
m(r + 5,
c + 0), &
m(r + 5,
c + 1), &
m(r + 5,
c + 2), &
m(r + 5,
c + 3),
595 &
m(r + 5,
c + 4), &
m(r + 5,
c + 5)
607 auto v = getVolume();
608 auto ts_a = getTSa();
609 auto t_w = getFTensor0IntegrationWeight();
611 int row_nb_base_functions = row_data.getN().size2();
612 auto t_row_base_fun = row_data.getFTensor0N();
613 auto t_row_grad_fun = row_data.getFTensor1DiffN<3>();
616 dataAtPts->getFTensorDiffStretch(nb_integration_pts);
618 dataAtPts->getFTensorLogStretch(nb_integration_pts);
620 dataAtPts->getFTensorLogStretch2H1(nb_integration_pts);
621 auto t_u = dataAtPts->getFTensorStretch(nb_integration_pts);
622 auto t_approx_P_adjoint__dstretch =
623 dataAtPts->getFTensorAdjointPdstretch(nb_integration_pts);
624 auto t_eigen_vals = dataAtPts->getFTensorEigenVals(nb_integration_pts);
625 auto t_eigen_vecs = dataAtPts->getFTensorEigenVecs(nb_integration_pts);
626 auto &nbUniq = dataAtPts->nbUniq;
633 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
638 auto d_neohookean = [c10,
lambda](
auto v) {
643 t_eigen_vals, t_eigen_vecs, neohookean, d_neohookean, t_nb_uniq);
645 const auto tr = t_log_u(
i,
i);
647 t_dP(L,
J) = t_L(
i,
j, L) * ((t_diff_neohookean(
i,
j,
k,
l) +
649 t_kd_sym(
i,
j) * t_kd_sym(
k,
l)) *
651 t_dP(L,
J) += (alpha_u * ts_a) *
652 (t_L(
i,
j, L) * (t_diff(
i,
j,
k,
l) * t_L(
k,
l,
J)));
659 t_deltaP(
i,
j) = (t_approx_P_adjoint__dstretch(
i,
j) ||
660 t_approx_P_adjoint__dstretch(
j,
i)) /
665 t_dP(L,
J) -= t_L(
i,
j, L) * (t_diff2_uP(
i,
j,
k,
l) * t_L(
k,
l,
J));
667 ++t_approx_P_adjoint__dstretch;
676 t_hessian_eig_vecs(L,
J) = (t_dP(L,
J) + t_dP(
J, L)) / 2.;
678 CHKERR computeEigenValuesSymmetric(t_hessian_eig_vecs,
680 auto min_eig_val = [
this](
double v) {
681 return (
v - minimEigenValue + std::abs(
v - minimEigenValue)) / 2.;
684 t_hessian_eig_vecs, min_eig_val);
685 t_dP(L,
J) = t_dP_min_eig(L,
J);
688 for (; rr != row_nb_dofs /
size_symm; ++rr) {
689 auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
690 auto t_col_grad_fun = col_data.getFTensor1DiffN<3>(gg, 0);
692 auto t_m = get_ftensor2(K, 6 * rr, 0);
693 for (
int cc = 0; cc != col_nb_dofs /
size_symm; ++cc) {
694 double b =
a * t_row_base_fun * t_col_base_fun;
695 double c = (
a * alpha_grad_u * ts_a) *
696 (t_row_grad_fun(
i) * t_col_grad_fun(
i));
697 t_m(L,
J) += b * t_dP(L,
J);
698 t_m(L,
J) +=
c * t_kd_sym(L,
J);
708 for (; rr != row_nb_base_functions; ++rr) {
720 "Not implemented for Neo-Hookean (used ADOL-C)");
734 "gradApproximator not handled");
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define FTENSOR_INDEX(DIM, I)
Kronecker Delta class symmetric.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#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 getMat(A &&t_val, B &&t_vec, Fun< double > f)
Get the Mat object.
auto getDiffMat(A &&t_val, B &&t_vec, Fun< double > f, Fun< double > d_f, const int nb)
Get the Diff Mat object.
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.
void tetcircumcenter_tp(double a[3], double b[3], double c[3], double d[3], double circumcenter[3], double *xi, double *eta, double *zeta)
EntitiesFieldData::EntData EntData
ForcesAndSourcesCore::UserDataOperator UserDataOperator
static constexpr auto size_symm
constexpr auto field_name
FTensor::Index< 'm', 3 > m
static enum StretchSelector stretchSelector
static enum RotSelector gradApproximator
static PetscBool physicalTimeFlg
static double exponentBase
static double currentPhysicalTime
static boost::function< double(const double)> f
static boost::function< double(const double)> dd_f
static boost::function< double(const double)> d_f
MoFEMErrorCode evaluateRhs(EntData &data)
MoFEMErrorCode evaluateLhs(EntData &data)
MoFEMErrorCode integrate(EntData &data)
boost::shared_ptr< ExternalStrainVec > externalStrainVecPtr
std::map< std::string, boost::shared_ptr< ScalingMethod > > scalingMethodsMap
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)
OpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
MoFEMErrorCode getOptions()
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
OpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
MoFEMErrorCode integrate(EntData &data)
static double fun_diff_neohookean_bulk(double K, double tr)
Definition of derivative of axiator of Neo-hookean function.
static double fun_d_neohookean(double c10, double v)
Definition of derivative of Neo-hookean function.
UserDataOperator * returnOpJacobian(const bool eval_rhs, const bool eval_lhs, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
static double fun_neohookean_bulk(double K, double tr)
Definition of axiator of Neo-hookean function.
virtual VolUserDataOperator * returnOpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
std::vector< BlockData > blockData
MoFEMErrorCode extractBlockData(std::vector< const CubitMeshSets * > meshset_vec_ptr, Sev sev)
MoFEMErrorCode extractBlockData(Sev sev)
static double fun_neohookean(double c10, double v)
Definition of Neo-hookean function.
MoFEMErrorCode getOptions()
MoFEM::Interface & mField
auto getMaterialParameters(EntityHandle ent)
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)
HMHNeohookean(MoFEM::Interface &m_field, const double c10, const double K)
VolUserDataOperator * returnOpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
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)
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 zeta
Viscous hardening.