16 #include <deal.II/base/quadrature_lib.h> 17 #include <deal.II/base/work_stream.h> 18 #include <deal.II/lac/vector.h> 19 #include <deal.II/lac/block_vector.h> 20 #include <deal.II/grid/tria.h> 21 #include <deal.II/dofs/dof_handler.h> 22 #include <deal.II/dofs/dof_accessor.h> 23 #include <deal.II/grid/tria_iterator.h> 24 #include <deal.II/fe/fe.h> 25 #include <deal.II/fe/fe_values.h> 26 #include <deal.II/hp/fe_values.h> 27 #include <deal.II/fe/mapping_q1.h> 28 #include <deal.II/numerics/data_out_rotation.h> 32 DEAL_II_NAMESPACE_OPEN
48 namespace DataOutRotationImplementation
50 template <
int dim,
int spacedim>
51 ParallelData<dim,spacedim>::
52 ParallelData (
const unsigned int n_datasets,
53 const unsigned int n_subdivisions,
54 const unsigned int n_patches_per_circle,
55 const std::vector<unsigned int> &n_postprocessor_outputs,
61 ParallelDataBase<dim,spacedim> (n_datasets,
63 n_postprocessor_outputs,
68 n_patches_per_circle (n_patches_per_circle)
77 template <
int dim,
int spacedim>
82 for (
unsigned int i=0; i<new_patches.size(); ++i)
84 patches.push_back (new_patches[i]);
85 patches.back().patch_index = patches.size()-1;
93 template <
int dim,
typename DoFHandlerType>
108 Assert ((*cell)->is_locally_owned(),
111 const unsigned int n_patches_per_circle = data.n_patches_per_circle;
114 const unsigned int n_points = data.n_subdivisions+1;
120 std::vector<Point<dimension+1> > angle_directions (n_patches_per_circle+1);
121 for (
unsigned int i=0; i<=n_patches_per_circle; ++i)
123 angle_directions[i][dimension-1] = std::cos(2*
numbers::PI *
124 i/n_patches_per_circle);
125 angle_directions[i][dimension] = std::sin(2*
numbers::PI *
126 i/n_patches_per_circle);
129 for (
unsigned int angle=0; angle<n_patches_per_circle; ++angle)
138 const double r1 = (*cell)->vertex(0)(0),
139 r2 = (*cell)->vertex(1)(0);
140 Assert (r1 >= 0, ExcRadialVariableHasNegativeValues(r1));
141 Assert (r2 >= 0, ExcRadialVariableHasNegativeValues(r2));
143 my_patches[angle].vertices[0] = r1*angle_directions[angle];
144 my_patches[angle].vertices[1] = r2*angle_directions[angle];
145 my_patches[angle].vertices[2] = r1*angle_directions[angle+1];
146 my_patches[angle].vertices[3] = r2*angle_directions[angle+1];
153 for (
unsigned int vertex=0;
154 vertex<GeometryInfo<dimension>::vertices_per_cell;
160 Assert (v(0) >= 0, ExcRadialVariableHasNegativeValues(v(0)));
163 my_patches[angle].vertices[vertex] = v(0) * angle_directions[angle];
164 my_patches[angle].vertices[vertex][0] = v(1);
167 = v(0) * angle_directions[angle+1];
180 if (data.n_datasets > 0)
182 unsigned int offset=0;
184 data.reinit_all_fe_values(this->dof_data, *cell);
186 for (
unsigned int dataset=0; dataset<this->dof_data.size(); ++dataset)
189 = data.get_present_fe_values(dataset);
191 = fe_patch_values.
get_fe().n_components();
193 if (postprocessor !=
nullptr)
206 this->dof_data[dataset]->get_function_values (fe_patch_values,
207 internal::DataOutImplementation::ComponentExtractor::real_part,
208 data.patch_values_scalar.solution_values);
210 this->dof_data[dataset]->get_function_gradients (fe_patch_values,
211 internal::DataOutImplementation::ComponentExtractor::real_part,
212 data.patch_values_scalar.solution_gradients);
214 this->dof_data[dataset]->get_function_hessians (fe_patch_values,
215 internal::DataOutImplementation::ComponentExtractor::real_part,
216 data.patch_values_scalar.solution_hessians);
221 const typename DoFHandlerType::active_cell_iterator dh_cell(&(*cell)->get_triangulation(),
224 this->dof_data[dataset]->dof_handler);
225 data.patch_values_scalar.template set_cell<DoFHandlerType> (dh_cell);
228 evaluate_scalar_field(data.patch_values_scalar,
229 data.postprocessed_values[dataset]);
238 this->dof_data[dataset]->get_function_values (fe_patch_values,
239 internal::DataOutImplementation::ComponentExtractor::real_part,
240 data.patch_values_system.solution_values);
242 this->dof_data[dataset]->get_function_gradients (fe_patch_values,
243 internal::DataOutImplementation::ComponentExtractor::real_part,
244 data.patch_values_system.solution_gradients);
246 this->dof_data[dataset]->get_function_hessians (fe_patch_values,
247 internal::DataOutImplementation::ComponentExtractor::real_part,
248 data.patch_values_system.solution_hessians);
253 const typename DoFHandlerType::active_cell_iterator dh_cell(&(*cell)->get_triangulation(),
256 this->dof_data[dataset]->dof_handler);
257 data.patch_values_system.template set_cell<DoFHandlerType> (dh_cell);
260 evaluate_vector_field(data.patch_values_system,
261 data.postprocessed_values[dataset]);
264 for (
unsigned int component=0;
265 component<this->dof_data[dataset]->n_output_variables;
271 for (
unsigned int x=0; x<n_points; ++x)
272 for (
unsigned int y=0; y<n_points; ++y)
273 my_patches[angle].data(offset+component,
275 = data.postprocessed_values[dataset][x](component);
279 for (
unsigned int x=0; x<n_points; ++x)
280 for (
unsigned int y=0; y<n_points; ++y)
281 for (
unsigned int z=0; z<n_points; ++z)
282 my_patches[angle].data(offset+component,
283 x*n_points*n_points +
286 = data.postprocessed_values[dataset][x*n_points+z](component);
296 this->dof_data[dataset]->get_function_values (fe_patch_values,
297 internal::DataOutImplementation::ComponentExtractor::real_part,
298 data.patch_values_scalar.solution_values);
303 for (
unsigned int x=0; x<n_points; ++x)
304 for (
unsigned int y=0; y<n_points; ++y)
305 my_patches[angle].data(offset,
307 = data.patch_values_scalar.solution_values[x];
311 for (
unsigned int x=0; x<n_points; ++x)
312 for (
unsigned int y=0; y<n_points; ++y)
313 for (
unsigned int z=0; z<n_points; ++z)
314 my_patches[angle].data(offset,
315 x*n_points*n_points +
318 = data.patch_values_scalar.solution_values[x*n_points+z];
329 this->dof_data[dataset]->get_function_values (fe_patch_values,
330 internal::DataOutImplementation::ComponentExtractor::real_part,
331 data.patch_values_system.solution_values);
339 for (
unsigned int x=0; x<n_points; ++x)
340 for (
unsigned int y=0; y<n_points; ++y)
341 my_patches[angle].data(offset+component,
343 = data.patch_values_system.solution_values[x](component);
347 for (
unsigned int x=0; x<n_points; ++x)
348 for (
unsigned int y=0; y<n_points; ++y)
349 for (
unsigned int z=0; z<n_points; ++z)
350 my_patches[angle].data(offset+component,
351 x*n_points*n_points +
354 = data.patch_values_system.solution_values[x*n_points+z](component);
362 offset+=this->dof_data[dataset]->n_output_variables;
366 for (
unsigned int dataset=0; dataset<this->cell_data.size(); ++dataset)
371 Assert ((*cell)->active(),
372 ExcMessage(
"Cell must be active for cell data"));
373 const unsigned int cell_number
374 = std::distance (this->triangulation->begin_active(),
377 = this->cell_data[dataset]->get_cell_data_value (cell_number,
378 internal::DataOutImplementation::ComponentExtractor::real_part);
382 for (
unsigned int x=0; x<n_points; ++x)
383 for (
unsigned int y=0; y<n_points; ++y)
384 my_patches[angle].data(dataset+offset,
391 for (
unsigned int x=0; x<n_points; ++x)
392 for (
unsigned int y=0; y<n_points; ++y)
393 for (
unsigned int z=0; z<n_points; ++z)
394 my_patches[angle].data(dataset+offset,
395 x*n_points*n_points +
411 template <
int dim,
typename DoFHandlerType>
413 const unsigned int nnnn_subdivisions)
418 Assert (this->triangulation !=
nullptr,
421 const unsigned int n_subdivisions = (nnnn_subdivisions != 0)
423 : this->default_subdivisions;
424 Assert (n_subdivisions >= 1,
427 this->validate_dataset_names();
429 unsigned int n_datasets=this->cell_data.size();
430 for (
unsigned int i=0; i<this->dof_data.size(); ++i)
431 n_datasets+= this->dof_data[i]->n_output_variables;
434 for (
unsigned int i=0; i<this->dof_data.size(); ++i)
435 if (this->dof_data[i]->postprocessor)
436 update_flags |= this->dof_data[i]->postprocessor->get_needed_update_flags();
441 ExcMessage(
"The update of normal vectors may not be requested for " 442 "evaluation of data on cells via DataPostprocessor."));
447 std::vector<cell_iterator> all_cells;
448 for (
cell_iterator cell=first_cell(); cell != this->triangulation->end();
449 cell = next_cell(cell))
450 all_cells.push_back (cell);
457 this->patches.clear();
458 this->patches.reserve (all_cells.size() * n_patches_per_circle);
461 std::vector<unsigned int> n_postprocessor_outputs (this->dof_data.size());
462 for (
unsigned int dataset=0; dataset<this->dof_data.size(); ++dataset)
463 if (this->dof_data[dataset]->postprocessor)
464 n_postprocessor_outputs[dataset] = this->dof_data[dataset]->n_output_variables;
466 n_postprocessor_outputs[dataset] = 0;
469 thread_data (n_datasets,
470 n_subdivisions, n_patches_per_circle,
471 n_postprocessor_outputs,
475 std::vector<DataOutBase::Patch<dimension+1,space_dimension+1> >
476 new_patches (n_patches_per_circle);
477 for (
unsigned int i=0; i<new_patches.size(); ++i)
479 new_patches[i].n_subdivisions = n_subdivisions;
480 new_patches[i].data.reinit (n_datasets,
481 Utilities::fixed_power<dimension+1>(n_subdivisions+1));
486 &all_cells[0]+all_cells.size(),
488 this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),
490 ::append_patch_to_list<dim,space_dimension>,
491 std::placeholders::_1, std::ref(this->patches)),
498 template <
int dim,
typename DoFHandlerType>
502 return this->triangulation->begin_active ();
506 template <
int dim,
typename DoFHandlerType>
521 #include "data_out_rotation.inst" 524 DEAL_II_NAMESPACE_CLOSE
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
static ::ExceptionBase & ExcNoTriangulationSelected()
virtual cell_iterator next_cell(const cell_iterator &cell)
const FiniteElement< dim, spacedim > & get_fe() const
Transformed quadrature points.
static ::ExceptionBase & ExcInvalidNumberOfSubdivisions(int arg1)
const std::vector< Point< spacedim > > & get_quadrature_points() const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
Abstract base class for mapping classes.
Second derivatives of shape functions.
virtual cell_iterator first_cell()
virtual void build_patches(const unsigned int n_patches_per_circle, const unsigned int n_subdivisions=0)
DataOut_DoFData< DoFHandlerType, dimension+1 >::cell_iterator cell_iterator
Shape function gradients.
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)
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
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)
virtual UpdateFlags get_needed_update_flags() const =0