290 using number = Number;
292 if (
const auto *triangulation =
dynamic_cast<
297 (subdomain_id_ == triangulation->locally_owned_subdomain()),
299 "For distributed Triangulation objects and associated "
300 "DoFHandler objects, asking for any subdomain other than the "
301 "locally owned one does not make sense."));
302 subdomain_id = triangulation->locally_owned_subdomain();
306 subdomain_id = subdomain_id_;
310 const unsigned int n_solution_vectors = solutions.size();
315 ExcMessage(
"You are not allowed to list the special boundary "
316 "indicator for internal boundaries in your boundary "
319 for (
const auto &boundary_function : neumann_bc)
321 (void)boundary_function;
322 Assert(boundary_function.second->n_components == n_components,
323 ExcInvalidBoundaryFunction(boundary_function.first,
324 boundary_function.second->n_components,
329 ExcInvalidComponentMask());
331 ExcInvalidComponentMask());
333 Assert((coefficient ==
nullptr) ||
336 ExcInvalidCoefficient());
338 Assert(solutions.size() > 0, ExcNoSolutions());
339 Assert(solutions.size() == errors.size(),
340 ExcIncompatibleNumberOfElements(solutions.size(), errors.size()));
341 for (
unsigned int n = 0; n < solutions.size(); ++n)
345 Assert((coefficient ==
nullptr) ||
348 ExcInvalidCoefficient());
350 for (
const auto &boundary_function : neumann_bc)
352 (void)boundary_function;
353 Assert(boundary_function.second->n_components == n_components,
354 ExcInvalidBoundaryFunction(boundary_function.first,
355 boundary_function.second->n_components,
360 for (
unsigned int n = 0; n < n_solution_vectors; ++n)
367 std::vector<std::vector<std::vector<Tensor<1, spacedim, number>>>>
368 gradients_here(n_solution_vectors,
372 std::vector<std::vector<std::vector<Tensor<1, spacedim, number>>>>
373 gradients_neighbor(gradients_here);
374 std::vector<Vector<typename ProductType<number, double>::type>>
375 grad_dot_n_neighbor(n_solution_vectors,
383 if (coefficient ==
nullptr)
384 for (
unsigned int c = 0; c < n_components; ++c)
385 coefficient_values(c) = 1;
407 (cell->subdomain_id() == subdomain_id)) &&
409 (cell->material_id() == material_id)))
411 for (
unsigned int n = 0; n < n_solution_vectors; ++n)
412 (*errors[n])(cell->active_cell_index()) = 0;
415 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
417 *solutions[s], gradients_here[s]);
421 for (
unsigned int n = 0; n < 2; ++n)
424 auto neighbor = cell->neighbor(n);
426 while (neighbor->has_children())
427 neighbor = neighbor->child(n == 0 ? 1 : 0);
429 fe_face_values.
reinit(cell, n);
435 fe_values.
reinit(neighbor);
437 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
439 *solutions[s], gradients_neighbor[s]);
441 fe_face_values.
reinit(neighbor, n == 0 ? 1 : 0);
444 .get_normal_vectors()[0];
448 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
449 for (
unsigned int c = 0; c < n_components; ++c)
450 grad_dot_n_neighbor[s](c) =
451 -(gradients_neighbor[s][n == 0 ? 1 : 0][c] *
454 else if (neumann_bc.find(n) != neumann_bc.end())
458 if (n_components == 1)
461 neumann_bc.find(n)->second->
value(cell->vertex(n));
463 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
464 grad_dot_n_neighbor[s](0) = v;
469 neumann_bc.find(n)->second->vector_value(cell->vertex(n),
472 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
473 grad_dot_n_neighbor[s] = v;
478 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
479 grad_dot_n_neighbor[s] = 0;
483 if (coefficient !=
nullptr)
487 const double c_value = coefficient->
value(cell->vertex(n));
488 for (
unsigned int c = 0; c < n_components; ++c)
489 coefficient_values(c) = c_value;
497 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
498 for (
unsigned int component = 0; component < n_components;
500 if (component_mask[component] ==
true)
505 gradients_here[s][n][component] * normal;
508 ((grad_dot_n_here - grad_dot_n_neighbor[s](component)) *
509 coefficient_values(component));
510 (*errors[s])(cell->active_cell_index()) +=
513 double>::type>::abs_square(jump) *
518 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
519 (*errors[s])(cell->active_cell_index()) =
520 std::sqrt((*errors[s])(cell->active_cell_index()));
static void estimate(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const Quadrature< dim - 1 > &quadrature, const std::map< types::boundary_id, const Function< spacedim, Number > * > &neumann_bc, const ReadVector< Number > &solution, Vector< float > &error, const ComponentMask &component_mask={}, const Function< spacedim > *coefficients=nullptr, const unsigned int n_threads=numbers::invalid_unsigned_int, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id, const types::material_id material_id=numbers::invalid_material_id, const Strategy strategy=cell_diameter_over_24)