SPH
QuantityHelpers.h
Go to the documentation of this file.
1 #pragma once
2 
7 
10 
12 
14 
16 template <typename T>
17 struct GetValueEnum;
18 template <>
20  static constexpr ValueEnum type = ValueEnum::SCALAR;
21 };
22 template <>
24  static constexpr ValueEnum type = ValueEnum::VECTOR;
25 };
26 template <>
28  static constexpr ValueEnum type = ValueEnum::TENSOR;
29 };
30 template <>
32  static constexpr ValueEnum type = ValueEnum::SYMMETRIC_TENSOR;
33 };
34 template <>
36  static constexpr ValueEnum type = ValueEnum::TRACELESS_TENSOR;
37 };
38 template <>
39 struct GetValueEnum<Size> {
40  static constexpr ValueEnum type = ValueEnum::INDEX;
41 };
42 
44 template <ValueEnum Type>
46 template <>
48  using Type = Float;
49 };
50 template <>
52  using Type = Vector;
53 };
54 template <>
56  using Type = Tensor;
57 };
58 template <>
61 };
62 template <>
65 };
66 template <>
68  using Type = Size;
69 };
70 
71 
75 template <typename TVisitor, typename... TArgs>
76 decltype(auto) dispatch(const ValueEnum value, TVisitor&& visitor, TArgs&&... args) {
77  switch (value) {
78  case ValueEnum::SCALAR:
79  return visitor.template visit<Float>(std::forward<TArgs>(args)...);
80  case ValueEnum::VECTOR:
81  return visitor.template visit<Vector>(std::forward<TArgs>(args)...);
82  case ValueEnum::TENSOR:
83  return visitor.template visit<Tensor>(std::forward<TArgs>(args)...);
85  return visitor.template visit<SymmetricTensor>(std::forward<TArgs>(args)...);
87  return visitor.template visit<TracelessTensor>(std::forward<TArgs>(args)...);
88  case ValueEnum::INDEX:
89  return visitor.template visit<Size>(std::forward<TArgs>(args)...);
90  default:
92  }
93 }
94 
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Definition: Assert.h:100
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
@ SYMMETRIC_TENSOR
@ TRACELESS_TENSOR
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
#define NAMESPACE_SPH_END
Definition: Object.h:12
@ INDEX
Index of particle.
ValueEnum
@ SYMMETRIC_TENSOR
@ TRACELESS_TENSOR
decltype(auto) dispatch(const ValueEnum value, TVisitor &&visitor, TArgs &&... args)
Selects type based on run-time ValueEnum value and runs visit<Type>() method of the visitor.
Generic tensor of the 2nd order.
Symmetric traceless 2nd order tensor.
BasicVector< Float > Vector
Definition: Vector.h:539
Symmetric tensor of 2nd order.
Generic 2nd-order tensor with 9 independent components.
Definition: Tensor.h:13
Symmetric traceless 2nd order tensor.
Convert ValueType enum to type.
Convert type to ValueType enum.