15#ifndef dealii_particles_particle_accessor_h
16#define dealii_particles_particle_accessor_h
43 template <
int dim,
int spacedim = dim>
101 std::vector<typename PropertyPool<dim, spacedim>::Handle>
particles;
387 template <
class Archive>
389 save(Archive &ar,
const unsigned int version)
const;
400 template <
class Archive>
402 load(Archive &ar,
const unsigned int version);
410 template <
class Archive>
412 serialize(Archive &archive,
const unsigned int version);
416 BOOST_SERIALIZATION_SPLIT_MEMBER()
506 template <
int dim,
int spacedim>
507 template <
class Archive>
511 unsigned int n_properties = 0;
516 ar &location &reference_location &
id &n_properties;
522 if (n_properties > 0)
526 properties.
size() == n_properties,
528 "This particle was serialized with " +
529 std::to_string(n_properties) +
530 " properties, but the new property handler provides space for " +
531 std::to_string(properties.
size()) +
532 " properties. Deserializing a particle only works for matching property sizes."));
534 ar &boost::serialization::make_array(properties.
data(), n_properties);
540 template <
int dim,
int spacedim>
541 template <
class Archive>
545 unsigned int n_properties = 0;
554 ar &location &reference_location &
id &n_properties;
556 if (n_properties > 0)
564 template <
int dim,
int spacedim>
573 template <
int dim,
int spacedim>
585 template <
int dim,
int spacedim>
595 const double *pdata =
reinterpret_cast<const double *
>(id_data);
598 for (
unsigned int i = 0; i < spacedim; ++i)
599 location[i] = *pdata++;
603 for (
unsigned int i = 0; i < dim; ++i)
604 reference_location[i] = *pdata++;
612 const unsigned int size = particle_properties.
size();
613 for (
unsigned int i = 0; i < size; ++i)
614 particle_properties[i] = *pdata++;
617 return static_cast<const void *
>(pdata);
622 template <
int dim,
int spacedim>
632 double *pdata =
reinterpret_cast<double *
>(id_data);
635 for (
unsigned int i = 0; i < spacedim; ++i, ++pdata)
639 for (
unsigned int i = 0; i < dim; ++i, ++pdata)
647 for (
unsigned int i = 0; i < particle_properties.
size(); ++i, ++pdata)
648 *pdata = particle_properties[i];
651 return static_cast<void *
>(pdata);
656 template <
int dim,
int spacedim>
667 template <
int dim,
int spacedim>
678 template <
int dim,
int spacedim>
689 template <
int dim,
int spacedim>
701 template <
int dim,
int spacedim>
712 template <
int dim,
int spacedim>
723 template <
int dim,
int spacedim>
734 template <
int dim,
int spacedim>
745 template <
int dim,
int spacedim>
763 template <
int dim,
int spacedim>
766 const std::vector<double> &new_properties)
776 template <
int dim,
int spacedim>
788 "You are trying to assign properties with an incompatible length. "
789 "The particle has space to store " +
790 std::to_string(property_values.
size()) +
791 " properties, but you are trying to assign " +
792 std::to_string(new_properties.
size()) +
793 " properties. This is not allowed."));
795 if (property_values.
size() > 0)
796 std::copy(new_properties.
begin(),
797 new_properties.
end(),
798 property_values.
begin());
803 template <
int dim,
int spacedim>
814 for (
unsigned int d = 0; d < dim; ++d)
815 array[d] = new_properties[d];
822 template <
int dim,
int spacedim>
833 template <
int dim,
int spacedim>
839 (void)new_property_pool;
844 template <
int dim,
int spacedim>
863 template <
int dim,
int spacedim>
869 std::size_t size =
sizeof(
get_id()) +
870 sizeof(
double) * spacedim +
871 sizeof(double) * dim;
882 template <
int dim,
int spacedim>
899 template <
int dim,
int spacedim>
918 template <
int dim,
int spacedim>
923 return !(*
this == other);
928 template <
int dim,
int spacedim>
940 template <
int dim,
int spacedim>
946 particle_index_within_cell < particles_in_cell->particles.size())
960 template <
int dim,
int spacedim>
969 template <
int dim,
int spacedim>
994 template <
int dim,
int spacedim>
1007 return accessor.get_location();
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
value_type * data() const noexcept
particle_container::iterator particles_in_cell
const Point< spacedim > & get_location() const
types::particle_index get_id() const
void save(Archive &ar, const unsigned int version) const
unsigned int particle_index_within_cell
types::particle_index get_local_index() const
std::list< ParticlesInCell > particle_container
friend class ParticleIterator
const void * read_particle_data_from_memory(const void *data)
void load(Archive &ar, const unsigned int version)
const Triangulation< dim, spacedim >::cell_iterator & get_surrounding_cell() const
IteratorState::IteratorStates state() const
bool operator!=(const ParticleAccessor< dim, spacedim > &other) const
void set_properties(const Tensor< 1, dim > &new_properties)
friend class ParticleHandler
void set_location(const Point< spacedim > &new_location)
PropertyPool< dim, spacedim >::Handle & get_handle()
void serialize(Archive &archive, const unsigned int version)
void set_property_pool(PropertyPool< dim, spacedim > &property_pool)
ArrayView< double > get_properties()
void set_reference_location(const Point< dim > &new_reference_location)
const Point< dim > & get_reference_location() const
std::size_t serialized_size_in_bytes() const
const PropertyPool< dim, spacedim >::Handle & get_handle() const
void set_properties(const std::vector< double > &new_properties)
Point< spacedim > & get_location()
ParticleAccessor(const typename particle_container::iterator particles_in_cell, const PropertyPool< dim, spacedim > &property_pool, const unsigned int particle_index_within_cell)
bool has_properties() const
PropertyPool< dim, spacedim > * property_pool
void * write_particle_data_to_memory(void *data) const
void set_properties(const ArrayView< const double > &new_properties)
ArrayView< const double > get_properties() const
bool operator==(const ParticleAccessor< dim, spacedim > &other) const
void set_id(const types::particle_index &new_id)
static const Handle invalid_handle
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
@ past_the_end
Iterator reached end of container.
@ valid
Iterator points to a valid object.
@ invalid
Iterator is invalid, probably due to an error.
unsigned int particle_index
Triangulation< dim, spacedim >::active_cell_iterator cell
ParticlesInCell()=default
ParticlesInCell(const std::vector< typename PropertyPool< dim, spacedim >::Handle > &particles, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)
std::vector< typename PropertyPool< dim, spacedim >::Handle > particles
const ::Point< spacedim > & result_type
result_type operator()(const ::Particles::ParticleAccessor< dim, spacedim > &accessor) const