Reference documentation for deal.II version 9.5.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
quadrature_generator.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2021 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_non_matching_quadrature_generator_h
17#define dealii_non_matching_quadrature_generator_h
18
19#include <deal.II/base/config.h>
20
26
28
29#include <deal.II/grid/tria.h>
30
32
34
35#include <functional>
36
38namespace NonMatching
39{
40 namespace internal
41 {
42 namespace QuadratureGeneratorImplementation
43 {
44 template <int dim, int spacedim>
45 class QGenerator;
46 } // namespace QuadratureGeneratorImplementation
47
48
49 namespace DiscreteQuadratureGeneratorImplementation
50 {
51 template <int dim>
52 class CellWiseFunction;
53 } // namespace DiscreteQuadratureGeneratorImplementation
54 } // namespace internal
55
56
61 {
65 AdditionalQGeneratorData(const unsigned int max_box_splits = 4,
66 const double lower_bound_implicit_function = 1e-11,
67 const double min_distance_between_roots = 1e-12,
68 const double limit_to_be_definite = 1e-11,
69 const double root_finder_tolerance = 1e-12,
70 const unsigned int max_root_finder_splits = 2,
71 bool split_in_half = true);
72
77 unsigned int max_box_splits;
78
97
103
112
117
123
130 };
131
132
133
187 template <int dim>
189 {
190 public:
192
201 const hp::QCollection<1> &quadratures1D,
202 const AdditionalData & additional_data = AdditionalData());
203
216 void
217 generate(const Function<dim> &level_set, const BoundingBox<dim> &box);
218
225 const Quadrature<dim> &
226 get_inside_quadrature() const;
227
234 const Quadrature<dim> &
236
247
252 void
253 set_1D_quadrature(const unsigned int q_index);
254
255 private:
262 };
263
264
291 template <int dim>
293 {
294 public:
296
305 const hp::QCollection<1> &quadratures1D,
306 const AdditionalData & additional_data = AdditionalData());
307
320 void
321 generate(const Function<dim> & level_set,
322 const BoundingBox<dim> &box,
323 const unsigned int face_index);
324
331 const Quadrature<dim - 1> &
332 get_inside_quadrature() const;
333
340 const Quadrature<dim - 1> &
342
351 const ImmersedSurfaceQuadrature<dim - 1, dim> &
353
358 void
359 set_1D_quadrature(const unsigned int q_index);
360
361 private:
367
373 };
374
375
392 template <>
394 {
395 public:
397
403 const hp::QCollection<1> &quadratures1D,
404 const AdditionalData & additional_data = AdditionalData());
405
415 void
416 generate(const Function<1> & level_set,
417 const BoundingBox<1> &box,
418 const unsigned int face_index);
419
423 const Quadrature<0> &
424 get_inside_quadrature() const;
425
429 const Quadrature<0> &
431
441
446 void
447 set_1D_quadrature(const unsigned int q_index);
448
449 private:
456
463
470 };
471
472
490 template <int dim>
492 {
493 public:
495
503 template <class VectorType>
505 const hp::QCollection<1> &quadratures1D,
506 const DoFHandler<dim> & dof_handler,
507 const VectorType & level_set,
508 const AdditionalData & additional_data = AdditionalData());
509
517 void
519
520 private:
524 std::unique_ptr<internal::DiscreteQuadratureGeneratorImplementation::
525 CellWiseFunction<dim>>
527 };
528
546 template <int dim>
548 {
549 public:
551
559 template <class VectorType>
561 const hp::QCollection<1> &quadratures1D,
562 const DoFHandler<dim> & dof_handler,
563 const VectorType & level_set,
564 const AdditionalData & additional_data = AdditionalData());
565
573 void
575 const unsigned int face_index);
576
577 private:
581 std::unique_ptr<internal::DiscreteQuadratureGeneratorImplementation::
582 CellWiseFunction<dim>>
584 };
585
586
587 namespace internal
588 {
589 namespace QuadratureGeneratorImplementation
590 {
609 {
610 public:
615 {
619 AdditionalData(const double tolerance = 1e-12,
620 const unsigned int max_recursion_depth = 2,
621 const unsigned int max_iterations = 500);
622
627 double tolerance;
628
634
639 unsigned int max_iterations;
640 };
641
642
647
655 void
656 find_roots(const std::vector<std::reference_wrapper<const Function<1>>>
657 & functions,
658 const BoundingBox<1> &interval,
659 std::vector<double> & roots);
660
661 private:
667 void
668 find_roots(const Function<1> & function,
669 const BoundingBox<1> &interval,
670 const unsigned int recursion_depth,
671 std::vector<double> & roots);
672
674 };
675
676
689 template <int dim>
691 {
692 public:
698
702 ExtendableQuadrature(const Quadrature<dim> &quadrature);
703
707 void
708 push_back(const Point<dim> &point, const double weight);
709 };
710
711
715 enum class Definiteness
716 {
717 negative,
718 positive,
720 };
721
722
752 template <int dim>
754 {
755 public:
761 quadrature_by_definiteness(const Definiteness definiteness);
762
768
774
780
786 };
787
788
827 template <int dim, int spacedim>
829 {
830 public:
837
843 void
844 generate(const std::vector<std::reference_wrapper<const Function<dim>>>
845 & level_sets,
846 const BoundingBox<dim> & box,
847 const Quadrature<dim - 1> &low_dim_quadrature,
848 const unsigned int height_function_direction,
849 QPartitioning<dim> & q_partitioning);
850
855 void
856 set_1D_quadrature(const unsigned int q_index);
857
858 private:
867 void
869 const Point<dim - 1> &point,
870 const double weight,
871 const std::vector<std::reference_wrapper<const Function<dim>>>
872 & level_sets,
873 const BoundingBox<dim> & box,
874 const unsigned int height_function_direction,
875 ImmersedSurfaceQuadrature<dim> &surface_quadrature);
876
882
887
892 unsigned int q_index;
893
899
904
911 std::vector<double> roots;
912 };
913
914
932 {
938
939
943 unsigned int direction;
944
950 };
951
952
957 template <int dim, int spacedim>
959 {
960 public:
963
967 void
969
973 const QPartitioning<dim> &
974 get_quadratures() const;
975
976 protected:
981
986 unsigned int q_index;
987
993
998 };
999
1000
1084 template <int dim, int spacedim>
1085 class QGenerator : public QGeneratorBase<dim, spacedim>
1086 {
1087 public:
1093
1104 void
1105 generate(const std::vector<std::reference_wrapper<const Function<dim>>>
1106 & level_sets,
1107 const BoundingBox<dim> &box,
1108 const unsigned int n_box_splits);
1109
1114 void
1115 set_1D_quadrature(const unsigned int q_index);
1116
1117 private:
1124 void
1126 const unsigned int height_function_direction,
1127 const std::vector<std::reference_wrapper<const Function<dim>>>
1128 & level_sets,
1129 const BoundingBox<dim> &box,
1130 const unsigned int n_box_splits);
1131
1137 void
1139 const unsigned int height_function_direction,
1140 const std::vector<std::reference_wrapper<const Function<dim>>>
1141 & level_sets,
1142 const BoundingBox<dim> &box);
1143
1149 void
1151 const std::vector<std::reference_wrapper<const Function<dim>>>
1152 & level_sets,
1153 const BoundingBox<dim> & box,
1154 const std_cxx17::optional<HeightDirectionData> &direction_data,
1155 const unsigned int n_box_splits);
1156
1166 void
1168 const std::vector<std::reference_wrapper<const Function<dim>>>
1169 & level_sets,
1170 const BoundingBox<dim> &box);
1171
1176 QGenerator<dim - 1, spacedim> low_dim_algorithm;
1177
1183
1189 };
1190
1191
1207 template <int spacedim>
1208 class QGenerator<1, spacedim> : public QGeneratorBase<1, spacedim>
1209 {
1210 public:
1214 QGenerator(const hp::QCollection<1> & quadratures1D,
1216
1223 void
1224 generate(const std::vector<std::reference_wrapper<const Function<1>>>
1225 & level_sets,
1226 const BoundingBox<1> &box,
1227 const unsigned int n_box_splits);
1228
1233 void
1234 set_1D_quadrature(const unsigned int q_index);
1235
1236 private:
1241 void
1242 create_surface_points(
1243 const std::vector<std::reference_wrapper<const Function<1>>>
1244 &level_sets);
1245
1250
1254 std::vector<double> roots;
1255
1260 const unsigned int direction = 0;
1261
1267 const double unit_weight = 1;
1268 };
1269
1270
1279 template <int dim>
1280 void
1282 const double weight,
1283 const Quadrature<1> & quadrature1D,
1284 const double start,
1285 const double end,
1286 const unsigned int component_in_dim,
1287 ExtendableQuadrature<dim> &quadrature);
1288
1289
1296 template <int dim>
1299 const std::vector<std::reference_wrapper<const Function<dim>>>
1300 & functions,
1301 const Point<dim> &point);
1302
1303
1308 template <int dim>
1310 {
1311 public:
1315 std::pair<double, double> value;
1316
1320 std::array<std::pair<double, double>, dim> gradient;
1321 };
1322
1323
1331 template <int dim>
1332 std::pair<double, double>
1334 const std::vector<FunctionBounds<dim>> &all_function_bounds);
1335
1336
1369 template <int dim>
1370 std_cxx17::optional<HeightDirectionData>
1372 const std::vector<FunctionBounds<dim>> &all_function_bounds);
1373
1374 } // namespace QuadratureGeneratorImplementation
1375
1376
1377 namespace DiscreteQuadratureGeneratorImplementation
1378 {
1384 template <int dim>
1385 class CellWiseFunction : public Function<dim>
1386 {
1387 public:
1391 virtual ~CellWiseFunction() = default;
1392
1396 virtual void
1398 const typename Triangulation<dim>::active_cell_iterator &cell) = 0;
1399 };
1400
1401 } // namespace DiscreteQuadratureGeneratorImplementation
1402 } // namespace internal
1403
1404} // namespace NonMatching
1406
1407#endif /* dealii_non_matching_quadrature_generator_h */
void generate(const typename Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index)
std::unique_ptr< internal::DiscreteQuadratureGeneratorImplementation::CellWiseFunction< dim > > reference_space_level_set
void generate(const typename Triangulation< dim >::active_cell_iterator &cell)
std::unique_ptr< internal::DiscreteQuadratureGeneratorImplementation::CellWiseFunction< dim > > reference_space_level_set
const ImmersedSurfaceQuadrature< 0, 1 > surface_quadrature
const Quadrature< dim - 1 > & get_inside_quadrature() const
void generate(const Function< dim > &level_set, const BoundingBox< dim > &box, const unsigned int face_index)
ImmersedSurfaceQuadrature< dim - 1, dim > surface_quadrature
void set_1D_quadrature(const unsigned int q_index)
const ImmersedSurfaceQuadrature< dim - 1, dim > & get_surface_quadrature() const
QuadratureGenerator< dim - 1 > quadrature_generator
const Quadrature< dim - 1 > & get_outside_quadrature() const
void set_1D_quadrature(const unsigned int q_index)
AdditionalQGeneratorData AdditionalData
const Quadrature< dim > & get_inside_quadrature() const
const Quadrature< dim > & get_outside_quadrature() const
internal::QuadratureGeneratorImplementation::QGenerator< dim, dim > q_generator
const ImmersedSurfaceQuadrature< dim > & get_surface_quadrature() const
void generate(const Function< dim > &level_set, const BoundingBox< dim > &box)
virtual void set_active_cell(const typename Triangulation< dim >::active_cell_iterator &cell)=0
void create_high_dim_quadratures(const unsigned int height_function_direction, const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box)
void generate(const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box, const unsigned int n_box_splits)
void use_midpoint_method(const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box)
void split_box_and_recurse(const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box, const std_cxx17::optional< HeightDirectionData > &direction_data, const unsigned int n_box_splits)
void create_low_dim_quadratures(const unsigned int height_function_direction, const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box, const unsigned int n_box_splits)
ExtendableQuadrature< dim > & quadrature_by_definiteness(const Definiteness definiteness)
void find_roots(const std::vector< std::reference_wrapper< const Function< 1 > > > &functions, const BoundingBox< 1 > &interval, std::vector< double > &roots)
void generate(const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box, const Quadrature< dim - 1 > &low_dim_quadrature, const unsigned int height_function_direction, QPartitioning< dim > &q_partitioning)
void create_surface_point(const Point< dim - 1 > &point, const double weight, const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box, const unsigned int height_function_direction, ImmersedSurfaceQuadrature< dim > &surface_quadrature)
Definition point.h:112
const Point< dim > & point(const unsigned int i) const
double weight(const unsigned int i) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
std_cxx17::optional< HeightDirectionData > find_best_height_direction(const std::vector< FunctionBounds< dim > > &all_function_bounds)
std::pair< double, double > find_extreme_values(const std::vector< FunctionBounds< dim > > &all_function_bounds)
void tensor_point_with_1D_quadrature(const Point< dim - 1 > &point, const double weight, const Quadrature< 1 > &quadrature1D, const double start, const double end, const unsigned int component_in_dim, ExtendableQuadrature< dim > &quadrature)
Definiteness pointwise_definiteness(const std::vector< std::reference_wrapper< const Function< dim > > > &functions, const Point< dim > &point)