NEML2 2.0.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
mandel_notation.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 <array>
28
29#include "neml2/misc/types.h"
30#include "neml2/misc/defaults.h"
31
32namespace neml2
33{
34class Tensor;
35
36constexpr std::array<std::array<Size, 3>, 3> mandel_reverse_index{
37 std::array<Size, 3>{0, 5, 4}, std::array<Size, 3>{5, 1, 3}, std::array<Size, 3>{4, 3, 2}};
38constexpr std::array<std::array<Size, 2>, 6> mandel_index{std::array<Size, 2>{0, 0},
39 std::array<Size, 2>{1, 1},
40 std::array<Size, 2>{2, 2},
41 std::array<Size, 2>{1, 2},
42 std::array<Size, 2>{0, 2},
43 std::array<Size, 2>{0, 1}};
44
45constexpr std::array<std::array<Size, 3>, 3> skew_reverse_index{
46 std::array<Size, 3>{0, 2, 1}, std::array<Size, 3>{2, 0, 0}, std::array<Size, 3>{1, 0, 0}};
47constexpr std::array<std::array<Real, 3>, 3> skew_factor{std::array<Real, 3>{0.0, -1.0, 1.0},
48 std::array<Real, 3>{1.0, 0.0, -1.0},
49 std::array<Real, 3>{-1.0, 1.0, 0.0}};
50
51inline constexpr Real
53{
54 return i < 3 ? 1.0 : sqrt2;
55}
56
59const Tensor & full_to_mandel_factor(const TensorOptions & opt = default_tensor_options());
60const Tensor & mandel_to_full_factor(const TensorOptions & opt = default_tensor_options());
63const Tensor & full_to_skew_factor(const TensorOptions & opt = default_tensor_options());
64const Tensor & skew_to_full_factor(const TensorOptions & opt = default_tensor_options());
65
87Tensor
88full_to_reduced(const Tensor & full, const Tensor & rmap, const Tensor & rfactors, Size dim = 0);
89
101Tensor
102reduced_to_full(const Tensor & reduced, const Tensor & rmap, const Tensor & rfactors, Size dim = 0);
103
120Tensor full_to_mandel(const Tensor & full, Size dim = 0);
121
131Tensor mandel_to_full(const Tensor & mandel, Size dim = 0);
132
150Tensor full_to_skew(const Tensor & full, Size dim = 0);
151
161Tensor skew_to_full(const Tensor & skew, Size dim = 0);
162} // namespace neml2
Definition Tensor.h:46
Definition DiagnosticsInterface.cxx:30
Tensor full_to_reduced(const Tensor &full, const Tensor &rmap, const Tensor &rfactors, Size dim)
Generic function to reduce two axes to one with some map.
Definition mandel_notation.cxx:105
const Tensor & skew_to_full_map(const TensorOptions &opt)
Definition mandel_notation.cxx:78
TensorOptions default_tensor_options()
Default floating point tensor options.
Definition defaults.cxx:44
const Tensor & skew_to_full_factor(const TensorOptions &opt)
Definition mandel_notation.cxx:96
Tensor full_to_skew(const Tensor &full, Size dim)
Convert a Tensor from full notation to skew vector notation.
Definition mandel_notation.cxx:169
double Real
Definition types.h:68
Tensor mandel_to_full(const Tensor &mandel, Size dim)
Convert a Tensor from Mandel notation to full notation.
Definition mandel_notation.cxx:160
constexpr std::array< std::array< Real, 3 >, 3 > skew_factor
Definition mandel_notation.h:47
const Tensor & full_to_mandel_map(const TensorOptions &opt)
Definition mandel_notation.cxx:31
Tensor reduced_to_full(const Tensor &reduced, const Tensor &rmap, const Tensor &rfactors, Size dim)
Convert a Tensor from reduced notation to full notation.
Definition mandel_notation.cxx:129
constexpr std::array< std::array< Size, 3 >, 3 > mandel_reverse_index
Definition mandel_notation.h:36
int64_t Size
Definition types.h:69
constexpr Real mandel_factor(Size i)
Definition mandel_notation.h:52
constexpr std::array< std::array< Size, 2 >, 6 > mandel_index
Definition mandel_notation.h:38
TensorOptions default_integer_tensor_options()
Default integral tensor options.
Definition defaults.cxx:50
const Tensor & mandel_to_full_factor(const TensorOptions &opt)
Definition mandel_notation.cxx:58
const Tensor & full_to_mandel_factor(const TensorOptions &opt)
Definition mandel_notation.cxx:49
c10::TensorOptions TensorOptions
Definition types.h:63
const Tensor & full_to_skew_map(const TensorOptions &opt)
Definition mandel_notation.cxx:70
const Tensor & full_to_skew_factor(const TensorOptions &opt)
Definition mandel_notation.cxx:87
Tensor skew_to_full(const Tensor &skew, Size dim)
Convert a Tensor from skew vector notation to full notation.
Definition mandel_notation.cxx:178
constexpr std::array< std::array< Size, 3 >, 3 > skew_reverse_index
Definition mandel_notation.h:45
const Tensor & mandel_to_full_map(const TensorOptions &opt)
Definition mandel_notation.cxx:40
Tensor full_to_mandel(const Tensor &full, Size dim)
Convert a Tensor from full notation to Mandel notation.
Definition mandel_notation.cxx:151
constexpr Real sqrt2
Definition types.h:102