27 const std::vector<std::string> &data_component_names,
28 const std::vector<DataComponentInterpretation::DataComponentInterpretation>
29 &data_component_interpretations_)
32 data_component_names.size() == data_component_interpretations_.size(),
34 "When calling Particles::DataOut::build_patches with data component "
35 "names and interpretations you need to provide as many data component "
36 "names as interpretations. Provide the same name for components that "
37 "belong to a single vector or tensor."));
39 if ((data_component_names.size() > 0) &&
43 particles.
begin()->has_properties(),
45 "You called Particles::DataOut::build_patches with data component "
46 "names and interpretations, but the particles do not seem to own "
50 data_component_names.size() ==
51 particles.
begin()->get_properties().size(),
53 "When calling Particles::DataOut::build_patches with data component "
54 "names and interpretations you need to provide as many data component "
55 "names as the particles have properties."));
58 dataset_names.clear();
59 dataset_names.emplace_back(
"id");
60 dataset_names.insert(dataset_names.end(),
61 data_component_names.begin(),
62 data_component_names.end());
64 data_component_interpretations.clear();
65 data_component_interpretations.emplace_back(
67 data_component_interpretations.insert(
68 data_component_interpretations.end(),
69 data_component_interpretations_.begin(),
70 data_component_interpretations_.end());
72 const unsigned int n_property_components = data_component_names.size();
73 const unsigned int n_data_components = dataset_names.size();
77 auto particle = particles.
begin();
78 for (
unsigned int i = 0; particle != particles.
end(); ++particle, ++i)
80 patches[i].vertices[0] = particle->get_location();
81 patches[i].patch_index = i;
84 patches[i].data.reinit(n_data_components, 1);
86 patches[i].data(0, 0) = particle->get_id();
88 if (n_data_components > 1)
91 for (
unsigned int property_index = 0;
92 property_index < n_property_components;
94 patches[i].
data(property_index + 1, 0) =
95 properties[property_index];
129 std::tuple<
unsigned int,
138 Assert(dataset_names.size() == data_component_interpretations.size(),
142 const unsigned int n_output_components =
143 data_component_interpretations.size();
144 unsigned int output_component = 0;
145 for (
unsigned int i = 0; i < n_output_components; )
148 switch (data_component_interpretations[i])
163 i + spacedim <= n_output_components,
165 i, dataset_names[i]));
166 for (
unsigned int dd = 1; dd < spacedim; ++dd)
168 data_component_interpretations[i + dd] ==
171 ExcInvalidVectorDeclaration(i, dataset_names[i]));
176 std::string name = dataset_names[i];
177 for (
unsigned int dd = 1; dd < spacedim; ++dd)
178 if (name != dataset_names[i + dd])
188 ranges.emplace_back(std::forward_as_tuple(
190 output_component + spacedim - 1,
197 output_component += spacedim;
205 const unsigned int size = spacedim * spacedim;
209 i +
size <= n_output_components,
211 i, dataset_names[i]));
212 for (
unsigned int dd = 1; dd <
size; ++dd)
214 data_component_interpretations[i + dd] ==
217 ExcInvalidTensorDeclaration(i, dataset_names[i]));
222 std::string name = dataset_names[i];
223 for (
unsigned int dd = 1; dd <
size; ++dd)
224 if (name != dataset_names[i + dd])
231 ranges.emplace_back(std::forward_as_tuple(
233 output_component +
size - 1,
240 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