deal.II version 9.8.0
\(\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>
47} // namespace hp
48#endif
49
50
262template <int dim, int spacedim = dim>
264{
265public:
280
341 template <typename Number>
342 static void
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
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
458 template <typename Number>
460 "Use the version of this function which takes a hp::MappingCollection instead.")
461 static void estimate(
462 const Mapping<dim, spacedim> &mapping,
463 const DoFHandler<dim, spacedim> &dof,
464 const hp::QCollection<dim - 1> &quadrature,
465 const std::map<types::boundary_id, const Function<spacedim, Number> *>
466 &neumann_bc,
467 const ReadVector<Number> &solution,
468 Vector<float> &error,
469 const ComponentMask &component_mask = {},
470 const Function<spacedim> *coefficients = nullptr,
471 const unsigned int n_threads = numbers::invalid_unsigned_int,
474 const Strategy strategy = cell_diameter_over_24);
475
476
481 template <typename Number>
482 static void
484 const DoFHandler<dim, spacedim> &dof,
485 const hp::QCollection<dim - 1> &quadrature,
486 const std::map<types::boundary_id, const Function<spacedim, Number> *>
487 &neumann_bc,
488 const ReadVector<Number> &solution,
489 Vector<float> &error,
490 const ComponentMask &component_mask = {},
491 const Function<spacedim> *coefficients = nullptr,
492 const unsigned int n_threads = numbers::invalid_unsigned_int,
495 const Strategy strategy = cell_diameter_over_24);
496
497
502 template <typename Number>
503 static void
506 const DoFHandler<dim, spacedim> &dof,
507 const hp::QCollection<dim - 1> &quadrature,
508 const std::map<types::boundary_id, const Function<spacedim, Number> *>
509 &neumann_bc,
510 const ArrayView<const ReadVector<Number> *> &solutions,
511 ArrayView<Vector<float> *> &errors,
512 const ComponentMask &component_mask = {},
513 const Function<spacedim> *coefficients = nullptr,
514 const unsigned int n_threads = numbers::invalid_unsigned_int,
517 const Strategy strategy = cell_diameter_over_24);
518
519
527 template <typename Number>
529 "Use the version of this function which takes a hp::MappingCollection instead.")
530 static void estimate(
531 const Mapping<dim, spacedim> &mapping,
532 const DoFHandler<dim, spacedim> &dof,
533 const hp::QCollection<dim - 1> &quadrature,
534 const std::map<types::boundary_id, const Function<spacedim, Number> *>
535 &neumann_bc,
536 const ArrayView<const ReadVector<Number> *> &solutions,
537 ArrayView<Vector<float> *> &errors,
538 const ComponentMask &component_mask = {},
539 const Function<spacedim> *coefficients = nullptr,
540 const unsigned int n_threads = numbers::invalid_unsigned_int,
543 const Strategy strategy = cell_diameter_over_24);
544
545
550 template <typename Number>
551 static void
553 const DoFHandler<dim, spacedim> &dof,
554 const hp::QCollection<dim - 1> &quadrature,
555 const std::map<types::boundary_id, const Function<spacedim, Number> *>
556 &neumann_bc,
557 const ArrayView<const ReadVector<Number> *> &solutions,
558 ArrayView<Vector<float> *> &errors,
559 const ComponentMask &component_mask = {},
560 const Function<spacedim> *coefficients = nullptr,
561 const unsigned int n_threads = numbers::invalid_unsigned_int,
564 const Strategy strategy = cell_diameter_over_24);
565
570 "You provided a ComponentMask argument that is invalid. "
571 "Component masks need to be either default constructed "
572 "(in which case they indicate that every component is "
573 "selected) or need to have a length equal to the number "
574 "of vector components of the finite element in use "
575 "by the DoFHandler object. In the latter case, at "
576 "least one component needs to be selected.");
582 "If you do specify the argument for a (possibly "
583 "spatially variable) coefficient function for this function, "
584 "then it needs to refer to a coefficient that is either "
585 "scalar (has one vector component) or has as many vector "
586 "components as there are in the finite element used by "
587 "the DoFHandler argument.");
593 int,
594 int,
595 << "You provided a function map that for boundary indicator "
596 << arg1 << " specifies a function with " << arg2
597 << " vector components. However, the finite "
598 "element in use has "
599 << arg3
600 << " components, and these two numbers need to match.");
605 int,
606 int,
607 << "The number of input vectors, " << arg1
608 << " needs to be equal to the number of output vectors, "
609 << arg2
610 << ". This is not the case in your call of this function.");
615 "You need to specify at least one solution vector as "
616 "input.");
617};
618
619
620
630template <int spacedim>
631class KellyErrorEstimator<1, spacedim>
632{
633public:
648
649
650
673 template <typename Number>
674 static void
675 estimate(
677 const DoFHandler<1, spacedim> &dof,
678 const Quadrature<0> &quadrature,
679 const std::map<types::boundary_id, const Function<spacedim, Number> *>
680 &neumann_bc,
681 const ReadVector<Number> &solution,
682 Vector<float> &error,
683 const ComponentMask &component_mask = {},
684 const Function<spacedim> *coefficient = nullptr,
685 const unsigned int n_threads = numbers::invalid_unsigned_int,
688 const Strategy strategy = cell_diameter_over_24);
689
690
691
696 template <typename Number>
697 static void
698 estimate(
699 const DoFHandler<1, spacedim> &dof,
700 const Quadrature<0> &quadrature,
701 const std::map<types::boundary_id, const Function<spacedim, Number> *>
702 &neumann_bc,
703 const ReadVector<Number> &solution,
704 Vector<float> &error,
705 const ComponentMask &component_mask = {},
706 const Function<spacedim> *coefficients = nullptr,
707 const unsigned int n_threads = numbers::invalid_unsigned_int,
710 const Strategy strategy = cell_diameter_over_24);
711
712
713
727 template <typename Number>
728 static void
729 estimate(
730 const Mapping<1, spacedim> &mapping,
731 const DoFHandler<1, spacedim> &dof,
732 const Quadrature<0> &quadrature,
733 const std::map<types::boundary_id, const Function<spacedim, Number> *>
734 &neumann_bc,
735 const ArrayView<const ReadVector<Number> *> &solutions,
736 ArrayView<Vector<float> *> &errors,
737 const ComponentMask &component_mask = {},
738 const Function<spacedim> *coefficients = nullptr,
739 const unsigned int n_threads = numbers::invalid_unsigned_int,
742 const Strategy strategy = cell_diameter_over_24);
743
744
745
750 template <typename Number>
751 static void
752 estimate(
753 const DoFHandler<1, spacedim> &dof,
754 const Quadrature<0> &quadrature,
755 const std::map<types::boundary_id, const Function<spacedim, Number> *>
756 &neumann_bc,
757 const ArrayView<const ReadVector<Number> *> &solutions,
758 ArrayView<Vector<float> *> &errors,
759 const ComponentMask &component_mask = {},
760 const Function<spacedim> *coefficients = nullptr,
761 const unsigned int n_threads = numbers::invalid_unsigned_int,
764 const Strategy strategy = cell_diameter_over_24);
765
766
767
772 template <typename Number>
773 static void
774 estimate(
775 const hp::MappingCollection<1, spacedim> &mapping,
776 const DoFHandler<1, spacedim> &dof,
777 const hp::QCollection<0> &quadrature,
778 const std::map<types::boundary_id, const Function<spacedim, Number> *>
779 &neumann_bc,
780 const ReadVector<Number> &solution,
781 Vector<float> &error,
782 const ComponentMask &component_mask = {},
783 const Function<spacedim> *coefficients = nullptr,
784 const unsigned int n_threads = numbers::invalid_unsigned_int,
787 const Strategy strategy = cell_diameter_over_24);
788
789
790
798 template <typename Number>
800 "Use the version of this function which takes a hp::MappingCollection instead.")
801 static void estimate(
802 const Mapping<1, spacedim> &mapping,
803 const DoFHandler<1, spacedim> &dof,
804 const hp::QCollection<0> &quadrature,
805 const std::map<types::boundary_id, const Function<spacedim, Number> *>
806 &neumann_bc,
807 const ReadVector<Number> &solution,
808 Vector<float> &error,
809 const ComponentMask &component_mask = {},
810 const Function<spacedim> *coefficients = nullptr,
811 const unsigned int n_threads = numbers::invalid_unsigned_int,
814 const Strategy strategy = cell_diameter_over_24);
815
816
817
822 template <typename Number>
823 static void
824 estimate(
825 const DoFHandler<1, spacedim> &dof,
826 const hp::QCollection<0> &quadrature,
827 const std::map<types::boundary_id, const Function<spacedim, Number> *>
828 &neumann_bc,
829 const ReadVector<Number> &solution,
830 Vector<float> &error,
831 const ComponentMask &component_mask = {},
832 const Function<spacedim> *coefficients = nullptr,
833 const unsigned int n_threads = numbers::invalid_unsigned_int,
836 const Strategy strategy = cell_diameter_over_24);
837
838
839
844 template <typename Number>
845 static void
846 estimate(
847 const hp::MappingCollection<1, spacedim> &mapping,
848 const DoFHandler<1, spacedim> &dof,
849 const hp::QCollection<0> &quadrature,
850 const std::map<types::boundary_id, const Function<spacedim, Number> *>
851 &neumann_bc,
852 const ArrayView<const ReadVector<Number> *> &solutions,
853 ArrayView<Vector<float> *> &errors,
854 const ComponentMask &component_mask = {},
855 const Function<spacedim> *coefficients = nullptr,
856 const unsigned int n_threads = numbers::invalid_unsigned_int,
859 const Strategy strategy = cell_diameter_over_24);
860
861
862
870 template <typename Number>
872 "Use the version of this function which takes a hp::MappingCollection instead.")
873 static void estimate(
874 const Mapping<1, spacedim> &mapping,
875 const DoFHandler<1, spacedim> &dof,
876 const hp::QCollection<0> &quadrature,
877 const std::map<types::boundary_id, const Function<spacedim, Number> *>
878 &neumann_bc,
879 const ArrayView<const ReadVector<Number> *> &solutions,
880 ArrayView<Vector<float> *> &errors,
881 const ComponentMask &component_mask = {},
882 const Function<spacedim> *coefficients = nullptr,
883 const unsigned int n_threads = numbers::invalid_unsigned_int,
886 const Strategy strategy = cell_diameter_over_24);
887
888
889
894 template <typename Number>
895 static void
896 estimate(
897 const DoFHandler<1, spacedim> &dof,
898 const hp::QCollection<0> &quadrature,
899 const std::map<types::boundary_id, const Function<spacedim, Number> *>
900 &neumann_bc,
901 const ArrayView<const ReadVector<Number> *> &solutions,
902 ArrayView<Vector<float> *> &errors,
903 const ComponentMask &component_mask = {},
904 const Function<spacedim> *coefficients = nullptr,
905 const unsigned int n_threads = numbers::invalid_unsigned_int,
908 const Strategy strategy = cell_diameter_over_24);
909
910
911
916 "You provided a ComponentMask argument that is invalid. "
917 "Component masks need to be either default constructed "
918 "(in which case they indicate that every component is "
919 "selected) or need to have a length equal to the number "
920 "of vector components of the finite element in use "
921 "by the DoFHandler object. In the latter case, at "
922 "least one component needs to be selected.");
923
929 "If you do specify the argument for a (possibly "
930 "spatially variable) coefficient function for this function, "
931 "then it needs to refer to a coefficient that is either "
932 "scalar (has one vector component) or has as many vector "
933 "components as there are in the finite element used by "
934 "the DoFHandler argument.");
935
941 int,
942 int,
943 << "You provided a function map that for boundary indicator "
944 << arg1 << " specifies a function with " << arg2
945 << " vector components. However, the finite "
946 "element in use has "
947 << arg3
948 << " components, and these two numbers need to match.");
949
954 int,
955 int,
956 << "The number of input vectors, " << arg1
957 << " needs to be equal to the number of output vectors, "
958 << arg2
959 << ". This is not the case in your call of this function.");
960
965 "You need to specify at least one solution vector as "
966 "input.");
967};
968
969
971
972#endif
@ cell_diameter
Kelly error estimator with the factor .
@ cell_diameter_over_24
Kelly error estimator with the factor .
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_DEPRECATED_WITH_COMMENT(comment)
Definition config.h:287
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:246
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
static ::ExceptionBase & ExcInvalidBoundaryFunction(types::boundary_id arg1, int arg2, int arg3)
static ::ExceptionBase & ExcInvalidBoundaryFunction(types::boundary_id arg1, int arg2, int arg3)
static ::ExceptionBase & ExcIncompatibleNumberOfElements(int arg1, int arg2)
static ::ExceptionBase & ExcNoSolutions()
#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 & ExcInvalidCoefficient()
static ::ExceptionBase & ExcNoSolutions()
static ::ExceptionBase & ExcIncompatibleNumberOfElements(int arg1, int arg2)
MappingQ< dim, spacedim > StaticMappingQ1< dim, spacedim >::mapping
Definition mapping_q1.h:101
Definition hp.h:115
constexpr unsigned int invalid_unsigned_int
Definition types.h:236
constexpr types::material_id invalid_material_id
Definition types.h:292
constexpr types::subdomain_id invalid_subdomain_id
Definition types.h:393
STL namespace.
Definition types.h:30
unsigned int material_id
Definition types.h:182
unsigned int boundary_id
Definition types.h:159
unsigned int subdomain_id
Definition types.h:50