59 template <
int spacedim>
60 template <
typename InputVector,
typename DoFHandlerType>
64 const DoFHandlerType & dof_handler,
69 const InputVector & solution,
70 Vector<float> & error,
73 const unsigned int n_threads,
79 const std::vector<const InputVector *> solutions(1, &solution);
80 std::vector<Vector<float> *> errors(1, &error);
97 template <
int spacedim>
98 template <
typename InputVector,
typename DoFHandlerType>
101 const DoFHandlerType &dof_handler,
106 const InputVector & solution,
107 Vector<float> & error,
110 const unsigned int n_threads,
131 template <
int spacedim>
132 template <
typename InputVector,
typename DoFHandlerType>
135 const DoFHandlerType &dof_handler,
140 const std::vector<const InputVector *> &solutions,
141 std::vector<Vector<float> *> & errors,
144 const unsigned int n_threads,
165 template <
int spacedim>
166 template <
typename InputVector,
typename DoFHandlerType>
170 const DoFHandlerType & dof_handler,
175 const InputVector & solution,
176 Vector<float> & error,
179 const unsigned int n_threads,
185 const std::vector<const InputVector *> solutions(1, &solution);
186 std::vector<Vector<float> *> errors(1, &error);
202 template <
int spacedim>
203 template <
typename InputVector,
typename DoFHandlerType>
206 const DoFHandlerType & dof_handler,
211 const InputVector & solution,
212 Vector<float> & error,
215 const unsigned int n_threads,
236 template <
int spacedim>
237 template <
typename InputVector,
typename DoFHandlerType>
240 const DoFHandlerType & dof_handler,
245 const std::vector<const InputVector *> &solutions,
246 std::vector<Vector<float> *> & errors,
249 const unsigned int n_threads,
270 template <
int spacedim>
271 template <
typename InputVector,
typename DoFHandlerType>
275 const DoFHandlerType & ,
280 const std::vector<const InputVector *> & ,
281 std::vector<Vector<float> *> & ,
294 template <
int spacedim>
295 template <
typename InputVector,
typename DoFHandlerType>
299 const DoFHandlerType & dof_handler,
304 const std::vector<const InputVector *> &solutions,
305 std::vector<Vector<float> *> & errors,
314 using number =
typename InputVector::value_type;
315 #ifdef DEAL_II_WITH_P4EST
317 &dof_handler.get_triangulation()) !=
nullptr)
322 dof_handler.get_triangulation())
325 "For parallel distributed triangulations, the only "
326 "valid subdomain_id that can be passed here is the "
327 "one that corresponds to the locally owned subdomain id."));
331 &dof_handler.get_triangulation()) !=
nullptr) ?
333 dof_handler.get_triangulation())
334 .locally_owned_subdomain() :
340 const unsigned int n_components = dof_handler.get_fe(0).n_components();
341 const unsigned int n_solution_vectors = solutions.size();
346 ExcMessage(
"You are not allowed to list the special boundary "
347 "indicator for internal boundaries in your boundary "
350 for (
const auto &boundary_function : neumann_bc)
352 (void)boundary_function;
355 boundary_function.second->n_components,
364 Assert((coefficient ==
nullptr) ||
370 Assert(solutions.size() == errors.size(),
372 for (
unsigned int n = 0; n < solutions.size(); ++n)
373 Assert(solutions[n]->size() == dof_handler.n_dofs(),
376 Assert((coefficient ==
nullptr) ||
381 for (
const auto &boundary_function : neumann_bc)
383 (void)boundary_function;
386 boundary_function.second->n_components,
391 for (
unsigned int n = 0; n < n_solution_vectors; ++n)
392 (*errors[n]).reinit(dof_handler.get_triangulation().n_active_cells());
398 std::vector<std::vector<std::vector<Tensor<1, spacedim, number>>>>
399 gradients_here(n_solution_vectors,
403 std::vector<std::vector<std::vector<Tensor<1, spacedim, number>>>>
404 gradients_neighbor(gradients_here);
405 std::vector<Vector<typename ProductType<number, double>::type>>
406 grad_dot_n_neighbor(n_solution_vectors,
414 if (coefficient ==
nullptr)
416 coefficient_values(c) = 1;
438 for (
const auto &cell : dof_handler.active_cell_iterators())
444 for (
unsigned int n = 0; n < n_solution_vectors; ++n)
445 (*errors[n])(cell->active_cell_index()) = 0;
448 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
450 *solutions[s], gradients_here[s]);
454 for (
unsigned int n = 0; n < 2; ++n)
457 typename DoFHandlerType::cell_iterator neighbor = cell->neighbor(n);
459 while (neighbor->has_children())
460 neighbor = neighbor->child(n == 0 ? 1 : 0);
462 fe_face_values.
reinit(cell, n);
468 fe_values.
reinit(neighbor);
470 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
472 *solutions[s], gradients_neighbor[s]);
474 fe_face_values.
reinit(neighbor, n == 0 ? 1 : 0);
477 .get_normal_vectors()[0];
481 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
483 grad_dot_n_neighbor[s](c) =
484 -(gradients_neighbor[s][n == 0 ? 1 : 0][c] *
487 else if (neumann_bc.find(n) != neumann_bc.end())
493 const typename InputVector::value_type v =
494 neumann_bc.find(n)->second->value(cell->vertex(n));
496 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
497 grad_dot_n_neighbor[s](0) = v;
501 Vector<typename InputVector::value_type> v(
n_components);
502 neumann_bc.find(n)->second->vector_value(cell->vertex(n),
505 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
506 grad_dot_n_neighbor[s] = v;
511 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
512 grad_dot_n_neighbor[s] = 0;
516 if (coefficient !=
nullptr)
520 const double c_value = coefficient->
value(cell->vertex(n));
522 coefficient_values(c) = c_value;
530 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
531 for (
unsigned int component = 0; component <
n_components;
533 if (component_mask[component] ==
true)
538 gradients_here[s][n][component] * normal;
541 ((grad_dot_n_here - grad_dot_n_neighbor[s](component)) *
542 coefficient_values(component));
543 (*errors[s])(cell->active_cell_index()) +=
546 double>::type>::abs_square(jump) *
551 for (
unsigned int s = 0; s < n_solution_vectors; ++s)
552 (*errors[s])(cell->active_cell_index()) =
553 std::sqrt((*errors[s])(cell->active_cell_index()));
559 #include "error_estimator_1d.inst"