v0.14.0
Classes | Functions | Variables
HenckyOps Namespace Reference

Classes

struct  CommonData
 
struct  HenkyIntegrators
 
struct  isEq
 
struct  OpCalculateEigenValsImpl
 
struct  OpCalculateEigenValsImpl< DIM, GAUSS, DomainEleOp >
 
struct  OpCalculateHenckyPlasticStressImpl
 
struct  OpCalculateHenckyPlasticStressImpl< DIM, GAUSS, DomainEleOp, S >
 
struct  OpCalculateHenckyStressImpl
 
struct  OpCalculateHenckyStressImpl< DIM, GAUSS, DomainEleOp, S >
 
struct  OpCalculateLogC_dCImpl
 
struct  OpCalculateLogC_dCImpl< DIM, GAUSS, DomainEleOp >
 
struct  OpCalculateLogCImpl
 
struct  OpCalculateLogCImpl< DIM, GAUSS, DomainEleOp >
 
struct  OpCalculatePiolaStressImpl
 
struct  OpCalculatePiolaStressImpl< DIM, GAUSS, DomainEleOp, S >
 
struct  OpHenckyTangentImpl
 
struct  OpHenckyTangentImpl< DIM, GAUSS, DomainEleOp, S >
 

Functions

auto is_eq (const double &a, const double &b)
 
template<int DIM>
auto get_uniq_nb (double *ptr)
 
template<int DIM>
auto sort_eigen_vals (FTensor::Tensor1< double, DIM > &eig, FTensor::Tensor2< double, DIM, DIM > &eigen_vec)
 
template<int DIM>
MoFEMErrorCode addMatBlockOps (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string block_name, boost::shared_ptr< MatrixDouble > mat_D_Ptr, Sev sev, double scale=1)
 
template<int DIM, IntegrationType I, typename DomainEleOp >
auto commonDataFactory (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, std::string block_name, Sev sev, double scale=1)
 
template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode opFactoryDomainRhs (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, boost::shared_ptr< HenckyOps::CommonData > common_ptr, Sev sev)
 
template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode opFactoryDomainRhs (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, std::string block_name, Sev sev, double scale=1)
 
template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode opFactoryDomainLhs (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, boost::shared_ptr< HenckyOps::CommonData > common_ptr, Sev sev)
 
template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode opFactoryDomainLhs (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, std::string block_name, Sev sev, double scale=1)
 

Variables

constexpr double eps = std::numeric_limits<float>::epsilon()
 
auto f = [](double v) { return 0.5 * std::log(v); }
 
auto d_f = [](double v) { return 0.5 / v; }
 
auto dd_f = [](double v) { return -0.5 / (v * v); }
 

Function Documentation

◆ addMatBlockOps()

template<int DIM>
MoFEMErrorCode HenckyOps::addMatBlockOps ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pip,
std::string  block_name,
boost::shared_ptr< MatrixDouble >  mat_D_Ptr,
Sev  sev,
double  scale = 1 
)

[Calculate elasticity tensor]

[Calculate elasticity tensor]

Definition at line 601 of file HenckyOps.hpp.

