77 "extract block data failed");
79#ifdef NEOHOOKEAN_SCALING
94 "Stretch selector is not equal to LOG");
98 "Exponent base is not equal to exp(1)");
106 if (b.blockEnts.find(ent) != b.blockEnts.end()) {
107 return std::make_pair(b.c10, b.K);
112 "Block not found for entity handle. If you mat set "
113 "block, set it to all elements");
119 boost::shared_ptr<PhysicalEquations> physics_ptr)
123 MoFEMErrorCode
doWork(
int side, EntityType type,
124 EntitiesFieldData::EntData &data) {
126 auto neohookean_ptr =
127 boost::dynamic_pointer_cast<HMHNeohookean>(
physicsPtr);
128 *(
scalePtr) = neohookean_ptr->eqScaling;
139 boost::shared_ptr<PhysicalEquations> physics_ptr) {
141 return new OpGetScale(scale_ptr, physics_ptr);
145 using EshelbianPlasticity::OpJacobian::OpJacobian;
152 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
153 boost::shared_ptr<PhysicalEquations> physics_ptr) {
156 data_ptr, physics_ptr);
158 return (
new OpJacobian(tag, eval_rhs, eval_lhs, data_ptr, physics_ptr));
164 PetscOptionsBegin(PETSC_COMM_WORLD,
"neo_hookean_",
"",
"none");
174 CHKERR PetscOptionsScalar(
"-viscosity_alpha_grad_u",
"viscosity",
"",
198 (boost::format(
"%s(.*)") %
"MAT_NEOHOOKEAN").str()
210 for (
auto m : meshset_vec_ptr) {
212 std::vector<double> block_data;
213 CHKERR m->getAttributes(block_data);
214 if (block_data.size() < 2) {
216 "Expected that block has atleast two attributes");
218 auto get_block_ents = [&]() {
224 double c10 = block_data[0];
225 double K = block_data[1];
227 blockData.push_back({c10, K, get_block_ents()});
229 MOFEM_LOG(
"EP", sev) <<
"MatBlock Neo-Hookean c10 = "
231 <<
" K = " <<
blockData.back().K <<
" nb ents. = "
252 ih(
i,
j) = (*t_h_ptr)(
i,
j);
259 enableMinMaxUsingAbs();
292 "gradApproximator not handled");
301 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
302 const double alpha_u);
312 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
313 const double alpha_u) {
326 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
327 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
328 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
339 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
340 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
341 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv) {
343 external_strain_vec_ptr, smv);
348 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
357 std::string row_field, std::string col_field,
358 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha) {
361 row_field, col_field, data_ptr, alpha);
395 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha_u)
400 double circumcenter[3],
double *xi,
double *
eta,
407 auto neohookean_ptr =
408 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
409 if (!neohookean_ptr) {
411 "Pointer to HMHNeohookean is null");
413 auto [def_c10, def_K] =
414 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
416 double c10 = def_c10 / neohookean_ptr->eqScaling;
417 double alpha_u = alphaU / neohookean_ptr->eqScaling;
418 double K = def_K / neohookean_ptr->eqScaling;
420 double alpha_grad_u =
421 neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
430 int nb_integration_pts = data.
getN().size1();
431 auto v = getVolume();
432 auto t_w = getFTensor0IntegrationWeight();
433 auto t_approx_P_adjoint_log_du =
434 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
435 auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
436 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
438 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchDotTensorAtPts);
440 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
442 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTensorAtPts);
444 getFTensor2FromMat<6, 3>(dataAtPts->gradLogStretchDotTensorAtPts);
446 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretch2H1AtPts);
448 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
449 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
450 auto &nbUniq = dataAtPts->nbUniq;
463 auto get_ftensor2 = [](
auto &
v) {
465 &
v[0], &
v[1], &
v[2], &
v[3], &
v[4], &
v[5]);
468 int nb_base_functions = data.
getN().size2();
475 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
480 auto t_neohookean_hencky =
486 const double tr = t_log_u(
i,
i);
488 t_P(L) = t_L(
i,
j, L) * (t_neohookean_hencky(
i,
j) +
491 t_viscous_P(L) = alpha_u * (t_L(
i,
j, L) * t_dot_log_u(
i,
j));
494 t_residual(L) = t_approx_P_adjoint_log_du(L) - t_P(L) - t_viscous_P(L);
498 t_grad_residual(L,
i) = alpha_grad_u * t_grad_log_u(L,
i);
499 t_grad_residual(L,
i) *=
a;
501 ++t_approx_P_adjoint_log_du;
506 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
508 for (; bb != nb_dofs /
size_symm; ++bb) {
509 t_nf(L) -= t_row_base_fun * t_residual(L);
510 t_nf(L) += t_grad_base_fun(
i) * t_grad_residual(L,
i);
515 for (; bb != nb_base_functions; ++bb) {
527 "Not implemented for Neo-Hookean (used ADOL-C)");
541 "gradApproximator not handled");
549 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
550 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
551 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv)
553 externalStrainVecPtr(external_strain_vec_ptr), scalingMethodsMap{smv} {}
559 auto neohookean_ptr =
560 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
561 if (!neohookean_ptr) {
563 "Pointer to HMHNeohookean is null");
574 for (
auto &ext_strain_block : (*externalStrainVecPtr)) {
575 auto block_name =
"(.*)ANALYTICAL_EXTERNALSTRAIN(.*)";
576 std::regex reg_name(block_name);
577 if (std::regex_match(ext_strain_block.blockName, reg_name)) {
579 "Analytical external strain not implemented for Neo-Hookean "
583 if (ext_strain_block.ents.find(fe_ent) != ext_strain_block.ents.end()) {
585 if (scalingMethodsMap.find(ext_strain_block.blockName) !=
586 scalingMethodsMap.end()) {
588 scalingMethodsMap.at(ext_strain_block.blockName)->getScale(time);
591 <<
"No scaling method found for " << ext_strain_block.blockName;
595 double external_strain_val =
scale * ext_strain_block.val;
596 double K = ext_strain_block.bulkModulusK;
603 int nb_integration_pts = data.
getN().size1();
604 auto v = getVolume();
605 auto t_w = getFTensor0IntegrationWeight();
614 int nb_base_functions = data.
getN().size2();
617 const double tr = 3.0 * external_strain_val;
618 const double sigma_J = K * tr;
620 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
626 t_residual(L) += (t_L(
i,
j, L) *
t_kd(
i,
j)) * sigma_J;
629 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
631 for (; bb != nb_dofs /
size_symm; ++bb) {
632 t_nf(L) -= t_row_base_fun * t_residual(L);
636 for (; bb != nb_base_functions; ++bb) {
646 std::string row_field, std::string col_field,
647 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
const double alpha)
659 auto neohookean_ptr =
660 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
661 if (!neohookean_ptr) {
663 "Pointer to HMHNeohookean is null");
665 auto [def_c10, def_K] =
666 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
668 double c10 = def_c10 / neohookean_ptr->eqScaling;
669 double alpha_u = alphaU / neohookean_ptr->eqScaling;
670 double lambda = def_K / neohookean_ptr->eqScaling;
672 double alpha_grad_u =
673 neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
684 int nb_integration_pts = row_data.
getN().size1();
685 int row_nb_dofs = row_data.
getIndices().size();
686 int col_nb_dofs = col_data.
getIndices().size();
688 auto get_ftensor2 = [](MatrixDouble &
m,
const int r,
const int c) {
692 &
m(r + 0,
c + 0), &
m(r + 0,
c + 1), &
m(r + 0,
c + 2), &
m(r + 0,
c + 3),
693 &
m(r + 0,
c + 4), &
m(r + 0,
c + 5),
695 &
m(r + 1,
c + 0), &
m(r + 1,
c + 1), &
m(r + 1,
c + 2), &
m(r + 1,
c + 3),
696 &
m(r + 1,
c + 4), &
m(r + 1,
c + 5),
698 &
m(r + 2,
c + 0), &
m(r + 2,
c + 1), &
m(r + 2,
c + 2), &
m(r + 2,
c + 3),
699 &
m(r + 2,
c + 4), &
m(r + 2,
c + 5),
701 &
m(r + 3,
c + 0), &
m(r + 3,
c + 1), &
m(r + 3,
c + 2), &
m(r + 3,
c + 3),
702 &
m(r + 3,
c + 4), &
m(r + 3,
c + 5),
704 &
m(r + 4,
c + 0), &
m(r + 4,
c + 1), &
m(r + 4,
c + 2), &
m(r + 4,
c + 3),
705 &
m(r + 4,
c + 4), &
m(r + 4,
c + 5),
707 &
m(r + 5,
c + 0), &
m(r + 5,
c + 1), &
m(r + 5,
c + 2), &
m(r + 5,
c + 3),
708 &
m(r + 5,
c + 4), &
m(r + 5,
c + 5)
720 auto v = getVolume();
721 auto ts_a = getTSa();
722 auto t_w = getFTensor0IntegrationWeight();
724 int row_nb_base_functions = row_data.
getN().size2();
728 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
730 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
732 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTensorAtPts);
734 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretch2H1AtPts);
735 auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
736 auto t_approx_P_adjoint__dstretch =
737 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
738 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
739 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
740 auto &nbUniq = dataAtPts->nbUniq;
747 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
752 auto d_neohookean = [c10,
lambda](
auto v) {
757 t_eigen_vals, t_eigen_vecs, neohookean, d_neohookean, t_nb_uniq);
759 const auto tr = t_log_u(
i,
i);
761 t_dP(L,
J) = -t_L(
i,
j, L) * ((t_diff_neohookean(
i,
j,
k,
l) +
763 t_kd_sym(
i,
j) * t_kd_sym(
k,
l)) *
765 t_dP(L,
J) -= (alpha_u * ts_a) *
766 (t_L(
i,
j, L) * (t_diff(
i,
j,
k,
l) * t_L(
k,
l,
J)));
770 t_deltaP(
i,
j) = (t_approx_P_adjoint__dstretch(
i,
j) ||
771 t_approx_P_adjoint__dstretch(
j,
i)) /
776 t_dP(L,
J) += t_L(
i,
j, L) * (t_diff2_uP(
i,
j,
k,
l) * t_L(
k,
l,
J));
778 ++t_approx_P_adjoint__dstretch;
785 for (; rr != row_nb_dofs /
size_symm; ++rr) {
789 auto t_m = get_ftensor2(K, 6 * rr, 0);
790 for (
int cc = 0; cc != col_nb_dofs /
size_symm; ++cc) {
791 double b =
a * t_row_base_fun * t_col_base_fun;
792 double c = (
a * alpha_grad_u * ts_a) *
793 (t_row_grad_fun(
i) * t_col_grad_fun(
i));
794 t_m(L,
J) -= b * t_dP(L,
J);
795 t_m(L,
J) +=
c * t_kd_sym(L,
J);
805 for (; rr != row_nb_base_functions; ++rr) {
817 "Not implemented for Neo-Hookean (used ADOL-C)");
831 "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)
ForcesAndSourcesCore::UserDataOperator UserDataOperator
static constexpr auto size_symm
constexpr IntegrationType I
constexpr auto field_name
FTensor::Index< 'm', 3 > m
static enum StretchSelector stretchSelector
static double dynamicTime
static enum RotSelector gradApproximator
static PetscBool dynamicRelaxation
static double exponentBase
static boost::function< double(const double)> f
static boost::function< double(const double)> dd_f
static boost::function< double(const double)> d_f
OpGetScale(boost::shared_ptr< double > scale_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
boost::shared_ptr< double > scalePtr
boost::shared_ptr< PhysicalEquations > physicsPtr
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
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 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.
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 constexpr int numberOfDependentVariables
VolUserDataOperator * returnOpSetScale(boost::shared_ptr< double > scale_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
static double fun_neohookean(double c10, double v)
Definition of Neo-hookean function.
MoFEMErrorCode getOptions()
MoFEM::Interface & mField
auto getMaterialParameters(EntityHandle ent)
static constexpr int numberOfActiveVariables
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)
MoFEMErrorCode recordTape(const int tape, DTensor2Ptr *t_h_ptr)
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)
virtual VolUserDataOperator * returnOpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
virtual VolUserDataOperator * returnOpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
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)
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 zeta
Viscous hardening.