Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
particle_accessor.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/particles/particle_accessor.h>
17 
18 DEAL_II_NAMESPACE_OPEN
19 
20 namespace Particles
21 {
22  template <int dim, int spacedim>
24  : map(nullptr)
25  , particle()
26  {}
27 
28 
29 
30  template <int dim, int spacedim>
32  const std::multimap<internal::LevelInd, Particle<dim, spacedim>> &map,
33  const typename std::multimap<internal::LevelInd,
34  Particle<dim, spacedim>>::iterator & particle)
35  : map(const_cast<
36  std::multimap<internal::LevelInd, Particle<dim, spacedim>> *>(&map))
37  , particle(particle)
38  {}
39 
40 
41 
42  template <int dim, int spacedim>
43  void
45  {
46  Assert(particle != map->end(), ExcInternalError());
47 
48  particle->second.write_data(data);
49  }
50 
51 
52 
53  template <int dim, int spacedim>
54  void
56  {
57  Assert(particle != map->end(), ExcInternalError());
58 
59  particle->second.set_location(new_loc);
60  }
61 
62 
63 
64  template <int dim, int spacedim>
65  const Point<spacedim> &
67  {
68  Assert(particle != map->end(), ExcInternalError());
69 
70  return particle->second.get_location();
71  }
72 
73 
74 
75  template <int dim, int spacedim>
76  void
78  const Point<dim> &new_loc)
79  {
80  Assert(particle != map->end(), ExcInternalError());
81 
82  particle->second.set_reference_location(new_loc);
83  }
84 
85 
86 
87  template <int dim, int spacedim>
88  const Point<dim> &
90  {
91  Assert(particle != map->end(), ExcInternalError());
92 
93  return particle->second.get_reference_location();
94  }
95 
96 
97 
98  template <int dim, int spacedim>
101  {
102  Assert(particle != map->end(), ExcInternalError());
103 
104  return particle->second.get_id();
105  }
106 
107 
108 
109  template <int dim, int spacedim>
110  void
112  PropertyPool &new_property_pool)
113  {
114  Assert(particle != map->end(), ExcInternalError());
115 
116  particle->second.set_property_pool(new_property_pool);
117  }
118 
119 
120 
121  template <int dim, int spacedim>
122  bool
124  {
125  Assert(particle != map->end(), ExcInternalError());
126 
127  return particle->second.has_properties();
128  }
129 
130 
131 
132  template <int dim, int spacedim>
133  void
135  const std::vector<double> &new_properties)
136  {
137  Assert(particle != map->end(), ExcInternalError());
138 
139  particle->second.set_properties(new_properties);
140  return;
141  }
142 
143 
144 
145  template <int dim, int spacedim>
148  {
149  Assert(particle != map->end(), ExcInternalError());
150 
151  return particle->second.get_properties();
152  }
153 
154 
155 
156  template <int dim, int spacedim>
159  const Triangulation<dim, spacedim> &triangulation) const
160  {
161  Assert(particle != map->end(), ExcInternalError());
162 
164  &triangulation, particle->first.first, particle->first.second);
165  return cell;
166  }
167 
168 
169 
170  template <int dim, int spacedim>
171  const ArrayView<double>
173  {
174  Assert(particle != map->end(), ExcInternalError());
175 
176  return particle->second.get_properties();
177  }
178 
179 
180 
181  template <int dim, int spacedim>
182  std::size_t
184  {
185  Assert(particle != map->end(), ExcInternalError());
186 
187  return particle->second.serialized_size_in_bytes();
188  }
189 
190 
191 
192  template <int dim, int spacedim>
193  void
195  {
196  Assert(particle != map->end(), ExcInternalError());
197  ++particle;
198  }
199 
200 
201 
202  template <int dim, int spacedim>
203  void
205  {
206  Assert(particle != map->begin(), ExcInternalError());
207  --particle;
208  }
209 
210 
211 
212  template <int dim, int spacedim>
213  bool
216  {
217  return (map != other.map) || (particle != other.particle);
218  }
219 
220 
221 
222  template <int dim, int spacedim>
223  bool
226  {
227  return (map == other.map) && (particle == other.particle);
228  }
229 } // namespace Particles
230 
231 DEAL_II_NAMESPACE_CLOSE
232 
233 DEAL_II_NAMESPACE_OPEN
234 
235 #include "particle_accessor.inst"
236 
237 DEAL_II_NAMESPACE_CLOSE
std::multimap< internal::LevelInd, Particle< dim, spacedim > > * map
std::multimap< internal::LevelInd, Particle< dim, spacedim > >::iterator particle
const Point< spacedim > & get_location() const
void set_property_pool(PropertyPool &property_pool)
void set_reference_location(const Point< dim > &new_reference_location)
const ArrayView< double > get_properties()
STL namespace.
Triangulation< dim, spacedim >::cell_iterator get_surrounding_cell(const Triangulation< dim, spacedim > &triangulation) const
unsigned int particle_index
Definition: particle.h:64
const Point< dim > & get_reference_location() const
types::particle_index get_id() const
void write_data(void *&data) const
#define Assert(cond, exc)
Definition: exceptions.h:1407
void set_location(const Point< spacedim > &new_location)
void set_properties(const std::vector< double > &new_properties)
std::size_t serialized_size_in_bytes() const
bool operator==(const ParticleAccessor< dim, spacedim > &other) const
bool operator!=(const ParticleAccessor< dim, spacedim > &other) const
static ::ExceptionBase & ExcInternalError()