16 #include <deal.II/base/thread_management.h> 17 #include <deal.II/base/quadrature.h> 18 #include <deal.II/base/quadrature_lib.h> 19 #include <deal.II/base/work_stream.h> 20 #include <deal.II/lac/vector.h> 21 #include <deal.II/lac/la_vector.h> 22 #include <deal.II/lac/la_parallel_vector.h> 23 #include <deal.II/lac/block_vector.h> 24 #include <deal.II/lac/la_parallel_block_vector.h> 25 #include <deal.II/lac/petsc_parallel_vector.h> 26 #include <deal.II/lac/petsc_parallel_block_vector.h> 27 #include <deal.II/lac/trilinos_vector.h> 28 #include <deal.II/lac/trilinos_parallel_block_vector.h> 29 #include <deal.II/grid/tria_iterator.h> 30 #include <deal.II/base/geometry_info.h> 31 #include <deal.II/dofs/dof_handler.h> 32 #include <deal.II/dofs/dof_accessor.h> 33 #include <deal.II/fe/fe.h> 34 #include <deal.II/fe/fe_values.h> 35 #include <deal.II/hp/fe_values.h> 36 #include <deal.II/fe/fe_update_flags.h> 37 #include <deal.II/fe/mapping_q1.h> 38 #include <deal.II/hp/q_collection.h> 39 #include <deal.II/hp/mapping_collection.h> 40 #include <deal.II/numerics/error_estimator.h> 41 #include <deal.II/distributed/tria.h> 50 DEAL_II_NAMESPACE_OPEN
54 template <
int spacedim>
55 template <
typename InputVector,
typename DoFHandlerType>
59 const DoFHandlerType &dof_handler,
62 const InputVector &solution,
66 const unsigned int n_threads,
72 const std::vector<const InputVector *> solutions (1, &solution);
73 std::vector<Vector<float>*> errors (1, &error);
74 estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors,
75 component_mask, coefficients, n_threads, subdomain_id, material_id,strategy);
80 template <
int spacedim>
81 template <
typename InputVector,
typename DoFHandlerType>
87 const InputVector &solution,
91 const unsigned int n_threads,
97 error, component_mask, coefficients, n_threads, subdomain_id, material_id,strategy);
102 template <
int spacedim>
103 template <
typename InputVector,
typename DoFHandlerType>
109 const std::vector<const InputVector *> &solutions,
110 std::vector<Vector<float>*> &errors,
113 const unsigned int n_threads,
119 errors, component_mask, coefficients, n_threads, subdomain_id, material_id,strategy);
124 template <
int spacedim>
125 template <
typename InputVector,
typename DoFHandlerType>
129 const DoFHandlerType &dof_handler,
132 const InputVector &solution,
133 Vector<float> &error,
136 const unsigned int n_threads,
142 const std::vector<const InputVector *> solutions (1, &solution);
143 std::vector<Vector<float>*> errors (1, &error);
144 estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors,
145 component_mask, coefficients, n_threads, subdomain_id, material_id, strategy);
149 template <
int spacedim>
150 template <
typename InputVector,
typename DoFHandlerType>
156 const InputVector &solution,
157 Vector<float> &error,
160 const unsigned int n_threads,
166 error, component_mask, coefficients, n_threads, subdomain_id, material_id,strategy);
171 template <
int spacedim>
172 template <
typename InputVector,
typename DoFHandlerType>
178 const std::vector<const InputVector *> &solutions,
179 std::vector<Vector<float>*> &errors,
182 const unsigned int n_threads,
188 errors, component_mask, coefficients, n_threads, subdomain_id, material_id,strategy);
194 template <
int spacedim>
195 template <
typename InputVector,
typename DoFHandlerType>
198 const DoFHandlerType & ,
201 const std::vector<const InputVector *> & ,
202 std::vector<Vector<float>*> & ,
215 template <
int spacedim>
216 template <
typename InputVector,
typename DoFHandlerType>
219 const DoFHandlerType &dof_handler,
222 const std::vector<const InputVector *> &solutions,
223 std::vector<Vector<float>*> &errors,
232 typedef typename InputVector::value_type number;
233 #ifdef DEAL_II_WITH_P4EST 235 (&dof_handler.get_triangulation())
241 (dof_handler.get_triangulation()).locally_owned_subdomain()),
242 ExcMessage (
"For parallel distributed triangulations, the only " 243 "valid subdomain_id that can be passed here is the " 244 "one that corresponds to the locally owned subdomain id."));
248 (&dof_handler.get_triangulation())
252 (dof_handler.get_triangulation()).locally_owned_subdomain()
260 const unsigned int n_components = dof_handler.get_fe(0).n_components();
261 const unsigned int n_solution_vectors = solutions.size();
265 ExcMessage(
"You are not allowed to list the special boundary " 266 "indicator for internal boundaries in your boundary " 270 i!=neumann_bc.end(); ++i)
271 Assert (i->second->n_components == n_components,
273 i->second->n_components,
281 Assert ((coefficient ==
nullptr) ||
286 Assert (solutions.size() > 0,
288 Assert (solutions.size() == errors.size(),
290 for (
unsigned int n=0; n<solutions.size(); ++n)
291 Assert (solutions[n]->size() == dof_handler.n_dofs(),
293 dof_handler.n_dofs()));
295 Assert ((coefficient ==
nullptr) ||
301 i!=neumann_bc.end(); ++i)
302 Assert (i->second->n_components == n_components,
304 i->second->n_components,
308 for (
unsigned int n=0; n<n_solution_vectors; ++n)
309 (*errors[n]).reinit (dof_handler.get_triangulation().n_active_cells());
315 std::vector<std::vector<std::vector<Tensor<1,spacedim,number> > > >
316 gradients_here (n_solution_vectors,
318 std::vector<std::vector<std::vector<Tensor<1,spacedim,number> > > >
319 gradients_neighbor (gradients_here);
320 std::vector<Vector<typename ProductType<number,double>::type> >
321 grad_dot_n_neighbor (n_solution_vectors, Vector<
typename ProductType<number,double>::type>(n_components));
327 if (coefficient ==
nullptr)
328 for (
unsigned int c=0; c<n_components; ++c)
329 coefficient_values(c) = 1;
349 for (
typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active();
350 cell != dof_handler.end();
354 (cell->subdomain_id() == subdomain_id))
358 (cell->material_id() == material_id)))
360 for (
unsigned int n=0; n<n_solution_vectors; ++n)
361 (*errors[n])(cell->active_cell_index()) = 0;
364 for (
unsigned int s=0; s<n_solution_vectors; ++s)
366 .get_function_gradients (*solutions[s], gradients_here[s]);
370 for (
unsigned int n=0; n<2; ++n)
373 typename DoFHandlerType::cell_iterator neighbor = cell->neighbor(n);
375 while (neighbor->has_children())
376 neighbor = neighbor->child(n==0 ? 1 : 0);
378 fe_face_values.
reinit (cell, n);
384 fe_values.
reinit (neighbor);
386 for (
unsigned int s=0; s<n_solution_vectors; ++s)
388 .get_function_gradients (*solutions[s],
389 gradients_neighbor[s]);
391 fe_face_values.
reinit (neighbor, n==0 ? 1 : 0);
396 for (
unsigned int s=0; s<n_solution_vectors; ++s)
397 for (
unsigned int c=0; c<n_components; ++c)
398 grad_dot_n_neighbor[s](c)
399 = - (gradients_neighbor[s][n==0 ? 1 : 0][c]*neighbor_normal);
401 else if (neumann_bc.find(n) != neumann_bc.end())
407 const typename InputVector::value_type
408 v = neumann_bc.find(n)->second->value(cell->vertex(n));
410 for (
unsigned int s=0; s<n_solution_vectors; ++s)
411 grad_dot_n_neighbor[s](0) = v;
415 Vector<typename InputVector::value_type> v(n_components);
416 neumann_bc.find(n)->second->vector_value(cell->vertex(n), v);
418 for (
unsigned int s=0; s<n_solution_vectors; ++s)
419 grad_dot_n_neighbor[s] = v;
424 for (
unsigned int s=0; s<n_solution_vectors; ++s)
425 grad_dot_n_neighbor[s] = 0;
429 if (coefficient !=
nullptr)
433 const double c_value = coefficient->
value (cell->vertex(n));
434 for (
unsigned int c=0; c<n_components; ++c)
435 coefficient_values(c) = c_value;
443 for (
unsigned int s=0; s<n_solution_vectors; ++s)
444 for (
unsigned int component=0; component<n_components; ++component)
445 if (component_mask[component] ==
true)
448 const typename ProductType<number,double>::type
449 grad_dot_n_here = gradients_here[s][n][component] * normal;
451 const typename ProductType<number,double>::type
452 jump = ((grad_dot_n_here - grad_dot_n_neighbor[s](component)) *
453 coefficient_values(component));
454 (*errors[s])(cell->active_cell_index())
455 +=
numbers::NumberTraits<
typename ProductType<number,double>::type>::abs_square(jump) * cell->diameter();
459 for (
unsigned int s=0; s<n_solution_vectors; ++s)
460 (*errors[s])(cell->active_cell_index()) = std::sqrt((*errors[s])(cell->active_cell_index()));
466 #include "error_estimator_1d.inst" 469 DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcInvalidBoundaryFunction(types::boundary_id arg1, int arg2, int arg3)
static ::ExceptionBase & ExcInvalidCoefficient()
const types::subdomain_id invalid_subdomain_id
const unsigned int n_components
static ::ExceptionBase & ExcInvalidComponentMask()
void push_back(const Mapping< dim, spacedim > &new_mapping)
bool represents_n_components(const unsigned int n) const
#define AssertThrow(cond, exc)
const ::FEValues< dim, spacedim > & get_present_fe_values() const
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType, lda > > cell, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
Abstract base class for mapping classes.
static void estimate(const Mapping< dim, spacedim > &mapping, const DoFHandlerType &dof, const Quadrature< dim-1 > &quadrature, const typename FunctionMap< spacedim, typename InputVector::value_type >::type &neumann_bc, const InputVector &solution, Vector< float > &error, const ComponentMask &component_mask=ComponentMask(), 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)
std::map< types::boundary_id, const Function< dim, Number > * > type
static ::ExceptionBase & ExcIncompatibleNumberOfElements(int arg1, int arg2)
virtual void vector_value(const Point< dim > &p, Vector< RangeNumberType > &values) const
unsigned int subdomain_id
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType, lda > > cell, const unsigned int face_no, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
Shape function gradients.
unsigned int n_selected_components(const unsigned int overall_number_of_components=numbers::invalid_unsigned_int) const
static ::ExceptionBase & ExcNotImplemented()
Iterator points to a valid object.
const types::boundary_id internal_face_boundary_id
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
Kelly error estimator with the factor .
const types::material_id invalid_material_id
static ::ExceptionBase & ExcNoSolutions()
static ::ExceptionBase & ExcInternalError()