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_faces.h> 36 DEAL_II_NAMESPACE_OPEN
41 namespace DataOutFacesImplementation
43 template <
int dim,
int spacedim>
44 ParallelData<dim, spacedim>::ParallelData(
45 const unsigned int n_datasets,
46 const unsigned int n_subdivisions,
47 const std::vector<unsigned int> &n_postprocessor_outputs,
53 :
internal::DataOutImplementation::ParallelDataBase<dim, spacedim>(
56 n_postprocessor_outputs,
69 template <
int dim,
int spacedim>
75 patches.push_back(patch);
76 patches.back().patch_index = patches.size() - 1;
83 template <
int dim,
typename DoFHandlerType>
92 template <
int dim,
typename DoFHandlerType>
106 for (
unsigned int vertex = 0;
107 vertex <
GeometryInfo<dimension - 1>::vertices_per_cell;
110 data.mapping_collection[0].transform_unit_to_real_cell(
111 cell_and_face->first,
114 cell_and_face->second,
116 cell_and_face->first->face_orientation(cell_and_face->second),
117 cell_and_face->first->face_flip(cell_and_face->second),
118 cell_and_face->first->face_rotation(cell_and_face->second))));
120 if (data.n_datasets > 0)
122 data.reinit_all_fe_values(this->dof_data,
123 cell_and_face->first,
124 cell_and_face->second);
126 data.get_present_fe_values(0);
132 const std::vector<Point<dimension>> &q_points =
141 for (
unsigned int i = 0; i < dimension; ++i)
142 for (
unsigned int q = 0; q < n_q_points; ++q)
143 patch.
data(patch.
data.
size(0) - dimension + i, q) = q_points[q][i];
146 unsigned int offset = 0;
149 for (
unsigned int dataset = 0; dataset < this->dof_data.size(); ++dataset)
152 data.get_present_fe_values(dataset);
154 this_fe_patch_values.
get_fe().n_components();
156 this->dof_data[dataset]->postprocessor;
157 if (postprocessor !=
nullptr)
169 this->dof_data[dataset]->get_function_values(
170 this_fe_patch_values,
171 internal::DataOutImplementation::ComponentExtractor::
173 data.patch_values_scalar.solution_values);
175 this->dof_data[dataset]->get_function_gradients(
176 this_fe_patch_values,
177 internal::DataOutImplementation::ComponentExtractor::
179 data.patch_values_scalar.solution_gradients);
181 this->dof_data[dataset]->get_function_hessians(
182 this_fe_patch_values,
183 internal::DataOutImplementation::ComponentExtractor::
185 data.patch_values_scalar.solution_hessians);
188 data.patch_values_scalar.evaluation_points =
192 data.patch_values_scalar.normals =
195 const typename DoFHandlerType::active_cell_iterator dh_cell(
196 &cell_and_face->first->get_triangulation(),
197 cell_and_face->first->level(),
198 cell_and_face->first->index(),
199 this->dof_data[dataset]->dof_handler);
200 data.patch_values_scalar.template set_cell<DoFHandlerType>(
204 data.patch_values_scalar,
205 data.postprocessed_values[dataset]);
213 this->dof_data[dataset]->get_function_values(
214 this_fe_patch_values,
215 internal::DataOutImplementation::ComponentExtractor::
217 data.patch_values_system.solution_values);
219 this->dof_data[dataset]->get_function_gradients(
220 this_fe_patch_values,
221 internal::DataOutImplementation::ComponentExtractor::
223 data.patch_values_system.solution_gradients);
225 this->dof_data[dataset]->get_function_hessians(
226 this_fe_patch_values,
227 internal::DataOutImplementation::ComponentExtractor::
229 data.patch_values_system.solution_hessians);
232 data.patch_values_system.evaluation_points =
236 data.patch_values_system.normals =
239 const typename DoFHandlerType::active_cell_iterator dh_cell(
240 &cell_and_face->first->get_triangulation(),
241 cell_and_face->first->level(),
242 cell_and_face->first->index(),
243 this->dof_data[dataset]->dof_handler);
244 data.patch_values_system.template set_cell<DoFHandlerType>(
248 data.patch_values_system,
249 data.postprocessed_values[dataset]);
252 for (
unsigned int q = 0; q < n_q_points; ++q)
253 for (
unsigned int component = 0;
254 component < this->dof_data[dataset]->n_output_variables;
256 patch.
data(offset + component, q) =
257 data.postprocessed_values[dataset][q](component);
265 this->dof_data[dataset]->get_function_values(
266 this_fe_patch_values,
267 internal::DataOutImplementation::ComponentExtractor::real_part,
268 data.patch_values_scalar.solution_values);
269 for (
unsigned int q = 0; q < n_q_points; ++q)
270 patch.
data(offset, q) =
271 data.patch_values_scalar.solution_values[q];
276 this->dof_data[dataset]->get_function_values(
277 this_fe_patch_values,
278 internal::DataOutImplementation::ComponentExtractor::real_part,
279 data.patch_values_system.solution_values);
280 for (
unsigned int component = 0; component <
n_components;
282 for (
unsigned int q = 0; q < n_q_points; ++q)
283 patch.
data(offset + component, q) =
284 data.patch_values_system.solution_values[q](component);
287 offset += this->dof_data[dataset]->n_output_variables;
291 for (
unsigned int dataset = 0; dataset < this->cell_data.size();
298 cell_and_face->first->active(),
300 "The current function is trying to generate cell-data output " 301 "for a face that does not belong to an active cell. This is " 303 const unsigned int cell_number =
304 std::distance(this->triangulation->begin_active(),
308 const double value = this->cell_data[dataset]->get_cell_data_value(
310 internal::DataOutImplementation::ComponentExtractor::real_part);
311 for (
unsigned int q = 0; q < n_q_points; ++q)
312 patch.
data(dataset + offset, q) = value;
319 template <
int dim,
typename DoFHandlerType>
322 const unsigned int n_subdivisions_)
329 template <
int dim,
typename DoFHandlerType>
333 const unsigned int n_subdivisions_)
338 const unsigned int n_subdivisions =
339 (n_subdivisions_ != 0) ? n_subdivisions_ : this->default_subdivisions;
341 Assert(n_subdivisions >= 1,
345 Assert(this->triangulation !=
nullptr,
348 this->validate_dataset_names();
350 unsigned int n_datasets = this->cell_data.size();
351 for (
unsigned int i = 0; i < this->dof_data.size(); ++i)
352 n_datasets += this->dof_data[i]->n_output_variables;
358 std::vector<FaceDescriptor> all_faces;
360 ((face.first != this->triangulation->end()) &&
362 face = next_face(face))
363 all_faces.push_back(face);
366 this->patches.clear();
367 this->patches.reserve(all_faces.size());
371 std::vector<unsigned int> n_postprocessor_outputs(this->dof_data.size());
372 for (
unsigned int dataset = 0; dataset < this->dof_data.size(); ++dataset)
373 if (this->dof_data[dataset]->postprocessor)
374 n_postprocessor_outputs[dataset] =
375 this->dof_data[dataset]->n_output_variables;
377 n_postprocessor_outputs[dataset] = 0;
380 for (
unsigned int i = 0; i < this->dof_data.size(); ++i)
381 if (this->dof_data[i]->postprocessor)
383 this->dof_data[i]->postprocessor->get_needed_update_flags();
387 thread_data(n_datasets,
389 n_postprocessor_outputs,
395 sample_patch.data.reinit(
396 n_datasets, Utilities::fixed_power<dimension - 1>(n_subdivisions + 1));
400 all_faces.data() + all_faces.size(),
403 std::placeholders::_1,
404 std::placeholders::_2,
405 std::placeholders::_3),
407 append_patch_to_list<dim, space_dimension>,
408 std::placeholders::_1,
409 std::ref(this->patches)),
416 template <
int dim,
typename DoFHandlerType>
422 cell = this->triangulation->begin_active();
423 for (; cell != this->triangulation->end(); ++cell)
424 if (cell->is_locally_owned())
425 for (
unsigned int f = 0; f < GeometryInfo<dimension>::faces_per_cell; ++f)
426 if (!surface_only || cell->face(f)->at_boundary())
437 template <
int dim,
typename DoFHandlerType>
446 for (
unsigned int f = face.second + 1;
449 if (!surface_only || face.first->face(f)->at_boundary())
461 active_cell = face.first;
467 while (active_cell != this->triangulation->end())
471 if (active_cell->is_locally_owned())
472 for (
unsigned int f = 0; f < GeometryInfo<dimension>::faces_per_cell;
474 if (!surface_only || active_cell->face(f)->at_boundary())
476 face.first = active_cell;
487 face.first = this->triangulation->end();
495 #include "data_out_faces.inst" 497 DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNoTriangulationSelected()
const FiniteElement< dim, spacedim > & get_fe() const
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
Transformed quadrature points.
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
static ::ExceptionBase & ExcInvalidNumberOfSubdivisions(int arg1)
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
virtual FaceDescriptor first_face()
const std::vector< Point< spacedim > > & get_quadrature_points() const
static ::ExceptionBase & ExcMessage(std::string arg1)
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
Abstract base class for mapping classes.
virtual FaceDescriptor next_face(const FaceDescriptor &face)
unsigned int n_subdivisions
Second derivatives of shape functions.
const std::vector< Tensor< 1, spacedim > > & get_all_normal_vectors() const
DataOutFaces(const bool surface_only=true)
const unsigned int n_quadrature_points
size_type size(const unsigned int i) const
static const unsigned int space_dim
Shape function gradients.
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
typename std::pair< cell_iterator, unsigned int > FaceDescriptor
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)
void build_one_patch(const FaceDescriptor *cell_and_face, internal::DataOutFacesImplementation::ParallelData< dimension, dimension > &data, DataOutBase::Patch< dimension - 1, space_dimension > &patch)
bool points_are_available
virtual void build_patches(const unsigned int n_subdivisions=0)
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
static ::ExceptionBase & ExcInternalError()
virtual UpdateFlags get_needed_update_flags() const =0