26 template <
int dim,
int spacedim>
30 const std::vector<std::string> & data_component_names,
31 const std::vector<DataComponentInterpretation::DataComponentInterpretation>
32 &data_component_interpretations_)
35 data_component_names.size() == data_component_interpretations_.size(),
37 "When calling Particles::DataOut::build_patches with data component "
38 "names and interpretations you need to provide as many data component "
39 "names as interpretations. Provide the same name for components that "
40 "belong to a single vector or tensor."));
42 if ((data_component_names.size() > 0) &&
46 particles.
begin()->has_properties(),
48 "You called Particles::DataOut::build_patches with data component "
49 "names and interpretations, but the particles do not seem to own "
53 data_component_names.size() ==
54 particles.
begin()->get_properties().size(),
56 "When calling Particles::DataOut::build_patches with data component "
57 "names and interpretations you need to provide as many data component "
58 "names as the particles have properties."));
61 dataset_names.clear();
62 dataset_names.emplace_back(
"id");
63 dataset_names.insert(dataset_names.end(),
64 data_component_names.begin(),
65 data_component_names.end());
67 data_component_interpretations.clear();
68 data_component_interpretations.emplace_back(
70 data_component_interpretations.insert(
71 data_component_interpretations.end(),
72 data_component_interpretations_.begin(),
73 data_component_interpretations_.end());
75 const unsigned int n_property_components = data_component_names.size();
76 const unsigned int n_data_components = dataset_names.size();
80 auto particle = particles.
begin();
81 for (
unsigned int i = 0; particle != particles.
end(); ++particle, ++i)
83 patches[i].vertices[0] = particle->get_location();
84 patches[i].patch_index = i;
87 patches[i].data.reinit(n_data_components, 1);
89 patches[i].data(0, 0) = particle->get_id();
91 if (n_data_components > 1)
94 for (
unsigned int property_index = 0;
95 property_index < n_property_components;
97 patches[i].data(property_index + 1, 0) =
98 properties[property_index];
105 template <
int dim,
int spacedim>
106 const std::vector<DataOutBase::Patch<0, spacedim>> &
114 template <
int dim,
int spacedim>
115 std::vector<std::string>
118 return dataset_names;
123 template <
int dim,
int spacedim>
125 std::tuple<
unsigned int,
132 std::tuple<
unsigned int,
141 Assert(dataset_names.size() == data_component_interpretations.size(),
145 const unsigned int n_output_components =
146 data_component_interpretations.size();
147 unsigned int output_component = 0;
148 for (
unsigned int i = 0; i < n_output_components; )
151 switch (data_component_interpretations[i])
166 i + spacedim <= n_output_components,
168 i, dataset_names[i]));
169 for (
unsigned int dd = 1; dd < spacedim; ++dd)
171 data_component_interpretations[i + dd] ==
174 ExcInvalidVectorDeclaration(i, dataset_names[i]));
179 std::string name = dataset_names[i];
180 for (
unsigned int dd = 1; dd < spacedim; ++dd)
181 if (name != dataset_names[i + dd])
191 ranges.emplace_back(std::forward_as_tuple(
193 output_component + spacedim - 1,
200 output_component += spacedim;
208 const unsigned int size = spacedim * spacedim;
212 i + size <= n_output_components,
214 i, dataset_names[i]));
215 for (
unsigned int dd = 1; dd < size; ++dd)
217 data_component_interpretations[i + dd] ==
220 ExcInvalidTensorDeclaration(i, dataset_names[i]));
225 std::string name = dataset_names[i];
226 for (
unsigned int dd = 1; dd < size; ++dd)
227 if (name != dataset_names[i + dd])
234 ranges.emplace_back(std::forward_as_tuple(
236 output_component + size - 1,
243 output_component += size;
257#include "data_out.inst"
virtual const std::vector< DataOutBase::Patch< 0, spacedim > > & get_patches() const override
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
void build_patches(const Particles::ParticleHandler< dim, spacedim > &particles, const std::vector< std::string > &data_component_names={}, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretations={})
virtual std::vector< std::string > get_dataset_names() const override
particle_iterator begin() const
particle_iterator end() const
types::particle_index n_locally_owned_particles() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcInvalidTensorDeclaration(int arg1, std::string arg2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcInvalidVectorDeclaration(int arg1, std::string arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
DataComponentInterpretation
@ component_is_part_of_tensor
@ component_is_part_of_vector