16 #include <deal.II/base/geometry_info.h> 17 #include <deal.II/base/memory_consumption.h> 18 #include <deal.II/base/qprojector.h> 19 #include <deal.II/base/quadrature.h> 20 #include <deal.II/base/std_cxx14/memory.h> 21 #include <deal.II/base/utilities.h> 27 DEAL_II_NAMESPACE_OPEN
32 : quadrature_points(n_q)
34 , is_tensor_product_flag(false)
41 : quadrature_points(n_q,
Point<dim>())
43 , is_tensor_product_flag(dim == 1)
51 const std::vector<double> & w)
54 quadrature_points = p;
62 const std::vector<double> & weights)
63 : quadrature_points(points)
65 , is_tensor_product_flag(dim == 1)
75 : quadrature_points(points)
76 , weights(points.size(),
std::numeric_limits<double>::infinity())
77 , is_tensor_product_flag(dim == 1)
87 : quadrature_points(
std::vector<
Point<dim>>(1, point))
88 , weights(
std::vector<double>(1, 1.))
89 , is_tensor_product_flag(true)
92 for (
unsigned int i = 0; i < dim; ++i)
94 const std::vector<Point<1>> quad_vec_1d(1,
Point<1>(
point[i]));
103 : quadrature_points(
std::vector<
Point<1>>(1, point))
104 , weights(
std::vector<double>(1, 1.))
105 , is_tensor_product_flag(true)
120 : quadrature_points(q1.size() * q2.size())
121 , weights(q1.size() * q2.size())
122 , is_tensor_product_flag(q1.is_tensor_product())
124 unsigned int present_index = 0;
125 for (
unsigned int i2 = 0; i2 < q2.
size(); ++i2)
126 for (
unsigned int i1 = 0; i1 < q1.
size(); ++i1)
131 for (
unsigned int d = 0; d < dim - 1; ++d)
144 for (
unsigned int i = 0; i <
size(); ++i)
155 tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>>();
156 for (
unsigned int i = 0; i < dim - 1; ++i)
158 (*tensor_basis)[dim - 1] = q2;
166 : quadrature_points(q2.size())
168 , is_tensor_product_flag(true)
170 unsigned int present_index = 0;
171 for (
unsigned int i2 = 0; i2 < q2.
size(); ++i2)
187 for (
unsigned int i = 0; i <
size(); ++i)
205 , is_tensor_product_flag(false)
224 , quadrature_points(
Utilities::fixed_power<dim>(q.size()))
225 , weights(
Utilities::fixed_power<dim>(q.size()))
226 , is_tensor_product_flag(true)
230 const unsigned int n0 = q.
size();
231 const unsigned int n1 = (dim > 1) ? n0 : 1;
232 const unsigned int n2 = (dim > 2) ? n0 : 1;
235 for (
unsigned int i2 = 0; i2 < n2; ++i2)
236 for (
unsigned int i1 = 0; i1 < n1; ++i1)
237 for (
unsigned int i0 = 0; i0 < n0; ++i0)
252 tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>>();
253 for (
unsigned int i = 0; i < dim; ++i)
262 , quadrature_points(q.quadrature_points)
264 , is_tensor_product_flag(q.is_tensor_product_flag)
268 std_cxx14::make_unique<std::array<Quadrature<1>, dim>>(*q.
tensor_basis);
280 if (dim > 1 && is_tensor_product_flag)
282 if (tensor_basis ==
nullptr)
283 tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>>(
313 typename std::conditional<dim == 1,
314 std::array<Quadrature<1>, dim>,
315 const std::array<Quadrature<1>, dim> &>::type
318 Assert(this->is_tensor_product_flag ==
true,
319 ExcMessage(
"This function only makes sense if " 320 "this object represents a tensor product!"));
323 return *tensor_basis;
329 std::array<Quadrature<1>, 1>
333 ExcMessage(
"This function only makes sense if " 334 "this object represents a tensor product!"));
336 return std::array<Quadrature<1>, 1>{{*
this}};
348 for (
unsigned int k1 = 0; k1 < qx.
size(); ++k1)
374 for (
unsigned int k2 = 0; k2 < qy.
size(); ++k2)
375 for (
unsigned int k1 = 0; k1 < qx.
size(); ++k1)
383 const std::array<Quadrature<1>, 2> q_array{{qx, qy}};
385 std_cxx14::make_unique<std::array<Quadrature<1>, 2>>(q_array);
394 :
Quadrature<dim>(qx.size() * qy.size() * qz.size())
405 :
Quadrature<3>(qx.size() * qy.size() * qz.size())
408 for (
unsigned int k3 = 0; k3 < qz.
size(); ++k3)
409 for (
unsigned int k2 = 0; k2 < qy.
size(); ++k2)
410 for (
unsigned int k1 = 0; k1 < qx.
size(); ++k1)
419 const std::array<Quadrature<1>, 3> q_array{{qx, qy, qz}};
421 std_cxx14::make_unique<std::array<Quadrature<1>, 3>>(q_array);
434 std::vector<Point<2>> q_points(q.
size());
435 std::vector<double> weights(q.
size());
436 for (
unsigned int i = 0; i < q.
size(); ++i)
438 q_points[i][0] = q.
point(i)[1];
439 q_points[i][1] = q.
point(i)[0];
452 std::vector<Point<2>> q_points(q.
size());
453 std::vector<double> weights(q.
size());
454 for (
unsigned int i = 0; i < q.
size(); ++i)
460 q_points[i][0] = q.
point(i)[0];
461 q_points[i][1] = q.
point(i)[1];
465 q_points[i][0] = 1.0 - q.
point(i)[1];
466 q_points[i][1] = q.
point(i)[0];
470 q_points[i][0] = 1.0 - q.
point(i)[0];
471 q_points[i][1] = 1.0 - q.
point(i)[1];
475 q_points[i][0] = q.
point(i)[1];
476 q_points[i][1] = 1.0 - q.
point(i)[0];
490 const unsigned int face_no,
493 const unsigned int dim = 1;
497 q_points[0] =
Point<dim>(
static_cast<double>(face_no));
505 const unsigned int face_no,
508 const unsigned int dim = 2;
513 for (
unsigned int p = 0; p < quadrature.
size(); ++p)
538 const unsigned int face_no,
541 const unsigned int dim = 3;
546 for (
unsigned int p = 0; p < quadrature.
size(); ++p)
584 const unsigned int face_no,
589 const unsigned int dim = 1;
593 q_points[0] =
Point<dim>(
static_cast<double>(face_no));
601 const unsigned int face_no,
602 const unsigned int subface_no,
606 const unsigned int dim = 2;
613 for (
unsigned int p = 0; p < quadrature.
size(); ++p)
679 const unsigned int face_no,
680 const unsigned int subface_no,
684 const unsigned int dim = 3;
693 double const_value = face_no % 2;
702 const_index = face_no / 2;
708 double xi_scale = 1.0, eta_scale = 1.0, xi_translation = 0.0,
709 eta_translation = 0.0;
733 xi_translation = subface_no % 2 * 0.5;
737 eta_translation = subface_no % 2 * 0.5;
742 xi_translation = int(subface_no % 2) * 0.5;
743 eta_translation = int(subface_no / 2) * 0.5;
751 for (
unsigned int p = 0; p < quadrature.
size(); ++p)
753 q_points[p][xi_index] =
754 xi_scale * quadrature.
point(p)(0) + xi_translation;
755 q_points[p][eta_index] =
756 eta_scale * quadrature.
point(p)(1) + eta_translation;
757 q_points[p][const_index] = const_value;
766 const unsigned int dim = 1;
771 std::vector<Point<dim>> q_points;
772 q_points.reserve(n_points * n_faces);
773 std::vector<Point<dim>> help(n_points);
778 for (
unsigned int face = 0; face < n_faces; ++face)
780 project_to_face(quadrature, face, help);
781 std::copy(help.begin(), help.end(), std::back_inserter(q_points));
785 std::vector<double> weights;
786 weights.reserve(n_points * n_faces);
787 for (
unsigned int face = 0; face < n_faces; ++face)
790 std::back_inserter(weights));
804 const unsigned int dim = 2;
806 const unsigned int n_points = quadrature.size(),
810 std::vector<Point<dim>> q_points;
811 q_points.reserve(n_points * n_faces);
812 std::vector<Point<dim>> help(n_points);
816 for (
unsigned int face = 0; face < n_faces; ++face)
818 project_to_face(quadrature, face, help);
819 std::copy(help.begin(), help.end(), std::back_inserter(q_points));
823 std::vector<double> weights;
824 weights.reserve(n_points * n_faces);
825 for (
unsigned int face = 0; face < n_faces; ++face)
826 std::copy(quadrature.get_weights().begin(),
827 quadrature.get_weights().end(),
828 std::back_inserter(weights));
842 const unsigned int dim = 3;
844 SubQuadrature q_reflected = reflect(quadrature);
845 SubQuadrature q[8] = {quadrature,
856 const unsigned int n_points = quadrature.size(),
860 std::vector<Point<dim>> q_points;
861 q_points.reserve(n_points * n_faces * 8);
862 std::vector<Point<dim>> help(n_points);
864 std::vector<double> weights;
865 weights.reserve(n_points * n_faces * 8);
871 for (
const auto &mutation : q)
875 for (
unsigned int face = 0; face < n_faces; ++face)
877 project_to_face(mutation, face, help);
878 std::copy(help.begin(), help.end(), std::back_inserter(q_points));
882 for (
unsigned int face = 0; face < n_faces; ++face)
883 std::copy(mutation.get_weights().begin(),
884 mutation.get_weights().end(),
885 std::back_inserter(weights));
901 const unsigned int dim = 1;
908 std::vector<Point<dim>> q_points;
909 q_points.reserve(n_points * n_faces * subfaces_per_face);
910 std::vector<Point<dim>> help(n_points);
914 for (
unsigned int face = 0; face < n_faces; ++face)
915 for (
unsigned int subface = 0; subface < subfaces_per_face; ++subface)
917 project_to_subface(quadrature, face, subface, help);
918 std::copy(help.begin(), help.end(), std::back_inserter(q_points));
922 std::vector<double> weights;
923 weights.reserve(n_points * n_faces * subfaces_per_face);
924 for (
unsigned int face = 0; face < n_faces; ++face)
925 for (
unsigned int subface = 0; subface < subfaces_per_face; ++subface)
928 std::back_inserter(weights));
930 Assert(q_points.size() == n_points * n_faces * subfaces_per_face,
932 Assert(weights.size() == n_points * n_faces * subfaces_per_face,
944 const unsigned int dim = 2;
946 const unsigned int n_points = quadrature.size(),
952 std::vector<Point<dim>> q_points;
953 q_points.reserve(n_points * n_faces * subfaces_per_face);
954 std::vector<Point<dim>> help(n_points);
958 for (
unsigned int face = 0; face < n_faces; ++face)
959 for (
unsigned int subface = 0; subface < subfaces_per_face; ++subface)
961 project_to_subface(quadrature, face, subface, help);
962 std::copy(help.begin(), help.end(), std::back_inserter(q_points));
966 std::vector<double> weights;
967 weights.reserve(n_points * n_faces * subfaces_per_face);
968 for (
unsigned int face = 0; face < n_faces; ++face)
969 for (
unsigned int subface = 0; subface < subfaces_per_face; ++subface)
970 std::copy(quadrature.get_weights().begin(),
971 quadrature.get_weights().end(),
972 std::back_inserter(weights));
974 Assert(q_points.size() == n_points * n_faces * subfaces_per_face,
976 Assert(weights.size() == n_points * n_faces * subfaces_per_face,
988 const unsigned int dim = 3;
989 SubQuadrature q_reflected = reflect(quadrature);
990 SubQuadrature q[8] = {quadrature,
999 const unsigned int n_points = quadrature.size(),
1001 total_subfaces_per_face = 2 + 2 + 4;
1004 std::vector<Point<dim>> q_points;
1005 q_points.reserve(n_points * n_faces * total_subfaces_per_face * 8);
1006 std::vector<Point<dim>> help(n_points);
1008 std::vector<double> weights;
1009 weights.reserve(n_points * n_faces * total_subfaces_per_face * 8);
1015 for (
const auto &mutation : q)
1019 for (
unsigned int face = 0; face < n_faces; ++face)
1023 for (
unsigned int subface = 0;
1028 project_to_subface(mutation,
1033 std::copy(help.begin(), help.end(), std::back_inserter(q_points));
1037 for (
unsigned int face = 0; face < n_faces; ++face)
1041 for (
unsigned int subface = 0;
1045 std::copy(mutation.get_weights().begin(),
1046 mutation.get_weights().end(),
1047 std::back_inserter(weights));
1050 Assert(q_points.size() == n_points * n_faces * total_subfaces_per_face * 8,
1052 Assert(weights.size() == n_points * n_faces * total_subfaces_per_face * 8,
1064 const unsigned int child_no)
1069 const unsigned int n_q_points = quadrature.
size();
1071 std::vector<Point<dim>> q_points(n_q_points);
1072 for (
unsigned int i = 0; i < n_q_points; ++i)
1080 std::vector<double> weights = quadrature.
get_weights();
1081 for (
unsigned int i = 0; i < n_q_points; ++i)
1092 const unsigned int n_points = quadrature.
size(),
1095 std::vector<Point<dim>> q_points(n_points * n_children);
1096 std::vector<double> weights(n_points * n_children);
1100 for (
unsigned int child = 0; child < n_children; ++child)
1103 for (
unsigned int i = 0; i < n_points; ++i)
1105 q_points[child * n_points + i] = help.
point(i);
1106 weights[child * n_points + i] = help.
weight(i);
1120 const unsigned int n = quadrature.
size();
1121 std::vector<Point<dim>> points(n);
1122 std::vector<double> weights(n);
1123 const double length = p1.
distance(p2);
1125 for (
unsigned int k = 0; k < n; ++k)
1127 const double alpha = quadrature.
point(k)(0);
1128 points[k] = alpha * p2;
1129 points[k] += (1. - alpha) * p1;
1130 weights[k] = length * quadrature.
weight(k);
1140 const bool face_orientation,
1141 const bool face_flip,
1142 const bool face_rotation,
1143 const unsigned int n_quadrature_points)
1151 return face_no * n_quadrature_points;
1176 static const unsigned int offset[2][2][2] = {
1195 (face_no + offset[face_orientation][face_flip][face_rotation]) *
1196 n_quadrature_points);
1210 const unsigned int face_no,
1211 const unsigned int subface_no,
1215 const unsigned int n_quadrature_points,
1223 n_quadrature_points);
1231 const unsigned int face_no,
1232 const unsigned int subface_no,
1236 const unsigned int n_quadrature_points,
1244 n_quadrature_points);
1251 const unsigned int face_no,
1252 const unsigned int subface_no,
1253 const bool face_orientation,
1254 const bool face_flip,
1255 const bool face_rotation,
1256 const unsigned int n_quadrature_points,
1259 const unsigned int dim = 3;
1289 const unsigned int total_subfaces_per_face = 8;
1306 static const unsigned int orientation_offset[2][2][2] = {
1335 static const unsigned int ref_case_offset[3] = {
1411 static const unsigned int 1447 equivalent_refine_case[ref_case][subface_no];
1448 const unsigned int equ_subface_no =
1449 equivalent_subface_number[ref_case][subface_no];
1456 (face_orientation == face_rotation ? ref_case_permutation[equ_ref_case] :
1485 const unsigned int final_subface_no =
1494 return (((face_no * total_subfaces_per_face +
1495 ref_case_offset[final_ref_case - 1] + final_subface_no) +
1496 orientation_offset[face_orientation][face_flip][face_rotation]) *
1497 n_quadrature_points);
1505 const unsigned int face_no)
1507 std::vector<Point<dim>> points(quadrature.
size());
1516 const unsigned int face_no,
1517 const unsigned int subface_no,
1520 std::vector<Point<dim>> points(quadrature.
size());
1530 namespace QIteratedImplementation
1537 bool at_left =
false, at_right =
false;
1538 for (
unsigned int i = 0; i < base_quadrature.
size(); ++i)
1546 return (at_left && at_right);
1667 const unsigned int n_copies)
1669 internal::QIteratedImplementation::uses_both_endpoints(base_quadrature) ?
1670 (base_quadrature.size() - 1) * n_copies + 1 :
1671 base_quadrature.size() * n_copies)
1677 if (!internal::QIteratedImplementation::uses_both_endpoints(base_quadrature))
1682 unsigned int next_point = 0;
1683 for (
unsigned int copy = 0; copy < n_copies; ++copy)
1684 for (
unsigned int q_point = 0; q_point < base_quadrature.
size();
1687 this->quadrature_points[next_point] =
1689 (1.0 * copy) / n_copies);
1690 this->weights[next_point] =
1691 base_quadrature.
weight(q_point) / n_copies;
1699 unsigned int next_point = 0;
1706 double double_point_weight = 0;
1707 unsigned int n_end_points = 0;
1708 for (
unsigned int i = 0; i < base_quadrature.
size(); ++i)
1714 double_point_weight += base_quadrature.
weight(i);
1718 double_point_weight /= n_copies;
1723 Assert(n_end_points == 2, ExcInvalidQuadratureFormula());
1726 for (
unsigned int copy = 0; copy < n_copies; ++copy)
1727 for (
unsigned int q_point = 0; q_point < base_quadrature.
size();
1734 if ((copy > 0) && (base_quadrature.
point(q_point) ==
Point<1>(0.0)))
1737 this->quadrature_points[next_point] =
1739 (1.0 * copy) / n_copies);
1746 if ((copy != n_copies - 1) &&
1748 this->weights[next_point] = double_point_weight;
1750 this->weights[next_point] =
1751 base_quadrature.
weight(q_point) / n_copies;
1758 double sum_of_weights = 0;
1759 for (
unsigned int i = 0; i < this->size(); ++i)
1760 sum_of_weights += this->weight(i);
1778 const unsigned int N)
1800 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
static Quadrature< dim > project_to_child(const Quadrature< dim > &quadrature, const unsigned int child_no)
#define AssertDimension(dim1, dim2)
std::vector< double > weights
static void project_to_subface(const SubQuadrature &quadrature, const unsigned int face_no, const unsigned int subface_no, std::vector< Point< dim >> &q_points, const RefinementCase< dim - 1 > &ref_case=RefinementCase< dim - 1 >::isotropic_refinement)
const std::vector< double > & get_weights() const
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Quadrature(const unsigned int n_quadrature_points=0)
static Quadrature< 2 > rotate(const Quadrature< 2 > &q, const unsigned int n_times)
#define AssertIndexRange(index, range)
const Point< dim > & point(const unsigned int i) const
const std::array< Quadrature< 1 >, dim > & get_tensor_basis() const
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
Quadrature & operator=(const Quadrature< dim > &)
static Quadrature< dim > project_to_all_subfaces(const SubQuadrature &quadrature)
static Quadrature< dim > project_to_line(const Quadrature< 1 > &quadrature, const Point< dim > &p1, const Point< dim > &p2)
QAnisotropic(const Quadrature< 1 > &qx)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
T sum(const T &t, const MPI_Comm &mpi_communicator)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
std::size_t memory_consumption() const
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
bool is_tensor_product_flag
std::vector< Point< dim > > quadrature_points
unsigned int size() const
static Quadrature< 2 > reflect(const Quadrature< 2 > &q)
static unsigned int n_children(const RefinementCase< dim > &refinement_case)
static Quadrature< dim > project_to_all_faces(const SubQuadrature &quadrature)
static void project_to_face(const SubQuadrature &quadrature, const unsigned int face_no, std::vector< Point< dim >> &q_points)
bool operator==(const Quadrature< dim > &p) const
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim - 1 > &face_refinement_case=RefinementCase< dim - 1 >::isotropic_refinement)
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
static DataSetDescriptor subface(const unsigned int face_no, const unsigned int subface_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points, const internal::SubfaceCase< dim > ref_case=internal::SubfaceCase< dim >::case_isotropic)
static ::ExceptionBase & ExcNotImplemented()
void initialize(const std::vector< Point< dim >> &points, const std::vector< double > &weights)
static ::ExceptionBase & ExcZero()
static Quadrature< dim > project_to_all_children(const Quadrature< dim > &quadrature)
double weight(const unsigned int i) const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcInternalError()
static DataSetDescriptor face(const unsigned int face_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points)