22 const std::size_t offset,
23 const std::vector<std::vector<double>> &
data,
24 const std::vector<std::string> &data_component_names,
25 const std::vector<DataComponentInterpretation::DataComponentInterpretation>
26 &data_component_interpretations_)
29 data_component_names.size() == data_component_interpretations_.size(),
31 "When calling PointDataOut::build_patches() with data component "
32 "names and interpretations you need to provide as many data component "
33 "names as interpretations. Provide the same name for components that "
34 "belong to a single vector or tensor."));
38 "You need to either provide no data or data for each point."));
39 for (
const auto &datum :
data)
40 Assert(datum.size() == data_component_names.size(),
42 "The data provided in each point needs to have the same number "
43 "of components as names were provided."));
46 dataset_names.clear();
47 dataset_names.emplace_back(
"id");
48 dataset_names.insert(dataset_names.end(),
49 data_component_names.begin(),
50 data_component_names.end());
52 data_component_interpretations.clear();
53 data_component_interpretations.emplace_back(
55 data_component_interpretations.insert(data_component_interpretations.end(),
56 data_component_interpretations_.begin(),
57 data_component_interpretations_.end());
59 const unsigned int n_property_components = data_component_names.size();
60 const unsigned int n_data_components = dataset_names.size();
62 patches.resize(locations.size());
64 for (
unsigned int i = 0; i < locations.size(); ++i)
66 patches[i].vertices[0] = locations[i];
67 patches[i].patch_index = i;
70 patches[i].data.reinit(n_data_components, 1);
71 patches[i].data(0, 0) =
static_cast<float>(offset + i);
72 for (
unsigned int property_index = 0;
73 property_index < n_property_components;
75 patches[i].
data(property_index + 1, 0) =
data[i][property_index];
108 std::tuple<
unsigned int,
117 Assert(dataset_names.size() == data_component_interpretations.size(),
120 const unsigned int n_output_components =
121 data_component_interpretations.size();
122 unsigned int output_component = 0;
123 for (
unsigned int i = 0; i < n_output_components; )
124 switch (data_component_interpretations[i])
139 i + spacedim <= n_output_components,
141 i, dataset_names[i]));
142 for (
unsigned int dd = 1; dd < spacedim; ++dd)
144 data_component_interpretations[i + dd] ==
147 i, dataset_names[i]));
152 std::string name = dataset_names[i];
153 for (
unsigned int dd = 1; dd < spacedim; ++dd)
154 if (name != dataset_names[i + dd])
164 ranges.emplace_back(std::forward_as_tuple(
166 output_component + spacedim - 1,
173 output_component += spacedim;
181 const unsigned int size = spacedim * spacedim;
185 i +
size <= n_output_components,
187 i, dataset_names[i]));
188 for (
unsigned int dd = 1; dd <
size; ++dd)
190 data_component_interpretations[i + dd] ==
193 i, dataset_names[i]));
198 std::string name = dataset_names[i];
199 for (
unsigned int dd = 1; dd <
size; ++dd)
200 if (name != dataset_names[i + dd])
207 ranges.emplace_back(std::forward_as_tuple(
209 output_component +
size - 1,
216 output_component +=
size;
void build_patches(const std::vector< Point< spacedim > > &locations, const std::size_t offset=0, const std::vector< std::vector< double > > &data={}, const std::vector< std::string > &data_component_names={}, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretations={})