SimiLie
Loading...
Searching...
No Matches
elasticity_quantities.hpp
1// SPDX-FileCopyrightText: 2026 Baptiste Legouix
2// SPDX-License-Identifier: AGPL-3.0-or-later
3// AI-GENERATED
4
5#pragma once
6
7#include <cmath>
8#include <cstddef>
9#include <type_traits>
10
11#include <Kokkos_Core.hpp>
12
14
15template <std::size_t I, std::size_t J>
17{
18 static constexpr std::size_t FIRST = I;
19 static constexpr std::size_t SECOND = J;
20};
21
25
26// Packed tensorial shear: xy = epsilon_xy, not engineering shear gamma_xy.
27// Hence dW/d(xy) = 2 sigma_xy; B^T dW/d(strain) already includes this
28// multiplicity. Only stress output divides the shear derivative by two.
30{
31 double xx = 0.0;
32 double yy = 0.0;
33 double xy = 0.0;
34
35 template <class Index>
36 [[nodiscard]] KOKKOS_FUNCTION constexpr double get() const
37 {
38 if constexpr (std::is_same_v<Index, StrainXX>) {
39 return xx;
40 } else if constexpr (std::is_same_v<Index, StrainXY>) {
41 return xy;
42 } else if constexpr (std::is_same_v<Index, StrainYY>) {
43 return yy;
44 } else {
45 static_assert(
46 std::is_same_v<Index, StrainXX> || std::is_same_v<Index, StrainYY>
47 || std::is_same_v<Index, StrainXY>,
48 "unsupported elasticity strain component index");
49 }
50 }
51};
52
54{
55 [[nodiscard]] KOKKOS_FUNCTION static constexpr Strain2D from_gradient(
56 double dux_dx,
57 double duy_dy,
58 double dux_dy,
59 double duy_dx)
60 {
61 return {
62 .xx = dux_dx,
63 .yy = duy_dy,
64 .xy = 0.5 * (dux_dy + duy_dx),
65 };
66 }
67};
68
70{
71 double xx = 0.0;
72 double yy = 0.0;
73 double xy = 0.0;
74
75 [[nodiscard]] KOKKOS_FUNCTION double von_mises() const
76 {
77 return Kokkos::sqrt(xx * xx - xx * yy + yy * yy + 3.0 * xy * xy);
78 }
79};
80
81} // namespace similie::physics::elasticity
static KOKKOS_FUNCTION constexpr Strain2D from_gradient(double dux_dx, double duy_dy, double dux_dy, double duy_dx)
KOKKOS_FUNCTION constexpr double get() const