NEML2 2.0.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
R2Base.h
1// Copyright 2024, UChicago Argonne, LLC
2// All Rights Reserved
3// Software Name: NEML2 -- the New Engineering material Model Library, version 2
4// By: Argonne National Laboratory
5// OPEN SOURCE LICENSE (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24
25#pragma once
26
27#include "neml2/tensors/PrimitiveTensor.h"
28
29namespace neml2
30{
31class Scalar;
32class Vec;
33class SR2;
34class R3;
35class R4;
36class Rot;
37class WR2;
38class R2;
39
40template <class>
41class VecBase;
42
48template <class Derived>
49class R2Base : public PrimitiveTensor<Derived, 3, 3>
50{
51public:
52 using PrimitiveTensor<Derived, 3, 3>::PrimitiveTensor;
53
55 explicit operator SR2() const;
56
58 [[nodiscard]] static Derived fill(const Real & a,
59 const TensorOptions & options = default_tensor_options());
60 [[nodiscard]] static Derived fill(const Scalar & a);
62 [[nodiscard]] static Derived fill(const Real & a11,
63 const Real & a22,
64 const Real & a33,
65 const TensorOptions & options = default_tensor_options());
66 [[nodiscard]] static Derived fill(const Scalar & a11, const Scalar & a22, const Scalar & a33);
68 [[nodiscard]] static Derived fill(const Real & a11,
69 const Real & a22,
70 const Real & a33,
71 const Real & a23,
72 const Real & a13,
73 const Real & a12,
74 const TensorOptions & options = default_tensor_options());
75 [[nodiscard]] static Derived fill(const Scalar & a11,
76 const Scalar & a22,
77 const Scalar & a33,
78 const Scalar & a23,
79 const Scalar & a13,
80 const Scalar & a12);
82 [[nodiscard]] static Derived fill(const Real & a11,
83 const Real & a12,
84 const Real & a13,
85 const Real & a21,
86 const Real & a22,
87 const Real & a23,
88 const Real & a31,
89 const Real & a32,
90 const Real & a33,
91 const TensorOptions & options = default_tensor_options());
92 [[nodiscard]] static Derived fill(const Scalar & a11,
93 const Scalar & a12,
94 const Scalar & a13,
95 const Scalar & a21,
96 const Scalar & a22,
97 const Scalar & a23,
98 const Scalar & a31,
99 const Scalar & a32,
100 const Scalar & a33);
102 [[nodiscard]] static Derived skew(const Vec & v);
104 [[nodiscard]] static Derived identity(const TensorOptions & options = default_tensor_options());
105
107 Derived rotate(const Rot & r) const;
108
110 Derived rotate(const R2 & R) const;
111
113 R3 drotate(const Rot & r) const;
114
116 R4 drotate(const R2 & R) const;
117
119 Scalar operator()(Size i, Size j) const;
120
122 Derived inverse() const;
123
125 Derived transpose() const;
126};
127
129// TODO: Fix the return type
130template <class Derived1,
131 class Derived2,
132 typename = typename std::enable_if_t<std::is_base_of_v<R2Base<Derived1>, Derived1>>,
133 typename = typename std::enable_if_t<std::is_base_of_v<VecBase<Derived2>, Derived2>>>
134Vec operator*(const Derived1 & A, const Derived2 & b);
135
137// TODO: Fix the return type
138template <class Derived1,
139 class Derived2,
140 typename = typename std::enable_if_t<std::is_base_of_v<R2Base<Derived1>, Derived1>>,
141 typename = typename std::enable_if_t<std::is_base_of_v<R2Base<Derived2>, Derived2>>>
142R2 operator*(const Derived1 & A, const Derived2 & B);
143
144} // namespace neml2
Base class for second order tensor.
Definition R2Base.h:50
Derived rotate(const Rot &r) const
Rotate using a Rodrigues vector.
Definition R2Base.cxx:173
R3 drotate(const Rot &r) const
Derivative of the rotated tensor w.r.t. the Rodrigues vector.
Definition R2Base.cxx:187
Scalar operator()(Size i, Size j) const
Accessor.
Definition R2Base.cxx:207
Derived transpose() const
transpose
Definition R2Base.cxx:221
static Derived fill(const Real &a, const TensorOptions &options=default_tensor_options())
Fill the diagonals with a11 = a22 = a33 = a.
Definition R2Base.cxx:41
Derived inverse() const
Inversion.
Definition R2Base.cxx:214
static Derived identity(const TensorOptions &options=default_tensor_options())
Identity.
Definition R2Base.cxx:166
static Derived skew(const Vec &v)
Skew matrix from Vec.
Definition R2Base.cxx:155
Second order tensor without symmetry.
Definition R2.h:42
Third order tensor without symmetry.
Definition R3.h:41
Fourth order tensor without symmetry.
Definition R4.h:44
Rotation stored as modified Rodrigues parameters.
Definition Rot.h:49
The symmetric second order tensor.
Definition SR2.h:46
Scalar.
Definition Scalar.h:38
Base class 3-vector.
Definition VecBase.h:44
3-vector.
Definition Vec.h:42
A skew-symmetric second order tensor, represented as an axial vector.
Definition WR2.h:43
Definition DiagnosticsInterface.cxx:30
TensorOptions default_tensor_options()
Default floating point tensor options.
Definition defaults.cxx:44
double Real
Definition types.h:68
Tensor operator*(const Tensor &a, const Tensor &b)
Definition operators.cxx:134
int64_t Size
Definition types.h:69
c10::TensorOptions TensorOptions
Definition types.h:63