7 #ifndef SHAPEFACTORS_H_
8 #define SHAPEFACTORS_H_
25 template <
int depos_order>
28 template<
typename T >
34 if constexpr (depos_order == 0){
35 const auto j =
static_cast<int>(xmid + T(0.5));
39 else if constexpr (depos_order == 1){
40 const auto j =
static_cast<int>(xmid);
41 const T xint = xmid - T(j);
42 sx[0] = T(1.0) - xint;
46 else if constexpr (depos_order == 2){
47 const auto j =
static_cast<int>(xmid + T(0.5));
48 const T xint = xmid - T(j);
49 sx[0] = T(0.5)*(T(0.5) - xint)*(T(0.5) - xint);
50 sx[1] = T(0.75) - xint*xint;
51 sx[2] = T(0.5)*(T(0.5) + xint)*(T(0.5) + xint);
55 else if constexpr (depos_order == 3){
56 const auto j =
static_cast<int>(xmid);
57 const T xint = xmid - T(j);
58 sx[0] = (T(1.0))/(T(6.0))*(T(1.0) - xint)*(T(1.0) - xint)*(T(1.0) - xint);
59 sx[1] = (T(2.0))/(T(3.0)) - xint*xint*(T(1.0) - xint/(T(2.0)));
60 sx[2] = (T(2.0))/(T(3.0)) - (T(1.0) - xint)*(T(1.0) - xint)*(T(1.0) - T(0.5)*(T(1.0) - xint));
61 sx[3] = (T(1.0))/(T(6.0))*xint*xint*xint;
66 amrex::Abort(
"Unknown particle shape selected in Compute_shape_factor");
80 template <
int depos_order>
83 template<
typename T >
88 const int i_new)
const
90 if constexpr (depos_order == 1){
91 const auto i =
static_cast<int>(x_old);
92 const int i_shift =
i - i_new;
93 const T xint = x_old - T(
i);
94 sx[1+i_shift] = T(1.0) - xint;
98 else if constexpr (depos_order == 2){
99 const auto i =
static_cast<int>(x_old + T(0.5));
100 const int i_shift =
i - (i_new + 1);
101 const T xint = x_old - T(
i);
102 sx[1+i_shift] = T(0.5)*(T(0.5) - xint)*(T(0.5) - xint);
103 sx[2+i_shift] = T(0.75) - xint*xint;
104 sx[3+i_shift] = T(0.5)*(T(0.5) + xint)*(T(0.5) + xint);
108 else if constexpr (depos_order == 3){
109 const auto i =
static_cast<int>(x_old);
110 const int i_shift =
i - (i_new + 1);
111 const T xint = x_old -
i;
112 sx[1+i_shift] = (T(1.0))/(T(6.0))*(T(1.0) - xint)*(T(1.0) - xint)*(T(1.0) - xint);
113 sx[2+i_shift] = (T(2.0))/(T(3.0)) - xint*xint*(T(1.0) - xint/(T(2.0)));
114 sx[3+i_shift] = (T(2.0))/(T(3.0)) - (T(1.0) - xint)*(T(1.0) - xint)*(T(1.0) - T(0.5)*(T(1.0) - xint));
115 sx[4+i_shift] = (T(1.0))/(T(6.0))*xint*xint*xint;
120 amrex::Abort(
"Unknown particle shape selected in Compute_shifted_shape_factor");
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
void Abort(const std::string &msg)
i
Definition: check_interp_points_and_weights.py:174
Definition: ShapeFactors.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int operator()(T *const sx, T xmid) const
Definition: ShapeFactors.H:30
Definition: ShapeFactors.H:82
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int operator()(T *const sx, const T x_old, const int i_new) const
Definition: ShapeFactors.H:85