16 #include <deal.II/base/function_bessel.h> 17 #include <deal.II/base/function_lib.h> 18 #include <deal.II/base/numbers.h> 19 #include <deal.II/base/point.h> 20 #include <deal.II/base/std_cxx17/cmath.h> 21 #include <deal.II/base/tensor.h> 23 #include <deal.II/lac/vector.h> 27 DEAL_II_NAMESPACE_OPEN
53 std::vector<double> & values,
54 const unsigned int)
const 56 Assert(values.size() == points.size(),
59 for (
unsigned int i = 0; i < points.size(); ++i)
78 std::vector<double> & values,
79 const unsigned int)
const 81 Assert(values.size() == points.size(),
84 for (
unsigned int i = 0; i < points.size(); ++i)
112 SquareFunction<dim>::gradient_list(
const std::vector<
Point<dim>> &points,
114 const unsigned int)
const 116 Assert(gradients.size() == points.size(),
119 for (
unsigned int i = 0; i < points.size(); ++i)
140 std::vector<double> & values,
141 const unsigned int)
const 144 Assert(values.size() == points.size(),
147 for (
unsigned int i = 0; i < points.size(); ++i)
150 values[i] = p(0) * p(1);
162 Assert(values.size() == points.size(),
166 for (
unsigned int i = 0; i < points.size(); ++i)
169 values[i](0) = p(0) * p(1);
186 std::vector<double> & values,
187 const unsigned int)
const 190 Assert(values.size() == points.size(),
193 for (
unsigned int i = 0; i < points.size(); ++i)
216 const unsigned int)
const 219 Assert(gradients.size() == points.size(),
222 for (
unsigned int i = 0; i < points.size(); ++i)
224 gradients[i][0] = points[i](1);
225 gradients[i][1] = points[i](0);
232 Q1WedgeFunction<dim>::vector_gradient_list(
237 Assert(gradients.size() == points.size(),
239 Assert(gradients[0].size() == 1,
242 for (
unsigned int i = 0; i < points.size(); ++i)
244 gradients[i][0][0] = points[i](1);
245 gradients[i][0][1] = points[i](0);
266 return 1. - p(0) * p(0) + offset;
268 return (1. - p(0) * p(0)) * (1. - p(1) * p(1)) + offset;
270 return (1. - p(0) * p(0)) * (1. - p(1) * p(1)) * (1. - p(2) * p(2)) +
281 std::vector<double> & values,
282 const unsigned int)
const 284 Assert(values.size() == points.size(),
287 for (
unsigned int i = 0; i < points.size(); ++i)
293 values[i] = 1. - p(0) * p(0) + offset;
296 values[i] = (1. - p(0) * p(0)) * (1. - p(1) * p(1)) + offset;
300 (1. - p(0) * p(0)) * (1. - p(1) * p(1)) * (1. - p(2) * p(2)) +
320 return -2. * ((1. - p(0) * p(0)) + (1. - p(1) * p(1)));
322 return -2. * ((1. - p(0) * p(0)) * (1. - p(1) * p(1)) +
323 (1. - p(1) * p(1)) * (1. - p(2) * p(2)) +
324 (1. - p(2) * p(2)) * (1. - p(0) * p(0)));
334 std::vector<double> & values,
335 const unsigned int)
const 337 Assert(values.size() == points.size(),
340 for (
unsigned int i = 0; i < points.size(); ++i)
349 values[i] = -2. * ((1. - p(0) * p(0)) + (1. - p(1) * p(1)));
352 values[i] = -2. * ((1. - p(0) * p(0)) * (1. - p(1) * p(1)) +
353 (1. - p(1) * p(1)) * (1. - p(2) * p(2)) +
354 (1. - p(2) * p(2)) * (1. - p(0) * p(0)));
370 result[0] = -2. * p(0);
373 result[0] = -2. * p(0) * (1. - p(1) * p(1));
374 result[1] = -2. * p(1) * (1. - p(0) * p(0));
377 result[0] = -2. * p(0) * (1. - p(1) * p(1)) * (1. - p(2) * p(2));
378 result[1] = -2. * p(1) * (1. - p(0) * p(0)) * (1. - p(2) * p(2));
379 result[2] = -2. * p(2) * (1. - p(0) * p(0)) * (1. - p(1) * p(1));
391 const unsigned int)
const 393 Assert(gradients.size() == points.size(),
396 for (
unsigned int i = 0; i < points.size(); ++i)
402 gradients[i][0] = -2. * p(0);
405 gradients[i][0] = -2. * p(0) * (1. - p(1) * p(1));
406 gradients[i][1] = -2. * p(1) * (1. - p(0) * p(0));
410 -2. * p(0) * (1. - p(1) * p(1)) * (1. - p(2) * p(2));
412 -2. * p(1) * (1. - p(0) * p(0)) * (1. - p(2) * p(2));
414 -2. * p(2) * (1. - p(0) * p(0)) * (1. - p(1) * p(1));
455 std::vector<double> & values,
456 const unsigned int)
const 458 Assert(values.size() == points.size(),
461 for (
unsigned int i = 0; i < points.size(); ++i)
462 values[i] = value(points[i]);
472 Assert(values.size() == points.size(),
475 for (
unsigned int i = 0; i < points.size(); ++i)
477 const double v = value(points[i]);
478 for (
unsigned int k = 0; k < values[i].size(); ++k)
511 std::vector<double> & values,
512 const unsigned int)
const 514 Assert(values.size() == points.size(),
517 for (
unsigned int i = 0; i < points.size(); ++i)
518 values[i] = laplacian(points[i]);
558 const unsigned int)
const 560 Assert(gradients.size() == points.size(),
563 for (
unsigned int i = 0; i < points.size(); ++i)
622 const double cococo = -pi2 * std::cos(
numbers::PI_2 * p(0)) *
635 result[0][0] = cococo;
636 result[1][1] = cococo;
637 result[2][2] = cococo;
639 result[0][1] = sisico;
640 result[0][2] = sicosi;
641 result[1][2] = cosisi;
655 const unsigned int)
const 657 Assert(hessians.size() == points.size(),
662 for (
unsigned int i = 0; i < points.size(); ++i)
676 hessians[i][0][0] = coco;
677 hessians[i][1][1] = coco;
679 hessians[i][0][1] = sisi;
684 const double cococo = -pi2 * std::cos(
numbers::PI_2 * p(0)) *
697 hessians[i][0][0] = cococo;
698 hessians[i][1][1] = cococo;
699 hessians[i][2][2] = cococo;
701 hessians[i][0][1] = sisico;
702 hessians[i][0][2] = sicosi;
703 hessians[i][1][2] = cosisi;
723 const unsigned int d)
const 726 const unsigned int d1 = (d + 1) % dim;
727 const unsigned int d2 = (d + 2) % dim;
783 std::vector<double> & values,
784 const unsigned int d)
const 786 Assert(values.size() == points.size(),
789 const unsigned int d1 = (d + 1) % dim;
790 const unsigned int d2 = (d + 2) % dim;
792 for (
unsigned int i = 0; i < points.size(); ++i)
822 Assert(values.size() == points.size(),
825 for (
unsigned int i = 0; i < points.size(); ++i)
860 const unsigned int d)
const 869 const unsigned int d)
const 872 const unsigned int d1 = (d + 1) % dim;
873 const unsigned int d2 = (d + 2) % dim;
910 const unsigned int d)
const 913 const unsigned int d1 = (d + 1) % dim;
914 const unsigned int d2 = (d + 2) % dim;
917 Assert(gradients.size() == points.size(),
919 for (
unsigned int i = 0; i < points.size(); ++i)
955 CosineGradFunction<dim>::vector_gradient_list(
962 for (
unsigned int i = 0; i < points.size(); ++i)
976 gradients[i][0][0] = coco;
977 gradients[i][1][1] = coco;
978 gradients[i][0][1] = sisi;
979 gradients[i][1][0] = sisi;
984 const double cococo = -pi2 * std::cos(
numbers::PI_2 * p(0)) *
997 gradients[i][0][0] = cococo;
998 gradients[i][1][1] = cococo;
999 gradients[i][2][2] = cococo;
1000 gradients[i][0][1] = sisico;
1001 gradients[i][1][0] = sisico;
1002 gradients[i][0][2] = sicosi;
1003 gradients[i][2][0] = sicosi;
1004 gradients[i][1][2] = cosisi;
1005 gradients[i][2][1] = cosisi;
1024 return std::exp(p(0));
1026 return std::exp(p(0)) * std::exp(p(1));
1028 return std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
1038 std::vector<double> & values,
1039 const unsigned int)
const 1041 Assert(values.size() == points.size(),
1044 for (
unsigned int i = 0; i < points.size(); ++i)
1050 values[i] = std::exp(p(0));
1053 values[i] = std::exp(p(0)) * std::exp(p(1));
1056 values[i] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
1071 return std::exp(p(0));
1073 return 2 * std::exp(p(0)) * std::exp(p(1));
1075 return 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
1085 std::vector<double> & values,
1086 const unsigned int)
const 1088 Assert(values.size() == points.size(),
1091 for (
unsigned int i = 0; i < points.size(); ++i)
1097 values[i] = std::exp(p(0));
1100 values[i] = 2 * std::exp(p(0)) * std::exp(p(1));
1103 values[i] = 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
1119 result[0] = std::exp(p(0));
1122 result[0] = std::exp(p(0)) * std::exp(p(1));
1123 result[1] = result[0];
1126 result[0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
1127 result[1] = result[0];
1128 result[2] = result[0];
1140 const unsigned int)
const 1142 Assert(gradients.size() == points.size(),
1145 for (
unsigned int i = 0; i < points.size(); ++i)
1151 gradients[i][0] = std::exp(p(0));
1154 gradients[i][0] = std::exp(p(0)) * std::exp(p(1));
1155 gradients[i][1] = gradients[i][0];
1159 std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
1160 gradients[i][1] = gradients[i][0];
1161 gradients[i][2] = gradients[i][0];
1173 LSingularityFunction::value(
const Point<2> &p,
const unsigned int)
const 1178 if ((x >= 0) && (y >= 0))
1182 double r2 = x * x + y * y;
1184 return std::pow(r2, 1. / 3.) * std::sin(2. / 3. * phi);
1189 LSingularityFunction::value_list(
const std::vector<
Point<2>> &points,
1190 std::vector<double> & values,
1191 const unsigned int)
const 1193 Assert(values.size() == points.size(),
1196 for (
unsigned int i = 0; i < points.size(); ++i)
1198 double x = points[i](0);
1199 double y = points[i](1);
1201 if ((x >= 0) && (y >= 0))
1206 double r2 = x * x + y * y;
1208 values[i] = std::pow(r2, 1. / 3.) * std::sin(2. / 3. * phi);
1215 LSingularityFunction::vector_value_list(
1216 const std::vector<
Point<2>> &points,
1219 Assert(values.size() == points.size(),
1222 for (
unsigned int i = 0; i < points.size(); ++i)
1224 Assert(values[i].size() == 1,
1226 double x = points[i](0);
1227 double y = points[i](1);
1229 if ((x >= 0) && (y >= 0))
1234 double r2 = x * x + y * y;
1236 values[i](0) = std::pow(r2, 1. / 3.) * std::sin(2. / 3. * phi);
1243 LSingularityFunction::laplacian(
const Point<2> &,
const unsigned int)
const 1250 LSingularityFunction::laplacian_list(
const std::vector<
Point<2>> &points,
1251 std::vector<double> & values,
1252 const unsigned int)
const 1254 Assert(values.size() == points.size(),
1257 for (
unsigned int i = 0; i < points.size(); ++i)
1263 LSingularityFunction::gradient(
const Point<2> &p,
const unsigned int)
const 1268 double r43 = std::pow(x * x + y * y, 2. / 3.);
1271 result[0] = 2. / 3. *
1272 (std::sin(2. / 3. * phi) * x + std::cos(2. / 3. * phi) * y) /
1274 result[1] = 2. / 3. *
1275 (std::sin(2. / 3. * phi) * y - std::cos(2. / 3. * phi) * x) /
1282 LSingularityFunction::gradient_list(
const std::vector<
Point<2>> &points,
1284 const unsigned int)
const 1286 Assert(gradients.size() == points.size(),
1289 for (
unsigned int i = 0; i < points.size(); ++i)
1295 double r43 = std::pow(x * x + y * y, 2. / 3.);
1299 (std::sin(2. / 3. * phi) * x + std::cos(2. / 3. * phi) * y) / r43;
1302 (std::sin(2. / 3. * phi) * y - std::cos(2. / 3. * phi) * x) / r43;
1308 LSingularityFunction::vector_gradient_list(
1309 const std::vector<
Point<2>> & points,
1310 std::vector<std::vector<
Tensor<1, 2>>> &gradients)
const 1312 Assert(gradients.size() == points.size(),
1315 for (
unsigned int i = 0; i < points.size(); ++i)
1317 Assert(gradients[i].size() == 1,
1323 double r43 = std::pow(x * x + y * y, 2. / 3.);
1325 gradients[i][0][0] =
1327 (std::sin(2. / 3. * phi) * x + std::cos(2. / 3. * phi) * y) / r43;
1328 gradients[i][0][1] =
1330 (std::sin(2. / 3. * phi) * y - std::cos(2. / 3. * phi) * x) / r43;
1342 LSingularityGradFunction::value(
const Point<2> &p,
const unsigned int d)
const 1346 const double x = p(0);
1347 const double y = p(1);
1348 const double phi = std::atan2(y, -x) +
numbers::PI;
1349 const double r43 = std::pow(x * x + y * y, 2. / 3.);
1352 (std::sin(2. / 3. * phi) * p(d) +
1353 (d == 0 ? (std::cos(2. / 3. * phi) * y) :
1354 (-std::cos(2. / 3. * phi) * x))) /
1360 LSingularityGradFunction::value_list(
const std::vector<
Point<2>> &points,
1361 std::vector<double> & values,
1362 const unsigned int d)
const 1367 for (
unsigned int i = 0; i < points.size(); ++i)
1370 const double x = p(0);
1371 const double y = p(1);
1372 const double phi = std::atan2(y, -x) +
numbers::PI;
1373 const double r43 = std::pow(x * x + y * y, 2. / 3.);
1375 values[i] = 2. / 3. *
1376 (std::sin(2. / 3. * phi) * p(d) +
1377 (d == 0 ? (std::cos(2. / 3. * phi) * y) :
1378 (-std::cos(2. / 3. * phi) * x))) /
1385 LSingularityGradFunction::vector_value_list(
1386 const std::vector<
Point<2>> &points,
1389 Assert(values.size() == points.size(),
1392 for (
unsigned int i = 0; i < points.size(); ++i)
1396 const double x = p(0);
1397 const double y = p(1);
1398 const double phi = std::atan2(y, -x) +
numbers::PI;
1399 const double r43 = std::pow(x * x + y * y, 2. / 3.);
1403 (std::sin(2. / 3. * phi) * x + std::cos(2. / 3. * phi) * y) / r43;
1406 (std::sin(2. / 3. * phi) * y - std::cos(2. / 3. * phi) * x) / r43;
1412 LSingularityGradFunction::laplacian(
const Point<2> &,
1413 const unsigned int)
const 1420 LSingularityGradFunction::laplacian_list(
const std::vector<
Point<2>> &points,
1421 std::vector<double> & values,
1422 const unsigned int)
const 1424 Assert(values.size() == points.size(),
1427 for (
unsigned int i = 0; i < points.size(); ++i)
1434 LSingularityGradFunction::gradient(
const Point<2> & ,
1435 const unsigned int )
const 1443 LSingularityGradFunction::gradient_list(
1446 const unsigned int )
const 1453 LSingularityGradFunction::vector_gradient_list(
1465 const unsigned int)
const 1471 double r2 = x * x + y * y;
1473 return std::pow(r2, .25) * std::sin(.5 * phi);
1481 std::vector<double> & values,
1482 const unsigned int)
const 1484 Assert(values.size() == points.size(),
1487 for (
unsigned int i = 0; i < points.size(); ++i)
1489 double x = points[i](0);
1490 double y = points[i](1);
1493 double r2 = x * x + y * y;
1495 values[i] = std::pow(r2, .25) * std::sin(.5 * phi);
1506 Assert(values.size() == points.size(),
1509 for (
unsigned int i = 0; i < points.size(); ++i)
1511 Assert(values[i].size() == 1,
1514 double x = points[i](0);
1515 double y = points[i](1);
1518 double r2 = x * x + y * y;
1520 values[i](0) = std::pow(r2, .25) * std::sin(.5 * phi);
1528 const unsigned int)
const 1538 std::vector<double> & values,
1539 const unsigned int)
const 1541 Assert(values.size() == points.size(),
1544 for (
unsigned int i = 0; i < points.size(); ++i)
1552 const unsigned int)
const 1557 double r64 = std::pow(x * x + y * y, 3. / 4.);
1560 result[0] = 1. / 2. *
1561 (std::sin(1. / 2. * phi) * x + std::cos(1. / 2. * phi) * y) /
1563 result[1] = 1. / 2. *
1564 (std::sin(1. / 2. * phi) * y - std::cos(1. / 2. * phi) * x) /
1575 const unsigned int)
const 1577 Assert(gradients.size() == points.size(),
1580 for (
unsigned int i = 0; i < points.size(); ++i)
1586 double r64 = std::pow(x * x + y * y, 3. / 4.);
1590 (std::sin(1. / 2. * phi) * x + std::cos(1. / 2. * phi) * y) / r64;
1593 (std::sin(1. / 2. * phi) * y - std::cos(1. / 2. * phi) * x) / r64;
1594 for (
unsigned int d = 2; d < dim; ++d)
1595 gradients[i][d] = 0.;
1601 SlitSingularityFunction<dim>::vector_gradient_list(
1605 Assert(gradients.size() == points.size(),
1608 for (
unsigned int i = 0; i < points.size(); ++i)
1610 Assert(gradients[i].size() == 1,
1617 double r64 = std::pow(x * x + y * y, 3. / 4.);
1619 gradients[i][0][0] =
1621 (std::sin(1. / 2. * phi) * x + std::cos(1. / 2. * phi) * y) / r64;
1622 gradients[i][0][1] =
1624 (std::sin(1. / 2. * phi) * y - std::cos(1. / 2. * phi) * x) / r64;
1625 for (
unsigned int d = 2;
d < dim; ++
d)
1626 gradients[i][0][d] = 0.;
1634 SlitHyperSingularityFunction::value(
const Point<2> &p,
1635 const unsigned int)
const 1641 double r2 = x * x + y * y;
1643 return std::pow(r2, .125) * std::sin(.25 * phi);
1648 SlitHyperSingularityFunction::value_list(
const std::vector<
Point<2>> &points,
1649 std::vector<double> & values,
1650 const unsigned int)
const 1652 Assert(values.size() == points.size(),
1655 for (
unsigned int i = 0; i < points.size(); ++i)
1657 double x = points[i](0);
1658 double y = points[i](1);
1661 double r2 = x * x + y * y;
1663 values[i] = std::pow(r2, .125) * std::sin(.25 * phi);
1669 SlitHyperSingularityFunction::vector_value_list(
1670 const std::vector<
Point<2>> &points,
1673 Assert(values.size() == points.size(),
1676 for (
unsigned int i = 0; i < points.size(); ++i)
1678 Assert(values[i].size() == 1,
1681 double x = points[i](0);
1682 double y = points[i](1);
1685 double r2 = x * x + y * y;
1687 values[i](0) = std::pow(r2, .125) * std::sin(.25 * phi);
1693 SlitHyperSingularityFunction::laplacian(
const Point<2> &,
1694 const unsigned int)
const 1701 SlitHyperSingularityFunction::laplacian_list(
1702 const std::vector<
Point<2>> &points,
1703 std::vector<double> & values,
1704 const unsigned int)
const 1706 Assert(values.size() == points.size(),
1709 for (
unsigned int i = 0; i < points.size(); ++i)
1715 SlitHyperSingularityFunction::gradient(
const Point<2> &p,
1716 const unsigned int)
const 1721 double r78 = std::pow(x * x + y * y, 7. / 8.);
1725 result[0] = 1. / 4. *
1726 (std::sin(1. / 4. * phi) * x + std::cos(1. / 4. * phi) * y) /
1728 result[1] = 1. / 4. *
1729 (std::sin(1. / 4. * phi) * y - std::cos(1. / 4. * phi) * x) /
1736 SlitHyperSingularityFunction::gradient_list(
1737 const std::vector<
Point<2>> &points,
1739 const unsigned int)
const 1741 Assert(gradients.size() == points.size(),
1744 for (
unsigned int i = 0; i < points.size(); ++i)
1750 double r78 = std::pow(x * x + y * y, 7. / 8.);
1754 (std::sin(1. / 4. * phi) * x + std::cos(1. / 4. * phi) * y) / r78;
1757 (std::sin(1. / 4. * phi) * y - std::cos(1. / 4. * phi) * x) / r78;
1763 SlitHyperSingularityFunction::vector_gradient_list(
1764 const std::vector<
Point<2>> & points,
1765 std::vector<std::vector<
Tensor<1, 2>>> &gradients)
const 1767 Assert(gradients.size() == points.size(),
1770 for (
unsigned int i = 0; i < points.size(); ++i)
1772 Assert(gradients[i].size() == 1,
1779 double r78 = std::pow(x * x + y * y, 7. / 8.);
1781 gradients[i][0][0] =
1783 (std::sin(1. / 4. * phi) * x + std::cos(1. / 4. * phi) * y) / r78;
1784 gradients[i][0][1] =
1786 (std::sin(1. / 4. * phi) * y - std::cos(1. / 4. * phi) * x) / r78;
1794 const double steepness)
1795 : direction(direction)
1796 , steepness(steepness)
1819 double x = steepness * (-cosine * p(0) + sine * p(1));
1820 return -std::atan(x);
1828 std::vector<double> & values,
1829 const unsigned int)
const 1831 Assert(values.size() == p.size(),
1834 for (
unsigned int i = 0; i < p.size(); ++i)
1836 double x = steepness * (-cosine * p[i](0) + sine * p[i](1));
1837 values[i] = -std::atan(x);
1846 double x = steepness * (-cosine * p(0) + sine * p(1));
1847 double r = 1 + x * x;
1848 return 2 * steepness * steepness * x / (r * r);
1855 std::vector<double> & values,
1856 const unsigned int)
const 1858 Assert(values.size() == p.size(),
1861 double f = 2 * steepness * steepness;
1863 for (
unsigned int i = 0; i < p.size(); ++i)
1865 double x = steepness * (-cosine * p[i](0) + sine * p[i](1));
1866 double r = 1 + x * x;
1867 values[i] = f * x / (r * r);
1877 double x = steepness * (-cosine * p(0) + sine * p(1));
1878 double r = -steepness * (1 + x * x);
1880 erg[0] = cosine * r;
1891 const unsigned int)
const 1893 Assert(gradients.size() == p.size(),
1896 for (
unsigned int i = 0; i < p.size(); ++i)
1898 double x = steepness * (cosine * p[i](0) + sine * p[i](1));
1899 double r = -steepness * (1 + x * x);
1900 gradients[i][0] = cosine * r;
1901 gradients[i][1] = sine * r;
1913 return sizeof(*this);
1925 , fourier_coefficients(fourier_coefficients)
1933 const unsigned int component)
const 1937 return std::cos(fourier_coefficients * p);
1945 const unsigned int component)
const 1949 return -fourier_coefficients * std::sin(fourier_coefficients * p);
1957 const unsigned int component)
const 1961 return (fourier_coefficients * fourier_coefficients) *
1962 (-std::cos(fourier_coefficients * p));
1975 , fourier_coefficients(fourier_coefficients)
1983 const unsigned int component)
const 1987 return std::sin(fourier_coefficients * p);
1995 const unsigned int component)
const 1999 return fourier_coefficients * std::cos(fourier_coefficients * p);
2007 const unsigned int component)
const 2011 return (fourier_coefficients * fourier_coefficients) *
2012 (-std::sin(fourier_coefficients * p));
2023 const std::vector<
Point<dim>> &fourier_coefficients,
2024 const std::vector<double> & weights)
2026 , fourier_coefficients(fourier_coefficients)
2039 const unsigned int component)
const 2044 const unsigned int n = weights.size();
2046 for (
unsigned int s = 0; s < n; ++s)
2047 sum += weights[s] * std::sin(fourier_coefficients[s] * p);
2057 const unsigned int component)
const 2062 const unsigned int n = weights.size();
2064 for (
unsigned int s = 0; s < n; ++s)
2065 sum += fourier_coefficients[s] * std::cos(fourier_coefficients[s] * p);
2075 const unsigned int component)
const 2080 const unsigned int n = weights.size();
2082 for (
unsigned int s = 0; s < n; ++s)
2083 sum -= (fourier_coefficients[s] * fourier_coefficients[s]) *
2084 std::sin(fourier_coefficients[s] * p);
2097 const std::vector<
Point<dim>> &fourier_coefficients,
2098 const std::vector<double> & weights)
2100 , fourier_coefficients(fourier_coefficients)
2113 const unsigned int component)
const 2118 const unsigned int n = weights.size();
2120 for (
unsigned int s = 0; s < n; ++s)
2121 sum += weights[s] * std::cos(fourier_coefficients[s] * p);
2131 const unsigned int component)
const 2136 const unsigned int n = weights.size();
2138 for (
unsigned int s = 0; s < n; ++s)
2139 sum -= fourier_coefficients[s] * std::sin(fourier_coefficients[s] * p);
2149 const unsigned int component)
const 2154 const unsigned int n = weights.size();
2156 for (
unsigned int s = 0; s < n; ++s)
2157 sum -= (fourier_coefficients[s] * fourier_coefficients[s]) *
2158 std::cos(fourier_coefficients[s] * p);
2171 const unsigned int n_components)
2173 , exponents(exponents)
2183 Assert(component < this->n_components,
2187 for (
unsigned int s = 0; s < dim; ++s)
2190 Assert(std::floor(exponents[s]) == exponents[s],
2191 ExcMessage(
"Exponentiation of a negative base number with " 2192 "a real exponent can't be performed."));
2193 prod *= std::pow(p[s], exponents[s]);
2207 for (
unsigned int i = 0; i < values.
size(); ++i)
2216 const unsigned int component)
const 2222 for (
unsigned int d = 0; d < dim; ++d)
2225 for (
unsigned int s = 0; s < dim; ++s)
2227 if ((s == d) && (exponents[s] == 0) && (p[s] == 0))
2235 Assert(std::floor(exponents[s]) == exponents[s],
2237 "Exponentiation of a negative base number with " 2238 "a real exponent can't be performed."));
2240 (s == d ? exponents[s] * std::pow(p[s], exponents[s] - 1) :
2241 std::pow(p[s], exponents[s]));
2255 std::vector<double> & values,
2256 const unsigned int component)
const 2258 Assert(values.size() == points.size(),
2261 for (
unsigned int i = 0; i < points.size(); ++i)
2268 const double wave_number,
2271 , wave_number(wave_number)
2282 const double r = p.
distance(center);
2283 return std_cxx17::cyl_bessel_j(order, r * wave_number);
2290 std::vector<double> & values,
2291 const unsigned int)
const 2295 for (
unsigned int k = 0; k < points.size(); ++k)
2297 const double r = points[k].distance(center);
2298 values[k] = std_cxx17::cyl_bessel_j(order, r * wave_number);
2308 const double r = p.
distance(center);
2309 const double co = (r == 0.) ? 0. : (p(0) - center(0)) / r;
2310 const double si = (r == 0.) ? 0. : (p(1) - center(1)) / r;
2314 (-std_cxx17::cyl_bessel_j(1, r * wave_number)) :
2315 (.5 * (std_cxx17::cyl_bessel_j(order - 1, wave_number * r) -
2316 std_cxx17::cyl_bessel_j(order + 1, wave_number * r)));
2318 result[0] = wave_number * co * dJn;
2319 result[1] = wave_number * si * dJn;
2329 const unsigned int)
const 2333 for (
unsigned int k = 0; k < points.size(); ++k)
2336 const double r = p.
distance(center);
2337 const double co = (r == 0.) ? 0. : (p(0) - center(0)) / r;
2338 const double si = (r == 0.) ? 0. : (p(1) - center(1)) / r;
2342 (-std_cxx17::cyl_bessel_j(1, r * wave_number)) :
2343 (.5 * (std_cxx17::cyl_bessel_j(order - 1, wave_number * r) -
2344 std_cxx17::cyl_bessel_j(order + 1, wave_number * r)));
2346 result[0] = wave_number * co * dJn;
2347 result[1] = wave_number * si * dJn;
2363 return ((1 - xi[0]) * data_values[ix[0]] +
2364 xi[0] * data_values[ix[0] + 1]);
2372 return (((1 - p_unit[0]) * data_values[ix[0]][ix[1]] +
2373 p_unit[0] * data_values[ix[0] + 1][ix[1]]) *
2375 ((1 - p_unit[0]) * data_values[ix[0]][ix[1] + 1] +
2376 p_unit[0] * data_values[ix[0] + 1][ix[1] + 1]) *
2385 return ((((1 - p_unit[0]) * data_values[ix[0]][ix[1]][ix[2]] +
2386 p_unit[0] * data_values[ix[0] + 1][ix[1]][ix[2]]) *
2388 ((1 - p_unit[0]) * data_values[ix[0]][ix[1] + 1][ix[2]] +
2389 p_unit[0] * data_values[ix[0] + 1][ix[1] + 1][ix[2]]) *
2392 (((1 - p_unit[0]) * data_values[ix[0]][ix[1]][ix[2] + 1] +
2393 p_unit[0] * data_values[ix[0] + 1][ix[1]][ix[2] + 1]) *
2395 ((1 - p_unit[0]) * data_values[ix[0]][ix[1] + 1][ix[2] + 1] +
2396 p_unit[0] * data_values[ix[0] + 1][ix[1] + 1][ix[2] + 1]) *
2414 grad[0] = (data_values[ix[0] + 1] - data_values[ix[0]]) / dx[0];
2426 double u00 = data_values[ix[0]][ix[1]],
2427 u01 = data_values[ix[0] + 1][ix[1]],
2428 u10 = data_values[ix[0]][ix[1] + 1],
2429 u11 = data_values[ix[0] + 1][ix[1] + 1];
2432 ((1 - p_unit[1]) * (u01 - u00) + p_unit[1] * (u11 - u10)) /
dx[0];
2434 ((1 - p_unit[0]) * (u10 - u00) + p_unit[0] * (u11 - u01)) /
dx[1];
2446 double u000 = data_values[ix[0]][ix[1]][ix[2]],
2447 u001 = data_values[ix[0] + 1][ix[1]][ix[2]],
2448 u010 = data_values[ix[0]][ix[1] + 1][ix[2]],
2449 u100 = data_values[ix[0]][ix[1]][ix[2] + 1],
2450 u011 = data_values[ix[0] + 1][ix[1] + 1][ix[2]],
2451 u101 = data_values[ix[0] + 1][ix[1]][ix[2] + 1],
2452 u110 = data_values[ix[0]][ix[1] + 1][ix[2] + 1],
2453 u111 = data_values[ix[0] + 1][ix[1] + 1][ix[2] + 1];
2457 ((1 - p_unit[1]) * (u001 - u000) + p_unit[1] * (u011 - u010)) +
2459 ((1 - p_unit[1]) * (u101 - u100) + p_unit[1] * (u111 - u110))) /
2463 ((1 - p_unit[0]) * (u010 - u000) + p_unit[0] * (u011 - u001)) +
2465 ((1 - p_unit[0]) * (u110 - u100) + p_unit[0] * (u111 - u101))) /
2469 ((1 - p_unit[0]) * (u100 - u000) + p_unit[0] * (u101 - u001)) +
2471 ((1 - p_unit[0]) * (u110 - u010) + p_unit[0] * (u111 - u011))) /
2480 const std::array<std::vector<double>, dim> &coordinate_values,
2482 : coordinate_values(coordinate_values)
2483 , data_values(data_values)
2485 for (
unsigned int d = 0; d < dim; ++d)
2490 "Coordinate arrays must have at least two coordinate values!"));
2495 "Coordinate arrays must be sorted in strictly ascending order."));
2499 "Data and coordinate tables do not have the same size."));
2515 for (
unsigned int d = 0; d < dim; ++d)
2519 ix[d] = (std::lower_bound(coordinate_values[d].begin(),
2520 coordinate_values[d].end(),
2522 coordinate_values[d].begin());
2531 if (ix[d] == coordinate_values[d].size())
2532 ix[d] = coordinate_values[d].size() - 2;
2546 const unsigned int component)
const 2552 "This is a scalar function object, the component can only be zero."));
2561 for (
unsigned int d = 0; d < dim; ++d)
2562 p_unit[d] = std::max(std::min((p[d] - coordinate_values[d][ix[d]]) /
2563 (coordinate_values[d][ix[d] + 1] -
2564 coordinate_values[d][ix[d]]),
2568 return interpolate(data_values, ix, p_unit);
2577 const unsigned int component)
const 2583 "This is a scalar function object, the component can only be zero."));
2589 for (
unsigned int d = 0; d < dim; ++d)
2590 dx[d] = coordinate_values[d][ix[d] + 1] - coordinate_values[d][ix[d]];
2593 for (
unsigned int d = 0; d < dim; ++d)
2595 std::max(std::min((p[d] - coordinate_values[d][ix[d]]) / dx[d], 1.),
2598 return gradient_interpolate(data_values, ix, p_unit, dx);
2605 const std::array<std::pair<double, double>, dim> &interval_endpoints,
2606 const std::array<unsigned int, dim> & n_subintervals,
2608 : interval_endpoints(interval_endpoints)
2609 , n_subintervals(n_subintervals)
2610 , data_values(data_values)
2612 for (
unsigned int d = 0; d < dim; ++d)
2615 ExcMessage(
"There needs to be at least one subinterval in each " 2616 "coordinate direction."));
2618 ExcMessage(
"The interval in each coordinate direction needs " 2619 "to have positive size"));
2621 ExcMessage(
"The data table does not have the correct size."));
2629 const unsigned int component)
const 2635 "This is a scalar function object, the component can only be zero."));
2640 for (
unsigned int d = 0; d < dim; ++d)
2642 const double delta_x =
2643 ((interval_endpoints[d].second - interval_endpoints[d].first) /
2645 if (p[d] <= interval_endpoints[d].first)
2647 else if (p[d] >= interval_endpoints[d].second - delta_x)
2648 ix[d] = n_subintervals[d] - 1;
2650 ix[d] =
static_cast<unsigned int>(
2651 (p[d] - interval_endpoints[d].first) / delta_x);
2658 for (
unsigned int d = 0; d < dim; ++d)
2660 const double delta_x =
2661 ((interval_endpoints[d].second - interval_endpoints[d].first) /
2663 p_unit[d] = std::max(std::min((p[d] - interval_endpoints[d].first -
2670 return interpolate(data_values, ix, p_unit);
2679 const std::vector<double> &coefficients)
2681 , exponents(exponents)
2682 , coefficients(coefficients)
2695 const unsigned int component)
const 2701 for (
unsigned int monom = 0; monom < exponents.n_rows(); ++monom)
2704 for (
unsigned int s = 0; s < dim; ++s)
2707 Assert(std::floor(exponents[monom][s]) == exponents[monom][s],
2708 ExcMessage(
"Exponentiation of a negative base number with " 2709 "a real exponent can't be performed."));
2710 prod *= std::pow(p[s], exponents[monom][s]);
2712 sum += coefficients[monom] * prod;
2722 std::vector<double> & values,
2723 const unsigned int component)
const 2725 Assert(values.size() == points.size(),
2728 for (
unsigned int i = 0; i < points.size(); ++i)
2737 const unsigned int component)
const 2744 for (
unsigned int d = 0; d < dim; ++d)
2748 for (
unsigned int monom = 0; monom < exponents.n_rows(); ++monom)
2751 for (
unsigned int s = 0; s < dim; ++s)
2753 if ((s == d) && (exponents[monom][s] == 0) && (p[s] == 0))
2761 Assert(std::floor(exponents[monom][s]) ==
2762 exponents[monom][s],
2764 "Exponentiation of a negative base number with " 2765 "a real exponent can't be performed."));
2767 (s == d ? exponents[monom][s] *
2768 std::pow(p[s], exponents[monom][s] - 1) :
2769 std::pow(p[s], exponents[monom][s]));
2772 sum += coefficients[monom] * prod;
2833 DEAL_II_NAMESPACE_CLOSE
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component) const override
virtual SymmetricTensor< 2, dim > hessian(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
#define AssertDimension(dim1, dim2)
TableIndices< dim > table_index_of_point(const Point< dim > &p) const
virtual void hessian_list(const std::vector< Point< dim >> &points, std::vector< SymmetricTensor< 2, dim >> &hessians, const unsigned int component=0) const override
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component) const override
LSingularityGradFunction()
Monomial(const Tensor< 1, dim > &exponents, const unsigned int n_components=1)
Polynomial(const Table< 2, double > &exponents, const std::vector< double > &coefficients)
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
#define AssertIndexRange(index, range)
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual void vector_value(const Point< dim > &p, Vector< double > &values) const override
#define AssertVectorVectorDimension(VEC, DIM1, DIM2)
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
FourierCosineSum(const std::vector< Point< dim >> &fourier_coefficients, const std::vector< double > &weights)
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
CosineFunction(const unsigned int n_components=1)
const Table< dim, double > data_values
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &points, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcMessage(std::string arg1)
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
std::size_t memory_consumption() const
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual void vector_value(const Point< dim > &p, Vector< double > &values) const override
#define Assert(cond, exc)
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
Bessel1(const unsigned int order, const double wave_number, const Point< dim > center=Point< dim >())
virtual void vector_value(const Point< dim > &p, Vector< double > &values) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
const std::vector< Point< dim > > fourier_coefficients
static constexpr double PI_2
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
virtual void gradient_list(const std::vector< Point< dim >> &points, std::vector< Tensor< 1, dim >> &gradients, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component) const override
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
const Table< 2, double > exponents
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
const std::vector< double > coefficients
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual void vector_value_list(const std::vector< Point< dim >> &points, std::vector< Vector< double >> &values) const override
virtual void vector_value_list(const std::vector< Point< dim >> &points, std::vector< Vector< double >> &values) const override
virtual void vector_value_list(const std::vector< Point< dim >> &points, std::vector< Vector< double >> &values) const override
const Point< dim > direction
size_type size(const unsigned int i) const
const std::vector< Point< dim > > fourier_coefficients
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual void vector_value_list(const std::vector< Point< dim >> &points, std::vector< Vector< double >> &values) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
PillowFunction(const double offset=0.)
static constexpr double PI
const std::array< std::vector< double >, dim > coordinate_values
InterpolatedTensorProductGridData(const std::array< std::vector< double >, dim > &coordinate_values, const Table< dim, double > &data_values)
numbers::NumberTraits< Number >::real_type square() const
FourierCosineFunction(const Tensor< 1, dim > &fourier_coefficients)
virtual void gradient_list(const std::vector< Point< dim >> &points, std::vector< Tensor< 1, dim >> &gradients, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcNotImplemented()
FourierSineSum(const std::vector< Point< dim >> &fourier_coefficients, const std::vector< double > &weights)
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
FourierSineFunction(const Tensor< 1, dim > &fourier_coefficients)
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
virtual void gradient_list(const std::vector< Point< dim >> &points, std::vector< Tensor< 1, dim >> &gradients, const unsigned int component=0) const override
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcZero()
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component) const override
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual void laplacian_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcInternalError()
virtual void value_list(const std::vector< Point< dim >> &points, std::vector< double > &values, const unsigned int component=0) const override
JumpFunction(const Point< dim > &direction, const double steepness)