17#ifndef dealii_vector_tools_evaluation_h
18#define dealii_vector_tools_evaluation_h
119 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
124 typename VectorType::value_type>::value_type>
128 const VectorType & vector,
145 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
150 typename VectorType::value_type>::value_type>
154 const VectorType & vector,
167 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
172 typename VectorType::value_type>::gradient_type>
176 const VectorType & vector,
192 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
197 typename VectorType::value_type>::gradient_type>
201 const VectorType & vector,
210 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
215 typename VectorType::value_type>::value_type>
218 const VectorType & vector,
225 return point_values<n_components>(cache, dof_handler, vector, flags);
230 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
235 typename VectorType::value_type>::gradient_type>
238 const VectorType & vector,
245 return point_gradients<n_components>(cache, dof_handler, vector, flags);
255 template <
typename T>
262 case EvaluationFlags::avg:
264 return std::accumulate(
values.begin(),
values.end(), T{}) /
267 case EvaluationFlags::max:
269 case EvaluationFlags::min:
271 case EvaluationFlags::insert:
284 template <
int rank,
int dim,
typename Number>
291 case EvaluationFlags::avg:
293 return std::accumulate(
values.begin(),
296 (Number(1.0) *
values.size());
298 case EvaluationFlags::insert:
308 template <
int n_components,
313 inline std::vector<value_type>
317 const VectorType & vector,
320 const ::EvaluationFlags::EvaluationFlags evaluation_flags,
325 typename VectorType::value_type> &,
326 const unsigned int &)> process_quadrature_point)
330 "Utilities::MPI::RemotePointEvaluation is not ready yet! "
331 "Please call Utilities::MPI::RemotePointEvaluation::reinit() "
332 "yourself or another function that does this for you."));
337 "The provided Utilities::MPI::RemotePointEvaluation and DoFHandler "
338 "object have been set up with different Triangulation objects, "
339 "a scenario not supported!"));
342 const auto evaluation_point_results = [&]() {
345 const auto evaluation_function = [&](
auto &
values,
346 const auto &cell_data) {
347 std::vector<typename VectorType::value_type> solution_values;
353 typename VectorType::value_type>>>
356 for (
unsigned int i = 0; i < cell_data.cells.size(); ++i)
360 cell_data.cells[i].first,
361 cell_data.cells[i].second,
365 cell_data.reference_point_values.data() +
366 cell_data.reference_point_ptrs[i],
367 cell_data.reference_point_ptrs[i + 1] -
368 cell_data.reference_point_ptrs[i]);
370 solution_values.resize(
372 cell->get_dof_values(vector,
373 solution_values.begin(),
374 solution_values.end());
376 if (evaluators[cell->active_fe_index()] ==
nullptr)
377 evaluators[cell->active_fe_index()] = std::make_unique<
381 typename VectorType::value_type>>(
383 auto &evaluator = *evaluators[cell->active_fe_index()];
385 evaluator.
reinit(cell, unit_points);
386 evaluator.evaluate(solution_values, evaluation_flags);
388 for (
unsigned int q = 0; q < unit_points.size(); ++q)
389 values[q + cell_data.reference_point_ptrs[i]] =
390 process_quadrature_point(evaluator, q);
394 std::vector<value_type> evaluation_point_results;
395 std::vector<value_type> buffer;
397 cache.template evaluate_and_process<value_type>(
398 evaluation_point_results, buffer, evaluation_function);
400 return evaluation_point_results;
406 return evaluation_point_results;
412 std::vector<value_type> unique_evaluation_point_results(
417 for (
unsigned int i = 0; i < ptr.size() - 1; ++i)
419 const auto n_entries = ptr[i + 1] - ptr[i];
423 unique_evaluation_point_results[i] =
426 evaluation_point_results.data() + ptr[i], n_entries));
429 return unique_evaluation_point_results;
434 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
439 typename VectorType::value_type>::value_type>
443 const VectorType & vector,
446 return internal::evaluate_at_points<
454 typename VectorType::value_type>::value_type>(
461 [](
const auto &evaluator,
const auto &q) {
462 return evaluator.get_value(q);
466 template <
int n_components,
int dim,
int spacedim,
typename VectorType>
471 typename VectorType::value_type>::gradient_type>
475 const VectorType & vector,
478 return internal::evaluate_at_points<
487 typename VectorType::value_type>::gradient_type>(
494 [](
const auto &evaluator,
const auto &q) {
495 return evaluator.get_gradient(q);
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const Triangulation< dim, spacedim > & get_triangulation() const
void reinit(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const ArrayView< const Point< dim > > &unit_points)
unsigned int n_dofs_per_cell() 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
void reinit(const std::vector< Point< spacedim > > &points, const Triangulation< dim, spacedim > &tria, const Mapping< dim, spacedim > &mapping)
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
@ update_values
Shape function values.
@ update_gradients
Shape function gradients.
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::active_cell_iterator active_cell_iterator
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)