deal.II version GIT relicensing-1936-ge55124254b 2024-10-04 21:10:00+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
quadrature_generator.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2020 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_non_matching_quadrature_generator_h
16#define dealii_non_matching_quadrature_generator_h
17
18#include <deal.II/base/config.h>
19
24
26
27#include <deal.II/grid/tria.h>
28
30
32
33#include <functional>
34#include <optional>
35
37namespace NonMatching
38{
39 namespace internal
40 {
41 namespace QuadratureGeneratorImplementation
42 {
43 template <int dim, int spacedim>
44 class QGenerator;
45 } // namespace QuadratureGeneratorImplementation
46
47
48 namespace DiscreteQuadratureGeneratorImplementation
49 {
50 template <int dim>
51 class CellWiseFunction;
52 } // namespace DiscreteQuadratureGeneratorImplementation
53 } // namespace internal
54
55
60 {
64 AdditionalQGeneratorData(const unsigned int max_box_splits = 4,
65 const double lower_bound_implicit_function = 1e-11,
66 const double min_distance_between_roots = 1e-12,
67 const double limit_to_be_definite = 1e-11,
68 const double root_finder_tolerance = 1e-12,
69 const unsigned int max_root_finder_splits = 2,
70 bool split_in_half = true);
71
76 unsigned int max_box_splits;
77
96
102
111
116
122
129 };
130
131
132
186 template <int dim>
188 {
189 public:
191
200 const hp::QCollection<1> &quadratures1D,
201 const AdditionalData &additional_data = AdditionalData());
202
206 void
208
221 void
222 generate(const Function<dim> &level_set, const BoundingBox<dim> &box);
223
228 void
229 generate_append(const Function<dim> &level_set,
230 const BoundingBox<dim> &box);
231
238 const Quadrature<dim> &
239 get_inside_quadrature() const;
240
247 const Quadrature<dim> &
249
260
265 void
266 set_1D_quadrature(const unsigned int q_index);
267
268 private:
275 };
276
277
304 template <int dim>
306 {
307 public:
309
318 const hp::QCollection<1> &quadratures1D,
319 const AdditionalData &additional_data = AdditionalData());
320
324 void
326
339 void
340 generate(const Function<dim> &level_set,
341 const BoundingBox<dim> &box,
342 const unsigned int face_index);
343
348 void
349 generate_append(const Function<dim> &level_set,
350 const BoundingBox<dim> &box,
351 const unsigned int face_index);
352
359 const Quadrature<dim - 1> &
360 get_inside_quadrature() const;
361
368 const Quadrature<dim - 1> &
370
379 const ImmersedSurfaceQuadrature<dim - 1, dim> &
381
386 void
387 set_1D_quadrature(const unsigned int q_index);
388
389 private:
395
401 };
402
403
420 template <>
422 {
423 public:
425
431 const hp::QCollection<1> &quadratures1D,
432 const AdditionalData &additional_data = AdditionalData());
433
437 void
439
449 void
450 generate(const Function<1> &level_set,
451 const BoundingBox<1> &box,
452 const unsigned int face_index);
453
458 void
459 generate_append(const Function<1> &level_set,
460 const BoundingBox<1> &box,
461 const unsigned int face_index);
462
466 const Quadrature<0> &
467 get_inside_quadrature() const;
468
472 const Quadrature<0> &
474
484
489 void
490 set_1D_quadrature(const unsigned int q_index);
491
492 private:
499
506
513 };
514
515
533 template <int dim>
535 {
536 public:
538
546 template <typename VectorType>
548 const hp::QCollection<1> &quadratures1D,
549 const DoFHandler<dim> &dof_handler,
550 const VectorType &level_set,
551 const AdditionalData &additional_data = AdditionalData());
552
560 void
562
563 private:
567 void
568 generate_fe_q_iso_q1(const BoundingBox<dim> &unit_box);
569
573 std::unique_ptr<internal::DiscreteQuadratureGeneratorImplementation::
574 CellWiseFunction<dim>>
576 };
577
595 template <int dim>
597 {
598 public:
600
608 template <typename VectorType>
610 const hp::QCollection<1> &quadratures1D,
611 const DoFHandler<dim> &dof_handler,
612 const VectorType &level_set,
613 const AdditionalData &additional_data = AdditionalData());
614
622 void
624 const unsigned int face_index);
625
626 private:
630 void
632 unsigned int face_index);
633
637 std::unique_ptr<internal::DiscreteQuadratureGeneratorImplementation::
638 CellWiseFunction<dim>>
640 };
641
642
643 namespace internal
644 {
645 namespace QuadratureGeneratorImplementation
646 {
665 {
666 public:
671 {
675 AdditionalData(const double tolerance = 1e-12,
676 const unsigned int max_recursion_depth = 2,
677 const unsigned int max_iterations = 500);
678
683 double tolerance;
684
690
695 unsigned int max_iterations;
696 };
697
698
703
711 void
712 find_roots(const std::vector<std::reference_wrapper<const Function<1>>>
713 &functions,
714 const BoundingBox<1> &interval,
715 std::vector<double> &roots);
716
717 private:
723 void
724 find_roots(const Function<1> &function,
725 const BoundingBox<1> &interval,
726 const unsigned int recursion_depth,
727 std::vector<double> &roots);
728
730 };
731
732
745 template <int dim>
747 {
748 public:
754
758 ExtendableQuadrature(const Quadrature<dim> &quadrature);
759
763 void
764 clear();
765
769 void
770 push_back(const Point<dim> &point, const double weight);
771 };
772
773
777 enum class Definiteness
778 {
779 negative,
780 positive,
782 };
783
784
814 template <int dim>
855
856
895 template <int dim, int spacedim>
897 {
898 public:
905
911 void
912 generate(const std::vector<std::reference_wrapper<const Function<dim>>>
913 &level_sets,
914 const BoundingBox<dim> &box,
915 const Quadrature<dim - 1> &low_dim_quadrature,
916 const unsigned int height_function_direction,
917 QPartitioning<dim> &q_partitioning);
918
923 void
924 set_1D_quadrature(const unsigned int q_index);
925
926 private:
935 void
937 const Point<dim - 1> &point,
938 const double weight,
939 const std::vector<std::reference_wrapper<const Function<dim>>>
940 &level_sets,
941 const BoundingBox<dim> &box,
942 const unsigned int height_function_direction,
943 ImmersedSurfaceQuadrature<dim> &surface_quadrature);
944
950
955
960 unsigned int q_index;
961
967
972
979 std::vector<double> roots;
980 };
981
982
1000 {
1006
1007
1011 unsigned int direction;
1012
1018 };
1019
1020
1025 template <int dim, int spacedim>
1067
1068
1152 template <int dim, int spacedim>
1153 class QGenerator : public QGeneratorBase<dim, spacedim>
1154 {
1155 public:
1161
1172 void
1173 generate(const std::vector<std::reference_wrapper<const Function<dim>>>
1174 &level_sets,
1175 const BoundingBox<dim> &box,
1176 const unsigned int n_box_splits);
1177
1182 void
1183 set_1D_quadrature(const unsigned int q_index);
1184
1185 private:
1192 void
1194 const unsigned int height_function_direction,
1195 const std::vector<std::reference_wrapper<const Function<dim>>>
1196 &level_sets,
1197 const BoundingBox<dim> &box,
1198 const unsigned int n_box_splits);
1199
1205 void
1207 const unsigned int height_function_direction,
1208 const std::vector<std::reference_wrapper<const Function<dim>>>
1209 &level_sets,
1210 const BoundingBox<dim> &box);
1211
1217 void
1219 const std::vector<std::reference_wrapper<const Function<dim>>>
1220 &level_sets,
1221 const BoundingBox<dim> &box,
1222 const std::optional<HeightDirectionData> &direction_data,
1223 const unsigned int n_box_splits);
1224
1234 void
1236 const std::vector<std::reference_wrapper<const Function<dim>>>
1237 &level_sets,
1238 const BoundingBox<dim> &box);
1239
1244 QGenerator<dim - 1, spacedim> low_dim_algorithm;
1245
1251
1257 };
1258
1259
1275 template <int spacedim>
1276 class QGenerator<1, spacedim> : public QGeneratorBase<1, spacedim>
1277 {
1278 public:
1282 QGenerator(const hp::QCollection<1> &quadratures1D,
1284
1291 void
1292 generate(const std::vector<std::reference_wrapper<const Function<1>>>
1293 &level_sets,
1294 const BoundingBox<1> &box,
1295 const unsigned int n_box_splits);
1296
1301 void
1302 set_1D_quadrature(const unsigned int q_index);
1303
1304 private:
1309 void
1310 create_surface_points(
1311 const std::vector<std::reference_wrapper<const Function<1>>>
1312 &level_sets);
1313
1318
1322 std::vector<double> roots;
1323
1328 const unsigned int direction = 0;
1329
1335 const double unit_weight = 1;
1336 };
1337
1338
1347 template <int dim>
1348 void
1350 const double weight,
1351 const Quadrature<1> &quadrature1D,
1352 const double start,
1353 const double end,
1354 const unsigned int component_in_dim,
1355 ExtendableQuadrature<dim> &quadrature);
1356
1357
1364 template <int dim>
1367 const std::vector<std::reference_wrapper<const Function<dim>>>
1368 &functions,
1369 const Point<dim> &point);
1370
1371
1376 template <int dim>
1378 {
1379 public:
1383 std::pair<double, double> value;
1384
1388 std::array<std::pair<double, double>, dim> gradient;
1389 };
1390
1391
1399 template <int dim>
1400 std::pair<double, double>
1402 const std::vector<FunctionBounds<dim>> &all_function_bounds);
1403
1404
1437 template <int dim>
1438 std::optional<HeightDirectionData>
1440 const std::vector<FunctionBounds<dim>> &all_function_bounds);
1441
1442 } // namespace QuadratureGeneratorImplementation
1443
1444
1445 namespace DiscreteQuadratureGeneratorImplementation
1446 {
1452 template <int dim>
1453 class CellWiseFunction : public Function<dim>
1454 {
1455 public:
1459 virtual ~CellWiseFunction() = default;
1460
1464 virtual void
1466 const typename Triangulation<dim>::active_cell_iterator &cell) = 0;
1467
1472 virtual void
1473 set_subcell(const std::vector<unsigned int> &mask,
1474 const BoundingBox<dim> &subcell_box) = 0;
1475
1479 virtual bool
1480 is_fe_q_iso_q1() const = 0;
1481
1485 virtual unsigned int
1486 n_subdivisions() const = 0;
1487 };
1488
1489 } // namespace DiscreteQuadratureGeneratorImplementation
1490 } // namespace internal
1491
1492} // namespace NonMatching
1494
1495#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_fe_q_iso_q1(const BoundingBox< dim > &unit_box, unsigned int face_index)
void generate(const typename Triangulation< dim >::active_cell_iterator &cell)
std::unique_ptr< internal::DiscreteQuadratureGeneratorImplementation::CellWiseFunction< dim > > reference_space_level_set
void generate_fe_q_iso_q1(const BoundingBox< dim > &unit_box)
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)
void generate_append(const Function< dim > &level_set, const BoundingBox< dim > &box, const unsigned int face_index)
const ImmersedSurfaceQuadrature< dim - 1, dim > & get_surface_quadrature() const
QuadratureGenerator< dim - 1 > quadrature_generator
const Quadrature< dim - 1 > & get_outside_quadrature() const
void generate_append(const Function< dim > &level_set, const BoundingBox< dim > &box)
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_subcell(const std::vector< unsigned int > &mask, const BoundingBox< dim > &subcell_box)=0
virtual void set_active_cell(const typename Triangulation< dim >::active_cell_iterator &cell)=0
const ObserverPointer< const hp::QCollection< 1 > > q_collection1D
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 split_box_and_recurse(const std::vector< std::reference_wrapper< const Function< dim > > > &level_sets, const BoundingBox< dim > &box, const std::optional< HeightDirectionData > &direction_data, 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 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:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
std::pair< double, double > find_extreme_values(const std::vector< FunctionBounds< dim > > &all_function_bounds)
std::optional< HeightDirectionData > find_best_height_direction(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)