605  {
607 
608  struct OpMatBlocks : public DomainEleOp {
609  OpMatBlocks(boost::shared_ptr<MatrixDouble> m, double bulk_modulus_K,
610  double shear_modulus_G, MoFEM::Interface &m_field, Sev sev,
611  std::vector<const CubitMeshSets *> meshset_vec_ptr,
612  double scale)
613  : DomainEleOp(NOSPACE, DomainEleOp::OPSPACE), matDPtr(m),
614  bulkModulusKDefault(bulk_modulus_K),
615  shearModulusGDefault(shear_modulus_G), scaleYoungModulus(scale) {
616  CHK_THROW_MESSAGE(extractBlockData(m_field, meshset_vec_ptr, sev),
617  "Can not get data from block");
618  }
619 
620  MoFEMErrorCode doWork(int side, EntityType type,
623 
624  for (auto &b : blockData) {
625 
626  if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
627  CHKERR getMatDPtr(matDPtr, b.bulkModulusK * scaleYoungModulus,
628  b.shearModulusG * scaleYoungModulus);
630  }
631  }
632 
633  CHKERR getMatDPtr(matDPtr, bulkModulusKDefault * scaleYoungModulus,
634  shearModulusGDefault * scaleYoungModulus);
636  }
637 
638  private:
639  boost::shared_ptr<MatrixDouble> matDPtr;
640  const double scaleYoungModulus;
641 
642  struct BlockData {
643  double bulkModulusK;
644  double shearModulusG;
645  Range blockEnts;
646  };
647 
648  double bulkModulusKDefault;
649  double shearModulusGDefault;
650  std::vector<BlockData> blockData;
651 
653  extractBlockData(MoFEM::Interface &m_field,
654  std::vector<const CubitMeshSets *> meshset_vec_ptr,
655  Sev sev) {
657 
658  for (auto m : meshset_vec_ptr) {
659  MOFEM_TAG_AND_LOG("WORLD", sev, "MatBlock") << *m;
660  std::vector<double> block_data;
661  CHKERR m->getAttributes(block_data);
662  if (block_data.size() != 2) {
663  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
664  "Expected that block has two attribute");
665  }
666  auto get_block_ents = [&]() {
667  Range ents;
668  CHKERR
669  m_field.get_moab().get_entities_by_handle(m->meshset, ents, true);
670  return ents;
671  };
672 
673  double young_modulus = block_data[0];
674  double poisson_ratio = block_data[1];
675  double bulk_modulus_K = young_modulus / (3 * (1 - 2 * poisson_ratio));
676  double shear_modulus_G = young_modulus / (2 * (1 + poisson_ratio));
677 
678  MOFEM_TAG_AND_LOG("WORLD", sev, "MatBlock")
679  << "E = " << young_modulus << " nu = " << poisson_ratio;
680 
681  blockData.push_back(
682  {bulk_modulus_K, shear_modulus_G, get_block_ents()});
683  }
684  MOFEM_LOG_CHANNEL("WORLD");
686  }
687 
688  MoFEMErrorCode getMatDPtr(boost::shared_ptr<MatrixDouble> mat_D_ptr,
689  double bulk_modulus_K, double shear_modulus_G) {
691  //! [Calculate elasticity tensor]
692  auto set_material_stiffness = [&]() {
698  double A = (DIM == 2)
699  ? 2 * shear_modulus_G /
700  (bulk_modulus_K + (4. / 3.) * shear_modulus_G)
701  : 1;
702  auto t_D = getFTensor4DdgFromMat<DIM, DIM, 0>(*mat_D_ptr);
703  t_D(i, j, k, l) =
704  2 * shear_modulus_G * ((t_kd(i, k) ^ t_kd(j, l)) / 4.) +
705  A * (bulk_modulus_K - (2. / 3.) * shear_modulus_G) * t_kd(i, j) *
706  t_kd(k, l);
707  };
708  //! [Calculate elasticity tensor]
709  constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
710  mat_D_ptr->resize(size_symm * size_symm, 1);
711  set_material_stiffness();
713  }
714  };
715 
716  double E = young_modulus;
717  double nu = poisson_ratio;
718 
719  CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "hencky_", "", "none");
720  CHKERR PetscOptionsScalar("-young_modulus", "Young modulus", "", E, &E,
721  PETSC_NULL);
722  CHKERR PetscOptionsScalar("-poisson_ratio", "poisson ratio", "", nu, &nu,
723  PETSC_NULL);
724  ierr = PetscOptionsEnd();
725 
726  double bulk_modulus_K = E / (3 * (1 - 2 * nu));
727  double shear_modulus_G = E / (2 * (1 + nu));
728  pip.push_back(new OpMatBlocks(
729  mat_D_Ptr, bulk_modulus_K, shear_modulus_G, m_field, sev,
730 
731  // Get blockset using regular expression
732  m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
733 
734  (boost::format("%s(.*)") % block_name).str()
735 
736  )),
737  scale
738 
739  ));
740 
742 }

◆ commonDataFactory()

template<int DIM, IntegrationType I, typename DomainEleOp >
auto HenckyOps::commonDataFactory ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pip,
std::string  field_name,
std::string  block_name,
Sev  sev,
double  scale = 1 
)

Definition at line 745 of file HenckyOps.hpp.

