DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
traits.h
1// Copyright (C) 2024-2026 Joseph P. Dean and Garth N. Wells
2// This file is part of DOLFINx (https://www.fenicsproject.org)
3//
4// SPDX-License-Identifier: LGPL-3.0-or-later
5
6#pragma once
7
8#include <basix/mdspan.hpp>
9#include <concepts>
10#include <cstdint>
11#include <dolfinx/common/types.h>
12#include <span>
13#include <tuple>
14#include <type_traits>
15
16namespace dolfinx::fem
17{
19template <class U, class T>
21 = std::is_invocable_v<U, std::span<T>, std::span<const std::uint32_t>,
22 std::int32_t, int>;
23
32template <typename F>
33constexpr bool is_transform_set(const F& fn)
34{
35 if constexpr (requires { static_cast<bool>(fn); })
36 return static_cast<bool>(fn);
37 else
38 return true;
39}
40
45template <class U, class T, class G = dolfinx::scalar_value_t<T>>
46concept FEkernel = std::is_invocable_v<U, T*, const T*, const T*, const G*,
47 const int*, const std::uint8_t*, void*>;
48
50template <class T>
51concept MDSpan2
52 = std::is_convertible_v<
53 std::remove_cvref_t<T>,
54 md::mdspan<const std::int32_t, md::dextents<std::size_t, 2>>>
55 or std::is_convertible_v<
56 std::remove_cvref_t<T>,
57 md::mdspan<const std::int32_t, md::dextents<std::size_t, 1>>>;
58
62template <class T>
65 and std::same_as<typename std::remove_cvref_t<T>::value_type,
66 std::int32_t>;
67
71template <class T, class U>
73 = std::floating_point<U> and dolfinx::MDSpanRank2<T>
74 and std::same_as<typename std::remove_cvref_t<T>::value_type, U>;
75
84template <class T>
85concept DofMapPackBase = requires(const std::remove_cvref_t<T>& t) {
86 requires std::tuple_size_v<std::remove_cvref_t<T>> == 3;
88 { std::get<1>(t) } -> std::convertible_to<int>;
89};
91
95template <class T>
97 = DofMapPackBase<T> and requires(const std::remove_cvref_t<T>& t) {
98 { std::get<2>(t)[0] } -> std::convertible_to<std::int32_t>;
99 };
100
104template <class T>
106 = DofMapPackBase<T> and requires(const std::remove_cvref_t<T>& t) {
107 { std::get<2>(t)(0, 0) } -> std::convertible_to<std::int32_t>;
108 };
109
113template <class T>
115 = DofMapPackBase<T> and requires(const std::remove_cvref_t<T>& t) {
116 { std::get<2>(t)(0, 0, 0) } -> std::convertible_to<std::int32_t>;
117 };
118} // namespace dolfinx::fem
mdspan/mdarray namespace
Definition types.h:60
Concept for the degree-of-freedom map data passed to the cell assembly kernel, whose (2) entry is a f...
Definition traits.h:97
Concept for the degree-of-freedom map data passed to the entity assembly kernel, whose (2) entry is i...
Definition traits.h:106
Concept for the degree-of-freedom map data passed to the interior facet assembly kernel,...
Definition traits.h:115
DOF transform kernel concept.
Definition traits.h:21
Finite element cell kernel concept.
Definition traits.h:46
Concept for a rank-2 mdspan of a floating-point type.
Definition traits.h:73
Concept for a rank-2 mdspan of 32-bit indices.
Definition traits.h:64
Concept for mdspan of rank 1 or 2.
Definition traits.h:52
Finite element method functionality.
Definition assemble_expression_impl.h:24
constexpr bool is_transform_set(const F &fn)
Whether a DofTransformKernel fn should be invoked.
Definition traits.h:33