Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana_Grid_ParticleList.hpp
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2018-2023 by the Cabana authors *
3 * All rights reserved. *
4 * *
5 * This file is part of the Cabana library. Cabana is distributed under a *
6 * BSD 3-clause license. For the licensing terms see the LICENSE file in *
7 * the top-level directory. *
8 * *
9 * SPDX-License-Identifier: BSD-3-Clause *
10 ****************************************************************************/
11
16#ifndef CABANA_GRID_PARTICLELIST_HPP
17#define CABANA_GRID_PARTICLELIST_HPP
18
19#include <Cabana_AoSoA.hpp>
22#include <Cabana_SoA.hpp>
23#include <Cabana_Tuple.hpp>
24
26
27#include <memory>
28#include <string>
29#include <type_traits>
30
31namespace Cabana
32{
33namespace Grid
34{
35
36//---------------------------------------------------------------------------//
38template <class MemorySpace, int VectorLength, class... FieldTags>
40 : public Cabana::ParticleList<MemorySpace, VectorLength, FieldTags...>
41{
42 public:
44 using memory_space = MemorySpace;
46 using base = Cabana::ParticleList<memory_space, VectorLength, FieldTags...>;
47
49 using traits = typename base::traits;
51 using aosoa_type = typename base::aosoa_type;
53 using tuple_type = typename base::tuple_type;
58 template <std::size_t M>
59 using slice_type = typename aosoa_type::template member_slice_type<M>;
64
66 ParticleList( const std::string& label )
67 : base( label )
68 {
69 }
70
75 template <class LocalGridType>
76 bool redistribute( const LocalGridType& local_grid,
77 const bool force_redistribute = false )
78 {
79 return redistribute(
81 force_redistribute );
82 }
83
89 template <class PositionFieldTag, class LocalGridType>
90 bool redistribute( const LocalGridType& local_grid, PositionFieldTag,
91 const bool force_redistribute = false )
92 {
93 return particleMigrate( local_grid, this->slice( PositionFieldTag() ),
94 _aosoa, local_grid.haloCellWidth(),
95 force_redistribute );
96 }
97
98 protected:
100 using base::_aosoa;
101};
102
103template <class>
104struct is_particle_list_impl : public std::false_type
105{
106};
107
108template <class MemorySpace, int VectorLength, class... FieldTags>
110 ParticleList<MemorySpace, VectorLength, FieldTags...>>
111 : public std::true_type
112{
113};
114
116template <class T>
118 : public is_particle_list_impl<typename std::remove_cv<T>::type>::type
119{
120};
121
122//---------------------------------------------------------------------------//
127template <class MemorySpace, int VectorLength, class... FieldTags>
128auto createParticleList( const std::string& label,
130{
131 return ParticleList<MemorySpace, VectorLength, FieldTags...>( label );
132}
133
138template <class MemorySpace, class... FieldTags>
139auto createParticleList( const std::string& label,
141{
142 return ParticleList<
143 MemorySpace,
145 typename MemorySpace::execution_space>::vector_length,
146 FieldTags...>( label );
147}
148
149//---------------------------------------------------------------------------//
150
151} // namespace Grid
152} // namespace Cabana
153
154#endif // end CABANA_GRID_PARTICLELIST_HPP
Array-of-Struct-of-Arrays particle data structure.
Multi-node particle redistribution using the grid halo.
bool particleMigrate(const LocalGridType &local_grid, const ParticlePositions &positions, ParticleContainer &particles, const int min_halo_width, const bool force_migrate=false)
Migrate data from one uniquely-owned decomposition to another uniquely-owned decomposition,...
Definition Cabana_Grid_ParticleDistributor.hpp:288
auto createParticleList(const std::string &label, Cabana::ParticleTraits< FieldTags... >)
ParticleList creation function.
Definition Cabana_Grid_ParticleList.hpp:128
AoSoA tuple member types.
Application-level particle storage and single particle access.
Struct-of-Arrays for building AoSoA.
Tuple of single particle information to build AoSoA.
List of particle fields stored in AoSoA with associated mesh.
Definition Cabana_Grid_ParticleList.hpp:41
typename base::tuple_type tuple_type
Particle tuple type.
Definition Cabana_Grid_ParticleList.hpp:53
typename base::traits traits
Particle AoSoA member types.
Definition Cabana_Grid_ParticleList.hpp:49
aosoa_type _aosoa
Particle AoSoA.
Definition Cabana_ParticleList.hpp:263
MemorySpace memory_space
Kokkos memory space.
Definition Cabana_Grid_ParticleList.hpp:44
ParticleList(const std::string &label)
Default constructor.
Definition Cabana_Grid_ParticleList.hpp:66
typename base::particle_view_type particle_view_type
Single SoA type.
Definition Cabana_Grid_ParticleList.hpp:63
typename base::aosoa_type aosoa_type
AoSoA type.
Definition Cabana_Grid_ParticleList.hpp:51
bool redistribute(const LocalGridType &local_grid, const bool force_redistribute=false)
Redistribute particles to new owning grids.
Definition Cabana_Grid_ParticleList.hpp:76
bool redistribute(const LocalGridType &local_grid, PositionFieldTag, const bool force_redistribute=false)
Redistribute particles to new owning grids with explicit field.
Definition Cabana_Grid_ParticleList.hpp:90
typename base::particle_type particle_type
Single particle type.
Definition Cabana_Grid_ParticleList.hpp:61
typename aosoa_type::template member_slice_type< M > slice_type
Single field slice type.
Definition Cabana_Grid_ParticleList.hpp:59
Cabana::ParticleList< memory_space, VectorLength, FieldTags... > base
Base Cabana particle list type.
Definition Cabana_Grid_ParticleList.hpp:46
Default settings for execution spaces.
Definition Cabana_PerformanceTraits.hpp:32
List of particle fields stored in AoSoA.
Definition Cabana_ParticleList.hpp:179
Particle< FieldTags... > particle_type
Definition Cabana_ParticleList.hpp:198
aosoa_type _aosoa
Definition Cabana_ParticleList.hpp:263
const std::string & label() const
Definition Cabana_ParticleList.hpp:250
ParticleTraits< FieldTags... > traits
Definition Cabana_ParticleList.hpp:184
typename aosoa_type::tuple_type tuple_type
Definition Cabana_ParticleList.hpp:190
ParticleView< aosoa_type::vector_length, FieldTags... > particle_view_type
Definition Cabana_ParticleList.hpp:200
slice_type< TypeIndexer< FieldTag, FieldTags... >::index > slice(FieldTag) const
Definition Cabana_ParticleList.hpp:255
Cabana::AoSoA< member_types, memory_space, VectorLength > aosoa_type
Definition Cabana_ParticleList.hpp:188
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
Particle position field type.
Definition Cabana_Fields.hpp:92
Definition Cabana_Grid_ParticleList.hpp:105
ParticleList static type checker.
Definition Cabana_Grid_ParticleList.hpp:119
Extract AoSoA particle fields for ParticleList.
Definition Cabana_ParticleList.hpp:35