748  {
749 
750  auto common_ptr = boost::make_shared<HenckyOps::CommonData>();
751  common_ptr->matDPtr = boost::make_shared<MatrixDouble>();
752  common_ptr->matGradPtr = boost::make_shared<MatrixDouble>();
753 
754  CHK_THROW_MESSAGE(addMatBlockOps<DIM>(m_field, pip, block_name,
755  common_ptr->matDPtr, sev, scale),
756  "addMatBlockOps");
757 
758  using H = HenkyIntegrators<DomainEleOp>;
759 
761  field_name, common_ptr->matGradPtr));
762  pip.push_back(new typename H::template OpCalculateEigenVals<DIM, I>(
763  field_name, common_ptr));
764  pip.push_back(
765  new typename H::template OpCalculateLogC<DIM, I>(field_name, common_ptr));
766  pip.push_back(new typename H::template OpCalculateLogC_dC<DIM, I>(
767  field_name, common_ptr));
768  // Assumes constant D matrix per entity
769  pip.push_back(new typename H::template OpCalculateHenckyStress<DIM, I, 0>(
770  field_name, common_ptr));
771  pip.push_back(new typename H::template OpCalculatePiolaStress<DIM, I, 0>(
772  field_name, common_ptr));
773 
774  return common_ptr;
775 }

◆ get_uniq_nb()

template<int DIM>
auto HenckyOps::get_uniq_nb ( double ptr)
inline

Definition at line 32 of file HenckyOps.hpp.

32  {
33  std::array<double, DIM> tmp;
34  std::copy(ptr, &ptr[DIM], tmp.begin());
35  std::sort(tmp.begin(), tmp.end());
36  isEq::absMax = std::max(std::abs(tmp[0]), std::abs(tmp[DIM - 1]));
37  return std::distance(tmp.begin(), std::unique(tmp.begin(), tmp.end(), is_eq));
38 };

◆ is_eq()

auto HenckyOps::is_eq ( const double a,
const double b 
)
inline

Definition at line 28 of file HenckyOps.hpp.

28  {
29  return isEq::check(a, b);
30 };

◆ opFactoryDomainLhs() [1/2]

template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode HenckyOps::opFactoryDomainLhs ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pip,
std::string  field_name,
boost::shared_ptr< HenckyOps::CommonData common_ptr,
Sev  sev 
)

Definition at line 811 of file HenckyOps.hpp.

815  {
817 
818  using B = typename FormsIntegrators<DomainEleOp>::template Assembly<
819  A>::template BiLinearForm<I>;
820  using OpKPiola = typename B::template OpGradTensorGrad<1, DIM, DIM, 1>;
821 
822  using H = HenkyIntegrators<DomainEleOp>;
823  // Assumes constant D matrix per entity
824  pip.push_back(
825  new typename H::template OpHenckyTangent<DIM, I, 0>(field_name, common_ptr));
826  pip.push_back(
827  new OpKPiola(field_name, field_name, common_ptr->getMatTangent()));
828 
830 }

◆ opFactoryDomainLhs() [2/2]

template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode HenckyOps::opFactoryDomainLhs ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pip,
std::string  field_name,
std::string  block_name,
Sev  sev,
double  scale = 1 
)

Definition at line 833 of file HenckyOps.hpp.

836  {
838 
839  auto common_ptr = commonDataFactory<DIM, I, DomainEleOp>(
840  m_field, pip, field_name, block_name, sev, scale);
841  CHKERR opFactoryDomainLhs<DIM, A, I, DomainEleOp>(m_field, pip, field_name,
842  common_ptr, sev);
843 
845 }

◆ opFactoryDomainRhs() [1/2]

template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode HenckyOps::opFactoryDomainRhs ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pip,
std::string  field_name,
boost::shared_ptr< HenckyOps::CommonData common_ptr,
Sev  sev 
)

Definition at line 778 of file HenckyOps.hpp.

782  {
784 
785  using B = typename FormsIntegrators<DomainEleOp>::template Assembly<
786  A>::template LinearForm<I>;
787  using OpInternalForcePiola =
788  typename B::template OpGradTimesTensor<1, DIM, DIM>;
789  pip.push_back(
790  new OpInternalForcePiola("U", common_ptr->getMatFirstPiolaStress()));
791 
793 }

◆ opFactoryDomainRhs() [2/2]

template<int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp >
MoFEMErrorCode HenckyOps::opFactoryDomainRhs ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pip,
std::string  field_name,
std::string  block_name,
Sev  sev,
double  scale = 1 
)

Definition at line 796 of file HenckyOps.hpp.

