deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
error_estimator.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 1998 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_error_estimator_h
14#define dealii_error_estimator_h
15
16
17#include <deal.II/base/config.h>
18
21
23
25
26#include <map>
27
29
30// Forward declarations
31#ifndef DOXYGEN
32template <int dim, int spacedim>
34class DoFHandler;
35template <int, int>
36class Mapping;
37template <int>
38class Quadrature;
39
40namespace hp
41{
42 template <int>
43 class QCollection;
44
45 template <int, int>
46 class MappingCollection;
47} // namespace hp
48#endif
49
50
262template <int dim, int spacedim = dim>
264{
265public:
280
341 template <typename Number>
342 static void
344 const Mapping<dim, spacedim> &mapping,
345 const DoFHandler<dim, spacedim> &dof,
346 const Quadrature<dim - 1> &quadrature,
347 const std::map<types::boundary_id, const Function<spacedim, Number> *>
348 &neumann_bc,
349 const ReadVector<Number> &solution,
350 Vector<float> &error,
351 const ComponentMask &component_mask = {},
352 const Function<spacedim> *coefficients = nullptr,
353 const unsigned int n_threads = numbers::invalid_unsigned_int,
356 const Strategy strategy = cell_diameter_over_24);
357
362 template <typename Number>
363 static void
365 const DoFHandler<dim, spacedim> &dof,
366 const Quadrature<dim - 1> &quadrature,
367 const std::map<types::boundary_id, const Function<spacedim, Number> *>
368 &neumann_bc,
369 const ReadVector<Number> &solution,
370 Vector<float> &error,
371 const ComponentMask &component_mask = {},
372 const Function<spacedim> *coefficients = nullptr,
373 const unsigned int n_threads = numbers::invalid_unsigned_int,
376 const Strategy strategy = cell_diameter_over_24);
377
391 template <typename Number>
392 static void
394 const Mapping<dim, spacedim> &mapping,
395 const DoFHandler<dim, spacedim> &dof,
396 const Quadrature<dim - 1> &quadrature,
397 const std::map<types::boundary_id, const Function<spacedim, Number> *>
398 &neumann_bc,
399 const ArrayView<const ReadVector<Number> *> &solutions,
400 ArrayView<Vector<float> *> &errors,
401 const ComponentMask &component_mask = {},
402 const Function<spacedim> *coefficients = nullptr,
403 const unsigned int n_threads = numbers::invalid_unsigned_int,
406 const Strategy strategy = cell_diameter_over_24);
407
412 template <typename Number>
413 static void
415 const DoFHandler<dim, spacedim> &dof,
416 const Quadrature<dim - 1> &quadrature,
417 const std::map<types::boundary_id, const Function<spacedim, Number> *>
418 &neumann_bc,
419 const ArrayView<const ReadVector<Number> *> &solutions,
420 ArrayView<Vector<float> *> &errors,
421 const ComponentMask &component_mask = {},
422 const Function<spacedim> *coefficients = nullptr,
423 const unsigned int n_threads = numbers::invalid_unsigned_int,
426 const Strategy strategy = cell_diameter_over_24);
427
428
433 template <typename Number>
434 static void
437 const DoFHandler<dim, spacedim> &dof,
438 const hp::QCollection<dim - 1> &quadrature,
439 const std::map<types::boundary_id, const Function<spacedim, Number> *>
440 &neumann_bc,
441 const ReadVector<Number> &solution,
442 Vector<float> &error,
443 const ComponentMask &component_mask = {},
444 const Function<spacedim> *coefficients = nullptr,
445 const unsigned int n_threads = numbers::invalid_unsigned_int,
448 const Strategy strategy = cell_diameter_over_24);
449
450
455 template <typename Number>
456 static void
458 const DoFHandler<dim, spacedim> &dof,
459 const hp::QCollection<dim - 1> &quadrature,
460 const std::map<types::boundary_id, const Function<spacedim, Number> *>
461 &neumann_bc,
462 const ReadVector<Number> &solution,
463 Vector<float> &error,
464 const ComponentMask &component_mask = {},
465 const Function<spacedim> *coefficients = nullptr,
466 const unsigned int n_threads = numbers::invalid_unsigned_int,
469 const Strategy strategy = cell_diameter_over_24);
470
471
476 template <typename Number>
477 static void
480 const DoFHandler<dim, spacedim> &dof,
481 const hp::QCollection<dim - 1> &quadrature,
482 const std::map<types::boundary_id, const Function<spacedim, Number> *>
483 &neumann_bc,
484 const ArrayView<const ReadVector<Number> *> &solutions,
485 ArrayView<Vector<float> *> &errors,
486 const ComponentMask &component_mask = {},
487 const Function<spacedim> *coefficients = nullptr,
488 const unsigned int n_threads = numbers::invalid_unsigned_int,
491 const Strategy strategy = cell_diameter_over_24);
492
493
494
499 template <typename Number>
500 static void
502 const DoFHandler<dim, spacedim> &dof,
503 const hp::QCollection<dim - 1> &quadrature,
504 const std::map<types::boundary_id, const Function<spacedim, Number> *>
505 &neumann_bc,
506 const ArrayView<const ReadVector<Number> *> &solutions,
507 ArrayView<Vector<float> *> &errors,
508 const ComponentMask &component_mask = {},
509 const Function<spacedim> *coefficients = nullptr,
510 const unsigned int n_threads = numbers::invalid_unsigned_int,
513 const Strategy strategy = cell_diameter_over_24);
514
519 "You provided a ComponentMask argument that is invalid. "
520 "Component masks need to be either default constructed "
521 "(in which case they indicate that every component is "
522 "selected) or need to have a length equal to the number "
523 "of vector components of the finite element in use "
524 "by the DoFHandler object. In the latter case, at "
525 "least one component needs to be selected.");
531 "If you do specify the argument for a (possibly "
532 "spatially variable) coefficient function for this function, "
533 "then it needs to refer to a coefficient that is either "
534 "scalar (has one vector component) or has as many vector "
535 "components as there are in the finite element used by "
536 "the DoFHandler argument.");
542 int,
543 int,
544 << "You provided a function map that for boundary indicator "
545 << arg1 << " specifies a function with " << arg2
546 << " vector components. However, the finite "
547 "element in use has "
548 << arg3
549 << " components, and these two numbers need to match.");
554 int,
555 int,
556 << "The number of input vectors, " << arg1
557 << " needs to be equal to the number of output vectors, "
558 << arg2
559 << ". This is not the case in your call of this function.");
564 "You need to specify at least one solution vector as "
565 "input.");
566};
567
568
569
579template <int spacedim>
580class KellyErrorEstimator<1, spacedim>
581{
582public:
597
598
599
622 template <typename Number>
623 static void
624 estimate(
625 const Mapping<1, spacedim> &mapping,
626 const DoFHandler<1, spacedim> &dof,
627 const Quadrature<0> &quadrature,
628 const std::map<types::boundary_id, const Function<spacedim, Number> *>
629 &neumann_bc,
630 const ReadVector<Number> &solution,
631 Vector<float> &error,
632 const ComponentMask &component_mask = {},
633 const Function<spacedim> *coefficient = nullptr,
634 const unsigned int n_threads = numbers::invalid_unsigned_int,
637 const Strategy strategy = cell_diameter_over_24);
638
639
640
645 template <typename Number>
646 static void
647 estimate(
648 const DoFHandler<1, spacedim> &dof,
649 const Quadrature<0> &quadrature,
650 const std::map<types::boundary_id, const Function<spacedim, Number> *>
651 &neumann_bc,
652 const ReadVector<Number> &solution,
653 Vector<float> &error,
654 const ComponentMask &component_mask = {},
655 const Function<spacedim> *coefficients = nullptr,
656 const unsigned int n_threads = numbers::invalid_unsigned_int,
659 const Strategy strategy = cell_diameter_over_24);
660
661
662
676 template <typename Number>
677 static void
678 estimate(
679 const Mapping<1, spacedim> &mapping,
680 const DoFHandler<1, spacedim> &dof,
681 const Quadrature<0> &quadrature,
682 const std::map<types::boundary_id, const Function<spacedim, Number> *>
683 &neumann_bc,
684 const ArrayView<const ReadVector<Number> *> &solutions,
685 ArrayView<Vector<float> *> &errors,
686 const ComponentMask &component_mask = {},
687 const Function<spacedim> *coefficients = nullptr,
688 const unsigned int n_threads = numbers::invalid_unsigned_int,
691 const Strategy strategy = cell_diameter_over_24);
692
693
694
699 template <typename Number>
700 static void
701 estimate(
702 const DoFHandler<1, spacedim> &dof,
703 const Quadrature<0> &quadrature,
704 const std::map<types::boundary_id, const Function<spacedim, Number> *>
705 &neumann_bc,
706 const ArrayView<const ReadVector<Number> *> &solutions,
707 ArrayView<Vector<float> *> &errors,
708 const ComponentMask &component_mask = {},
709 const Function<spacedim> *coefficients = nullptr,
710 const unsigned int n_threads = numbers::invalid_unsigned_int,
713 const Strategy strategy = cell_diameter_over_24);
714
715
716
721 template <typename Number>
722 static void
723 estimate(
725 const DoFHandler<1, spacedim> &dof,
726 const hp::QCollection<0> &quadrature,
727 const std::map<types::boundary_id, const Function<spacedim, Number> *>
728 &neumann_bc,
729 const ReadVector<Number> &solution,
730 Vector<float> &error,
731 const ComponentMask &component_mask = {},
732 const Function<spacedim> *coefficients = nullptr,
733 const unsigned int n_threads = numbers::invalid_unsigned_int,
736 const Strategy strategy = cell_diameter_over_24);
737
738
739
744 template <typename Number>
745 static void
746 estimate(
747 const DoFHandler<1, spacedim> &dof,
748 const hp::QCollection<0> &quadrature,
749 const std::map<types::boundary_id, const Function<spacedim, Number> *>
750 &neumann_bc,
751 const ReadVector<Number> &solution,
752 Vector<float> &error,
753 const ComponentMask &component_mask = {},
754 const Function<spacedim> *coefficients = nullptr,
755 const unsigned int n_threads = numbers::invalid_unsigned_int,
758 const Strategy strategy = cell_diameter_over_24);
759
760
761
766 template <typename Number>
767 static void
768 estimate(
770 const DoFHandler<1, spacedim> &dof,
771 const hp::QCollection<0> &quadrature,
772 const std::map<types::boundary_id, const Function<spacedim, Number> *>
773 &neumann_bc,
774 const ArrayView<const ReadVector<Number> *> &solutions,
775 ArrayView<Vector<float> *> &errors,
776 const ComponentMask &component_mask = {},
777 const Function<spacedim> *coefficients = nullptr,
778 const unsigned int n_threads = numbers::invalid_unsigned_int,
781 const Strategy strategy = cell_diameter_over_24);
782
783
784
789 template <typename Number>
790 static void
791 estimate(
792 const DoFHandler<1, spacedim> &dof,
793 const hp::QCollection<0> &quadrature,
794 const std::map<types::boundary_id, const Function<spacedim, Number> *>
795 &neumann_bc,
796 const ArrayView<const ReadVector<Number> *> &solutions,
797 ArrayView<Vector<float> *> &errors,
798 const ComponentMask &component_mask = {},
799 const Function<spacedim> *coefficients = nullptr,
800 const unsigned int n_threads = numbers::invalid_unsigned_int,
803 const Strategy strategy = cell_diameter_over_24);
804
805
806
811 "You provided a ComponentMask argument that is invalid. "
812 "Component masks need to be either default constructed "
813 "(in which case they indicate that every component is "
814 "selected) or need to have a length equal to the number "
815 "of vector components of the finite element in use "
816 "by the DoFHandler object. In the latter case, at "
817 "least one component needs to be selected.");
818
824 "If you do specify the argument for a (possibly "
825 "spatially variable) coefficient function for this function, "
826 "then it needs to refer to a coefficient that is either "
827 "scalar (has one vector component) or has as many vector "
828 "components as there are in the finite element used by "
829 "the DoFHandler argument.");
830
836 int,
837 int,
838 << "You provided a function map that for boundary indicator "
839 << arg1 << " specifies a function with " << arg2
840 << " vector components. However, the finite "
841 "element in use has "
842 << arg3
843 << " components, and these two numbers need to match.");
844
849 int,
850 int,
851 << "The number of input vectors, " << arg1
852 << " needs to be equal to the number of output vectors, "
853 << arg2
854 << ". This is not the case in your call of this function.");
855
860 "You need to specify at least one solution vector as "
861 "input.");
862};
863
864
866
867#endif
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)
static void estimate(const DoFHandler< dim, spacedim > &dof, const Quadrature< dim - 1 > &quadrature, const std::map< types::boundary_id, const Function< spacedim, Number > * > &neumann_bc, const ArrayView< const ReadVector< Number > * > &solutions, ArrayView< Vector< float > * > &errors, 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)
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 ArrayView< const ReadVector< Number > * > &solutions, ArrayView< Vector< float > * > &errors, 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)
static void estimate(const DoFHandler< dim, spacedim > &dof, const hp::QCollection< dim - 1 > &quadrature, const std::map< types::boundary_id, const Function< spacedim, Number > * > &neumann_bc, const ArrayView< const ReadVector< Number > * > &solutions, ArrayView< Vector< float > * > &errors, 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)
static void estimate(const hp::MappingCollection< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const hp::QCollection< 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)
@ cell_diameter_over_24
Kelly error estimator with the factor .
@ cell_diameter
Kelly error estimator with the factor .
static void estimate(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)
static void estimate(const DoFHandler< dim, spacedim > &dof, const hp::QCollection< 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)
static void estimate(const hp::MappingCollection< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const hp::QCollection< dim - 1 > &quadrature, const std::map< types::boundary_id, const Function< spacedim, Number > * > &neumann_bc, const ArrayView< const ReadVector< Number > * > &solutions, ArrayView< Vector< float > * > &errors, 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)
Abstract base class for mapping classes.
Definition mapping.h:318
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:249
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
static ::ExceptionBase & ExcInvalidBoundaryFunction(types::boundary_id arg1, int arg2, int arg3)
static ::ExceptionBase & ExcIncompatibleNumberOfElements(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
#define DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcInvalidComponentMask()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
static ::ExceptionBase & ExcInvalidCoefficient()
static ::ExceptionBase & ExcNoSolutions()
Definition hp.h:115
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
constexpr types::material_id invalid_material_id
Definition types.h:284
constexpr types::subdomain_id invalid_subdomain_id
Definition types.h:385
unsigned int subdomain_id
Definition types.h:50
unsigned int material_id
Definition types.h:182