37#include <boost/math/special_functions/relative_difference.hpp>
38#include <boost/math/special_functions/sign.hpp>
39#include <boost/math/tools/roots.hpp>
50 namespace QuadratureGeneratorImplementation
59 const unsigned int component_in_dim,
63 ExcMessage(
"Interval start must be less than interval end."));
65 const double length = end - start;
66 for (
unsigned int j = 0; j < quadrature1D.
size(); ++j)
68 const double x = start + length * quadrature1D.
point(j)[0];
70 point, component_in_dim, x),
71 length * weight * quadrature1D.
weight(j));
87 const unsigned int component_in_dim,
90 for (
unsigned int j = 0; j < lower.
size(); ++j)
107 const std::vector<std::reference_wrapper<
const Function<dim>>>
111 Assert(functions.size() > 0,
113 "The incoming vector must contain at least one function."));
115 const int sign_of_first =
116 boost::math::sign(functions[0].get().value(point));
118 if (sign_of_first == 0)
121 for (
unsigned int j = 1; j < functions.size(); ++j)
123 const int sign = boost::math::sign(functions[j].get().value(point));
125 if (sign != sign_of_first)
129 if (sign_of_first < 0)
153 std::pair<double, double> &value_bounds)
156 for (
unsigned int i = 0; i < cube.
n_vertices(); ++i)
158 const double vertex_value = function.
value(box.
vertex(i));
160 value_bounds.first =
std::min(value_bounds.first, vertex_value);
161 value_bounds.second =
std::max(value_bounds.second, vertex_value);
180 const std::vector<std::reference_wrapper<
const Function<dim>>>
185 all_function_bounds.clear();
186 all_function_bounds.reserve(functions.size());
194 all_function_bounds.push_back(bounds);
201 std::pair<double, double>
206 std::pair<double, double> extremes = bounds[0].value;
207 for (
unsigned int i = 1; i < bounds.size(); ++i)
209 extremes.first =
std::min(extremes.first, bounds[i].value.first);
210 extremes.second =
std::max(extremes.second, bounds[i].value.second);
225 if (function_bounds.first > 0)
227 if (function_bounds.second < 0)
257 Assert(function_bounds.first <= function_bounds.second,
258 ExcMessage(
"Function bounds reversed, max < min."));
260 return 0.5 * (
std::abs(function_bounds.second + function_bounds.first) -
261 (function_bounds.second - function_bounds.first));
275 std::optional<HeightDirectionData>
281 std::optional<std::array<double, dim>> min_lower_abs_grad;
289 if (!min_lower_abs_grad)
291 min_lower_abs_grad.emplace();
292 for (
unsigned int d = 0; d < dim; ++d)
294 (*min_lower_abs_grad)[d] =
300 for (
unsigned int d = 0; d < dim; ++d)
302 (*min_lower_abs_grad)[d] =
310 if (min_lower_abs_grad)
312 const auto max_element =
313 std::max_element(min_lower_abs_grad->begin(),
314 min_lower_abs_grad->end());
318 std::distance(min_lower_abs_grad->begin(), max_element);
324 return std::optional<HeightDirectionData>();
339 if (all_function_bounds.size() != 2)
346 if (bounds0.
value.first > 0 && bounds1.
value.second < 0)
348 if (bounds1.
value.first > 0 && bounds0.
value.second < 0)
369 for (
unsigned int i = 0; i < unit_quadrature.
size(); ++i)
372 const double weight = unit_quadrature.
weight(i) * box.
volume();
393 const std::vector<std::reference_wrapper<
const Function<dim>>>
396 const unsigned int direction,
401 restrictions.clear();
402 restrictions.reserve(2 * functions.size());
407 for (
const auto &function : functions)
410 function, direction, bottom));
412 function, direction, top));
429 const std::vector<std::reference_wrapper<
const Function<dim>>>
432 const unsigned int open_direction,
437 restrictions.clear();
438 restrictions.reserve(functions.size());
439 for (
const auto &function : functions)
442 function, open_direction, point));
466 const std::vector<double> &roots,
469 const unsigned int height_function_direction,
470 const std::vector<std::reference_wrapper<
const Function<1>>>
476 const int n_roots = roots.size();
479 for (
int i = -1; i < n_roots; ++i)
482 const double start = i < 0 ? interval.
lower_bound(0) : roots[i];
484 i + 1 < n_roots ? roots[i + 1] : interval.
upper_bound(0);
486 const double length = end - start;
507 height_function_direction,
516 const double tolerance,
517 const unsigned int max_recursion_depth,
518 const unsigned int max_iterations)
519 : tolerance(tolerance)
520 , max_recursion_depth(max_recursion_depth)
521 , max_iterations(max_iterations)
534 const std::vector<std::reference_wrapper<
const Function<1>>> &functions,
536 std::vector<double> &roots)
540 const unsigned int recursion_depth = 0;
541 find_roots(function, interval, recursion_depth, roots);
544 std::sort(roots.begin(), roots.end());
546 const auto roots_are_equal = [
this](
const double &a,
const double &b) {
549 roots.erase(unique(roots.begin(), roots.end(), roots_are_equal),
558 const unsigned int recursion_depth,
559 std::vector<double> &roots)
562 const double left_value = function.
value(interval.
vertex(0));
563 const double right_value = function.
value(interval.
vertex(1));
566 if (boost::math::sign(left_value) != boost::math::sign(right_value))
568 const auto lambda = [&function](
const double x) {
572 const auto stopping_criteria = [
this](
const double &a,
579 const std::pair<double, double> root_bracket =
580 boost::math::tools::toms748_solve(lambda,
588 const double root = .5 * (root_bracket.first + root_bracket.second);
589 roots.push_back(root);
596 std::pair<double, double> value_bounds;
597 std::array<std::pair<double, double>, 1> gradient_bounds;
605 const double function_min =
609 if (function_min > 0)
612 const double function_max =
616 if (function_max < 0)
650 this->quadrature_points.clear();
651 this->weights.clear();
661 this->quadrature_points.push_back(point);
662 this->weights.push_back(weight);
672 switch (definiteness)
707 const unsigned int direction,
715 const double bottom_value = level_set.
value(bottom_point);
721 const double top_value = level_set.
value(top_point);
731 template <
int dim,
int spacedim>
735 : q_collection1D(&q_collection1D)
736 , additional_data(additional_data)
738 RootFinder::AdditionalData(additional_data.root_finder_tolerance,
739 additional_data.max_root_finder_splits))
746 template <
int dim,
int spacedim>
749 const std::vector<std::reference_wrapper<
const Function<dim>>>
753 const unsigned int height_function_direction,
756 const Quadrature<1> &quadrature1D = (*q_collection1D)[q_index];
758 for (
unsigned int q = 0; q < low_dim_quadrature.
size(); ++q)
760 const Point<dim - 1> &point = low_dim_quadrature.
point(q);
761 const double weight = low_dim_quadrature.
weight(q);
764 height_function_direction,
768 const std::vector<std::reference_wrapper<const Function<1>>>
769 restrictions(point_restrictions.begin(),
770 point_restrictions.end());
773 box.
bounds(height_function_direction);
776 root_finder.find_roots(restrictions, bounds_in_direction, roots);
783 height_function_direction,
789 create_surface_point(point,
793 height_function_direction,
797 point_restrictions.clear();
802 template <
int dim,
int spacedim>
807 const std::vector<std::reference_wrapper<
const Function<dim>>>
810 const unsigned int height_function_direction,
820 if (roots.size() == 1)
823 point, height_function_direction, roots[0]);
839 point, height_function_direction, box, level_set);
844 normal *= 1. / normal.
norm();
848 const double surface_weight =
849 weight * gradient.norm() /
850 std::abs(gradient[height_function_direction]);
851 surface_quadrature.
push_back(surface_point, surface_weight, normal);
856 template <
int dim,
int spacedim>
859 unsigned int q_index)
862 this->q_index = q_index;
867 template <
int dim,
int spacedim>
871 : additional_data(additional_data)
872 , q_collection1D(&q_collection1D)
879 template <
int dim,
int spacedim>
884 , low_dim_algorithm(q_collection1D, additional_data)
885 , up_through_dimension_creator(q_collection1D, additional_data)
893 template <
int dim,
int spacedim>
897 q_partitioning.clear();
902 template <
int dim,
int spacedim>
906 return q_partitioning;
911 template <
int dim,
int spacedim>
914 const std::vector<std::reference_wrapper<
const Function<dim>>>
917 const unsigned int n_box_splits)
919 std::vector<FunctionBounds<dim>> all_function_bounds;
922 const std::pair<double, double> extreme_values =
925 if (extreme_values.first > this->additional_data.limit_to_be_definite)
929 this->q_partitioning.positive);
931 else if (extreme_values.second <
932 -(this->additional_data.limit_to_be_definite))
936 this->q_partitioning.negative);
942 this->q_partitioning.indefinite);
946 const std::optional<HeightDirectionData> data =
951 if (data && data->min_abs_dfdx >
952 this->additional_data.lower_bound_implicit_function)
954 create_low_dim_quadratures(data->direction,
958 create_high_dim_quadratures(data->direction, level_sets, box);
960 else if (n_box_splits < this->additional_data.max_box_splits)
962 split_box_and_recurse(level_sets, box, data, n_box_splits);
968 use_midpoint_method(level_sets, box);
981 std::optional<unsigned int>
985 std::array<std::pair<double, unsigned int>, dim> side_lengths;
986 for (
unsigned int i = 0; i < dim; ++i)
989 side_lengths[i].second = i;
992 std::sort(side_lengths.begin(), side_lengths.end());
996 if (boost::math::epsilon_difference(side_lengths[dim - 1].
first,
997 side_lengths[dim - 2].
first) < 100)
998 return std::optional<unsigned int>();
1000 return side_lengths.back().second;
1020 const std::optional<HeightDirectionData> &height_direction_data)
1022 const std::optional<unsigned int> direction =
1030 if (height_direction_data)
1031 return height_direction_data->direction;
1051 corners.second[direction] -= .5 * box.
side_length(direction);
1070 corners.first[direction] += .5 * box.
side_length(direction);
1077 template <
int dim,
int spacedim>
1080 const std::vector<std::reference_wrapper<
const Function<dim>>>
1083 const std::optional<HeightDirectionData> &direction_data,
1084 const unsigned int n_box_splits)
1086 if (this->additional_data.split_in_half)
1088 const unsigned int direction =
1094 generate(level_sets, left_box, n_box_splits + 1);
1095 generate(level_sets, right_box, n_box_splits + 1);
1099 for (
unsigned int i = 0;
1100 i < GeometryInfo<dim>::max_children_per_cell;
1103 generate(level_sets, box.
child(i), n_box_splits + 1);
1110 template <
int dim,
int spacedim>
1113 const unsigned int height_function_direction,
1114 const std::vector<std::reference_wrapper<
const Function<dim>>>
1117 const unsigned int n_box_splits)
1123 height_function_direction,
1127 const std::vector<std::reference_wrapper<
const Function<dim - 1>>>
1128 restrictions(face_restrictions.begin(), face_restrictions.end());
1133 low_dim_algorithm.clear_quadratures();
1134 low_dim_algorithm.generate(restrictions, cross_section, n_box_splits);
1139 template <
int dim,
int spacedim>
1142 const unsigned int height_function_direction,
1143 const std::vector<std::reference_wrapper<
const Function<dim>>>
1148 low_dim_algorithm.get_quadratures();
1151 (*this->q_collection1D)[this->q_index];
1157 height_function_direction,
1158 this->q_partitioning.negative);
1164 height_function_direction,
1165 this->q_partitioning.positive);
1167 up_through_dimension_creator.generate(level_sets,
1169 low_dim_quadratures.indefinite,
1170 height_function_direction,
1171 this->q_partitioning);
1176 template <
int dim,
int spacedim>
1179 const std::vector<std::reference_wrapper<
const Function<dim>>>
1188 this->q_partitioning.quadrature_by_definiteness(definiteness);
1195 template <
int dim,
int spacedim>
1201 this->q_index = q_index;
1202 low_dim_algorithm.set_1D_quadrature(q_index);
1203 up_through_dimension_creator.set_1D_quadrature(q_index);
1208 template <
int spacedim>
1214 RootFinder::AdditionalData(additional_data.root_finder_tolerance,
1215 additional_data.max_root_finder_splits))
1223 template <
int spacedim>
1226 const std::vector<std::reference_wrapper<
const Function<1>>>
1229 const unsigned int n_box_splits)
1234 root_finder.find_roots(level_sets, box, roots);
1237 (*this->q_collection1D)[this->q_index];
1246 this->additional_data,
1247 this->q_partitioning);
1250 this->create_surface_points(level_sets);
1255 template <
int spacedim>
1258 const std::vector<std::reference_wrapper<
const Function<1>>>
1263 for (
const double root : roots)
1267 const double weight = 1;
1270 Tensor<1, 1> normal = level_sets[0].get().gradient(point);
1271 const double gradient_norm = normal.
norm();
1273 gradient_norm > 1e-11,
1275 "The level set function has a gradient almost equal to 0."));
1276 normal *= 1. / gradient_norm;
1278 this->q_partitioning.surface.push_back(point, weight, normal);
1284 template <
int spacedim>
1289 this->q_index = q_index;
1298 namespace DiscreteQuadratureGeneratorImplementation
1302 "The set_active_cell function has to be called before calling this function.");
1306 "The reference cell of the incoming cell must be a hypercube.");
1334 template <
int dim,
typename VectorType = Vector<
double>>
1346 const VectorType &dof_values);
1359 set_subcell(
const std::vector<unsigned int> &mask,
1383 const unsigned int component = 0)
const override;
1394 const unsigned int component = 0)
const override;
1405 const unsigned int component = 0)
const override;
1464 std::vector<Polynomials::Polynomial<double>>
poly;
1484 template <
int dim,
typename VectorType>
1487 const VectorType &dof_values)
1488 : dof_handler(&dof_handler)
1489 , global_dof_values(&dof_values)
1490 , n_subdivisions_per_line(
numbers::invalid_unsigned_int)
1498 template <
int dim,
typename VectorType>
1504 &cell->get_triangulation() == &dof_handler->get_triangulation(),
1506 "The incoming cell must belong to the triangulation associated with "
1507 "the DoFHandler passed to the constructor."));
1509 const auto dof_handler_cell =
1510 cell->as_dof_handler_iterator(*dof_handler);
1518 if (element != &dof_handler_cell->get_fe())
1521 element = &dof_handler_cell->get_fe();
1527 &dof_handler_cell->get_fe()))
1529 this->n_subdivisions_per_line = fe_q_iso_q1->get_degree();
1532 .value_or_initialize(
1533 []() {
return std::make_unique<FE_Q<dim>>(1); })
1535 local_dof_values_subcell.resize(
1536 fe_q1.value()->n_dofs_per_cell());
1554 polynomials_are_hat_functions =
1555 (poly.size() == 2 && poly[0].value(0.) == 1. &&
1556 poly[0].value(1.) == 0. && poly[1].value(0.) == 0. &&
1557 poly[1].value(1.) == 1.);
1561 element = &dof_handler_cell->get_fe();
1563 local_dof_indices.resize(element->dofs_per_cell);
1564 dof_handler_cell->get_dof_indices(local_dof_indices);
1566 local_dof_values.resize(element->dofs_per_cell);
1568 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1569 local_dof_values[i] =
1571 *global_dof_values, local_dof_indices[i]);
1576 template <
int dim,
typename VectorType>
1579 const std::vector<unsigned int> &mask,
1582 for (
unsigned int i = 0; i < local_dof_values_subcell.size(); ++i)
1583 local_dof_values_subcell[i] = local_dof_values[renumber[mask[i]]];
1585 this->subcell_box = subcell_box;
1590 template <
int dim,
typename VectorType>
1599 template <
int dim,
typename VectorType>
1603 return n_subdivisions_per_line;
1608 template <
int dim,
typename VectorType>
1614 return local_dof_values.size() > 0;
1619 template <
int dim,
typename VectorType>
1623 const unsigned int component)
const
1628 if (!poly.empty() && component == 0)
1631 return this->is_fe_q_iso_q1() ?
1635 subcell_box.real_to_unit(point),
1636 polynomials_are_hat_functions) :
1641 polynomials_are_hat_functions,
1647 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1648 value += local_dof_values[i] *
1649 element->shape_value_component(i, point, component);
1657 template <
int dim,
typename VectorType>
1661 const unsigned int component)
const
1666 if (!poly.empty() && component == 0)
1669 return (this->is_fe_q_iso_q1() ?
1671 evaluate_tensor_product_value_and_gradient(
1674 subcell_box.real_to_unit(point),
1675 polynomials_are_hat_functions) :
1681 polynomials_are_hat_functions,
1688 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1689 gradient += local_dof_values[i] *
1690 element->shape_grad_component(i, point, component);
1698 template <
int dim,
typename VectorType>
1702 const unsigned int component)
const
1707 if (!poly.empty() && component == 0)
1710 return this->is_fe_q_iso_q1() ?
1714 subcell_box.real_to_unit(point)) :
1724 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1726 local_dof_values[i] *
1727 element->shape_grad_grad_component(i, point, component);
1738 const std::array<unsigned int, dim> &subcell_indices,
1739 const unsigned int n_subdivisions)
1742 for (
unsigned int d = 0; d < dim; ++d)
1746 const double split_box_side_length =
1748 corners.first[d] = subcell_indices[d] * split_box_side_length;
1749 corners.second[d] = corners.first[d] + split_box_side_length;
1758 std::vector<unsigned int>
1760 const std::array<unsigned int, dim> &subcell_indices,
1761 unsigned int dofs_per_line)
1766 std::vector<unsigned int> mask;
1767 mask.reserve(1 << dim);
1769 unsigned int stride = 1;
1770 for (
unsigned int d = 0; d < dim; ++d)
1772 const unsigned int previous_mask_size = 1U << d;
1774 for (
unsigned int i = 0; i < previous_mask_size; ++i)
1776 mask[i] += subcell_indices[d] * stride;
1777 mask.push_back(stride + mask[i]);
1779 stride *= dofs_per_line;
1789 const unsigned int max_box_splits,
1790 const double lower_bound_implicit_function,
1791 const double min_distance_between_roots,
1792 const double limit_to_be_definite,
1793 const double root_finder_tolerance,
1794 const unsigned int max_root_finder_splits,
1796 : max_box_splits(max_box_splits)
1797 , lower_bound_implicit_function(lower_bound_implicit_function)
1798 , min_distance_between_roots(min_distance_between_roots)
1799 , limit_to_be_definite(limit_to_be_definite)
1800 , root_finder_tolerance(root_finder_tolerance)
1801 , max_root_finder_splits(max_root_finder_splits)
1802 , split_in_half(split_in_half)
1811 : q_generator(q_collection, additional_data)
1814 ExcMessage(
"Incoming hp::QCollection<1> is empty."));
1823 q_generator.clear_quadratures();
1833 clear_quadratures();
1834 generate_append(level_set, box);
1846 "The incoming function should be a scalar level set function,"
1847 " it should have one component."));
1850 std::vector<std::reference_wrapper<const Function<dim>>> level_sets;
1851 level_sets.push_back(level_set);
1853 const unsigned int n_box_splits = 0;
1854 q_generator.generate(level_sets, box, n_box_splits);
1860 q_generator.get_quadratures().indefinite.empty(),
1862 "Generation of quadrature rules failed. This can mean that the level "
1863 "set function is degenerate in some way, e.g. oscillating extremely "
1873 return q_generator.get_quadratures().negative;
1882 return q_generator.get_quadratures().positive;
1891 return q_generator.get_quadratures().surface;
1899 q_generator.set_1D_quadrature(q_index);
1908 : quadrature_generator(quadratures1D, additional_data)
1917 quadrature_generator.clear_quadratures();
1918 surface_quadrature.clear();
1927 const unsigned int face_index)
1929 clear_quadratures();
1930 generate_append(level_set, box, face_index);
1939 const unsigned int face_index)
1946 const unsigned int face_normal_direction =
1951 const double coordinate_value = vertex0[face_normal_direction];
1954 level_set, face_normal_direction, coordinate_value);
1960 quadrature_generator.generate_append(face_restriction, cross_section);
1965 &surface_quadrature_wrong_normal =
1966 quadrature_generator.get_surface_quadrature();
1968 std::vector<Tensor<1, dim>> normals;
1969 normals.reserve(surface_quadrature_wrong_normal.size());
1970 for (
unsigned int i = 0; i < surface_quadrature_wrong_normal.size(); ++i)
1973 surface_quadrature_wrong_normal.point(i),
1974 face_normal_direction,
1978 normal /= normal.
norm();
1979 normals.push_back(normal);
1982 surface_quadrature_wrong_normal.get_points(),
1983 surface_quadrature_wrong_normal.get_weights(),
1993 quadrature_generator.set_1D_quadrature(q_index);
2002 return quadrature_generator.get_inside_quadrature();
2010 return quadrature_generator.get_outside_quadrature();
2019 return surface_quadrature;
2028 (void)quadratures1D;
2029 (void)additional_data;
2045 const unsigned int face_index)
2047 clear_quadratures();
2048 generate_append(level_set, box, face_index);
2056 const unsigned int face_index)
2064 const unsigned int n_points = 1;
2065 const double weight = 1;
2066 const std::vector<Point<0>> points(n_points);
2067 const std::vector<double> weights(n_points, weight);
2069 const double level_set_value = level_set.
value(vertex);
2070 if (level_set_value < 0)
2075 else if (level_set_value > 0)
2100 return inside_quadrature;
2107 return outside_quadrature;
2115 return surface_quadrature;
2121 template <
typename VectorType>
2125 const VectorType &level_set,
2128 , reference_space_level_set(
2129 std::make_unique<
internal::DiscreteQuadratureGeneratorImplementation::
2130 RefSpaceFEFieldFunction<dim, VectorType>>(
2142 const unsigned int n_subdivisions =
2143 reference_space_level_set->n_subdivisions();
2145 const unsigned int dofs_per_line = n_subdivisions + 1;
2147 this->clear_quadratures();
2156 std::vector<std::array<unsigned int, dim>> all_subcell_indices;
2157 all_subcell_indices.reserve(
Utilities::pow(n_subdivisions, dim));
2158 all_subcell_indices.emplace_back();
2159 for (
unsigned d = 0; d < dim; ++d)
2161 const unsigned int old_size = all_subcell_indices.size();
2162 for (
unsigned int i = 1; i < n_subdivisions; ++i)
2164 for (
unsigned int j = 0; j < old_size; ++j)
2166 std::array<unsigned int, dim> next_entry =
2167 all_subcell_indices[j];
2169 all_subcell_indices.push_back(next_entry);
2175 for (
const auto &subcell_indices : all_subcell_indices)
2177 const std::vector<unsigned int> lexicographic_mask =
2181 const auto subcell_box =
2185 reference_space_level_set->set_subcell(lexicographic_mask, subcell_box);
2199 Assert(cell->reference_cell().is_hyper_cube(),
2200 internal::DiscreteQuadratureGeneratorImplementation::
2201 ExcReferenceCellNotHypercube());
2203 reference_space_level_set->set_active_cell(cell);
2205 if (reference_space_level_set->is_fe_q_iso_q1())
2206 generate_fe_q_iso_q1(unit_box);
2214 template <
typename VectorType>
2218 const VectorType &level_set,
2221 , reference_space_level_set(
2222 std::make_unique<
internal::DiscreteQuadratureGeneratorImplementation::
2223 RefSpaceFEFieldFunction<dim, VectorType>>(
2234 unsigned int face_index)
2236 const unsigned int n_subdivisions =
2237 reference_space_level_set->n_subdivisions();
2239 const unsigned int dofs_per_line = n_subdivisions + 1;
2241 this->clear_quadratures();
2243 const unsigned int coordinate_direction_face = face_index / 2;
2244 const unsigned int coordinate_orientation_face = face_index % 2;
2256 std::vector<std::array<unsigned int, dim>> all_subcell_indices;
2257 all_subcell_indices.reserve(
Utilities::pow(n_subdivisions, dim));
2258 all_subcell_indices.emplace_back();
2259 all_subcell_indices[0][coordinate_direction_face] =
2260 coordinate_orientation_face == 0 ? 0 : n_subdivisions - 1;
2261 for (
unsigned d = 0; d < dim - 1; ++d)
2263 const unsigned int old_size = all_subcell_indices.size();
2264 for (
unsigned int i = 1; i < n_subdivisions; ++i)
2266 for (
unsigned int j = 0; j < old_size; ++j)
2268 std::array<unsigned int, dim> next_entry =
2269 all_subcell_indices[j];
2270 next_entry[(coordinate_direction_face + d + 1) % dim] = i;
2271 all_subcell_indices.push_back(next_entry);
2276 for (
const auto &subcell_indices : all_subcell_indices)
2278 const std::vector<unsigned int> lexicographic_mask =
2282 const auto subcell_box =
2286 reference_space_level_set->set_subcell(lexicographic_mask, subcell_box);
2289 *reference_space_level_set, subcell_box, face_index);
2299 const unsigned int face_index)
2301 Assert(cell->reference_cell().is_hyper_cube(),
2302 internal::DiscreteQuadratureGeneratorImplementation::
2303 ExcReferenceCellNotHypercube());
2305 reference_space_level_set->set_active_cell(cell);
2307 if (reference_space_level_set->is_fe_q_iso_q1())
2308 generate_fe_q_iso_q1(unit_box, face_index);
2315#include "quadrature_generator.inst"
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
BoundingBox< dim, Number > create_unit_bounding_box()
BoundingBox< 1, Number > bounds(const unsigned int direction) const
Point< spacedim, Number > center() const
Number lower_bound(const unsigned int direction) const
std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points()
Number side_length(const unsigned int direction) const
BoundingBox< spacedim, Number > child(const unsigned int index) const
Point< spacedim, Number > vertex(const unsigned int index) const
BoundingBox< spacedim - 1, Number > cross_section(const unsigned int direction) const
Number upper_bound(const unsigned int direction) const
Point< spacedim, Number > unit_to_real(const Point< spacedim, Number > &point) const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
unsigned int n_base_elements() const
virtual Tensor< 1, dim, RangeNumberType > gradient(const Point< dim > &p, const unsigned int component=0) const
const unsigned int n_components
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
DiscreteFaceQuadratureGenerator(const hp::QCollection< 1 > &quadratures1D, const DoFHandler< dim > &dof_handler, const VectorType &level_set, const AdditionalData &additional_data=AdditionalData())
void generate(const typename Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index)
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)
void generate_fe_q_iso_q1(const BoundingBox< dim > &unit_box)
DiscreteQuadratureGenerator(const hp::QCollection< 1 > &quadratures1D, const DoFHandler< dim > &dof_handler, const VectorType &level_set, const AdditionalData &additional_data=AdditionalData())
const Quadrature< dim - 1 > & get_inside_quadrature() const
void generate(const Function< dim > &level_set, const BoundingBox< dim > &box, const unsigned int face_index)
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)
FaceQuadratureGenerator(const hp::QCollection< 1 > &quadratures1D, const AdditionalData &additional_data=AdditionalData())
const ImmersedSurfaceQuadrature< dim - 1, dim > & get_surface_quadrature() const
const Quadrature< dim - 1 > & get_outside_quadrature() const
void push_back(const Point< dim > &point, const double weight, const Tensor< 1, spacedim > &normal)
void generate_append(const Function< dim > &level_set, const BoundingBox< dim > &box)
void set_1D_quadrature(const unsigned int q_index)
QuadratureGenerator(const hp::QCollection< 1 > &quadratures1D, const AdditionalData &additional_data=AdditionalData())
const Quadrature< dim > & get_inside_quadrature() const
const Quadrature< dim > & get_outside_quadrature() const
const ImmersedSurfaceQuadrature< dim > & get_surface_quadrature() const
void generate(const Function< dim > &level_set, const BoundingBox< dim > &box)
void set_active_cell(const typename Triangulation< dim >::active_cell_iterator &cell) override
bool is_fe_q_iso_q1() const override
Tensor< 1, dim > gradient(const Point< dim > &point, const unsigned int component=0) const override
double value(const Point< dim > &point, const unsigned int component=0) const override
std::vector< typename VectorType::value_type > local_dof_values_subcell
std::vector< types::global_dof_index > local_dof_indices
void set_subcell(const std::vector< unsigned int > &mask, const BoundingBox< dim > &subcell_box) override
unsigned int n_subdivisions_per_line
BoundingBox< dim > subcell_box
bool polynomials_are_hat_functions
RefSpaceFEFieldFunction(const DoFHandler< dim > &dof_handler, const VectorType &dof_values)
const SmartPointer< const DoFHandler< dim > > dof_handler
std::vector< Polynomials::Polynomial< double > > poly
SymmetricTensor< 2, dim > hessian(const Point< dim > &point, const unsigned int component=0) const override
unsigned int n_subdivisions() const override
SmartPointer< const FiniteElement< dim > > element
Lazy< std::unique_ptr< FE_Q< dim > > > fe_q1
std::vector< unsigned int > renumber
std::vector< typename VectorType::value_type > local_dof_values
const SmartPointer< const VectorType > global_dof_values
void push_back(const Point< dim > &point, const double weight)
ExtendableQuadrature()=default
const SmartPointer< const hp::QCollection< 1 > > q_collection1D
QGeneratorBase(const hp::QCollection< 1 > &q_collection1D, const AdditionalQGeneratorData &additional_data)
const QPartitioning< dim > & get_quadratures() const
QGenerator(const hp::QCollection< 1 > &q_collection1D, const AdditionalQGeneratorData &additional_data)
void set_1D_quadrature(const unsigned int q_index)
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)
hp::QCollection< dim > tensor_products
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)
ImmersedSurfaceQuadrature< dim > surface
const AdditionalData additional_data
void find_roots(const std::vector< std::reference_wrapper< const Function< 1 > > > &functions, const BoundingBox< 1 > &interval, std::vector< double > &roots)
RootFinder(const AdditionalData &data=AdditionalData())
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 set_1D_quadrature(const unsigned int q_index)
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)
UpThroughDimensionCreator(const hp::QCollection< 1 > &q_collection1D, const AdditionalQGeneratorData &additional_data)
const Point< dim > & point(const unsigned int i) const
double weight(const unsigned int i) const
unsigned int size() const
unsigned int n_vertices() const
numbers::NumberTraits< Number >::real_type norm() const
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcCellNotSet()
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcReferenceCellNotHypercube()
static ::ExceptionBase & ExcMessage(std::string arg1)
std::vector< unsigned int > setup_lexicographic_mask(const std::array< unsigned int, dim > &subcell_indices, unsigned int dofs_per_line)
BoundingBox< dim > create_subcell_box(const BoundingBox< dim > &unit_box, const std::array< unsigned int, dim > &subcell_indices, const unsigned int n_subdivisions)
void distribute_points_between_roots(const Quadrature< 1 > &quadrature1D, const BoundingBox< 1 > &interval, const std::vector< double > &roots, const Point< dim - 1 > &point, const double weight, const unsigned int height_function_direction, const std::vector< std::reference_wrapper< const Function< 1 > > > &level_sets, const AdditionalQGeneratorData &additional_data, QPartitioning< dim > &q_partitioning)
double lower_bound_on_abs(const std::pair< double, double > &function_bounds)
void estimate_function_bounds(const std::vector< std::reference_wrapper< const Function< dim > > > &functions, const BoundingBox< dim > &box, std::vector< FunctionBounds< dim > > &all_function_bounds)
BoundingBox< dim > left_half(const BoundingBox< dim > &box, const unsigned int direction)
std::optional< unsigned int > direction_of_largest_extent(const BoundingBox< dim > &box)
void add_tensor_product(const Quadrature< dim - 1 > &lower, const Quadrature< 1 > &quadrature1D, const double start, const double end, const unsigned int component_in_dim, ExtendableQuadrature< dim > &quadrature)
bool one_positive_one_negative_definite(const std::vector< FunctionBounds< dim > > &all_function_bounds)
void map_quadrature_to_box(const Quadrature< dim > &unit_quadrature, const BoundingBox< dim > &box, ExtendableQuadrature< dim > &quadrature)
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)
void restrict_to_point(const std::vector< std::reference_wrapper< const Function< dim > > > &functions, const Point< dim - 1 > &point, const unsigned int open_direction, std::vector< Functions::PointRestriction< dim - 1 > > &restrictions)
BoundingBox< dim > right_half(const BoundingBox< dim > &box, const unsigned int direction)
bool is_indefinite(const std::pair< double, double > &function_bounds)
void take_min_max_at_vertices(const Function< dim > &function, const BoundingBox< dim > &box, std::pair< double, double > &value_bounds)
unsigned int compute_split_direction(const BoundingBox< dim > &box, const std::optional< HeightDirectionData > &height_direction_data)
void restrict_to_top_and_bottom(const std::vector< std::reference_wrapper< const Function< dim > > > &functions, const BoundingBox< dim > &box, const unsigned int direction, std::vector< Functions::CoordinateRestriction< dim - 1 > > &restrictions)
Point< dim > face_projection_closest_zero_contour(const Point< dim - 1 > &point, const unsigned int direction, const BoundingBox< dim > &box, const Function< dim > &level_set)
Definiteness pointwise_definiteness(const std::vector< std::reference_wrapper< const Function< dim > > > &functions, const Point< dim > &point)
constexpr const ReferenceCell & get_hypercube()
constexpr T pow(const T base, const int iexp)
std::vector< Polynomials::Polynomial< double > > get_polynomial_space(const FiniteElement< dim, spacedim > &fe)
bool is_fast_path_supported(const FiniteElement< dim, spacedim > &fe, const unsigned int base_element_number)
SymmetricTensor< 2, dim, typename ProductTypeNoPoint< Number, Number2 >::type > evaluate_tensor_product_hessian(const std::vector< Polynomials::Polynomial< double > > &poly, const ArrayView< const Number > &values, const Point< dim, Number2 > &p, const std::vector< unsigned int > &renumber={})
std::pair< typename ProductTypeNoPoint< Number, Number2 >::type, Tensor< 1, dim, typename ProductTypeNoPoint< Number, Number2 >::type > > evaluate_tensor_product_value_and_gradient(const std::vector< Polynomials::Polynomial< double > > &poly, const ArrayView< const Number > &values, const Point< dim, Number2 > &p, const bool d_linear=false, const std::vector< unsigned int > &renumber={})
Point< dim+1 > create_higher_dim_point(const Point< dim > &point, const unsigned int component_in_dim_plus_1, const double coordinate_value)
ProductTypeNoPoint< Number, Number2 >::type evaluate_tensor_product_value(const std::vector< Polynomials::Polynomial< double > > &poly, const ArrayView< const Number > &values, const Point< dim, Number2 > &p, const bool d_linear=false, const std::vector< unsigned int > &renumber={})
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
double min_distance_between_roots
AdditionalQGeneratorData(const unsigned int max_box_splits=4, const double lower_bound_implicit_function=1e-11, const double min_distance_between_roots=1e-12, const double limit_to_be_definite=1e-11, const double root_finder_tolerance=1e-12, const unsigned int max_root_finder_splits=2, bool split_in_half=true)
std::array< std::pair< double, double >, dim > gradient
std::pair< double, double > value
AdditionalData(const double tolerance=1e-12, const unsigned int max_recursion_depth=2, const unsigned int max_iterations=500)
unsigned int max_iterations
unsigned int max_recursion_depth
void reinit(const Quadrature< dim_q > &quad, const FiniteElement< dim, spacedim > &fe_dim, const unsigned int base_element=0)
std::vector< unsigned int > lexicographic_numbering
DEAL_II_HOST constexpr SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)