29 const std::vector<std::string> &data_component_names,
30 const std::vector<DataComponentInterpretation::DataComponentInterpretation>
31 &data_component_interpretations_)
34 data_component_names.size() == data_component_interpretations_.size(),
36 "When calling Particles::DataOut::build_patches with data component "
37 "names and interpretations you need to provide as many data component "
38 "names as interpretations. Provide the same name for components that "
39 "belong to a single vector or tensor."));
41 if ((data_component_names.size() > 0) &&
45 particles.
begin()->has_properties(),
47 "You called Particles::DataOut::build_patches with data component "
48 "names and interpretations, but the particles do not seem to own "
52 data_component_names.size() ==
53 particles.
begin()->get_properties().size(),
55 "When calling Particles::DataOut::build_patches with data component "
56 "names and interpretations you need to provide as many data component "
57 "names as the particles have properties."));
60 dataset_names.clear();
61 dataset_names.emplace_back(
"id");
62 dataset_names.insert(dataset_names.end(),
63 data_component_names.begin(),
64 data_component_names.end());
66 data_component_interpretations.clear();
67 data_component_interpretations.emplace_back(
69 data_component_interpretations.insert(
70 data_component_interpretations.end(),
71 data_component_interpretations_.begin(),
72 data_component_interpretations_.end());
74 const unsigned int n_property_components = data_component_names.size();
75 const unsigned int n_data_components = dataset_names.size();
79 auto particle = particles.
begin();
80 for (
unsigned int i = 0; particle != particles.
end(); ++particle, ++i)
82 patches[i].vertices[0] = particle->get_location();
83 patches[i].patch_index = i;
86 patches[i].data.reinit(n_data_components, 1);
88 patches[i].data(0, 0) = particle->get_id();
90 if (n_data_components > 1)
93 for (
unsigned int property_index = 0;
94 property_index < n_property_components;
96 patches[i].data(property_index + 1, 0) =
97 properties[property_index];
131 std::tuple<
unsigned int,
140 Assert(dataset_names.size() == data_component_interpretations.size(),
144 const unsigned int n_output_components =
145 data_component_interpretations.size();
146 unsigned int output_component = 0;
147 for (
unsigned int i = 0; i < n_output_components; )
150 switch (data_component_interpretations[i])
165 i + spacedim <= n_output_components,
167 i, dataset_names[i]));
168 for (
unsigned int dd = 1; dd < spacedim; ++dd)
170 data_component_interpretations[i + dd] ==
173 ExcInvalidVectorDeclaration(i, dataset_names[i]));
178 std::string name = dataset_names[i];
179 for (
unsigned int dd = 1; dd < spacedim; ++dd)
180 if (name != dataset_names[i + dd])
190 ranges.emplace_back(std::forward_as_tuple(
192 output_component + spacedim - 1,
199 output_component += spacedim;
207 const unsigned int size = spacedim * spacedim;
211 i + size <= n_output_components,
213 i, dataset_names[i]));
214 for (
unsigned int dd = 1; dd < size; ++dd)
216 data_component_interpretations[i + dd] ==
219 ExcInvalidTensorDeclaration(i, dataset_names[i]));
224 std::string name = dataset_names[i];
225 for (
unsigned int dd = 1; dd < size; ++dd)
226 if (name != dataset_names[i + dd])
233 ranges.emplace_back(std::forward_as_tuple(
235 output_component + size - 1,
242 output_component += size;
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