7#include "ddc_alias_inline_functions.hpp"
8#include "ddc_aliases.hpp"
9#include "ddc_helper.hpp"
20 template <
class Gr
id1D,
class MemorySpace>
23 template <
class ODDim,
class OMemorySpace>
27 using discrete_element_type = Idx<Grid1D>;
30 using discrete_domain_type = IdxRange<Grid1D>;
32 using index_range_type = discrete_domain_type;
35 using discrete_vector_type = IdxStep<Grid1D>;
39 DFieldMem<index_range_type, MemorySpace> m_charge;
42 DFieldMem<index_range_type, MemorySpace> m_mass;
45 DConstField<index_range_type, MemorySpace> m_charge_view;
48 DConstField<index_range_type, MemorySpace> m_mass_view;
50 discrete_element_type m_ielec;
60 template <
class OMemorySpace>
62 : m_charge(get_idx_range(impl.m_charge))
63 , m_mass(get_idx_range(impl.m_mass))
64 , m_ielec(impl.m_ielec)
66 m_charge_view = get_const_field(m_charge);
67 m_mass_view = get_const_field(m_mass);
68 ddc::parallel_deepcopy(m_charge, impl.m_charge);
69 ddc::parallel_deepcopy(m_mass, impl.m_mass);
78 DFieldMem<index_range_type, MemorySpace>
mass)
79 : m_charge(std::move(
charge))
80 , m_mass(std::move(
mass))
82 m_charge_view = get_const_field(m_charge);
83 m_mass_view = get_const_field(m_mass);
84 assert(
charge.size() >= 2);
85 bool electron_found =
false;
86 for (discrete_element_type
const isp : get_idx_range(m_charge)) {
87 if (m_charge(isp) == -1.) {
88 electron_found =
true;
92 if (!electron_found) {
93 throw std::runtime_error(
"electron not found");
98 KOKKOS_FUNCTION discrete_element_type
ielec()
const
107 KOKKOS_FUNCTION
double charge(discrete_element_type
const isp)
const
109 return m_charge_view(isp);
116 KOKKOS_FUNCTION
double mass(discrete_element_type
const isp)
const
118 return m_mass_view(isp);
124 return get_const_field(m_charge);
130 return get_const_field(m_mass);
135template <
class Gr
id1D>
136inline constexpr bool is_species_information_v
137 = std::is_same_v<typename Grid1D::discrete_dimension_type, SpeciesInformation>;
145KOKKOS_INLINE_FUNCTION Idx<Species> ielec()
147 return ddc::discrete_space<Species>().ielec();
154KOKKOS_INLINE_FUNCTION
double charge(Idx<Species>
const isp)
156 return ddc::discrete_space<Species>().charge(isp);
163KOKKOS_INLINE_FUNCTION
double mass(Idx<Species>
const isp)
165 return ddc::discrete_space<Species>().mass(isp);
168using IdxSp = Idx<Species>;
169using IdxRangeSp = IdxRange<Species>;
170using IdxStepSp = IdxStep<Species>;
172template <
class ElementType>
173using FieldMemSp = FieldMem<ElementType, IdxRangeSp>;
174using DFieldMemSp = FieldMemSp<double>;
175using IFieldMemSp = FieldMemSp<int>;
177template <
class ElementType>
178using ConstFieldSp = ConstField<ElementType, IdxRangeSp>;
179using DConstFieldSp = ConstFieldSp<double>;
181template <
class ElementType>
182using FieldSp = Field<ElementType, IdxRangeSp>;
183using DFieldSp = FieldSp<double>;
Definition species_info.hpp:141