/home/runner/work/kynema/kynema/kynema/src/dof_management/freedom_signature.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/dof_management/freedom_signature.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
freedom_signature.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4
5#include <Kokkos_Core.hpp>
6
7namespace kynema::dof {
8
18enum class FreedomSignature : std::uint8_t {
19 AllComponents = 0b00111111, //< Enable all 6 degrees of freedom
20 JustPosition = 0b00111000, //< Enable only translational DOFs
21 JustRotation = 0b00000111, //< Enable only rotational DOFs
22 NoComponents = 0b00000000 //< Disable all degrees of freedom
23};
24
32KOKKOS_INLINE_FUNCTION
34 using T = std::underlying_type_t<FreedomSignature>;
35 return static_cast<FreedomSignature>(static_cast<T>(x) | static_cast<T>(y));
36}
37
44KOKKOS_INLINE_FUNCTION
46 using T = std::underlying_type_t<FreedomSignature>;
47 auto count = 0UL;
48 constexpr auto zero = T{0};
49 constexpr auto one = T{1};
50 for (auto value = static_cast<T>(x); value > zero; value = value >> 1) {
51 count += value & one;
52 }
53 return count;
54}
55
56} // namespace kynema::dof
Definition assemble_node_freedom_allocation_table.hpp:10
KOKKOS_INLINE_FUNCTION FreedomSignature operator|(FreedomSignature x, FreedomSignature y)
Combines two freedom signatures using bitwise OR.
Definition freedom_signature.hpp:33
FreedomSignature
Represents the active degrees of freedom for a node.
Definition freedom_signature.hpp:18
KOKKOS_INLINE_FUNCTION size_t count_active_dofs(FreedomSignature x)
Counts the number of active degrees of freedom in a signature.
Definition freedom_signature.hpp:45