25#include "neml2/misc/math.h"
26#include "neml2/tensors/SR2.h"
27#include "neml2/tensors/Scalar.h"
28#include "neml2/tensors/R2.h"
29#include "neml2/tensors/R3.h"
30#include "neml2/tensors/SFR3.h"
31#include "neml2/tensors/SSR4.h"
32#include "neml2/tensors/SFFR4.h"
33#include "neml2/tensors/Rot.h"
34#include "neml2/tensors/SWR4.h"
35#include "neml2/tensors/WR2.h"
36#include "neml2/tensors/R4.h"
41 :
SR2(math::full_to_mandel((T + T.transpose()) / 2.0))
54 auto zero = torch::zeros_like(a);
55 return SR2(torch::stack({a, a, a,
zero,
zero,
zero}, -1), a.batch_dim());
62 const torch::TensorOptions & options)
70 auto zero = torch::zeros_like(
a11);
81 const torch::TensorOptions & options)
99 return SR2(torch::stack({
a11,
112 return SR2(torch::tensor({1, 1, 1, 0, 0, 0}, options), 0);
169 return *
this -
vol();
175 auto a00 = (*this)(0, 0);
176 auto a11 = (*this)(1, 1);
177 auto a22 = (*this)(2, 2);
178 auto a12 = (*this)(1, 2);
179 auto a02 = (*this)(0, 2);
180 auto a01 = (*this)(0, 1);
TorchSize batch_dim() const
Return the number of batch dimensions.
Definition BatchTensorBase.cxx:128
BatchTensor base_index(const TorchSlice &indices) const
Return an index sliced on the base dimensions.
Definition BatchTensorBase.cxx:193
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
Derived rotate(const Rot &r) const
Rotate using a Rodrigues vector.
Definition R2Base.cxx:177
R3 drotate(const Rot &r) const
Derivative of the rotated tensor w.r.t. the Rodrigues vector.
Definition R2Base.cxx:191
Derived inverse() const
Inversion.
Definition R2Base.cxx:219
A basic R2.
Definition R2.h:42
Rotation stored as modified Rodrigues parameters.
Definition Rot.h:49
The logical fourth order tensor with minor symmetry in the 1st and 2nd dimensions.
Definition SFFR4.h:37
The logical third order tensor with symmetry in the first two dimensions.
Definition SFR3.h:38
The (logical) symmetric second order tensor.
Definition SR2.h:46
SR2 transpose() const
Transpose, no-op.
Definition SR2.cxx:218
SFR3 drotate(const Rot &r) const
Derivative of the rotated tensor w.r.t. the Rodrigues vector.
Definition SR2.cxx:134
Scalar tr() const
Trace.
Definition SR2.cxx:155
SR2 inverse() const
Inversion.
Definition SR2.cxx:212
static SR2 identity(const torch::TensorOptions &options=default_tensor_options())
Identity.
Definition SR2.cxx:110
SR2(const R2 &T)
Symmetrize an R2 then fill.
Definition SR2.cxx:40
Scalar inner(const SR2 &other) const
Double contraction ij,ij.
Definition SR2.cxx:186
SSR4 outer(const SR2 &other) const
Outer product ij,kl -> ijkl.
Definition SR2.cxx:205
Scalar det() const
Determinant.
Definition SR2.cxx:173
SR2 rotate(const Rot &r) const
Rotate.
Definition SR2.cxx:122
SR2 dev() const
Deviatoric part of the tensor.
Definition SR2.cxx:167
Scalar norm_sq() const
Norm squared.
Definition SR2.cxx:193
Scalar operator()(TorchSize i, TorchSize j) const
Accessor.
Definition SR2.cxx:148
Scalar norm(Real eps=0) const
Norm.
Definition SR2.cxx:199
SR2 vol() const
Volumetric part of the tensor.
Definition SR2.cxx:161
static SSR4 identity_map(const torch::TensorOptions &options=default_tensor_options())
The derivative of a SR2 with respect to itself.
Definition SR2.cxx:116
static SR2 fill(const Real &a, const torch::TensorOptions &options=default_tensor_options())
Fill the diagonals with a11 = a22 = a33 = a.
Definition SR2.cxx:46
The (logical) symmetric fourth order tensor, with symmetry in the first two dimensionss as well as in...
Definition SSR4.h:44
static SSR4 identity_sym(const torch::TensorOptions &options=default_tensor_options())
Create the symmetric identity tensor .
Definition SSR4.cxx:58
The (logical) scalar.
Definition Scalar.h:38
constexpr Real mandel_factor(TorchSize i)
Definition math.h:50
constexpr TorchSize mandel_reverse_index[3][3]
Definition math.h:43
BatchTensor full_to_mandel(const BatchTensor &full, TorchSize dim)
Convert a BatchTensor from full notation to Mandel notation.
Definition math.cxx:169
Derived sqrt(const Derived &a)
Definition BatchTensorBase.h:439
Definition CrossRef.cxx:32
int64_t TorchSize
Definition types.h:35
TorchSize broadcast_batch_dim(T &&...)
The batch dimension after broadcasting.
double Real
Definition types.h:33
void neml_assert_broadcastable_dbg(T &&...)
A helper function to assert (in Debug mode) that all tensors are broadcastable.