NEML2 2.0.0
Loading...
Searching...
No Matches
Rot.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/VecBase.h"
28
29namespace neml2
30{
31// Forward declarations
32class Scalar;
33class Vec;
34class R2;
35class R3;
36
48class Rot : public VecBase<Rot>
49{
50public:
51 using VecBase<Rot>::VecBase;
52
55 [[nodiscard]] static Rot rand(const TensorOptions & options = default_tensor_options());
56 [[nodiscard]] static Rot rand(const TraceableTensorShape & dynamic_shape,
57 TensorShapeRef intmd_shape,
58 const TensorOptions & options = default_tensor_options());
60
62 [[nodiscard]] static Rot identity(const TensorOptions & options = default_tensor_options());
63
65 [[nodiscard]] static Rot fill_euler_angles(const Vec & v,
66 const std::string & angle_convention,
67 const std::string & angle_type);
68
70 [[nodiscard]] static Rot fill_matrix(const R2 & M);
71
73 [[nodiscard]] static Rot fill_rodrigues(const Scalar & rx, const Scalar & ry, const Scalar & rz);
74
76 [[nodiscard]] static Rot rotation_from_to(const Vec & v1, const Vec & v2);
77
79 [[nodiscard]] static Rot axis_angle(const Vec & n, const Scalar & theta);
80
82 // This has a specialized use in integrating through ODFs, helping me avoid the need to calculate
83 // the arc length scaling term for our space
84 [[nodiscard]] static Rot axis_angle_standard(const Vec & n, const Scalar & theta);
85
87 R2 euler_rodrigues() const;
88
90 R3 deuler_rodrigues() const;
91
93 Rot rotate(const Rot & r) const;
94
96 R2 drotate(const Rot & r) const;
97
99 R2 drotate_self(const Rot & r) const;
100
102 Rot shadow() const;
103
105 R2 dshadow() const;
106
108 Scalar dist(const Rot & r) const;
109
111 Scalar gdist(const Rot & r) const;
112
114 Scalar dV() const;
115};
116
118// So this follows the "matrix" convention where it's exactly the same
119// as the standard matrix product R1 * R2 where R1 and R2 are the
120// matrix representations of r1 and r2
121Rot operator*(const Rot & r1, const Rot & r2);
122
123} // namespace neml2
Base class for second order tensor.
Definition R2.h:49
Third order tensor without symmetry.
Definition R3.h:41
Rotation stored as modified Rodrigues parameters.
Definition Rot.h:49
Rot rotate(const Rot &r) const
Rotate.
Definition Rot.cxx:218
static Rot fill_rodrigues(const Scalar &rx, const Scalar &ry, const Scalar &rz)
Fill from standard Rodrigues parameters.
Definition Rot.cxx:153
Scalar dist(const Rot &r) const
Distance measure between two rotations, accounting for shadow mapping.
Definition Rot.cxx:269
R3 deuler_rodrigues() const
d(R2)/d(r) – useful in constructing other derivatives
Definition Rot.cxx:203
static Rot axis_angle_standard(const Vec &n, const Scalar &theta)
Fill with axis/angle pairs as a standard Rodrigues parameter, then convert to MRP.
Definition Rot.cxx:185
static Rot rand(const TensorOptions &options=default_tensor_options())
Definition Rot.cxx:59
Rot shadow() const
Return the shadow parameter set (a set of MRPs that define the same orientation)
Definition Rot.cxx:256
R2 dshadow() const
Return the derivative of the shadow map.
Definition Rot.cxx:262
static Rot fill_matrix(const R2 &M)
Fill from rotation matrix.
Definition Rot.cxx:136
static Rot identity(const TensorOptions &options=default_tensor_options())
The identity rotation, helpfully the zero vector.
Definition Rot.cxx:82
static Rot fill_euler_angles(const Vec &v, const std::string &angle_convention, const std::string &angle_type)
Fill from Euler angle.
Definition Rot.cxx:88
R2 euler_rodrigues() const
Generate a rotation matrix using the Euler-Rodrigues formula.
Definition Rot.cxx:192
R2 drotate_self(const Rot &r) const
Derivative of the rotated Rodrigues vector w.r.t. this vector.
Definition Rot.cxx:240
Scalar gdist(const Rot &r) const
Raw distance formula, not accounting for shadown mapping.
Definition Rot.cxx:282
static Rot axis_angle(const Vec &n, const Scalar &theta)
Fill with axis/angle pairs.
Definition Rot.cxx:176
Scalar dV() const
Volume element at locations.
Definition Rot.cxx:291
R2 drotate(const Rot &r) const
Derivative of the rotated Rodrigues vector w.r.t. the other Rodrigues vector.
Definition Rot.cxx:224
static Rot rotation_from_to(const Vec &v1, const Vec &v2)
Fill by forming the rotation between two vectors.
Definition Rot.cxx:164
Scalar.
Definition Scalar.h:38
Base class 3-vector.
Definition VecBase.h:42
3-vector.
Definition Vec.h:43
Definition DiagnosticsInterface.cxx:30
TensorOptions default_tensor_options()
Default floating point tensor options.
Definition defaults.cxx:42
Tensor operator*(const Tensor &a, const Tensor &b)
Definition operators.cxx:171
c10::TensorOptions TensorOptions
Definition types.h:60
c10::ArrayRef< Size > TensorShapeRef
Definition types.h:67
Traceable tensor shape.
Definition TraceableTensorShape.h:38