17#ifndef dealii_vector_tools_evaluation_h
18#define dealii_vector_tools_evaluation_h
137 template <
int n_components,
153 const VectorType & vector,
156 Utilities::MPI::RemotePointEvaluation<dim,
161 const unsigned int first_selected_component = 0);
185 (
concepts::is_dealii_vector_type<VectorType> &&
193 RemotePointEvaluation<dim, spacedim> &cache,
195 const VectorType & vector,
198 const unsigned int first_selected_component = 0);
220 (
concepts::is_dealii_vector_type<VectorType> &&
229 const VectorType & vector,
238 first_selected_component = 0);
261 (
concepts::is_dealii_vector_type<VectorType> &&
269 RemotePointEvaluation<dim, spacedim>
272 const VectorType & vector,
276 first_selected_component = 0);
284 template <
int n_components,
300 const VectorType & vector,
303 Utilities::MPI::RemotePointEvaluation<dim,
307 const unsigned int first_selected_component)
309 cache.
reinit(evaluation_points,
mesh.get_triangulation(), mapping);
312 cache,
mesh, vector, flags, first_selected_component);
317 template <
int n_components,
333 const VectorType & vector,
342 first_selected_component)
344 cache.
reinit(evaluation_points,
mesh.get_triangulation(), mapping);
347 cache,
mesh, vector, flags, first_selected_component);
357 template <
typename T>
364 case EvaluationFlags::avg:
366 return std::accumulate(
values.begin(),
values.end(), T{}) /
369 case EvaluationFlags::max:
371 case EvaluationFlags::min:
373 case EvaluationFlags::insert:
386 template <
int rank,
int dim,
typename Number>
393 case EvaluationFlags::avg:
395 return std::accumulate(
values.begin(),
398 (Number(1.0) *
values.size());
400 case EvaluationFlags::insert:
414 template <
int n_components,
int rank,
int dim,
typename Number>
423 case EvaluationFlags::avg:
427 for (
unsigned int j = 0;
j <
values.size(); ++
j)
428 for (
unsigned int i = 0; i < n_components; ++i)
431 for (
unsigned int i = 0; i < n_components; ++i)
436 case EvaluationFlags::insert:
446 template <
int n_components,
453 const unsigned int i,
459 const VectorType & vector,
462 const unsigned int first_selected_component,
467 typename VectorType::value_type> &,
470 std::vector<typename VectorType::value_type> &solution_values,
475 typename VectorType::value_type>>>
483 cell_data.cells[i].first,
484 cell_data.cells[i].second,
488 cell_data.reference_point_values.data() +
489 cell_data.reference_point_ptrs[i],
490 cell_data.reference_point_ptrs[i + 1] -
491 cell_data.reference_point_ptrs[i]);
493 solution_values.resize(
494 dof_handler.get_fe(cell->active_fe_index()).n_dofs_per_cell());
495 cell->get_dof_values(vector,
496 solution_values.begin(),
497 solution_values.end());
499 if (
evaluators[cell->active_fe_index()] ==
nullptr)
504 typename VectorType::value_type>>(
508 first_selected_component);
514 for (
unsigned int q = 0;
q < unit_points.
size(); ++
q)
515 values[
q + cell_data.reference_point_ptrs[i]] =
521 template <
int dim,
int spacedim,
typename Number>
530 return vector[cell->active_cell_index()];
535 template <
int dim,
int spacedim,
typename Number>
542 const auto distributed_tria =
546 (distributed_tria ==
nullptr) ?
548 (vector.get_partitioner().get() ==
549 distributed_tria->global_active_cell_index_partitioner()
555 return vector[cell->global_active_cell_index()];
560 return vector[cell->active_cell_index()];
566 template <
typename Number,
typename Number2>
568 set_value(Number &dst,
const Number2 &src)
575 template <
typename Number,
int rank,
int dim,
typename Number2>
581 "A cell-data vector can only have a single component."));
586 template <
int n_components,
593 const unsigned int i,
599 const VectorType & vector,
602 const unsigned int first_selected_component,
607 typename VectorType::value_type> &,
608 const unsigned int &)>,
610 std::vector<typename VectorType::value_type> &,
615 typename VectorType::value_type>>> &)
618 (void)first_selected_component;
620 Assert(n_components == 1 && first_selected_component == 0,
622 "A cell-data vector can only have a single component."));
626 ExcMessage(
"For cell-data vectors, only values can be queried."));
629 &
triangulation, cell_data.cells[i].first, cell_data.cells[i].second};
633 for (
unsigned int q = cell_data.reference_point_ptrs[i];
634 q < cell_data.reference_point_ptrs[i + 1];
636 set_value(values[
q], value);
641 template <
int n_components,
653 const VectorType & vector,
655 const unsigned int first_selected_component,
662 typename VectorType::value_type> &,
667 "Utilities::MPI::RemotePointEvaluation is not ready yet! "
668 "Please call Utilities::MPI::RemotePointEvaluation::reinit() "
669 "yourself or another function that does this for you."));
674 "The provided Utilities::MPI::RemotePointEvaluation and DoFHandler "
675 "object have been set up with different Triangulation objects, "
676 "a scenario not supported!"));
683 const auto &cell_data) {
684 std::vector<typename VectorType::value_type> solution_values;
690 typename VectorType::value_type>>>
693 for (
unsigned int i = 0; i < cell_data.cells.size(); ++i)
702 first_selected_component,
710 std::vector<value_type>
buffer;
732 for (
unsigned int i = 0; i < ptr.size() - 1; ++i)
734 const auto n_entries = ptr[i + 1] - ptr[i];
749 template <
int n_components,
764 RemotePointEvaluation<dim, spacedim> &cache,
766 const VectorType & vector,
768 const unsigned int first_selected_component)
770 return internal::evaluate_at_points<
779 typename VectorType::value_type>::value_type>(
784 first_selected_component,
794 template <
int n_components,
809 RemotePointEvaluation<dim, spacedim>
812 const VectorType & vector,
816 first_selected_component)
818 return internal::evaluate_at_points<
828 typename VectorType::value_type>::gradient_type>(
833 first_selected_component,
836 [](
const auto &
evaluator,
const unsigned &
q) {
value_type * data() const noexcept
void reinit(value_type *starting_element, const std::size_t n_elements)
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
size_type locally_owned_size() const
Abstract base class for mapping classes.
const Triangulation< dim, spacedim > & get_triangulation() const
const std::vector< unsigned int > & get_point_ptrs() const
bool is_map_unique() const
const Mapping< dim, spacedim > & get_mapping() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::active_cell_iterator active_cell_iterator
@ update_values
Shape function values.
@ update_gradients
Shape function gradients.
The namespace for the EvaluationFlags enum.
EvaluationFlags
The EvaluationFlags enum.
T reduce(const T &local_value, const MPI_Comm comm, const std::function< T(const T &, const T &)> &combiner, const unsigned int root_process=0)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
const ::Triangulation< dim, spacedim > & tria