37 namespace DataOutImplementation
39 template <
int dim,
int spacedim>
41 const unsigned int n_datasets,
42 const unsigned int n_subdivisions,
43 const std::vector<unsigned int> &n_postprocessor_outputs,
44 const ::hp::MappingCollection<dim, spacedim> &mapping,
49 const std::vector<std::vector<unsigned int>> &cell_to_patch_index_map)
52 n_postprocessor_outputs,
57 , cell_to_patch_index_map(&cell_to_patch_index_map)
64template <
int dim,
int spacedim>
74 while ((cell != tria.
end()) && !cell->is_locally_owned())
83 while ((cell != tria.
end()) && !cell->is_locally_owned())
91template <
int dim,
int spacedim>
94 const std::pair<cell_iterator, unsigned int> *cell_and_index,
96 const unsigned int n_subdivisions,
111 const auto vertices =
113 std::copy(vertices.begin(), vertices.end(), std::begin(patch.
vertices));
124 for (
unsigned int dataset = 0;
140 if (curved_cell_region == curved_inner_cells ||
141 (curved_cell_region == curved_boundary &&
142 (cell_and_index->first->at_boundary() || (dim != spacedim))) ||
143 (cell_and_index->first->reference_cell() !=
144 ReferenceCells::get_hypercube<dim>()))
154 const std::vector<Point<spacedim>> &q_points =
157 patch.
data.reinit(scratch_data.
n_datasets + spacedim, n_q_points);
158 for (
unsigned int i = 0; i < spacedim; ++i)
159 for (
unsigned int q = 0; q < n_q_points; ++q)
160 patch.
data(patch.
data.size(0) - spacedim + i, q) = q_points[q][i];
173 unsigned int offset = 0;
176 unsigned int dataset_number = 0;
177 for (
const auto &dataset : this->dof_data)
181 const unsigned int n_components =
185 dataset->postprocessor;
187 if (postprocessor !=
nullptr)
194 if ((n_components == 1) &&
195 (dataset->is_complex_valued() ==
false))
204 dataset->get_function_values(
205 this_fe_patch_values,
211 dataset->get_function_gradients(
212 this_fe_patch_values,
218 dataset->get_function_hessians(
219 this_fe_patch_values,
222 scratch_data.patch_values_scalar.solution_hessians);
231 dh_cell(&cell_and_index->first->get_triangulation(),
232 cell_and_index->first->level(),
233 cell_and_index->first->index(),
234 dataset->dof_handler);
255 if (dataset->is_complex_valued() ==
false)
260 dataset->get_function_values(
261 this_fe_patch_values,
264 scratch_data.patch_values_system.solution_values);
267 dataset->get_function_gradients(
268 this_fe_patch_values,
271 scratch_data.patch_values_system.solution_gradients);
274 dataset->get_function_hessians(
275 this_fe_patch_values,
278 scratch_data.patch_values_system.solution_hessians);
286 if (n_components == 1)
295 dataset->get_function_values(
296 this_fe_patch_values,
298 ComponentExtractor::real_part,
302 for (
unsigned int i = 0;
304 .solution_values.size();
313 .solution_values[i][0] =
321 dataset->get_function_gradients(
322 this_fe_patch_values,
324 ComponentExtractor::real_part,
326 .solution_gradients);
328 for (
unsigned int i = 0;
330 .solution_gradients.size();
339 .solution_gradients[i][0] =
341 .solution_gradients[i];
347 dataset->get_function_hessians(
348 this_fe_patch_values,
351 scratch_data.patch_values_scalar
354 for (
unsigned int i = 0;
356 .solution_hessians.size();
361 .solution_hessians[i]
365 .solution_hessians[i][0] =
367 .solution_hessians[i];
378 dataset->get_function_values(
379 this_fe_patch_values,
381 ComponentExtractor::imaginary_part,
385 for (
unsigned int i = 0;
387 .solution_values.size();
396 .solution_values[i][1] =
404 dataset->get_function_gradients(
405 this_fe_patch_values,
407 ComponentExtractor::imaginary_part,
408 scratch_data.patch_values_scalar
409 .solution_gradients);
411 for (
unsigned int i = 0;
413 .solution_gradients.size();
422 .solution_gradients[i][1] =
424 .solution_gradients[i];
430 dataset->get_function_hessians(
431 this_fe_patch_values,
434 scratch_data.patch_values_scalar
437 for (
unsigned int i = 0;
439 .solution_hessians.size();
444 .solution_hessians[i]
448 .solution_hessians[i][1] =
450 .solution_hessians[i];
485 std::vector<Vector<double>> tmp(
491 dataset->get_function_values(
492 this_fe_patch_values,
499 for (
unsigned int i = 0;
501 .solution_values.size();
509 for (
unsigned int j = 0; j < n_components;
512 .solution_values[i][j] = tmp[i][j];
518 dataset->get_function_values(
519 this_fe_patch_values,
524 for (
unsigned int i = 0;
526 .solution_values.size();
529 for (
unsigned int j = 0; j < n_components;
532 .solution_values[i][j + n_components] =
540 std::vector<std::vector<Tensor<1, spacedim>>> tmp(
542 .solution_gradients.size(),
546 dataset->get_function_gradients(
547 this_fe_patch_values,
552 for (
unsigned int i = 0;
554 .solution_gradients.size();
559 .solution_gradients[i]
562 for (
unsigned int j = 0; j < n_components;
565 .solution_gradients[i][j] = tmp[i][j];
569 dataset->get_function_gradients(
570 this_fe_patch_values,
575 for (
unsigned int i = 0;
577 .solution_gradients.size();
580 for (
unsigned int j = 0; j < n_components;
583 .solution_gradients[i][j + n_components] =
591 std::vector<std::vector<Tensor<2, spacedim>>> tmp(
593 .solution_gradients.size(),
597 dataset->get_function_hessians(
598 this_fe_patch_values,
603 for (
unsigned int i = 0;
605 .solution_hessians.size();
610 .solution_hessians[i]
613 for (
unsigned int j = 0; j < n_components;
616 .solution_hessians[i][j] = tmp[i][j];
620 dataset->get_function_hessians(
621 this_fe_patch_values,
626 for (
unsigned int i = 0;
628 .solution_hessians.size();
631 for (
unsigned int j = 0; j < n_components;
634 .solution_hessians[i][j + n_components] =
647 dh_cell(&cell_and_index->first->get_triangulation(),
648 cell_and_index->first->level(),
649 cell_and_index->first->index(),
650 dataset->dof_handler);
666 for (
unsigned int q = 0; q < n_q_points; ++q)
667 for (
unsigned int component = 0;
670 patch.
data(offset + component, q) =
676 offset += dataset->n_output_variables;
683 if (n_components == 1)
688 dataset->get_function_values(
689 this_fe_patch_values,
692 scratch_data.patch_values_scalar.solution_values);
693 for (
unsigned int q = 0; q < n_q_points; ++q)
694 patch.
data(offset, q) =
703 if (dataset->is_complex_valued() ==
true)
705 dataset->get_function_values(
706 this_fe_patch_values,
709 scratch_data.patch_values_scalar.solution_values);
710 for (
unsigned int q = 0; q < n_q_points; ++q)
711 patch.
data(offset, q) =
725 if (dataset->is_complex_valued() ==
false)
727 dataset->get_function_values(
728 this_fe_patch_values,
731 scratch_data.patch_values_system.solution_values);
732 for (
unsigned int component = 0;
component < n_components;
734 for (
unsigned int q = 0; q < n_q_points; ++q)
735 patch.
data(offset + component, q) =
740 offset += dataset->n_output_variables;
772 dataset->get_function_values(
773 this_fe_patch_values,
776 scratch_data.patch_values_system.solution_values);
782 Assert(dataset->data_component_interpretation.size() ==
786 unsigned int destination = offset;
787 for (
unsigned int component = 0;
792 dataset->data_component_interpretation[component])
805 for (
unsigned int q = 0; q < n_q_points;
807 patch.
data(destination, q) =
831 const unsigned int size = spacedim;
832 for (
unsigned int c = 0; c <
size; ++c)
833 for (
unsigned int q = 0; q < n_q_points;
835 patch.
data(destination + c, q) =
840 destination += 2 *
size;
849 const unsigned int size =
851 for (
unsigned int c = 0; c <
size; ++c)
852 for (
unsigned int q = 0; q < n_q_points;
854 patch.
data(destination + c, q) =
859 destination += 2 *
size;
873 dataset->get_function_values(
874 this_fe_patch_values,
877 scratch_data.patch_values_system.solution_values);
879 unsigned int destination = offset;
880 for (
unsigned int component = 0;
885 dataset->data_component_interpretation[component])
894 for (
unsigned int q = 0; q < n_q_points;
896 patch.
data(destination + 1, q) =
914 const unsigned int size = spacedim;
915 for (
unsigned int c = 0; c <
size; ++c)
916 for (
unsigned int q = 0; q < n_q_points;
918 patch.
data(destination +
size + c, q) =
923 destination += 2 *
size;
932 const unsigned int size =
934 for (
unsigned int c = 0; c <
size; ++c)
935 for (
unsigned int q = 0; q < n_q_points;
937 patch.
data(destination +
size + c, q) =
942 destination += 2 *
size;
957 offset += dataset->n_output_variables * 2;
969 if (this->cell_data.size() != 0)
973 for (
const auto &dataset : this->cell_data)
978 dataset->get_cell_data_value(cell_and_index->second,
981 for (
unsigned int q = 0; q < n_q_points; ++q)
986 if (dataset->is_complex_valued() ==
true)
988 const double value = dataset->get_cell_data_value(
989 cell_and_index->second,
992 for (
unsigned int q = 0; q < n_q_points; ++q)
996 offset += (dataset->is_complex_valued() ? 2 : 1);
1002 for (
const unsigned int f : cell_and_index->
first->face_indices())
1014 if (cell_and_index->first->at_boundary(f) ||
1015 (cell_and_index->first->neighbor(f)->level() !=
1016 cell_and_index->first->level()))
1022 const cell_iterator neighbor = cell_and_index->first->neighbor(f);
1023 Assert(
static_cast<unsigned int>(neighbor->level()) <
1026 if ((
static_cast<unsigned int>(neighbor->index()) >=
1029 [neighbor->index()] ==
1043 const unsigned int patch_idx =
1045 [cell_and_index->first->index()];
1053 this->patches[patch_idx].swap(patch);
1058template <
int dim,
int spacedim>
1065 .template get_default_linear_mapping<spacedim>(),
1072template <
int dim,
int spacedim>
1075 const unsigned int n_subdivisions_,
1080 build_patches(mapping_collection, n_subdivisions_, curved_region);
1085template <
int dim,
int spacedim>
1089 const unsigned int n_subdivisions_,
1098 const unsigned int n_subdivisions =
1099 (n_subdivisions_ != 0) ? n_subdivisions_ : this->default_subdivisions;
1100 Assert(n_subdivisions >= 1,
1104 this->validate_dataset_names();
1122 std::vector<std::vector<unsigned int>> cell_to_patch_index_map;
1123 cell_to_patch_index_map.resize(this->
triangulation->n_levels());
1124 for (
unsigned int l = 0; l < this->
triangulation->n_levels(); ++l)
1127 unsigned int max_index = 0;
1131 if (
static_cast<unsigned int>(cell->level()) == l)
1133 std::max(max_index,
static_cast<unsigned int>(cell->index()));
1135 cell_to_patch_index_map[l].resize(
1140 std::vector<std::pair<cell_iterator, unsigned int>> all_cells;
1148 unsigned int active_index = 0;
1155 while (active_cell != this->
triangulation->end() && cell->is_active() &&
1156 decltype(active_cell)(cell) != active_cell)
1162 Assert(
static_cast<unsigned int>(cell->level()) <
1163 cell_to_patch_index_map.size(),
1165 Assert(
static_cast<unsigned int>(cell->index()) <
1166 cell_to_patch_index_map[cell->level()].size(),
1170 cell_to_patch_index_map[cell->level()][cell->index()] =
1173 all_cells.emplace_back(cell, active_index);
1177 this->patches.clear();
1178 this->patches.resize(all_cells.size());
1186 unsigned int n_datasets = 0;
1187 for (
unsigned int i = 0; i < this->cell_data.size(); ++i)
1188 n_datasets += (this->cell_data[i]->is_complex_valued() &&
1189 (this->cell_data[i]->postprocessor ==
nullptr) ?
1192 for (
unsigned int i = 0; i < this->dof_data.size(); ++i)
1193 n_datasets += (this->dof_data[i]->n_output_variables *
1194 (this->dof_data[i]->is_complex_valued() &&
1195 (this->dof_data[i]->postprocessor ==
nullptr) ?
1199 std::vector<unsigned int> n_postprocessor_outputs(this->dof_data.size());
1200 for (
unsigned int dataset = 0; dataset < this->dof_data.size(); ++dataset)
1201 if (this->dof_data[dataset]->postprocessor)
1202 n_postprocessor_outputs[dataset] =
1203 this->dof_data[dataset]->n_output_variables;
1205 n_postprocessor_outputs[dataset] = 0;
1208 (n_subdivisions < 2 ? no_curved_cells : curved_region);
1211 if (curved_cell_region != no_curved_cells)
1214 for (
unsigned int i = 0; i < this->dof_data.size(); ++i)
1215 if (this->dof_data[i]->postprocessor)
1217 this->dof_data[i]->postprocessor->get_needed_update_flags();
1223 "The update of normal vectors may not be requested for evaluation of "
1224 "data on cells via DataPostprocessor."));
1229 n_postprocessor_outputs,
1233 cell_to_patch_index_map);
1235 auto worker = [
this, n_subdivisions, curved_cell_region](
1236 const std::pair<cell_iterator, unsigned int> *cell_and_index,
1242 this->build_one_patch(cell_and_index,
1245 curved_cell_region);
1249 if (all_cells.size() > 0)
1251 all_cells.data() + all_cells.size(),
1254 std::function<
void(
const int)>(),
1269template <
int dim,
int spacedim>
1277 first_cell_function = first_cell;
1278 next_cell_function = next_cell;
1283template <
int dim,
int spacedim>
1288 const auto first_cell =
1299 const auto next_cell =
1319 set_cell_selection(first_cell, next_cell);
1324template <
int dim,
int spacedim>
1325std::pair<typename DataOut<dim, spacedim>::FirstCellFunctionType,
1329 return std::make_pair(first_cell_function, next_cell_function);
1335#include "numerics/data_out.inst"
virtual void build_patches(const unsigned int n_subdivisions=0)
typename std::function< cell_iterator(const Triangulation< dim, spacedim > &, const cell_iterator &)> NextCellFunctionType
void build_one_patch(const std::pair< cell_iterator, unsigned int > *cell_and_index, internal::DataOutImplementation::ParallelData< dim, spacedim > &scratch_data, const unsigned int n_subdivisions, const CurvedCellRegion curved_cell_region)
typename DataOut_DoFData< dim, dim, spacedim, spacedim >::cell_iterator cell_iterator
void set_cell_selection(const std::function< cell_iterator(const Triangulation< dim, spacedim > &)> &first_cell, const std::function< cell_iterator(const Triangulation< dim, spacedim > &, const cell_iterator &)> &next_cell)
std::pair< FirstCellFunctionType, NextCellFunctionType > get_cell_selection() const
virtual UpdateFlags get_needed_update_flags() const =0
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double > > &computed_quantities) const
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double > > &computed_quantities) const
const std::vector< Point< spacedim > > & get_quadrature_points() const
const Mapping< dim, spacedim > & get_mapping() const
const unsigned int n_quadrature_points
const FiniteElement< dim, spacedim > & get_fe() const
FilteredIterator & set_to_next_positive(const BaseIterator &bi)
unsigned int n_components() const
Abstract base class for mapping classes.
virtual boost::container::small_vector< Point< spacedim >, ReferenceCells::max_n_vertices< dim >() > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
static unsigned int n_threads()
cell_iterator end() const
active_cell_iterator begin_active(const unsigned int level=0) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcInvalidNumberOfSubdivisions(int arg1)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNoTriangulationSelected()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
@ component_is_part_of_tensor
@ component_is_part_of_vector
* * * ScaleZFunction< dim, Number, components >::ScaleZFunction * component(component)
void run(const std::vector< std::vector< Iterator > > &colored_iterators, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length=2 *MultithreadInfo::n_threads(), const unsigned int chunk_size=8)
constexpr unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
ReferenceCell< dim > reference_cell
static const unsigned int space_dim
unsigned int n_subdivisions
std::array< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > vertices
bool points_are_available
std::array< unsigned int, GeometryInfo< dim >::faces_per_cell > neighbors
const FEValuesBase< dim, spacedim > & get_present_fe_values(const unsigned int dataset) const
const unsigned int n_datasets
DataPostprocessorInputs::Scalar< spacedim > patch_values_scalar
std::vector< std::vector<::Vector< double > > > postprocessed_values
DataPostprocessorInputs::Vector< spacedim > patch_values_system
void reinit_all_fe_values(std::vector< std::shared_ptr< DataEntryBase< dim, spacedim > > > &dof_data, const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face=numbers::invalid_unsigned_int)
void resize_system_vectors(const unsigned int n_components)
const std::vector< std::vector< unsigned int > > * cell_to_patch_index_map
ParallelData(const unsigned int n_datasets, const unsigned int n_subdivisions, const std::vector< unsigned int > &n_postprocessor_outputs, const ::hp::MappingCollection< dim, spacedim > &mapping, const std::vector< std::shared_ptr<::hp::FECollection< dim, spacedim > > > &finite_elements, const UpdateFlags update_flags, const std::vector< std::vector< unsigned int > > &cell_to_patch_index_map)