799  {
801 
802  auto common_ptr = commonDataFactory<DIM, I, DomainEleOp>(
803  m_field, pip, field_name, block_name, sev, scale);
804  CHKERR opFactoryDomainRhs<DIM, A, I, DomainEleOp>(m_field, pip, field_name,
805  common_ptr, sev);
806 
808 }

◆ sort_eigen_vals()

template<int DIM>
auto HenckyOps::sort_eigen_vals ( FTensor::Tensor1< double, DIM > &  eig,
FTensor::Tensor2< double, DIM, DIM > &  eigen_vec 
)
inline

Definition at line 41 of file HenckyOps.hpp.

42  {
43 
44  isEq::absMax =
45  std::max(std::max(std::abs(eig(0)), std::abs(eig(1))), std::abs(eig(2)));
46 
47  int i = 0, j = 1, k = 2;
48 
49  if (is_eq(eig(0), eig(1))) {
50  i = 0;
51  j = 2;
52  k = 1;
53  } else if (is_eq(eig(0), eig(2))) {
54  i = 0;
55  j = 1;
56  k = 2;
57  } else if (is_eq(eig(1), eig(2))) {
58  i = 1;
59  j = 0;
60  k = 2;
61  }
62 
64  eigen_vec(i, 0), eigen_vec(i, 1), eigen_vec(i, 2),
65 
66  eigen_vec(j, 0), eigen_vec(j, 1), eigen_vec(j, 2),
67 
68  eigen_vec(k, 0), eigen_vec(k, 1), eigen_vec(k, 2)};
69 
70  FTensor::Tensor1<double, 3> eig_c{eig(i), eig(j), eig(k)};
71 
72  {
75  eig(i) = eig_c(i);
76  eigen_vec(i, j) = eigen_vec_c(i, j);
77  }
78 };

Variable Documentation

◆ d_f

auto HenckyOps::d_f = [](double v) { return 0.5 / v; }

◆ dd_f

auto HenckyOps::dd_f = [](double v) { return -0.5 / (v * v); }
Examples
EshelbianPlasticity.cpp, and matrix_function.cpp.

Definition at line 17 of file HenckyOps.hpp.

◆ eps

constexpr double HenckyOps::eps = std::numeric_limits<float>::epsilon()
constexpr

Definition at line 13 of file HenckyOps.hpp.

◆ f

auto HenckyOps::f = [](double v) { return 0.5 * std::log(v); }
NOSPACE
@ NOSPACE
Definition: definitions.h:83
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
FTensor::Tensor1< double, 3 >
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
young_modulus
double young_modulus
Young modulus.
Definition: plastic.cpp:121
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:609
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
E
OpKPiola
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradTensorGrad< 1, SPACE_DIM, SPACE_DIM, 1 > OpKPiola
[Only used for dynamics]
Definition: seepage.cpp:64
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
bulk_modulus_K
double bulk_modulus_K
Definition: dynamic_first_order_con_law.cpp:96
scale
double scale
Definition: plastic.cpp:119
FTensor::Tensor2< double, 3, 3 >
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
HenckyOps::is_eq
auto is_eq(const double &a, const double &b)
Definition: HenckyOps.hpp:28
MoFEM::Sev
MoFEM::LogManager::SeverityLevel Sev
Definition: CoreTemplates.hpp:17
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
OpInternalForcePiola
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForcePiola
Definition: seepage.cpp:66
BlockData
Definition: ElasticityMixedFormulation.hpp:12
a
constexpr double a
Definition: approx_sphere.cpp:30
convert.type
type
Definition: convert.py:64
poisson_ratio
double poisson_ratio
Poisson ratio.
Definition: plastic.cpp:122
size_symm
constexpr auto size_symm
Definition: plastic.cpp:42
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
t_kd
constexpr auto t_kd
Definition: free_surface.cpp:137
BiLinearForm
OpGradTimesTensor
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpGradTimesTensor< 1, FIELD_DIM, SPACE_DIM > OpGradTimesTensor
Definition: operators_tests.cpp:48
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FTensor::Index< 'i', DIM >
Range
DomainEleOp
MOFEM_TAG_AND_LOG
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
shear_modulus_G
double shear_modulus_G
Definition: dynamic_first_order_con_law.cpp:97
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
FTensor::Kronecker_Delta_symmetric
Kronecker Delta class symmetric.
Definition: Kronecker_Delta.hpp:49
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
H
double H
Hardening.
Definition: plastic.cpp:124
OpCalculateVectorFieldGradient
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21