7#ifndef GMATELASTOPLASTICQPOT_CARTESIAN3D_H
8#define GMATELASTOPLASTICQPOT_CARTESIAN3D_H
14#define _USE_MATH_DEFINES
36namespace Cartesian3d {
57 ret *= std::sqrt(0.5);
67template <
class T,
class U>
68inline void epsd(
const T& A, U& ret)
76 ret *= std::sqrt(0.5);
98 ret *= std::sqrt(2.0);
108template <
class T,
class U>
109inline void sigd(
const T& A, U& ret)
117 ret *= std::sqrt(2.0);
161 template <
class T,
class Y>
174 template <
class T,
class Y>
208#ifdef GMATELASTOPLASTICQPOT_ENABLE_ASSERT
280 ret.flat(
i) = 0.5 * (*(y) + *(y + 1));
286 void refresh(
bool compute_tangent =
true)
override
288 (void)(compute_tangent);
292#pragma omp parallel for
295 double K =
m_K.flat(
i);
296 double G =
m_G.flat(
i);
301 std::array<double, m_stride_tensor2>
Epsd;
302 double epsm = GT::Hydrostatic_deviatoric(
Eps, &
Epsd[0]);
303 double epsd = std::sqrt(0.5 * GT::A2s_ddot_B2s(&
Epsd[0], &
Epsd[0]));
307 size_t idx = QPot::iterator::lower_bound(y, y +
m_nyield,
epsd,
m_i.flat(
i));
317 double eps_min = 0.5 * (*(y + idx) + *(y + idx + 1));
319 double g = 2.0 *
G * (1.0 - eps_min /
epsd);
337#pragma omp parallel for
340 double K =
m_K.flat(
i);
341 double G =
m_G.flat(
i);
345 std::array<double, m_stride_tensor2>
Epsd;
346 double epsm = GT::Hydrostatic_deviatoric(
Eps, &
Epsd[0]);
347 double epsd = std::sqrt(0.5 * GT::A2s_ddot_B2s(&
Epsd[0], &
Epsd[0]));
350 size_t idx =
m_i.flat(
i);
352 double eps_min = 0.5 * (*(y + idx) + *(y + idx + 1));
353 double deps_y = 0.5 * (*(y + idx + 1) - *(y + idx));
355 double U = 3.0 *
K * std::pow(epsm, 2.0);
356 double V = 2.0 *
G * (std::pow(
epsd - eps_min, 2.0) - std::pow(deps_y, 2.0));
406 template <
class T,
class Y>
412 void refresh(
bool compute_tangent =
true)
override
414 (void)(compute_tangent);
418#pragma omp parallel for
421 double K =
m_K.flat(
i);
422 double G =
m_G.flat(
i);
427 std::array<double, m_stride_tensor2>
Epsd;
428 double epsm = GT::Hydrostatic_deviatoric(
Eps, &
Epsd[0]);
429 double epsd = std::sqrt(0.5 * GT::A2s_ddot_B2s(&
Epsd[0], &
Epsd[0]));
433 size_t idx = QPot::iterator::lower_bound(y, y +
m_nyield,
epsd,
m_i.flat(
i));
443 double eps_min = 0.5 * (*(y + idx) + *(y + idx + 1));
444 double deps_y = 0.5 * (*(y + idx + 1) - *(y + idx));
446 double g = (2.0 *
G /
epsd) * (deps_y / M_PI) * sin(M_PI / deps_y * (
epsd - eps_min));
464#pragma omp parallel for
467 double K =
m_K.flat(
i);
468 double G =
m_G.flat(
i);
472 std::array<double, m_stride_tensor2>
Epsd;
473 double epsm = GT::Hydrostatic_deviatoric(
Eps, &
Epsd[0]);
474 double epsd = std::sqrt(0.5 * GT::A2s_ddot_B2s(&
Epsd[0], &
Epsd[0]));
477 size_t idx =
m_i.flat(
i);
479 double eps_min = 0.5 * (*(y + idx) + *(y + idx + 1));
480 double deps_y = 0.5 * (*(y + idx + 1) - *(y + idx));
482 double U = 3.0 *
K * std::pow(epsm, 2.0);
483 double V = -4.0 *
G * std::pow(deps_y / M_PI, 2.0) *
484 (1.0 + cos(M_PI / deps_y * (
epsd - eps_min)));
Array of material points with a linear elastic constitutive response.
const array_type::tensor< double, N > & G() const
Shear modulus per item.
const array_type::tensor< double, N+2 > & Eps() const
Strain tensor per item.
const array_type::tensor< double, N > & K() const
Bulk modulus per item.
array_type::tensor< double, N+4 > m_C
Tangent per item.
void init_Elastic(const T &K, const T &G)
Construct system.
const array_type::tensor< double, N+2 > & Sig() const
Stress tensor per item.
array_type::tensor< double, N > m_G
Shear modulus per item.
array_type::tensor< double, N+2 > m_Sig
Stress tensor per item.
array_type::tensor< double, N > m_K
Bulk modulus per item.
array_type::tensor< double, N+2 > m_Eps
Strain tensor per item.
Array of material points with an elasto-plastic material model.
const array_type::tensor< size_t, N > & i() const
Index of the current yield strain per item.
Cusp(const T &K, const T &G, const Y &epsy)
Construct system.
array_type::tensor< size_t, N > m_i
Index of the current yield strain per item.
array_type::tensor< double, N > m_eps
Equivalent strain.
array_type::tensor< double, N > energy() const override
Potential energy per item.
void init_Cusp(const T &K, const T &G, const Y &epsy)
Construct system.
void set_epsy(const T &epsy)
Overwrite yield strains per item.
array_type::tensor< double, N > epsy_right() const
Current yield strain right per item.
array_type::tensor< double, N > epsy_left() const
Current yield strain left per item.
const array_type::tensor< double, N+1 > & epsy() const
Yield strains per item.
array_type::tensor< double, N+1 > m_epsy
Yield strain sequence.
const array_type::tensor< double, N > & eps() const
Equivalent strain per item.
array_type::tensor< double, N > epsp() const
Plastic strain per item.
void refresh(bool compute_tangent=true) override
Recompute stress from strain.
Array of material points with an elasto-plastic material model.
array_type::tensor< double, N > energy() const override
Potential energy per item.
void refresh(bool compute_tangent=true) override
Recompute stress from strain.
Smooth(const T &K, const T &G, const Y &epsy)
Construct system.
std::array< size_t, N+4 > m_shape_tensor4
Shape of an array of 4th-order tensors == [m_shape, 3, 3, 3, 3].
static constexpr size_t m_stride_tensor4
Storage stride for 4th-order tensors ( ).
static constexpr size_t m_ndim
Number of dimensions of tensors.
std::array< size_t, N > m_shape
Shape of the array (of scalars).
std::array< size_t, N+2 > m_shape_tensor2
Shape of an array of 2nd-order tensors == [m_shape, 3, 3].
static constexpr std::size_t rank
Rank of the array (the actual rank is increased with the tensor-rank).
size_t m_size
Size of the array (of scalars) == prod(m_shape).
static constexpr size_t m_stride_tensor2
Storage stride for 2nd-order tensors ( ).
auto Sigd(const T &A) -> typename GMatTensor::allocate< xt::get_rank< T >::value - 2, T >::type
Equivalent stress: norm of strain deviator.
auto Epsd(const T &A) -> typename GMatTensor::allocate< xt::get_rank< T >::value - 2, T >::type
Equivalent strain: norm of strain deviator.
void epsd(const T &A, U &ret)
Same as Epsd(), but writes to externally allocated output.
void sigd(const T &A, U &ret)
Same as Sigd(), but writes to externally allocated output.
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Material model based on a sequence of parabolic potentials.
API for individual tensors with pointer-only input.
auto Norm_deviatoric(const T &A)
Norm of the tensor's deviator:
void norm_deviatoric(const T &A, R &ret)
Same as Norm_deviatoric() but writes to externally allocated output.
Helper to allocate 'output' which is of the same type of some 'input', but of a different rank.
#define GMATELASTOPLASTICQPOT_ASSERT(expr)
All assertions are implementation as: