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;
85 patches[i].n_subdivisions = 1;
88 patches[i].data.reinit(n_data_components, 1);
90 patches[i].data(0, 0) = particle->get_id();
92 if (n_data_components > 1)
95 for (
unsigned int property_index = 0;
96 property_index < n_property_components;
98 patches[i].data(property_index + 1, 0) =
99 properties[property_index];
106 template <
int dim,
int spacedim>
107 const std::vector<DataOutBase::Patch<0, spacedim>> &
115 template <
int dim,
int spacedim>
116 std::vector<std::string>
119 return dataset_names;
124 template <
int dim,
int spacedim>
126 std::tuple<
unsigned int,
133 std::tuple<
unsigned int,
142 Assert(dataset_names.size() == data_component_interpretations.size(),
146 const unsigned int n_output_components =
147 data_component_interpretations.size();
148 unsigned int output_component = 0;
149 for (
unsigned int i = 0; i < n_output_components; )
152 switch (data_component_interpretations[i])
167 i + spacedim <= n_output_components,
169 i, dataset_names[i]));
170 for (
unsigned int dd = 1; dd < spacedim; ++dd)
172 data_component_interpretations[i + dd] ==
180 std::string name = dataset_names[i];
181 for (
unsigned int dd = 1; dd < spacedim; ++dd)
182 if (name != dataset_names[i + dd])
192 ranges.emplace_back(std::forward_as_tuple(
194 output_component + spacedim - 1,
201 output_component += spacedim;
209 const unsigned int size = spacedim * spacedim;
213 i + size <= n_output_components,
215 i, dataset_names[i]));
216 for (
unsigned int dd = 1; dd < size; ++dd)
218 data_component_interpretations[i + dd] ==
226 std::string name = dataset_names[i];
227 for (
unsigned int dd = 1; dd < size; ++dd)
228 if (name != dataset_names[i + dd])
235 ranges.emplace_back(std::forward_as_tuple(
237 output_component + size - 1,
244 output_component += size;
258#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