16 #include <deal.II/base/quadrature_lib.h> 17 #include <deal.II/base/work_stream.h> 19 #include <deal.II/dofs/dof_accessor.h> 20 #include <deal.II/dofs/dof_handler.h> 22 #include <deal.II/fe/fe.h> 23 #include <deal.II/fe/fe_values.h> 24 #include <deal.II/fe/mapping_q1.h> 26 #include <deal.II/grid/tria.h> 27 #include <deal.II/grid/tria_iterator.h> 29 #include <deal.II/hp/fe_values.h> 31 #include <deal.II/lac/block_vector.h> 32 #include <deal.II/lac/vector.h> 34 #include <deal.II/numerics/data_out_rotation.h> 38 DEAL_II_NAMESPACE_OPEN
54 namespace DataOutRotationImplementation
56 template <
int dim,
int spacedim>
57 ParallelData<dim, spacedim>::ParallelData(
58 const unsigned int n_datasets,
59 const unsigned int n_subdivisions,
60 const unsigned int n_patches_per_circle,
61 const std::vector<unsigned int> &n_postprocessor_outputs,
67 :
internal::DataOutImplementation::ParallelDataBase<dim, spacedim>(
70 n_postprocessor_outputs,
75 , n_patches_per_circle(n_patches_per_circle)
84 template <
int dim,
int spacedim>
90 for (
unsigned int i = 0; i < new_patches.size(); ++i)
92 patches.push_back(new_patches[i]);
101 template <
int dim,
typename DoFHandlerType>
120 const unsigned int n_patches_per_circle = data.n_patches_per_circle;
123 const unsigned int n_points = data.n_subdivisions + 1;
129 std::vector<Point<dimension + 1>> angle_directions(n_patches_per_circle + 1);
130 for (
unsigned int i = 0; i <= n_patches_per_circle; ++i)
133 std::cos(2 *
numbers::PI * i / n_patches_per_circle);
135 std::sin(2 *
numbers::PI * i / n_patches_per_circle);
138 for (
unsigned int angle = 0; angle < n_patches_per_circle; ++angle)
147 const double r1 = (*cell)->vertex(0)(0),
148 r2 = (*cell)->vertex(1)(0);
149 Assert(r1 >= 0, ExcRadialVariableHasNegativeValues(r1));
150 Assert(r2 >= 0, ExcRadialVariableHasNegativeValues(r2));
152 my_patches[angle].vertices[0] = r1 * angle_directions[angle];
153 my_patches[angle].vertices[1] = r2 * angle_directions[angle];
154 my_patches[angle].vertices[2] = r1 * angle_directions[angle + 1];
155 my_patches[angle].vertices[3] = r2 * angle_directions[angle + 1];
162 for (
unsigned int vertex = 0;
163 vertex < GeometryInfo<dimension>::vertices_per_cell;
169 Assert(v(0) >= 0, ExcRadialVariableHasNegativeValues(v(0)));
172 my_patches[angle].vertices[vertex] =
173 v(0) * angle_directions[angle];
174 my_patches[angle].vertices[vertex][0] = v(1);
179 v(0) * angle_directions[angle + 1];
194 if (data.n_datasets > 0)
196 unsigned int offset = 0;
198 data.reinit_all_fe_values(this->
dof_data, *cell);
200 for (
unsigned int dataset = 0; dataset < this->
dof_data.size();
204 data.get_present_fe_values(dataset);
205 const unsigned int n_components =
206 fe_patch_values.
get_fe().n_components();
208 this->
dof_data[dataset]->postprocessor;
209 if (postprocessor !=
nullptr)
217 if (n_components == 1)
223 this->
dof_data[dataset]->get_function_values(
225 internal::DataOutImplementation::ComponentExtractor::
227 data.patch_values_scalar.solution_values);
229 this->
dof_data[dataset]->get_function_gradients(
231 internal::DataOutImplementation::ComponentExtractor::
233 data.patch_values_scalar.solution_gradients);
235 this->
dof_data[dataset]->get_function_hessians(
237 internal::DataOutImplementation::ComponentExtractor::
239 data.patch_values_scalar.solution_hessians);
242 data.patch_values_scalar.evaluation_points =
245 const typename DoFHandlerType::active_cell_iterator
246 dh_cell(&(*cell)->get_triangulation(),
249 this->
dof_data[dataset]->dof_handler);
250 data.patch_values_scalar
251 .template set_cell<DoFHandlerType>(dh_cell);
254 data.patch_values_scalar,
255 data.postprocessed_values[dataset]);
259 data.resize_system_vectors(n_components);
264 this->
dof_data[dataset]->get_function_values(
266 internal::DataOutImplementation::ComponentExtractor::
268 data.patch_values_system.solution_values);
270 this->
dof_data[dataset]->get_function_gradients(
272 internal::DataOutImplementation::ComponentExtractor::
274 data.patch_values_system.solution_gradients);
276 this->
dof_data[dataset]->get_function_hessians(
278 internal::DataOutImplementation::ComponentExtractor::
280 data.patch_values_system.solution_hessians);
283 data.patch_values_system.evaluation_points =
286 const typename DoFHandlerType::active_cell_iterator
287 dh_cell(&(*cell)->get_triangulation(),
290 this->
dof_data[dataset]->dof_handler);
291 data.patch_values_system
292 .template set_cell<DoFHandlerType>(dh_cell);
295 data.patch_values_system,
296 data.postprocessed_values[dataset]);
299 for (
unsigned int component = 0;
300 component < this->
dof_data[dataset]->n_output_variables;
306 for (
unsigned int x = 0; x < n_points; ++x)
307 for (
unsigned int y = 0; y < n_points; ++y)
308 my_patches[angle].data(offset + component,
310 data.postprocessed_values[dataset][x](
315 for (
unsigned int x = 0; x < n_points; ++x)
316 for (
unsigned int y = 0; y < n_points; ++y)
317 for (
unsigned int z = 0; z < n_points; ++z)
318 my_patches[angle].data(offset + component,
322 data.postprocessed_values[dataset]
332 else if (n_components == 1)
334 this->
dof_data[dataset]->get_function_values(
336 internal::DataOutImplementation::ComponentExtractor::
338 data.patch_values_scalar.solution_values);
343 for (
unsigned int x = 0; x < n_points; ++x)
344 for (
unsigned int y = 0; y < n_points; ++y)
345 my_patches[angle].data(offset, x * n_points + y) =
346 data.patch_values_scalar.solution_values[x];
350 for (
unsigned int x = 0; x < n_points; ++x)
351 for (
unsigned int y = 0; y < n_points; ++y)
352 for (
unsigned int z = 0; z < n_points; ++z)
353 my_patches[angle].data(offset,
354 x * n_points * n_points +
356 data.patch_values_scalar
357 .solution_values[x * n_points + z];
367 data.resize_system_vectors(n_components);
368 this->
dof_data[dataset]->get_function_values(
370 internal::DataOutImplementation::ComponentExtractor::
372 data.patch_values_system.solution_values);
374 for (
unsigned int component = 0; component < n_components;
380 for (
unsigned int x = 0; x < n_points; ++x)
381 for (
unsigned int y = 0; y < n_points; ++y)
382 my_patches[angle].data(offset + component,
384 data.patch_values_system.solution_values[x](
389 for (
unsigned int x = 0; x < n_points; ++x)
390 for (
unsigned int y = 0; y < n_points; ++y)
391 for (
unsigned int z = 0; z < n_points; ++z)
392 my_patches[angle].data(offset + component,
396 data.patch_values_system
397 .solution_values[x * n_points + z](
406 offset += this->
dof_data[dataset]->n_output_variables;
410 for (
unsigned int dataset = 0; dataset < this->
cell_data.size();
417 ExcMessage(
"Cell must be active for cell data"));
418 const unsigned int cell_number = std::distance(
423 this->
cell_data[dataset]->get_cell_data_value(
425 internal::DataOutImplementation::ComponentExtractor::
430 for (
unsigned int x = 0; x < n_points; ++x)
431 for (
unsigned int y = 0; y < n_points; ++y)
432 my_patches[angle].data(dataset + offset,
433 x * n_points + y) = value;
437 for (
unsigned int x = 0; x < n_points; ++x)
438 for (
unsigned int y = 0; y < n_points; ++y)
439 for (
unsigned int z = 0; z < n_points; ++z)
440 my_patches[angle].data(dataset + offset,
441 x * n_points * n_points +
442 y * n_points + z) = value;
455 template <
int dim,
typename DoFHandlerType>
458 const unsigned int n_patches_per_circle,
459 const unsigned int nnnn_subdivisions)
467 const unsigned int n_subdivisions =
469 Assert(n_subdivisions >= 1,
475 unsigned int n_datasets = this->
cell_data.size();
476 for (
unsigned int i = 0; i < this->
dof_data.size(); ++i)
477 n_datasets += this->
dof_data[i]->n_output_variables;
480 for (
unsigned int i = 0; i < this->
dof_data.size(); ++i)
481 if (this->
dof_data[i]->postprocessor)
483 this->
dof_data[i]->postprocessor->get_needed_update_flags();
488 ExcMessage(
"The update of normal vectors may not be requested for " 489 "evaluation of data on cells via DataPostprocessor."));
494 std::vector<cell_iterator> all_cells;
496 cell = next_cell(cell))
497 all_cells.push_back(cell);
505 this->
patches.reserve(all_cells.size() * n_patches_per_circle);
508 std::vector<unsigned int> n_postprocessor_outputs(this->
dof_data.size());
509 for (
unsigned int dataset = 0; dataset < this->
dof_data.size(); ++dataset)
510 if (this->
dof_data[dataset]->postprocessor)
511 n_postprocessor_outputs[dataset] =
512 this->
dof_data[dataset]->n_output_variables;
514 n_postprocessor_outputs[dataset] = 0;
518 thread_data(n_datasets,
520 n_patches_per_circle,
521 n_postprocessor_outputs,
525 std::vector<DataOutBase::Patch<dimension + 1, space_dimension + 1>>
526 new_patches(n_patches_per_circle);
527 for (
unsigned int i = 0; i < new_patches.size(); ++i)
529 new_patches[i].n_subdivisions = n_subdivisions;
530 new_patches[i].data.reinit(
531 n_datasets, Utilities::fixed_power<dimension + 1>(n_subdivisions + 1));
537 &all_cells[0] + all_cells.size(),
540 std::placeholders::_1,
541 std::placeholders::_2,
542 std::placeholders::_3),
544 append_patch_to_list<dim, space_dimension>,
545 std::placeholders::_1,
553 template <
int dim,
typename DoFHandlerType>
561 template <
int dim,
typename DoFHandlerType>
577 #include "data_out_rotation.inst" 580 DEAL_II_NAMESPACE_CLOSE
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
static::ExceptionBase & ExcNoTriangulationSelected()
cell_iterator end() const
virtual cell_iterator next_cell(const cell_iterator &cell)
static const unsigned int space_dimension
Transformed quadrature points.
void build_one_patch(const cell_iterator *cell, internal::DataOutRotationImplementation::ParallelData< dimension, space_dimension > &data, std::vector< DataOutBase::Patch< dimension+1, space_dimension+1 >> &my_patches)
unsigned int default_subdivisions
static::ExceptionBase & ExcInvalidNumberOfSubdivisions(int arg1)
static const unsigned int dimension
std::vector< std::shared_ptr< internal::DataOutImplementation::DataEntryBase< DoFHandlerType > > > dof_data
static::ExceptionBase & ExcMessage(std::string arg1)
const std::vector< Point< spacedim > > & get_quadrature_points() const
#define Assert(cond, exc)
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
Abstract base class for mapping classes.
const FiniteElement< dim, spacedim > & get_fe() const
std::vector< Patch > patches
Second derivatives of shape functions.
virtual cell_iterator first_cell()
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
virtual void build_patches(const unsigned int n_patches_per_circle, const unsigned int n_subdivisions=0)
Shape function gradients.
typename DataOut_DoFData< DoFHandlerType, dimension+1 >::cell_iterator cell_iterator
static::ExceptionBase & ExcNotImplemented()
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)
std::vector< std::shared_ptr<::hp::FECollection< DoFHandlerType::dimension, DoFHandlerType::space_dimension > > > get_fes() const
active_cell_iterator begin_active(const unsigned int level=0) const
SmartPointer< const Triangulation< DoFHandlerType::dimension, DoFHandlerType::space_dimension > > triangulation
std::vector< std::shared_ptr< internal::DataOutImplementation::DataEntryBase< DoFHandlerType > > > cell_data
void validate_dataset_names() const
TriaActiveIterator< CellAccessor< dim, spacedim >> active_cell_iterator
virtual UpdateFlags get_needed_update_flags() const =0