13#include <Kokkos_Core.hpp>
15#include "ddc/coordinate.hpp"
16#include "ddc/discrete_domain.hpp"
17#include "ddc/discrete_element.hpp"
18#include "ddc/discrete_space.hpp"
19#include "ddc/discrete_vector.hpp"
20#include "ddc/real_type.hpp"
26struct UniformPointSamplingBase
33
38 using continuous_dimension_type = CDim;
40 using continuous_element_type = Coordinate<CDim>;
46 template <
class DDim,
class MemorySpace>
49 template <
class ODDim,
class OMemorySpace>
53 continuous_element_type m_origin {0};
62 using discrete_element_type = DiscreteElement<DDim>;
70 template <
class OriginMemorySpace>
71 explicit Impl(
Impl<DDim, OriginMemorySpace>
const& impl)
72 : m_origin(impl.m_origin)
80
81
82
83
84 Impl(continuous_element_type origin, Real step) : m_origin(origin), m_step(step)
104 return discrete_element_type {0};
115 coordinate(discrete_element_type
const& icoord)
const noexcept
117 return m_origin + continuous_element_type(icoord.uid()) * m_step;
122
123
124
125
126
127
128
129
130 template <
class DDim>
131 static std::tuple<
typename DDim::
template Impl<DDim, Kokkos::HostSpace>,
DiscreteDomain<DDim>>
136 typename DDim::
template Impl<DDim, Kokkos::HostSpace>
137 disc(a, Coordinate<CDim> {(b - a) / (n - 1)});
139 return std::make_tuple(std::move(disc), std::move(domain));
143
144
145
146
147
148
149
150
151
152
153 template <
class DDim>
155 typename DDim::
template Impl<DDim, Kokkos::HostSpace>,
170 Real
const discretization_step {(b - a) / (n - 1)};
171 typename DDim::
template Impl<DDim, Kokkos::HostSpace>
172 disc(a - n_ghosts_before.value() * discretization_step, discretization_step);
173 discrete_domain_type ghosted_domain
174 = discrete_domain_type(disc.front(), n + n_ghosts_before + n_ghosts_after);
175 discrete_domain_type pre_ghost
176 = discrete_domain_type(ghosted_domain.front(), n_ghosts_before);
177 discrete_domain_type main_domain
178 = discrete_domain_type(ghosted_domain.front() + n_ghosts_before, n);
179 discrete_domain_type post_ghost
180 = discrete_domain_type(main_domain.back() + 1, n_ghosts_after);
181 return std::make_tuple(
183 std::move(main_domain),
184 std::move(ghosted_domain),
185 std::move(pre_ghost),
186 std::move(post_ghost));
190
191
192
193
194
195
196
197
198
199 template <
class DDim>
201 typename DDim::
template Impl<DDim, Kokkos::HostSpace>,
212 return init_ghosted(a, b, n, n_ghosts, n_ghosts);
218 :
public std::is_base_of<detail::UniformPointSamplingBase, DDim>::type
228 is_uniform_point_sampling_v<
typename DDimImpl::discrete_dimension_type>,
231std::ostream& operator<<(std::ostream& out, DDimImpl
const& mesh)
233 return out <<
"UniformPointSampling( origin=" << mesh.origin() <<
", step=" << mesh.step()
237template <
class DDim, std::enable_if_t<is_uniform_point_sampling_v<DDim>,
int> = 0>
239 DiscreteElement<DDim>
const& c)
241 return discrete_space<DDim>().coordinate(c);
247 is_uniform_point_sampling_v<DDim>,
251 return discrete_space<DDim>().origin();
256KOKKOS_FUNCTION std::enable_if_t<is_uniform_point_sampling_v<DDim>, DiscreteElement<DDim>>
259 return discrete_space<DDim>().front();
266 return discrete_space<DDim>().step();
269template <
class DDim, std::enable_if_t<is_uniform_point_sampling_v<DDim>,
int> = 0>
270KOKKOS_FUNCTION Coordinate<
typename DDim::continuous_dimension_type> distance_at_left(
271 DiscreteElement<DDim>)
273 return Coordinate<
typename DDim::continuous_dimension_type>(step<DDim>());
276template <
class DDim, std::enable_if_t<is_uniform_point_sampling_v<DDim>,
int> = 0>
277KOKKOS_FUNCTION Coordinate<
typename DDim::continuous_dimension_type> distance_at_right(
278 DiscreteElement<DDim>)
280 return Coordinate<
typename DDim::continuous_dimension_type>(step<DDim>());
283template <
class DDim, std::enable_if_t<is_uniform_point_sampling_v<DDim>,
int> = 0>
284KOKKOS_FUNCTION Coordinate<
typename DDim::continuous_dimension_type> rmin(
287 return coordinate(d.front());
290template <
class DDim, std::enable_if_t<is_uniform_point_sampling_v<DDim>,
int> = 0>
291KOKKOS_FUNCTION Coordinate<
typename DDim::continuous_dimension_type> rmax(
294 return coordinate(d.back());
297template <
class DDim, std::enable_if_t<is_uniform_point_sampling_v<DDim>,
int> = 0>
298KOKKOS_FUNCTION Coordinate<
typename DDim::continuous_dimension_type> rlength(
301 return rmax(d) - rmin(d);
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
The top-level namespace of DDC.
constexpr bool is_uniform_point_sampling_v
KOKKOS_FUNCTION std::enable_if_t< is_uniform_point_sampling_v< DDim >, DiscreteElement< DDim > > front() noexcept
Lower bound index of the mesh.
KOKKOS_FUNCTION std::enable_if_t< is_uniform_point_sampling_v< DDim >, Coordinate< typename DDim::continuous_dimension_type > > origin() noexcept
Lower bound index of the mesh.
KOKKOS_FUNCTION constexpr Coordinate< typename DDim::continuous_dimension_type > coordinate(DiscreteElement< DDim > const &c)
KOKKOS_FUNCTION std::enable_if_t< is_uniform_point_sampling_v< DDim >, Real > step() noexcept
Spacing step of the mesh.