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)
155 const ReferenceCell &cube = ReferenceCells::get_hypercube<dim>();
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());
190 FunctionTools::taylor_estimate_function_bounds<dim>(
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);
319 data.min_abs_dfdx = *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;
496 const Point<1> center(start + 0.5 * length);
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;
598 FunctionTools::taylor_estimate_function_bounds<1>(function,
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 =
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))
1218 ExcMessage(
"Incoming quadrature collection is empty."));
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.");
1305 ExcReferenceCellNotHypercube,
1306 "The reference cell of the incoming cell must be a hypercube.");
1334 template <
int dim,
typename Number>
1359 set_subcell(
const std::vector<unsigned int> &mask,
1366 is_fe_q_iso_q1()
const override;
1372 n_subdivisions()
const override;
1383 const unsigned int component = 0)
const override;
1394 const unsigned int component = 0)
const override;
1405 const unsigned int component = 0)
const override;
1412 cell_is_set()
const;
1464 std::vector<Polynomials::Polynomial<double>>
poly;
1484 template <
int dim,
typename Number>
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 Number>
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 global_dof_values->extract_subvector_to(local_dof_indices,
1574 template <
int dim,
typename Number>
1577 const std::vector<unsigned int> &mask,
1580 for (
unsigned int i = 0; i < local_dof_values_subcell.size(); ++i)
1581 local_dof_values_subcell[i] = local_dof_values[renumber[mask[i]]];
1583 this->subcell_box = subcell_box;
1588 template <
int dim,
typename Number>
1597 template <
int dim,
typename Number>
1601 return n_subdivisions_per_line;
1606 template <
int dim,
typename Number>
1612 return local_dof_values.size() > 0;
1617 template <
int dim,
typename Number>
1621 const unsigned int component)
const
1626 if (!poly.empty() && component == 0)
1629 return this->is_fe_q_iso_q1() ?
1633 subcell_box.real_to_unit(point),
1634 polynomials_are_hat_functions) :
1639 polynomials_are_hat_functions,
1645 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1646 value += local_dof_values[i] *
1647 element->shape_value_component(i, point, component);
1655 template <
int dim,
typename Number>
1659 const unsigned int component)
const
1664 if (!poly.empty() && component == 0)
1667 return (this->is_fe_q_iso_q1() ?
1669 evaluate_tensor_product_value_and_gradient(
1672 subcell_box.real_to_unit(point),
1673 polynomials_are_hat_functions) :
1679 polynomials_are_hat_functions,
1686 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1687 gradient += local_dof_values[i] *
1688 element->shape_grad_component(i, point, component);
1696 template <
int dim,
typename Number>
1700 const unsigned int component)
const
1705 if (!poly.empty() && component == 0)
1708 return this->is_fe_q_iso_q1() ?
1712 subcell_box.real_to_unit(point)) :
1722 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
1724 local_dof_values[i] *
1725 element->shape_grad_grad_component(i, point, component);
1736 const std::array<unsigned int, dim> &subcell_indices,
1737 const unsigned int n_subdivisions)
1740 for (
unsigned int d = 0; d < dim; ++d)
1744 const double split_box_side_length =
1746 corners.first[d] = subcell_indices[d] * split_box_side_length;
1747 corners.second[d] = corners.first[d] + split_box_side_length;
1756 std::vector<unsigned int>
1758 const std::array<unsigned int, dim> &subcell_indices,
1759 unsigned int dofs_per_line)
1764 std::vector<unsigned int> mask;
1765 mask.reserve(1 << dim);
1767 unsigned int stride = 1;
1768 for (
unsigned int d = 0; d < dim; ++d)
1770 const unsigned int previous_mask_size = 1U << d;
1772 for (
unsigned int i = 0; i < previous_mask_size; ++i)
1774 mask[i] += subcell_indices[d] * stride;
1775 mask.push_back(stride + mask[i]);
1777 stride *= dofs_per_line;
1787 const unsigned int max_box_splits,
1788 const double lower_bound_implicit_function,
1789 const double min_distance_between_roots,
1790 const double limit_to_be_definite,
1791 const double root_finder_tolerance,
1792 const unsigned int max_root_finder_splits,
1794 : max_box_splits(max_box_splits)
1795 , lower_bound_implicit_function(lower_bound_implicit_function)
1796 , min_distance_between_roots(min_distance_between_roots)
1797 , limit_to_be_definite(limit_to_be_definite)
1798 , root_finder_tolerance(root_finder_tolerance)
1799 , max_root_finder_splits(max_root_finder_splits)
1800 , split_in_half(split_in_half)
1809 : q_generator(q_collection, additional_data)
1812 ExcMessage(
"Incoming hp::QCollection<1> is empty."));
1821 q_generator.clear_quadratures();
1831 clear_quadratures();
1832 generate_append(level_set, box);
1844 "The incoming function should be a scalar level set function,"
1845 " it should have one component."));
1848 std::vector<std::reference_wrapper<const Function<dim>>> level_sets;
1849 level_sets.push_back(level_set);
1851 const unsigned int n_box_splits = 0;
1852 q_generator.generate(level_sets, box, n_box_splits);
1858 q_generator.get_quadratures().indefinite.empty(),
1860 "Generation of quadrature rules failed. This can mean that the level "
1861 "set function is degenerate in some way, e.g. oscillating extremely "
1871 return q_generator.get_quadratures().negative;
1880 return q_generator.get_quadratures().positive;
1889 return q_generator.get_quadratures().surface;
1897 q_generator.set_1D_quadrature(q_index);
1906 : quadrature_generator(quadratures1D, additional_data)
1915 quadrature_generator.clear_quadratures();
1916 surface_quadrature.clear();
1925 const unsigned int face_index)
1927 clear_quadratures();
1928 generate_append(level_set, box, face_index);
1937 const unsigned int face_index)
1944 const unsigned int face_normal_direction =
1949 const double coordinate_value = vertex0[face_normal_direction];
1952 level_set, face_normal_direction, coordinate_value);
1958 quadrature_generator.generate_append(face_restriction, cross_section);
1963 &surface_quadrature_wrong_normal =
1964 quadrature_generator.get_surface_quadrature();
1966 std::vector<Tensor<1, dim>> normals;
1967 normals.reserve(surface_quadrature_wrong_normal.size());
1968 for (
unsigned int i = 0; i < surface_quadrature_wrong_normal.size(); ++i)
1971 surface_quadrature_wrong_normal.point(i),
1972 face_normal_direction,
1976 normal /= normal.
norm();
1977 normals.push_back(normal);
1980 surface_quadrature_wrong_normal.get_points(),
1981 surface_quadrature_wrong_normal.get_weights(),
1991 quadrature_generator.set_1D_quadrature(q_index);
2000 return quadrature_generator.get_inside_quadrature();
2008 return quadrature_generator.get_outside_quadrature();
2017 return surface_quadrature;
2026 (void)quadratures1D;
2027 (void)additional_data;
2043 const unsigned int face_index)
2045 clear_quadratures();
2046 generate_append(level_set, box, face_index);
2054 const unsigned int face_index)
2062 const unsigned int n_points = 1;
2063 const double weight = 1;
2064 const std::vector<Point<0>> points(n_points);
2065 const std::vector<double> weights(n_points, weight);
2067 const double level_set_value = level_set.
value(vertex);
2068 if (level_set_value < 0)
2073 else if (level_set_value > 0)
2098 return inside_quadrature;
2105 return outside_quadrature;
2113 return surface_quadrature;
2119 template <
typename Number>
2126 , reference_space_level_set(
2127 std::make_unique<
internal::DiscreteQuadratureGeneratorImplementation::
2128 RefSpaceFEFieldFunction<dim, Number>>(dof_handler,
2139 const unsigned int n_subdivisions =
2140 reference_space_level_set->n_subdivisions();
2142 const unsigned int dofs_per_line = n_subdivisions + 1;
2144 this->clear_quadratures();
2153 std::vector<std::array<unsigned int, dim>> all_subcell_indices;
2154 all_subcell_indices.reserve(
Utilities::pow(n_subdivisions, dim));
2155 all_subcell_indices.emplace_back();
2156 for (
unsigned d = 0; d < dim; ++d)
2158 const unsigned int old_size = all_subcell_indices.size();
2159 for (
unsigned int i = 1; i < n_subdivisions; ++i)
2161 for (
unsigned int j = 0; j < old_size; ++j)
2163 std::array<unsigned int, dim> next_entry =
2164 all_subcell_indices[j];
2166 all_subcell_indices.push_back(next_entry);
2172 for (
const auto &subcell_indices : all_subcell_indices)
2174 const std::vector<unsigned int> lexicographic_mask =
2175 internal::DiscreteQuadratureGeneratorImplementation::
2176 setup_lexicographic_mask<dim>(subcell_indices, dofs_per_line);
2178 const auto subcell_box =
2179 internal::DiscreteQuadratureGeneratorImplementation::
2180 create_subcell_box<dim>(unit_box, subcell_indices, n_subdivisions);
2182 reference_space_level_set->set_subcell(lexicographic_mask, subcell_box);
2196 Assert(cell->reference_cell().is_hyper_cube(),
2197 internal::DiscreteQuadratureGeneratorImplementation::
2198 ExcReferenceCellNotHypercube());
2200 reference_space_level_set->set_active_cell(cell);
2202 if (reference_space_level_set->is_fe_q_iso_q1())
2203 generate_fe_q_iso_q1(unit_box);
2211 template <
typename Number>
2218 , reference_space_level_set(
2219 std::make_unique<
internal::DiscreteQuadratureGeneratorImplementation::
2220 RefSpaceFEFieldFunction<dim, Number>>(dof_handler,
2230 unsigned int face_index)
2232 const unsigned int n_subdivisions =
2233 reference_space_level_set->n_subdivisions();
2235 const unsigned int dofs_per_line = n_subdivisions + 1;
2237 this->clear_quadratures();
2239 const unsigned int coordinate_direction_face = face_index / 2;
2240 const unsigned int coordinate_orientation_face = face_index % 2;
2252 std::vector<std::array<unsigned int, dim>> all_subcell_indices;
2253 all_subcell_indices.reserve(
Utilities::pow(n_subdivisions, dim));
2254 all_subcell_indices.emplace_back();
2255 all_subcell_indices[0][coordinate_direction_face] =
2256 coordinate_orientation_face == 0 ? 0 : n_subdivisions - 1;
2257 for (
unsigned d = 0; d < dim - 1; ++d)
2259 const unsigned int old_size = all_subcell_indices.size();
2260 for (
unsigned int i = 1; i < n_subdivisions; ++i)
2262 for (
unsigned int j = 0; j < old_size; ++j)
2264 std::array<unsigned int, dim> next_entry =
2265 all_subcell_indices[j];
2266 next_entry[(coordinate_direction_face + d + 1) % dim] = i;
2267 all_subcell_indices.push_back(next_entry);
2272 for (
const auto &subcell_indices : all_subcell_indices)
2274 const std::vector<unsigned int> lexicographic_mask =
2275 internal::DiscreteQuadratureGeneratorImplementation::
2276 setup_lexicographic_mask<dim>(subcell_indices, dofs_per_line);
2278 const auto subcell_box =
2279 internal::DiscreteQuadratureGeneratorImplementation::
2280 create_subcell_box<dim>(unit_box, subcell_indices, n_subdivisions);
2282 reference_space_level_set->set_subcell(lexicographic_mask, subcell_box);
2285 *reference_space_level_set, subcell_box, face_index);
2295 const unsigned int face_index)
2297 Assert(cell->reference_cell().is_hyper_cube(),
2298 internal::DiscreteQuadratureGeneratorImplementation::
2299 ExcReferenceCellNotHypercube());
2301 reference_space_level_set->set_active_cell(cell);
2303 if (reference_space_level_set->is_fe_q_iso_q1())
2304 generate_fe_q_iso_q1(unit_box, face_index);
2311#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< 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
void generate(const typename Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index)
DiscreteFaceQuadratureGenerator(const hp::QCollection< 1 > &quadratures1D, const DoFHandler< dim > &dof_handler, const ReadVector< Number > &level_set, const AdditionalData &additional_data=AdditionalData())
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)
DiscreteQuadratureGenerator(const hp::QCollection< 1 > &quadratures1D, const DoFHandler< dim > &dof_handler, const ReadVector< Number > &level_set, const AdditionalData &additional_data=AdditionalData())
void generate_fe_q_iso_q1(const BoundingBox< dim > &unit_box)
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)
Lazy< std::unique_ptr< FE_Q< dim > > > fe_q1
std::vector< unsigned int > renumber
std::vector< Number > local_dof_values_subcell
unsigned int n_subdivisions() const override
Tensor< 1, dim > gradient(const Point< dim > &point, const unsigned int component=0) const override
std::vector< types::global_dof_index > local_dof_indices
bool is_fe_q_iso_q1() const override
BoundingBox< dim > subcell_box
const ObserverPointer< const DoFHandler< dim > > dof_handler
unsigned int n_subdivisions_per_line
double value(const Point< dim > &point, const unsigned int component=0) const override
const ObserverPointer< const ReadVector< Number > > global_dof_values
SymmetricTensor< 2, dim > hessian(const Point< dim > &point, const unsigned int component=0) const override
void set_subcell(const std::vector< unsigned int > &mask, const BoundingBox< dim > &subcell_box) override
ObserverPointer< const FiniteElement< dim > > element
void set_active_cell(const typename Triangulation< dim >::active_cell_iterator &cell) override
std::vector< Polynomials::Polynomial< double > > poly
bool polynomials_are_hat_functions
std::vector< Number > local_dof_values
void push_back(const Point< dim > &point, const double weight)
ExtendableQuadrature()=default
QGeneratorBase(const hp::QCollection< 1 > &q_collection1D, const AdditionalQGeneratorData &additional_data)
const ObserverPointer< const hp::QCollection< 1 > > q_collection1D
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
virtual size_type size() const =0
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 & ExcMessage(std::string arg1)
std::vector< index_type > data
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 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)