8#include <deal.II/base/function.h>
20 template <
int dim,
typename Number,
typename Callable>
21 class ToFunction :
public dealii::Function<dim, Number>
24 ToFunction(
const Callable &callable,
const unsigned int k)
25 : dealii::Function<dim, Number>(1)
31 Number value(
const dealii::Point<dim> &point,
32 unsigned int )
const override
34 return callable_(point)[k_];
38 const Callable callable_;
39 const unsigned int k_;
68 template <
int dim,
typename Number,
typename Callable>
69 ToFunction<dim, Number, Callable>
to_function(
const Callable &callable,
79 template <
typename FT,
80 int problem_dim = FT::dimension,
81 typename TT =
typename FT::value_type,
82 typename T =
typename TT::value_type>
83 DEAL_II_ALWAYS_INLINE
inline dealii::Tensor<1, problem_dim, T>
86 dealii::Tensor<1, problem_dim, T> result;
87 for (
unsigned int k = 0; k < problem_dim; ++k)
88 result[k] = flux_ij[k] * c_ij;
96 template <
typename FT,
int problem_dim = FT::dimension>
97 DEAL_II_ALWAYS_INLINE
inline FT
add(
const FT &flux_left_ij,
98 const FT &flux_right_ij)
101 for (
unsigned int k = 0; k < problem_dim; ++k)
102 result[k] = flux_left_ij[k] + flux_right_ij[k];
120#define AssertThrowSIMD(variable, condition, exception) \
121 if constexpr (std::is_same< \
122 typename std::remove_const<decltype(variable)>::type, \
125 typename std::remove_const<decltype(variable)>::type, \
127 AssertThrow(condition(variable), exception); \
129 for (unsigned int k = 0; k < decltype(variable)::size(); ++k) { \
130 AssertThrow(condition((variable)[k]), exception); \
137 template <
typename T>
138 class is_dereferenceable
140 template <
typename C>
141 static auto test(...) -> std::false_type;
143 template <
typename C>
144 static auto test(C *) ->
decltype(*std::declval<C>(), std::true_type());
147 using type =
decltype(test<T>(
nullptr));
148 static constexpr auto value = type::value;
151 template <
typename T,
typename>
152 auto dereference(T &t) ->
decltype(dereference(*t)) &;
156 typename =
typename std::enable_if<!is_dereferenceable<T>::value>::type>
157 auto dereference(T &t) -> T &
164 typename =
typename std::enable_if<is_dereferenceable<T>::value>::type>
165 auto dereference(T &t) ->
decltype(*t) &
186#define ACCESSOR_READ_ONLY(member) \
187 inline auto &member() const \
189 return dereference(member##_); \
198#define ACCESSOR(member) \
199 inline auto &member() \
201 return dereference(member##_); \
211#define ACCESSOR_READ_ONLY_NO_DEREFERENCE(member) \
212 inline const auto &member() const \
223#define ASM_LABEL(label) asm("#" label);
ToFunction< dim, Number, Callable > to_function(const Callable &callable, const unsigned int k)
DEAL_II_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)
DEAL_II_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > contract(const FT &flux_ij, const TT &c_ij)