7#ifndef GMATELASTIC_CARTESIAN3D_H
8#define GMATELASTIC_CARTESIAN3D_H
20namespace Cartesian3d {
41 ret *= std::sqrt(2.0 / 3.0);
51template <
class T,
class U>
52inline void epseq(
const T& A, U& ret)
60 ret *= std::sqrt(2.0 / 3.0);
82 ret *= std::sqrt(1.5);
92template <
class T,
class U>
93inline void sigeq(
const T& A, U& ret)
101 ret *= std::sqrt(1.5);
152 std::copy(
K.shape().cbegin(),
K.shape().cend(),
m_shape.begin());
163 auto C = xt::adapt(
m_C.data(), {m_ndim, m_ndim, m_ndim, m_ndim});
170 for (
size_t i = 0; i <
m_size; ++i) {
208 std::copy(arg.cbegin(), arg.cend(),
m_Eps.begin());
220 void set_Eps(
const T& arg,
bool compute_tangent)
223 std::copy(arg.cbegin(), arg.cend(),
m_Eps.begin());
224 this->
refresh(compute_tangent);
248 virtual void refresh(
bool compute_tangent =
true)
250 (void)(compute_tangent);
252#pragma omp parallel for
253 for (
size_t i = 0; i <
m_size; ++i) {
255 double K =
m_K.flat(i);
256 double G =
m_G.flat(i);
263 Sig[0] = (3.0 *
K - 2.0 *
G) * epsm + 2.0 *
G *
Eps[0];
267 Sig[4] = (3.0 *
K - 2.0 *
G) * epsm + 2.0 *
G *
Eps[4];
271 Sig[8] = (3.0 *
K - 2.0 *
G) * epsm + 2.0 *
G *
Eps[8];
321#pragma omp parallel for
322 for (
size_t i = 0; i <
m_size; ++i) {
324 double K =
m_K.flat(i);
325 double G =
m_G.flat(i);
329 std::array<double, m_stride_tensor2> Epsd;
330 double epsm = GT::Hydrostatic_deviatoric(
Eps, &Epsd[0]);
331 double epsd = std::sqrt(0.5 * GT::A2s_ddot_B2s(&Epsd[0], &Epsd[0]));
333 double U = 3.0 *
K * std::pow(epsm, 2.0);
334 double V = 2.0 *
G * std::pow(epsd, 2.0);
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.
virtual array_type::tensor< double, N > energy() const
Potential energy per item.
virtual void refresh(bool compute_tangent=true)
Recompute stress from strain.
array_type::tensor< double, N+2 > m_Sig
Stress tensor per item.
const array_type::tensor< double, N+4 > & C() const
Tangent tensor per item.
void set_Eps(const T &arg, bool compute_tangent)
Set strain tensors.
Elastic(const T &K, const T &G)
Construct system.
array_type::tensor< double, N > m_K
Bulk modulus per item.
void set_Eps(const T &arg)
Set strain tensors.
array_type::tensor< double, N+2 > m_Eps
Strain tensor per item.
array_type::tensor< double, N+2 > & Eps()
Strain tensor per item.
array_type::tensor< double, N+4 > I4d() const
Array of Cartesian3d::I4d()
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).
array_type::tensor< double, N+4 > II() const
Array of Cartesian3d::II()
void init(const std::array< size_t, N > &shape)
Constructor 'alias'.
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 ( ).
void sigeq(const T &A, U &ret)
Same as Sigeq(), but writes to externally allocated output.
auto Epseq(const T &A) -> typename GMatTensor::allocate< xt::get_rank< T >::value - 2, T >::type
Von Mises equivalent strain: norm of strain deviator.
void epseq(const T &A, U &ret)
Same as epseq(), but writes to externally allocated output.
auto Sigeq(const T &A) -> typename GMatTensor::allocate< xt::get_rank< T >::value - 2, T >::type
Von Mises equivalent stress: norm of strain deviator.
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Linear elastic material model.
API for individual tensors with pointer-only input.
T Hydrostatic(const T *A)
See Cartesian3d::Hydrostatic()
array_type::tensor< double, 4 > II()
Result of the dyadic product of two 2nd-order identity tensors (see I2()).
array_type::tensor< double, 4 > I4d()
Fourth order deviatoric projection.
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 GMATELASTIC_ASSERT(expr)
All assertions are implementation as: