deal.II version GIT relicensing-2171-g98af52917d 2024-11-23 14:40: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
183 template <int dim>
185 {
186 public:
188
197 const hp::QCollection<1> &quadratures1D,
198 const AdditionalData &additional_data = AdditionalData());
199
203 void
205
218 void
219 generate(const Function<dim> &level_set, const BoundingBox<dim> &box);
220
225 void
226 generate_append(const Function<dim> &level_set,
227 const BoundingBox<dim> &box);
228
235 const Quadrature<dim> &
236 get_inside_quadrature() const;
237
244 const Quadrature<dim> &
246
257
262 void
263 set_1D_quadrature(const unsigned int q_index);
264
265 private:
272 };
273
274
301 template <int dim>
303 {
304 public:
306
315 const hp::QCollection<1> &quadratures1D,
316 const AdditionalData &additional_data = AdditionalData());
317
321 void
323
336 void
337 generate(const Function<dim> &level_set,
338 const BoundingBox<dim> &box,
339 const unsigned int face_index);
340
345 void
346 generate_append(const Function<dim> &level_set,
347 const BoundingBox<dim> &box,
348 const unsigned int face_index);
349
356 const Quadrature<dim - 1> &
357 get_inside_quadrature() const;
358
365 const Quadrature<dim - 1> &
367
376 const ImmersedSurfaceQuadrature<dim - 1, dim> &
378
383 void
384 set_1D_quadrature(const unsigned int q_index);
385
386 private:
392
398 };
399
400
417 template <>
419 {
420 public:
422
428 const hp::QCollection<1> &quadratures1D,
429 const AdditionalData &additional_data = AdditionalData());
430
434 void
436
446 void
447 generate(const Function<1> &level_set,
448 const BoundingBox<1> &box,
449 const unsigned int face_index);
450
455 void
456 generate_append(const Function<1> &level_set,
457 const BoundingBox<1> &box,
458 const unsigned int face_index);
459
463 const Quadrature<0> &
464 get_inside_quadrature() const;
465
469 const Quadrature<0> &
471
481
486 void
487 set_1D_quadrature(const unsigned int q_index);
488
489 private:
496
503
510 };
511
512
530 template <int dim>
532 {
533 public:
535
543 template <typename Number>
545 const hp::QCollection<1> &quadratures1D,
546 const DoFHandler<dim> &dof_handler,
547 const ReadVector<Number> &level_set,
548 const AdditionalData &additional_data = AdditionalData());
549
557 void
559
560 private:
564 void
565 generate_fe_q_iso_q1(const BoundingBox<dim> &unit_box);
566
570 std::unique_ptr<internal::DiscreteQuadratureGeneratorImplementation::
571 CellWiseFunction<dim>>
573 };
574
592 template <int dim>
594 {
595 public:
597
605 template <typename Number>
607 const hp::QCollection<1> &quadratures1D,
608 const DoFHandler<dim> &dof_handler,
609 const ReadVector<Number> &level_set,
610 const AdditionalData &additional_data = AdditionalData());
611
619 void
621 const unsigned int face_index);
622
623 private:
627 void
629 unsigned int face_index);
630
634 std::unique_ptr<internal::DiscreteQuadratureGeneratorImplementation::
635 CellWiseFunction<dim>>
637 };
638
639
640 namespace internal
641 {
642 namespace QuadratureGeneratorImplementation
643 {
662 {
663 public:
668 {
672 AdditionalData(const double tolerance = 1e-12,
673 const unsigned int max_recursion_depth = 2,
674 const unsigned int max_iterations = 500);
675
680 double tolerance;
681
687
692 unsigned int max_iterations;
693 };
694
695
700
708 void
709 find_roots(const std::vector<std::reference_wrapper<const Function<1>>>
710 &functions,
711 const BoundingBox<1> &interval,
712 std::vector<double> &roots);
713
714 private:
720 void
721 find_roots(const Function<1> &function,
722 const BoundingBox<1> &interval,
723 const unsigned int recursion_depth,
724 std::vector<double> &roots);
725
727 };
728
729
742 template <int dim>
744 {
745 public:
751
755 ExtendableQuadrature(const Quadrature<dim> &quadrature);
756
760 void
761 clear();
762
766 void
767 push_back(const Point<dim> &point, const double weight);
768 };
769
770
774 enum class Definiteness
775 {
776 negative,
777 positive,
779 };
780
781
811 template <int dim>
852
853
892 template <int dim, int spacedim>
894 {
895 public:
902
908 void
909 generate(const std::vector<std::reference_wrapper<const Function<dim>>>
910 &level_sets,
911 const BoundingBox<dim> &box,
912 const Quadrature<dim - 1> &low_dim_quadrature,
913 const unsigned int height_function_direction,
914 QPartitioning<dim> &q_partitioning);
915
920 void
921 set_1D_quadrature(const unsigned int q_index);
922
923 private:
932 void
934 const Point<dim - 1> &point,
935 const double weight,
936 const std::vector<std::reference_wrapper<const Function<dim>>>
937 &level_sets,
938 const BoundingBox<dim> &box,
939 const unsigned int height_function_direction,
940 ImmersedSurfaceQuadrature<dim> &surface_quadrature);
941
947
952
957 unsigned int q_index;
958
964
969
976 std::vector<double> roots;
977 };
978
979
997 {
1003
1004
1008 unsigned int direction;
1009
1015 };
1016
1017
1022 template <int dim, int spacedim>
1064
1065
1149 template <int dim, int spacedim>
1150 class QGenerator : public QGeneratorBase<dim, spacedim>
1151 {
1152 public:
1158
1169 void
1170 generate(const std::vector<std::reference_wrapper<const Function<dim>>>
1171 &level_sets,
1172 const BoundingBox<dim> &box,
1173 const unsigned int n_box_splits);
1174
1179 void
1180 set_1D_quadrature(const unsigned int q_index);
1181
1182 private:
1189 void
1191 const unsigned int height_function_direction,
1192 const std::vector<std::reference_wrapper<const Function<dim>>>
1193 &level_sets,
1194 const BoundingBox<dim> &box,
1195 const unsigned int n_box_splits);
1196
1202 void
1204 const unsigned int height_function_direction,
1205 const std::vector<std::reference_wrapper<const Function<dim>>>
1206 &level_sets,
1207 const BoundingBox<dim> &box);
1208
1214 void
1216 const std::vector<std::reference_wrapper<const Function<dim>>>
1217 &level_sets,
1218 const BoundingBox<dim> &box,
1219 const std::optional<HeightDirectionData> &direction_data,
1220 const unsigned int n_box_splits);
1221
1231 void
1233 const std::vector<std::reference_wrapper<const Function<dim>>>
1234 &level_sets,
1235 const BoundingBox<dim> &box);
1236
1241 QGenerator<dim - 1, spacedim> low_dim_algorithm;
1242
1248
1254 };
1255
1256
1272 template <int spacedim>
1273 class QGenerator<1, spacedim> : public QGeneratorBase<1, spacedim>
1274 {
1275 public:
1279 QGenerator(const hp::QCollection<1> &quadratures1D,
1281
1288 void
1289 generate(const std::vector<std::reference_wrapper<const Function<1>>>
1290 &level_sets,
1291 const BoundingBox<1> &box,
1292 const unsigned int n_box_splits);
1293
1298 void
1299 set_1D_quadrature(const unsigned int q_index);
1300
1301 private:
1306 void
1307 create_surface_points(
1308 const std::vector<std::reference_wrapper<const Function<1>>>
1309 &level_sets);
1310
1315
1319 std::vector<double> roots;
1320
1325 const unsigned int direction = 0;
1326
1332 const double unit_weight = 1;
1333 };
1334
1335
1344 template <int dim>
1345 void
1347 const double weight,
1348 const Quadrature<1> &quadrature1D,
1349 const double start,
1350 const double end,
1351 const unsigned int component_in_dim,
1352 ExtendableQuadrature<dim> &quadrature);
1353
1354
1361 template <int dim>
1364 const std::vector<std::reference_wrapper<const Function<dim>>>
1365 &functions,
1366 const Point<dim> &point);
1367
1368
1373 template <int dim>
1375 {
1376 public:
1380 std::pair<double, double> value;
1381
1385 std::array<std::pair<double, double>, dim> gradient;
1386 };
1387
1388
1396 template <int dim>
1397 std::pair<double, double>
1399 const std::vector<FunctionBounds<dim>> &all_function_bounds);
1400
1401
1434 template <int dim>
1435 std::optional<HeightDirectionData>
1437 const std::vector<FunctionBounds<dim>> &all_function_bounds);
1438
1439 } // namespace QuadratureGeneratorImplementation
1440
1441
1442 namespace DiscreteQuadratureGeneratorImplementation
1443 {
1449 template <int dim>
1450 class CellWiseFunction : public Function<dim>
1451 {
1452 public:
1456 virtual ~CellWiseFunction() = default;
1457
1461 virtual void
1463 const typename Triangulation<dim>::active_cell_iterator &cell) = 0;
1464
1469 virtual void
1470 set_subcell(const std::vector<unsigned int> &mask,
1471 const BoundingBox<dim> &subcell_box) = 0;
1472
1476 virtual bool
1477 is_fe_q_iso_q1() const = 0;
1478
1482 virtual unsigned int
1483 n_subdivisions() const = 0;
1484 };
1485
1486 } // namespace DiscreteQuadratureGeneratorImplementation
1487 } // namespace internal
1488
1489} // namespace NonMatching
1491
1492#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::vector< index_type > data
Definition mpi.cc:735
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)