v0.16.0
Loading...
Searching...
No Matches
MatOpsExampleGeneric.hpp
Go to the documentation of this file.
1/**
2 * @file MatOpsExampleGeneric.hpp
3 * @author your name (you@domain.com)
4 * @brief
5 * @version 0.1
6 * @date 2026-04-12
7 *
8 * @copyright Copyright (c) 2026
9 *
10 */
11
14 constexpr auto size_symm = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
15 matDPtr = boost::make_shared<MatrixDouble>(1, size_symm * size_symm);
16 auto set_material_stiffness = [this]() {
23 double A = 1.;
24 /**
25 * @brief Toggle for plane strain.
26 *
27 * @note If `SPACE_DIM == 2` and `is_plane_strain` is true, the code uses the
28 * plane strain elasticity tensor.
29 * @note If `SPACE_DIM == 2` and `is_plane_strain` is false, the code uses the
30 * plane stress elasticity tensor.
31 */
32
33 constexpr double bulk_modulus_K = 10;
34 constexpr double shear_modulus_G = 1;
35 if (SPACE_DIM == 2 /*&& !is_plane_strain*/) {
36 A = 2 * shear_modulus_G /
37 (bulk_modulus_K + (4. / 3.) * shear_modulus_G);
38 }
39 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*matDPtr);
40 t_D(i, j, k, l) = 2 * shear_modulus_G * ((t_kd(i, k) ^ t_kd(j, l)) / 4.) +
41 A * (bulk_modulus_K - (2. / 3.) * shear_modulus_G) *
42 t_kd(i, j) * t_kd(k, l);
44 };
45 CHK_THROW_MESSAGE(set_material_stiffness(),
46 "Failed to set material stiffness");
47 }
48
49 auto getMaterialStiffness() { return matDPtr; }
50
51 static MoFEMErrorCode
52 hookEvaluateVariable(boost::shared_ptr<MatOps::MatOpsData> mat_ops_data_ptr,
53 int, EntityHandle, int) {
54 auto t_grad = getFTensor2FromPtr<SPACE_DIM, SPACE_DIM>(
55 mat_ops_data_ptr->getActiveDataPtr("F")->data().data());
56 auto t_P = getFTensor2FromPtr<SPACE_DIM, SPACE_DIM>(
57 mat_ops_data_ptr->getDependentDataPtr("P")->data().data());
62 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*matDPtr);
63 t_P(i, J) = t_D(i, J, k, L) * t_grad(k, L);
64 return 0;
65 }
66
67 static MoFEMErrorCode
68 hookEvaluateDerivatives(boost::shared_ptr<MatOps::MatOpsData> mat_ops_data_ptr,
69 int, EntityHandle, int) {
70 auto t_dP = getFTensor4FromPtr<SPACE_DIM, SPACE_DIM, SPACE_DIM, SPACE_DIM>(
71 mat_ops_data_ptr->getDependentDerivativesDataPtr("P_dF")->data().data());
76 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*matDPtr);
77 t_dP(i, J, k, L) = t_D(i, J, k, L);
78 return 0;
79 };
80
81 static MoFEMErrorCode hookUpdateState(boost::shared_ptr<MatOps::MatOpsData>,
82 int, EntityHandle, int) {
83 return 0;
84 };
85
86protected:
87 inline static boost::shared_ptr<MatrixDouble> matDPtr;
88};
#define FTENSOR_INDEX(DIM, I)
constexpr int SPACE_DIM
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 ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
double bulk_modulus_K
double shear_modulus_G
constexpr auto t_kd
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'J', DIM1 > J
Definition level_set.cpp:30
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
constexpr AssemblyType A
static MoFEMErrorCode hookEvaluateVariable(boost::shared_ptr< MatOps::MatOpsData > mat_ops_data_ptr, int, EntityHandle, int)
static MoFEMErrorCode hookEvaluateDerivatives(boost::shared_ptr< MatOps::MatOpsData > mat_ops_data_ptr, int, EntityHandle, int)
static boost::shared_ptr< MatrixDouble > matDPtr
static MoFEMErrorCode hookUpdateState(boost::shared_ptr< MatOps::MatOpsData >, int, EntityHandle, int)
constexpr auto size_symm
Definition plastic.cpp:42