NEML2 2.0.0
Loading...
Searching...
No Matches
symmetrization.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#include "neml2/misc/errors.h"
32
33namespace neml2
34{
35class Tensor;
36
37constexpr std::array<std::array<Size, 3>, 3> mandel_reverse_index{
38 std::array<Size, 3>{0, 5, 4}, std::array<Size, 3>{5, 1, 3}, std::array<Size, 3>{4, 3, 2}};
39constexpr std::array<std::array<Size, 2>, 6> mandel_index{std::array<Size, 2>{0, 0},
40 std::array<Size, 2>{1, 1},
41 std::array<Size, 2>{2, 2},
42 std::array<Size, 2>{1, 2},
43 std::array<Size, 2>{0, 2},
44 std::array<Size, 2>{0, 1}};
45
46constexpr std::array<std::array<Size, 3>, 3> skew_reverse_index{
47 std::array<Size, 3>{0, 2, 1}, std::array<Size, 3>{2, 0, 0}, std::array<Size, 3>{1, 0, 0}};
48constexpr std::array<std::array<double, 3>, 3> skew_factor{std::array<double, 3>{0.0, -1.0, 1.0},
49 std::array<double, 3>{1.0, 0.0, -1.0},
50 std::array<double, 3>{-1.0, 1.0, 0.0}};
51
52inline constexpr double
54{
55 if (i < 0 || i >= 6)
56 throw NEMLException("Mandel factor index out of range: " + std::to_string(i));
57 return i < 3 ? 1.0 : sqrt2;
58}
59
76Tensor full_to_mandel(const Tensor & full, Size dim = 0);
77
87Tensor mandel_to_full(const Tensor & mandel, Size dim = 0);
88
106Tensor full_to_skew(const Tensor & full, Size dim = 0);
107
117Tensor skew_to_full(const Tensor & skew, Size dim = 0);
118
119namespace details
120{
142Tensor
143full_to_reduced(const Tensor & full, const Tensor & rmap, const Tensor & rfactors, Size dim = 0);
144
156Tensor
157reduced_to_full(const Tensor & reduced, const Tensor & rmap, const Tensor & rfactors, Size dim = 0);
158
159const Tensor & full_to_mandel_map(const TensorOptions & opt = default_integer_tensor_options());
160const Tensor & mandel_to_full_map(const TensorOptions & opt = default_integer_tensor_options());
161
162const Tensor & full_to_mandel_factor(const TensorOptions & opt = default_tensor_options());
163const Tensor & mandel_to_full_factor(const TensorOptions & opt = default_tensor_options());
164
165const Tensor & full_to_skew_map(const TensorOptions & opt = default_integer_tensor_options());
166const Tensor & skew_to_full_map(const TensorOptions & opt = default_integer_tensor_options());
167
168const Tensor & full_to_skew_factor(const TensorOptions & opt = default_tensor_options());
169const Tensor & skew_to_full_factor(const TensorOptions & opt = default_tensor_options());
170} // namespace details
171} // namespace neml2
Definition errors.h:34
Definition DiagnosticsInterface.cxx:30
TensorOptions default_tensor_options()
Default floating point tensor options.
Definition defaults.cxx:42
Tensor full_to_skew(const Tensor &full, Size dim)
Convert a Tensor from full notation to skew vector notation.
Definition symmetrization.cxx:52
Tensor mandel_to_full(const Tensor &mandel, Size dim)
Convert a Tensor from Mandel notation to full notation.
Definition symmetrization.cxx:42
constexpr std::array< std::array< double, 3 >, 3 > skew_factor
Definition symmetrization.h:48
constexpr std::array< std::array< Size, 3 >, 3 > mandel_reverse_index
Definition symmetrization.h:37
int64_t Size
Definition types.h:65
constexpr std::array< std::array< Size, 2 >, 6 > mandel_index
Definition symmetrization.h:39
TensorOptions default_integer_tensor_options()
Default integral tensor options.
Definition defaults.cxx:60
c10::TensorOptions TensorOptions
Definition types.h:60
constexpr double mandel_factor(Size i)
Definition symmetrization.h:53
Tensor skew_to_full(const Tensor &skew, Size dim)
Convert a Tensor from skew vector notation to full notation.
Definition symmetrization.cxx:62
constexpr std::array< std::array< Size, 3 >, 3 > skew_reverse_index
Definition symmetrization.h:46
constexpr double sqrt2
Definition types.h:93
Tensor full_to_mandel(const Tensor &full, Size dim)
Convert a Tensor from full notation to Mandel notation.
Definition symmetrization.cxx:32