1#ifndef __CORE_POST_PROCESS_PUBLIC_HPP__
2#define __CORE_POST_PROCESS_PUBLIC_HPP__
3#include "Kokkos_Core_fwd.hpp"
4#include "common/common.hpp"
5#include "mc/traits.hpp"
6#include <Kokkos_Core.hpp>
8#include <mc/particles_container.hpp>
10template <
typename MemorySpace>
11using ParticlePropertyViewType = Kokkos::View<double**, Kokkos::LayoutRight, MemorySpace>;
14 Kokkos::Subview<ParticlePropertyViewType<ComputeSpace>,
decltype(Kokkos::ALL), std::size_t>;
24 template <HasExportPropertiesFull Model,
typename ExecutionSpace>
27 const typename Model::SelfParticle& model,
28 ParticlePropertyViewType<ComputeSpace>& particle_values,
29 ParticlePropertyViewType<ComputeSpace>& spatial_values)
31 Kokkos::Experimental::ScatterView<double**, Kokkos::LayoutRight, ComputeSpace>
32 scatter_spatial_values(spatial_values);
35 "kernel_get_properties",
36 Kokkos::RangePolicy<ExecutionSpace>(0, n_p),
37 KOKKOS_LAMBDA(
const int i_particle) {
38 auto access = scatter_spatial_values.access();
40 for (std::size_t i = 0; i < Model::n_var; ++i)
42 access(i, position(i_particle)) += model(i_particle, i);
43 particle_values(i, i_particle) = model(i_particle, i);
45 auto mass = Model::mass(i_particle, model);
46 access(Model::n_var, position(i_particle)) += mass;
47 particle_values(Model::n_var, i_particle) = mass;
50 Kokkos::Experimental::contribute(spatial_values, scatter_spatial_values);
53 template <HasExportPropertiesPartial Model,
typename ExecutionSpace>
56 const typename Model::SelfParticle& model,
57 ParticlePropertyViewType<ComputeSpace>& particle_values,
58 ParticlePropertyViewType<ComputeSpace>& spatial_values)
60 Kokkos::Experimental::ScatterView<double**, Kokkos::LayoutRight, ComputeSpace>
61 scatter_spatial_values(spatial_values);
62 static const auto indices = Model::get_number();
64 static Kokkos::View<size_t*,HostSpace> host_index(
"host_index",indices.size());
66 for(
auto i =0;i< indices.size();++i)
68 host_index(i)=indices[i];
71 const Kokkos::View<const size_t*,ComputeSpace> kindices = Kokkos::create_mirror_view_and_copy(ComputeSpace(), host_index);
74 "kernel_get_properties",
75 Kokkos::RangePolicy<ExecutionSpace>(0, n_p),
76 KOKKOS_LAMBDA(
const int i_particle) {
77 auto access = scatter_spatial_values.access();
79 for (
int i = 0; i < kindices.extent(0); ++i)
81 auto index_export = kindices(i);
82 access(i, position(i_particle)) += model(i_particle, index_export);
83 particle_values(i, i_particle) = model(i_particle, index_export);
85 auto mass = Model::mass(i_particle, model);
86 access(kindices.extent(0), position(i_particle)) += mass;
87 particle_values(kindices.extent(0), i_particle) = mass;
90 Kokkos::Experimental::contribute(spatial_values, scatter_spatial_values);
93 template <ModelType M>
94 std::optional<PostProcessing::BonceBuffer>
101 const std::size_t n_p =
104 auto ar = M::names();
105 properties.
vnames = std::vector<std::string>(ar.begin(), ar.end());
106 properties.
vnames.emplace_back(
"mass");
108 size_t n_var = M::n_var + 1;
111 n_var = ar.size() + 1;
113 ParticlePropertyViewType<ComputeSpace> spatial_values(
114 "property_spatial", n_var, n_compartment);
115 ParticlePropertyViewType<ComputeSpace> particle_values(
"property_values", n_var, n_p);
121 n_p, container.
position, container.
model, particle_values, spatial_values);
127 n_p, container.
position, container.
model, particle_values, spatial_values);
131 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), particle_values);
133 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), spatial_values);
Main owning object for Monte-Carlo particles.
Definition particles_container.hpp:128
Model::SelfParticle model
Definition particles_container.hpp:139
KOKKOS_INLINE_FUNCTION std::size_t n_particles() const
Gets the number of particles in the container.
Definition particles_container.hpp:161
MC::ParticlePositions position
Definition particles_container.hpp:140
Definition traits.hpp:101
Kokkos::View< uint64_t *, ComputeSpace > ParticlePositions
Definition alias.hpp:19
Definition impl_post_process.hpp:17
void inner_partial(std::size_t n_p, const MC::ParticlePositions &position, const typename Model::SelfParticle &model, ParticlePropertyViewType< ComputeSpace > &particle_values, ParticlePropertyViewType< ComputeSpace > &spatial_values)
Definition post_process.hpp:54
std::optional< PostProcessing::BonceBuffer > get_properties(const MC::ParticlesContainer< M > &container, const std::size_t n_compartment)
Definition post_process.hpp:95
void inner(std::size_t n_p, const MC::ParticlePositions &position, const typename Model::SelfParticle &model, ParticlePropertyViewType< ComputeSpace > &particle_values, ParticlePropertyViewType< ComputeSpace > &spatial_values)
Definition post_process.hpp:25
Definition post_process.hpp:18
ParticlePropertyViewType< HostSpace > spatial_values
Definition post_process.hpp:20
std::vector< std::string > vnames
Definition post_process.hpp:21
ParticlePropertyViewType< HostSpace > particle_values
Definition post_process.hpp:19