9#include <kernel/analytic/static_wrapper.hpp>
10#include <kernel/analytic/wrappers.hpp>
11#include <kernel/util/math.hpp>
12#include <kernel/geometry/cgal.hpp>
15#include <initializer_list>
46 template<
typename Scalar_,
typename DataType_>
51 static DataType_
eval(DataType_ x)
53 return Scalar_::eval(x);
57 static DataType_
der_x(DataType_ x)
59 return Scalar_::der_x(x);
65 return Scalar_::der_xx(x);
69 static DataType_
eval(DataType_ x, DataType_ y)
71 return Scalar_::eval(x) * Scalar_::eval(y);
75 static DataType_
der_x(DataType_ x, DataType_ y)
77 return Scalar_::der_x(x) * Scalar_::eval(y);
81 static DataType_
der_y(DataType_ x, DataType_ y)
83 return Scalar_::eval(x) * Scalar_::der_x(y);
87 static DataType_
eval(DataType_ x, DataType_ y, DataType_ z)
89 return Scalar_::eval(x) * Scalar_::eval(y) * Scalar_::eval(z);
93 static DataType_
der_x(DataType_ x, DataType_ y, DataType_ z)
95 return Scalar_::der_x(x) * Scalar_::eval(y) * Scalar_::eval(z);
99 static DataType_
der_y(DataType_ x, DataType_ y, DataType_ z)
101 return Scalar_::eval(x) * Scalar_::der_x(y) * Scalar_::eval(z);
105 static DataType_
der_z(DataType_ x, DataType_ y, DataType_ z)
107 return Scalar_::eval(x) * Scalar_::eval(y) * Scalar_::der_x(z);
111 static DataType_
der_xx(DataType_ x, DataType_ y)
113 return Scalar_::der_xx(x) * Scalar_::eval(y);
117 static DataType_
der_yy(DataType_ x, DataType_ y)
119 return Scalar_::eval(x) * Scalar_::der_xx(y);
123 static DataType_
der_xy(DataType_ x, DataType_ y)
125 return Scalar_::der_x(x) * Scalar_::der_x(y);
129 static DataType_
der_yx(DataType_ x, DataType_ y)
131 return Scalar_::der_x(x) * Scalar_::der_x(y);
135 static DataType_
der_xx(DataType_ x, DataType_ y, DataType_ z)
137 return Scalar_::der_xx(x) * Scalar_::eval(y) * Scalar_::eval(z);
141 static DataType_
der_yy(DataType_ x, DataType_ y, DataType_ z)
143 return Scalar_::eval(x) * Scalar_::der_xx(y) * Scalar_::eval(z);
147 static DataType_
der_zz(DataType_ x, DataType_ y, DataType_ z)
149 return Scalar_::eval(x) * Scalar_::eval(y) * Scalar_::der_xx(z);
153 static DataType_
der_xy(DataType_ x, DataType_ y, DataType_ z)
155 return Scalar_::der_x(x) * Scalar_::der_x(y) * Scalar_::eval(z);
159 static DataType_
der_yx(DataType_ x, DataType_ y, DataType_ z)
161 return Scalar_::der_x(x) * Scalar_::der_x(y) * Scalar_::eval(z);
165 static DataType_
der_xz(DataType_ x, DataType_ y, DataType_ z)
167 return Scalar_::der_x(x) * Scalar_::eval(y) * Scalar_::der_x(z);
171 static DataType_
der_zx(DataType_ x, DataType_ y, DataType_ z)
173 return Scalar_::der_x(x) * Scalar_::eval(y) * Scalar_::der_x(z);
177 static DataType_
der_yz(DataType_ x, DataType_ y, DataType_ z)
179 return Scalar_::eval(x) * Scalar_::der_x(y) * Scalar_::der_x(z);
183 static DataType_
der_zy(DataType_ x, DataType_ y, DataType_ z)
185 return Scalar_::eval(x) * Scalar_::der_x(y) * Scalar_::der_x(z);
205 template<
typename DataType_,
int k_ = 1>
208 static_assert(k_ > 0,
"parameter k_ must be a positive integer");
214 return DataType_(k_) * Math::pi<DataType_>();
218 static DataType_
eval(DataType_ x)
224 static DataType_
eval(DataType_ x, DataType_ y)
230 static DataType_
eval(DataType_ x, DataType_ y, DataType_ z)
242 static DataType_
der_x(DataType_ x, DataType_ y)
248 static DataType_
der_y(DataType_ x, DataType_ y)
254 static DataType_
der_x(DataType_ x, DataType_ y, DataType_ z)
260 static DataType_
der_y(DataType_ x, DataType_ y, DataType_ z)
266 static DataType_
der_z(DataType_ x, DataType_ y, DataType_ z)
278 static DataType_
der_xx(DataType_ x, DataType_ y)
284 static DataType_
der_yy(DataType_ x, DataType_ y)
290 static DataType_
der_xy(DataType_ x, DataType_ y)
296 static DataType_
der_yx(DataType_ x, DataType_ y)
302 static DataType_
der_xx(DataType_ x, DataType_ y, DataType_ z)
308 static DataType_
der_yy(DataType_ x, DataType_ y, DataType_ z)
314 static DataType_
der_zz(DataType_ x, DataType_ y, DataType_ z)
320 static DataType_
der_xy(DataType_ x, DataType_ y, DataType_ z)
326 static DataType_
der_yx(DataType_ x, DataType_ y, DataType_ z)
332 static DataType_
der_xz(DataType_ x, DataType_ y, DataType_ z)
338 static DataType_
der_zx(DataType_ x, DataType_ y, DataType_ z)
344 static DataType_
der_yz(DataType_ x, DataType_ y, DataType_ z)
350 static DataType_
der_zy(DataType_ x, DataType_ y, DataType_ z)
357 template<
typename DataType_>
358 using SineBubbleStatic = SineTensorStatic<DataType_, 1>;
395 template<
typename DataType_,
int k_ = 1>
398 static_assert(k_ > 0,
"parameter k_ must be a positive integer");
404 return DataType_(k_) * Math::pi<DataType_>();
408 static DataType_
eval(DataType_ x)
414 static DataType_
eval(DataType_ x, DataType_ y)
420 static DataType_
eval(DataType_ x, DataType_ y, DataType_ z)
432 static DataType_
der_x(DataType_ x, DataType_ y)
438 static DataType_
der_y(DataType_ x, DataType_ y)
444 static DataType_
der_x(DataType_ x, DataType_ y, DataType_ z)
450 static DataType_
der_y(DataType_ x, DataType_ y, DataType_ z)
456 static DataType_
der_z(DataType_ x, DataType_ y, DataType_ z)
468 static DataType_
der_xx(DataType_ x, DataType_ y)
474 static DataType_
der_yy(DataType_ x, DataType_ y)
480 static DataType_
der_xy(DataType_ x, DataType_ y)
486 static DataType_
der_yx(DataType_ x, DataType_ y)
492 static DataType_
der_xx(DataType_ x, DataType_ y, DataType_ z)
498 static DataType_
der_yy(DataType_ x, DataType_ y, DataType_ z)
504 static DataType_
der_zz(DataType_ x, DataType_ y, DataType_ z)
510 static DataType_
der_xy(DataType_ x, DataType_ y, DataType_ z)
516 static DataType_
der_yx(DataType_ x, DataType_ y, DataType_ z)
522 static DataType_
der_xz(DataType_ x, DataType_ y, DataType_ z)
528 static DataType_
der_zx(DataType_ x, DataType_ y, DataType_ z)
534 static DataType_
der_yz(DataType_ x, DataType_ y, DataType_ z)
540 static DataType_
der_zy(DataType_ x, DataType_ y, DataType_ z)
547 template<
typename DataType_>
548 using CosineWaveStatic = CosineTensorStatic<DataType_, 1>;
579 template<
typename DataType_>
584 static DataType_
eval(DataType_ x)
592 return (DataType_(8)*x - DataType_(4))*
Math::exp(-
Math::sqr(DataType_(2)*x - DataType_(1))) / (
Math::exp(-DataType_(1)) - DataType_(1));
598 return (DataType_(64)*x*(DataType_(1)-x)-DataType_(8)) *
Math::exp(-
Math::sqr(DataType_(2)*x - DataType_(1))) / (
Math::exp(-DataType_(1)) - DataType_(1));
603 template<
typename DataType_>
604 using ExpBubbleStatic = TensorStatic<ExpBubbleScalarStatic<DataType_>, DataType_>;
634 template<
typename DataType_>
639 static DataType_
eval(DataType_ x)
641 return DataType_(4) * x * (DataType_(1) - x);
647 return DataType_(4) * (DataType_(1) - DataType_(2) * x);
653 return -DataType_(8);
658 template<
typename DataType_>
659 using Q2BubbleStatic = TensorStatic<Q2BubbleScalarStatic<DataType_>, DataType_>;
688 template<
int dim_,
typename DataType_ = Real>
693 static constexpr int domain_dim = dim_;
696 static constexpr bool can_value =
true;
697 static constexpr bool can_grad =
true;
698 static constexpr bool can_hess =
true;
701 template<
typename EvalTraits_>
735 return GradientType::null();
740 return HessianType::null();
765 template<
int dim_,
typename DataType_ = Real>
770 static constexpr int domain_dim = dim_;
773 static constexpr bool can_value =
true;
774 static constexpr bool can_grad =
true;
775 static constexpr bool can_hess =
true;
778 template<
typename EvalTraits_>
812 return GradientType::null();
817 return HessianType::null();
843 if constexpr(dim_ > 1)
847 explicit ConstantVectorFunction(DataType_ value_x, DataType_ value_y, DataType_ value_z) :
851 if constexpr(dim_ > 1)
853 if constexpr(dim_ > 2)
876 template<
typename AnalyticFunctionType1,
typename AnalyticFunctionType2>
882 static_assert(AnalyticFunctionType1::domain_dim == AnalyticFunctionType2::domain_dim,
"domain dimension mismatch");
885 static_assert(std::is_same<typename AnalyticFunctionType1::ImageType, Analytic::Image::Scalar>::value,
"invalid image type");
886 static_assert(std::is_same<typename AnalyticFunctionType2::ImageType, Analytic::Image::Scalar>::value,
"invalid image type");
889 static constexpr int domain_dim = AnalyticFunctionType1::domain_dim;
894 static constexpr bool can_value = (AnalyticFunctionType1::can_value && AnalyticFunctionType2::can_value);
896 static constexpr bool can_grad = (AnalyticFunctionType1::can_grad && AnalyticFunctionType2::can_grad);
898 static constexpr bool can_hess = (AnalyticFunctionType1::can_hess && AnalyticFunctionType2::can_hess);
902 template<
typename EvalTraits_>
946 return GradientType::null();
959 return HessianType::null();
969 const AnalyticFunctionType1&
_f1;
971 const AnalyticFunctionType2&
_f2;
975 explicit MinOfTwoFunctions(
const AnalyticFunctionType1& f1_,
const AnalyticFunctionType2& f2_) :
1002 template<
typename DataType_>
1003 class HeavisideStatic
1008 static DataType_ eval(DataType_ x)
1010 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(1);
1014 static DataType_ eval(DataType_ x, DataType_ y)
1016 return eval(x)*eval(y);
1020 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
1022 return eval(x)*eval(y)*eval(z);
1071 template<
typename DataType_>
1072 class HeavisideRegStatic
1077 static DataType_ eval(DataType_ x)
1079 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(2)*(Math::cosh(x) - DataType_(1));
1083 static DataType_ eval(DataType_ x, DataType_ y)
1085 return eval(x)*eval(y);
1089 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
1091 return eval(x)*eval(y)*eval(z);
1095 static DataType_ der_x(DataType_ x)
1097 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(2)*Math::sinh(x);
1101 static DataType_ der_x(DataType_ x, DataType_ y)
1103 return der_x(x)*eval(y);
1107 static DataType_ der_y(DataType_ x, DataType_ y)
1109 return eval(x)*der_x(y);
1113 static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
1115 return der_x(x)*eval(y)*eval(z);
1119 static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
1121 return eval(x)*der_x(y)*eval(z);
1125 static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
1127 return eval(x)*eval(y)*der_x(z);
1131 static DataType_ der_xx(DataType_ x)
1133 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(2)*Math::cosh(x);
1137 static DataType_ der_xx(DataType_ x, DataType_ y)
1139 return der_xx(x)*eval(y);
1143 static DataType_ der_yy(DataType_ x, DataType_ y)
1145 return eval(x)*der_xx(y);
1149 static DataType_ der_xy(DataType_ x, DataType_ y)
1151 return der_x(x)*der_x(y);
1155 static DataType_ der_yx(DataType_ x, DataType_ y)
1157 return der_xy(x, y);
1161 static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
1163 return der_xx(x)*eval(y)*eval(z);
1167 static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
1169 return eval(x)*der_xx(y)*eval(z);
1173 static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
1175 return eval(x)*eval(y)*der_xx(z);
1179 static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
1181 return der_x(x)*der_x(y)*eval(z);
1185 static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
1187 return der_x(x)*der_x(y)*eval(z);
1191 static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
1193 return der_x(x)*eval(y)*der_x(z);
1197 static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
1199 return der_xz(x, y, z);
1203 static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
1205 return eval(x)*der_x(y)*der_x(z);
1209 static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
1211 return der_yz(x, y, z);
1251 template<
typename DataType_>
1268 template<
typename EvalTraits_>
1273 typedef typename EvalTraits_::DataType DataType;
1274 typedef typename EvalTraits_::PointType PointType;
1275 typedef typename EvalTraits_::ValueType ValueType;
1276 typedef typename EvalTraits_::GradientType GradientType;
1277 typedef typename EvalTraits_::HessianType HessianType;
1287 for(
auto it = function.
_coeff.begin(); it != function.
_coeff.end(); ++it)
1288 _coeff.push_back(DataType(*it));
1291 ValueType
value(
const PointType& point)
const
1294 DataType x = point[0];
1295 DataType y = DataType(0);
1296 for(std::size_t k(
_coeff.size()); k > std::size_t(0); )
1302 GradientType gradient(
const PointType& point)
const
1304 std::size_t k =
_coeff.size();
1305 if(k <= std::size_t(0))
1306 return GradientType::null();
1309 DataType x = point[0];
1310 DataType y = DataType(0);
1311 for( ; (--k) > std::size_t(0); )
1312 y = x * y + (
_coeff[k] * DataType(k));
1314 return GradientType(y);
1317 HessianType hessian(
const PointType& point)
const
1319 std::size_t k =
_coeff.size();
1320 if(k <= std::size_t(1))
1321 return HessianType::null();
1324 DataType x = point[0];
1325 DataType y = DataType(0);
1326 for( ; (--k) > std::size_t(1); )
1327 y = x * y + (
_coeff[k] * DataType(k*(k-1)));
1329 return HessianType(y);
1371 _coeff.resize(std::size_t(degree+1), DataType_(0));
1374 _coeff.at(std::size_t(degree)) = coeff;
1397 template<
typename DataType_>
1398 class BazaraaShettyStatic
1402 static DataType_ eval(DataType_ x, DataType_ y)
1404 return Math::sqr(Math::sqr(x - DataType_(2))) + Math::sqr(x - DataType_(2)*y);
1408 static DataType_ der_x(DataType_ x, DataType_ y)
1410 return DataType_(4)*(x - DataType_(2))*Math::sqr(x - DataType_(2)) + DataType_(2)*(x - DataType_(2)*y);
1414 static DataType_ der_y(DataType_ x, DataType_ y)
1416 return DataType_(4)*(DataType_(2)*y - x);
1420 static DataType_ der_xx(DataType_ x, DataType_ DOXY(y))
1422 return DataType_(12)*Math::sqr(x - DataType_(2)) + DataType_(2);
1426 static DataType_ der_yy(DataType_ DOXY(x), DataType_ DOXY(y))
1428 return DataType_(8);
1432 static DataType_ der_xy(DataType_ DOXY(x), DataType_ DOXY(y))
1434 return DataType_(-4);
1438 static DataType_ der_yx(DataType_ x, DataType_ y)
1463 template<
typename DataType_>
1464 class GoldsteinPriceStatic
1468 static DataType_ eval(DataType_ x, DataType_ y)
1470 return (DataType_(1) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19))) * (DataType_(30) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)));
1474 static DataType_ der_x(DataType_ x, DataType_ y)
1476 return (DataType_(2) * (DataType_(1) + x + y) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19)) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(6) * x + DataType_(6) * y - DataType_(14))) * (DataType_(30) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18))) + (DataType_(1) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19))) * (DataType_(4) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(24) * x - DataType_(36) * y - DataType_(32)));
1480 static DataType_ der_y(DataType_ x, DataType_ y)
1482 return (DataType_(2) * (DataType_(1) + x + y) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19)) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(6) * x + DataType_(6) * y - DataType_(14))) * (DataType_(30) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18))) + (DataType_(1) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19))) * (-DataType_(6) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (-DataType_(36) * x + DataType_(54) * y + DataType_(48)));
1486 static DataType_ der_xx(DataType_ x, DataType_ y)
1488 return DataType_((DataType_(6) * Math::pow(x, DataType_(2)) + DataType_(12) * x * y + DataType_(6) * Math::pow(y, DataType_(2)) - DataType_(28) * x - DataType_(28) * y + DataType_(38) + DataType_(4) * (DataType_(1) + x + y) * (DataType_(6) * x + DataType_(6) * y - DataType_(14)) + DataType_(6) * Math::pow(DataType_(1) + x + y, DataType_(2))) * (DataType_(30) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18))) + DataType_(2) * (DataType_(2) * (DataType_(1) + x + y) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19)) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(6) * x + DataType_(6) * y - DataType_(14))) * (DataType_(4) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(24) * x - DataType_(36) * y - DataType_(32))) + (DataType_(1) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19))) * (DataType_(96) * Math::pow(x, DataType_(2)) - DataType_(288) * x * y + DataType_(216) * Math::pow(y, DataType_(2)) - DataType_(256) * x + DataType_(384) * y + DataType_(144) + DataType_(8) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(24) * x - DataType_(36) * y - DataType_(32)) + DataType_(24) * Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2))));
1492 static DataType_ der_yy(DataType_ x, DataType_ y)
1494 return (DataType_(6) * Math::pow(x, DataType_(2)) + DataType_(12) * x * y + DataType_(6) * Math::pow(y, DataType_(2)) - DataType_(28) * x - DataType_(28) * y + DataType_(38) + DataType_(4) * (DataType_(1) + x + y) * (DataType_(6) * x + DataType_(6) * y - DataType_(14)) + DataType_(6) * Math::pow(DataType_(1) + x + y, DataType_(2))) * (DataType_(30) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18))) + DataType_(2) * (DataType_(2) * (DataType_(1) + x + y) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19)) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(6) * x + DataType_(6) * y - DataType_(14))) * (-DataType_(6) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (-DataType_(36) * x + DataType_(54) * y + DataType_(48))) + (DataType_(1) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19))) * (DataType_(216) * Math::pow(x, DataType_(2)) - DataType_(648) * x * y + DataType_(486) * Math::pow(y, DataType_(2)) - DataType_(576) * x + DataType_(864) * y + DataType_(324) - DataType_(12) * (DataType_(2) * x - DataType_(3) * y) * (-DataType_(36) * x + DataType_(54) * y + DataType_(48)) + DataType_(54) * Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)));
1498 static DataType_ der_xy(DataType_ x, DataType_ y)
1500 return (DataType_(6) * Math::pow(x, DataType_(2)) + DataType_(12) * x * y + DataType_(6) * Math::pow(y, DataType_(2)) - DataType_(28) * x - DataType_(28) * y + DataType_(38) + DataType_(4) * (DataType_(1) + x + y) * (DataType_(6) * x + DataType_(6) * y - DataType_(14)) + DataType_(6) * Math::pow(DataType_(1) + x + y, DataType_(2))) * (DataType_(30) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18))) + (DataType_(2) * (DataType_(1) + x + y) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19)) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(6) * x + DataType_(6) * y - DataType_(14))) * (DataType_(4) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (DataType_(24) * x - DataType_(36) * y - DataType_(32))) + (DataType_(2) * (DataType_(1) + x + y) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19)) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(6) * x + DataType_(6) * y - DataType_(14))) * (-DataType_(6) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(12) * Math::pow(x, DataType_(2)) - DataType_(36) * x * y + DataType_(27) * Math::pow(y, DataType_(2)) - DataType_(32) * x + DataType_(48) * y + DataType_(18)) + Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)) * (-DataType_(36) * x + DataType_(54) * y + DataType_(48))) + (DataType_(1) + Math::pow(DataType_(1) + x + y, DataType_(2)) * (DataType_(3) * Math::pow(x, DataType_(2)) + DataType_(6) * x * y + DataType_(3) * Math::pow(y, DataType_(2)) - DataType_(14) * x - DataType_(14) * y + DataType_(19))) * (-DataType_(144) * Math::pow(x, DataType_(2)) + DataType_(432) * x * y - DataType_(324) * Math::pow(y, DataType_(2)) + DataType_(384) * x - DataType_(576) * y - DataType_(216) - DataType_(6) * (DataType_(2) * x - DataType_(3) * y) * (DataType_(24) * x - DataType_(36) * y - DataType_(32)) + DataType_(4) * (DataType_(2) * x - DataType_(3) * y) * (-DataType_(36) * x + DataType_(54) * y + DataType_(48)) - DataType_(36) * Math::pow(DataType_(2) * x - DataType_(3) * y, DataType_(2)));
1504 static DataType_ der_yx(DataType_ x, DataType_ y)
1506 return der_xy(x, y);
1568 template<
typename DataType_>
1569 class HimmelblauStatic
1573 static DataType_ eval(DataType_ x, DataType_ y)
1575 return Math::sqr(Math::sqr(x) + y - DataType_(11))
1576 + Math::sqr( x + Math::sqr(y) - DataType_(7));
1580 static DataType_ der_x(DataType_ x, DataType_ y)
1582 return DataType_(4)*x*(Math::sqr(x) + y - DataType_(11)) + DataType_(2)*(x + Math::sqr(y) - DataType_(7));
1586 static DataType_ der_y(DataType_ x, DataType_ y)
1588 return DataType_(2)* (Math::sqr(x) + y - DataType_(11)) + DataType_(4)*y*(x + Math::sqr(y) - DataType_(7));
1592 static DataType_ der_xx(DataType_ x, DataType_ y)
1594 return DataType_(12)*Math::sqr(x) + DataType_(4)*y - DataType_(42);
1598 static DataType_ der_yy(DataType_ x, DataType_ y)
1600 return DataType_(4)*x + DataType_(12)*Math::sqr(y) - DataType_(26);
1604 static DataType_ der_xy(DataType_ x, DataType_ y)
1606 return DataType_(4)*(x + y);
1610 static DataType_ der_yx(DataType_ x, DataType_ y)
1642 template<
typename DataType_>
1643 class RosenbrockStatic
1647 static DataType_ eval(DataType_ x, DataType_ y)
1649 return DataType_(100)*Math::sqr( y - Math::sqr(x)) + Math::sqr(DataType_(1) - x);
1653 static DataType_ der_x(DataType_ x, DataType_ y)
1655 return -DataType_(400)*x*(y - Math::sqr(x) ) + DataType_(2)*(x - DataType_(1));
1659 static DataType_ der_y(DataType_ x, DataType_ y)
1661 return DataType_(200)*(y - Math::sqr(x));
1665 static DataType_ der_xx(DataType_ x, DataType_ y)
1667 return DataType_(1200)*Math::sqr(x) - DataType_(400)*y + DataType_(2);
1671 static DataType_ der_yy(DataType_ DOXY(x), DataType_ DOXY(y))
1673 return DataType_(200);
1677 static DataType_ der_xy(DataType_ x, DataType_ DOXY(y))
1679 return -DataType_(400)*x;
1683 static DataType_ der_yx(DataType_ x, DataType_ y)
1719 template<
typename DataType_>
1724 static constexpr int domain_dim = 2;
1726 static constexpr bool can_value =
true;
1730 DataType_ _x0, _y0, _x1, _y1;
1742 _x0(0.0), _y0(0.0), _x1(0.0), _y1(1.0), _vmax(1.0)
1758 explicit ParProfileBase(DataType_ x0, DataType_ y0, DataType_ x1, DataType_ y1, DataType_ vmax = DataType_(1.0)) :
1759 _x0(x0), _y0(y0), _x1(x1), _y1(y1), _vmax(vmax)
1782 auto li = sbc.find_first_of(
'(');
1783 auto ri = sbc.find_last_of(
')');
1784 if((li == sbc.npos) || (ri == sbc.npos))
1787 std::deque<String> sv = sbc.substr(li+1, ri-li-1).
split_by_string(
",");
1788 if((sv.size() < std::size_t(2)) || (sv.size() > std::size_t(3)))
1791 std::deque<String> sv0 = sv[0].trim().split_by_whitespaces();
1792 std::deque<String> sv1 = sv[1].trim().split_by_whitespaces();
1793 if(sv0.size() != std::size_t(2))
return false;
1794 if(sv1.size() != std::size_t(2))
return false;
1796 if(!sv0[0].
parse(_x0))
return false;
1797 if(!sv0[1].
parse(_y0))
return false;
1798 if(!sv1[0].
parse(_x1))
return false;
1799 if(!sv1[1].
parse(_y1))
return false;
1801 if((sv.size() == std::size_t(3)) && !sv.back().parse(_vmax))
1816 template<
typename DataType_>
1821 static constexpr int domain_dim = 2;
1823 static constexpr bool can_value =
true;
1824 static constexpr bool can_grad =
true;
1825 static constexpr bool can_hess =
true;
1829 template<
typename Traits_>
1834 typedef typename Traits_::DataType DataType;
1835 typedef typename Traits_::PointType PointType;
1836 typedef typename Traits_::ValueType ValueType;
1837 typedef typename Traits_::GradientType GradientType;
1838 typedef typename Traits_::HessianType HessianType;
1841 DataType _den, _vmax;
1846 _vo[0] = DataType(function._x0);
1847 _vo[1] = DataType(function._y0);
1848 _ve[0] = DataType(function._x1 - function._x0);
1849 _ve[1] = DataType(function._y1 - function._y0);
1850 _den = DataType(1) /
Tiny::dot(_ve, _ve);
1851 _vmax = DataType(function._vmax);
1854 ValueType
value(
const PointType& point)
1859 return _vmax * DataType(4) * x * (DataType(1) - x);
1862 GradientType gradient(
const PointType& point)
1865 const DataType x =
Tiny::dot(point - _vo, _ve) * _den;
1868 if((x < DataType(0)) || (x > DataType(1)))
1869 return GradientType::null();
1871 return (_vmax * _den * DataType(4) * (DataType(1) - DataType(2)*x)) * _ve;
1874 HessianType hessian(
const PointType& point)
1877 const DataType x =
Tiny::dot(point - _vo, _ve) * _den;
1880 if((x < DataType(0)) || (x > DataType(1)))
1881 return HessianType::null();
1884 const DataType v = -DataType(8) * _vmax * _den * _den;
1885 hess[0][0] = v * _ve[0] * _ve[0];
1886 hess[0][1] =
hess[1][0] = v * _ve[0] * _ve[1];
1887 hess[1][1] = v * _ve[1] * _ve[1];
1901 template<
typename DataType_>
1906 static constexpr int domain_dim = 2;
1908 static constexpr bool can_value =
true;
1909 static constexpr bool can_grad =
true;
1910 static constexpr bool can_hess =
true;
1914 template<
typename Traits_>
1919 typedef typename Traits_::DataType DataType;
1920 typedef typename Traits_::PointType PointType;
1921 typedef typename Traits_::ValueType ValueType;
1922 typedef typename Traits_::GradientType GradientType;
1923 typedef typename Traits_::HessianType HessianType;
1925 PointType _vo, _ve, _vn;
1926 DataType _den, _vmax;
1931 _vo[0] = DataType(function._x0);
1932 _vo[1] = DataType(function._y0);
1933 _ve[0] = DataType(function._x1 - function._x0);
1934 _ve[1] = DataType(function._y1 - function._y0);
1938 _den = DataType(1) /
Tiny::dot(_ve, _ve);
1939 _vmax = DataType(function._vmax);
1942 ValueType
value(
const PointType& point)
1947 const DataType v = _vmax * DataType(4) * x * (DataType(1) - x);
1949 val[0] = _vn[0] * v;
1950 val[1] = _vn[1] * v;
1954 GradientType gradient(
const PointType& point)
1957 const DataType x =
Tiny::dot(point - _vo, _ve) * _den;
1960 if((x < DataType(0)) || (x > DataType(1)))
1961 return GradientType::null();
1963 const DataType v = _vmax * _den * DataType(4) * (DataType(1) - DataType(2)*x);
1965 grad(0,0) = v * _vn[0] * _ve[0];
1966 grad(0,1) = v * _vn[0] * _ve[1];
1967 grad(1,0) = v * _vn[1] * _ve[0];
1968 grad(1,1) = v * _vn[1] * _ve[1];
1972 HessianType hessian(
const PointType& point)
1975 const DataType x =
Tiny::dot(point - _vo, _ve) * _den;
1978 if((x < DataType(0)) || (x > DataType(1)))
1979 return HessianType::null();
1981 const DataType v = -DataType(8) * _vmax * _den * _den;
1983 hess(0,0,0) = v * _vn[0] * _ve[0] * _ve[0];
1984 hess(0,1,1) = v * _vn[0] * _ve[1] * _ve[1];
1985 hess(0,1,0) =
hess(0,0,1) = v * _vn[0] * _ve[0] * _ve[1];
1986 hess(1,1,0) =
hess(1,0,1) = v * _vn[1] * _ve[0] * _ve[1];
1987 hess(1,0,0) = v * _vn[1] * _ve[0] * _ve[0];
1988 hess(1,1,1) = v * _vn[1] * _ve[1] * _ve[1];
1994 template<
typename DT_>
1998 static constexpr DT_ p = DT_(10);
2000 static DT_ eval(DT_ x)
2005 static DT_ der_x(DT_ x)
2010 static DT_ der_xx(DT_ x)
2016 #ifdef FEAT_HAVE_HALFMATH
2022 static DT_ eval(DT_ x)
2027 static DT_ der_x(DT_ x)
2032 static DT_ der_xx(DT_ x)
2034 return -DT_(2)*DT_(10)*
Math::exp(DT_(10)*x*x)*(DT_(2)*DT_(10)*x*x+DT_(1))/(
Math::exp(DT_(10))-DT_(1));
2040 template<
typename DataType_>
2074 template<
typename DT_,
int dim_>
2094 template<
typename EvalTraits_>
2143 return HessianType::null();
2192 template<
typename DT_,
int dim_>
2212 template<
typename EvalTraits_>
2232 const std::vector<Tiny::Vector<DataType, 2>>&
_range;
2256 val(0) *= (point[d] -
_range.at(std::size_t(d-1))[0])*(
_range.at(std::size_t(d-1))[1] - point[d]);
2273 grad[d][0] *= (point[q] -
_range.at(std::size_t(q - 1))[0]) * (
_range.at(std::size_t(q - 1))[1] - point[q]);
2281 return HessianType::null();
2290 std::vector<Tiny::Vector<DataType, 2>>
_range;
2342 template<
typename DT_,
int dim_>
2362 template<
typename EvalTraits_>
2408 return HessianType::null();
2444 template<
typename DT_,
int dim_>
2464 template<
typename EvalTraits_>
2503 return GradientType::null();
2508 return HessianType::null();
2547 template<
typename DT_,
int dim_>
2567 template<
typename EvalTraits_>
2615 return HessianType::null();
2650 template<
typename DT_,
int dim_>
2670 template<
typename EvalTraits_>
2721 return HessianType::null();
2757 template<
typename DT_,
int dim_>
2777 template<
typename EvalTraits_>
2824 return GradientType::null();
2829 return HessianType::null();
2886 template<
typename EvalTraits_>
2913 const DataType re = pi / point.norm_euclid();
2930 grad[0] = +pi *
Math::cub(re) * (cx*sz*sy*y*y + cx*sz*sy*z*z - sx*x*y*cy*sz - sx*sy*x*z*cz);
2931 grad[1] = -pi *
Math::cub(re) * (x*y*cx*sy*sz - sz*sx*cy*x*x - sz*sx*cy*z*z + sx*sy*z*y*cz);
2932 grad[2] = -pi *
Math::cub(re) * (x*z*cx*sy*sz + sx*z*y*cy*sz - sx*cz*sy*x*x - sx*cz*sy*y*y);
2951 hess[0][0] = -pi*qo*(
2962 sx*y*y*pi*x*x*sy*sz +
2963 sx*sy*z*z*pi*x*x*sz +
2964 sy*sz*sx*pi*y*y*y*y +
2965 sy*sz*sx*pi*z*z*z*z +
2970 hess[1][1] = -pi*qo*(
2981 sy*sz*sx*pi*x*x*x*x +
2982 sx*y*y*pi*x*x*sy*sz +
2983 sy*sz*sx*pi*y*y*z*z +
2984 sy*sz*sx*pi*z*z*z*z +
2989 hess[2][2] = -pi*qo*(
3000 sy*sz*sx*pi*x*x*x*x +
3001 sx*sy*z*z*pi*x*x*sz +
3002 sy*sz*sx*pi*y*y*y*y +
3003 sy*sz*sx*pi*y*y*z*z +
3013 y*pi*x*x*cx*sy*z*cz +
3014 -cx*sy*cz*pi*y*y*y*z +
3015 -cx*sy*cz*pi*y*z*z*z +
3016 cx*sz*cy*pi*x*x*z*z +
3017 cx*sz*cy*pi*y*y*z*z +
3018 cx*sz*cy*pi*z*z*z*z +
3019 sy*sz*sx*pi*x*x*x*y +
3020 sy*sz*sx*pi*x*y*y*y +
3021 sx*sy*z*z*pi*x*y*sz +
3022 -sx*cy*cz*pi*x*x*x*z +
3023 sx*y*y*pi*x*cy*z*cz +
3024 -sx*cy*cz*pi*x*z*z*z +
3025 -cx*sy*sz*di*y*y*y +
3026 -cx*sy*sz*di*y*z*z +
3027 -cy*sz*sx*x*x*x*di +
3028 -cy*sz*sx*x*di*z*z);
3034 cx*sy*cz*pi*x*x*y*y +
3035 cx*sy*cz*pi*y*y*y*y +
3036 cx*sy*cz*pi*y*y*z*z +
3037 sy*sz*sx*pi*x*x*x*z +
3038 sx*y*y*pi*x*z*sy*sz +
3039 sy*sz*sx*pi*x*z*z*z +
3040 -sx*cy*cz*pi*x*x*x*y +
3041 -sx*cy*cz*pi*x*y*y*y +
3042 sx*y*pi*z*z*cy*x*cz +
3043 z*pi*x*x*cx*y*cy*sz +
3044 -cx*sz*cy*pi*y*y*y*z +
3045 -cx*sz*cy*pi*y*z*z*z +
3046 -sy*cz*sx*x*x*x*di +
3047 -sy*cz*sx*x*di*y*y +
3048 -sy*sz*cx*di*y*y*z +
3049 -sy*sz*cx*di*z*z*z);
3055 -cx*sy*cz*pi*x*x*x*y +
3056 -cx*sy*cz*pi*x*y*y*y +
3057 z*z*pi*x*cx*sy*y*cz +
3058 -cx*sz*cy*pi*x*x*x*z +
3059 y*y*pi*x*cx*z*cy*sz +
3060 -cx*sz*cy*pi*x*z*z*z +
3061 y*pi*x*x*z*sx*sy*sz +
3062 sy*sz*sx*pi*y*y*y*z +
3063 sy*sz*sx*pi*y*z*z*z +
3064 sx*cy*cz*pi*x*x*x*x +
3065 sx*cy*cz*pi*x*x*y*y +
3066 sx*cy*cz*pi*x*x*z*z +
3067 -sy*cz*sx*x*x*di*y +
3068 -sy*cz*sx*di*y*y*y +
3069 -sz*cy*sx*x*x*di*z +
3070 -sz*cy*sx*di*z*z*z);
3093 static constexpr int domain_dim = 2;
3095 static constexpr bool can_value =
true;
3096 static constexpr bool can_grad =
true;
3097 static constexpr bool can_hess =
false;
3099 template<
typename Traits_>
3104 typedef typename Traits_::DataType DataType;
3105 typedef typename Traits_::PointType PointType;
3106 typedef typename Traits_::ValueType ValueType;
3107 typedef typename Traits_::GradientType GradientType;
3114 ValueType
value(
const PointType& point)
const
3116 ValueType val(DataType(0));
3117 const DataType x = point[0] - DataType(0.5);
3118 const DataType y = point[1] - DataType(0.5);
3120 if (r < DataType(0.2))
3122 val[0] = DataType(5)*y;
3123 val[1] = -DataType(5)*x;
3125 else if (r < DataType(0.4))
3127 val[0] = ( DataType(2)/r - DataType(5))*y;
3128 val[1] = (-DataType(2)/r + DataType(5))*x;
3133 GradientType gradient(
const PointType& point)
const
3135 GradientType
grad(DataType(0));
3136 const DataType x = point[0] - DataType(0.5);
3137 const DataType y = point[1] - DataType(0.5);
3139 if (r < DataType(0.2))
3141 grad[0][1] = DataType(5);
3142 grad[1][0] = -DataType(5);
3144 else if (r < DataType(0.4))
3146 const DataType s = DataType(1) / (r*r*r);
3147 grad[0][0] = -DataType(2)*x*y*s;
3148 grad[0][1] = -DataType(2)*y*y*s + DataType(2)/r - DataType(5);
3149 grad[1][0] = DataType(2)*x*x*s - DataType(2)/r + DataType(5);
3150 grad[1][1] = DataType(2)*x*y*s;
3170 template<
typename DT_>
3210 template<
typename EvalTraits_>
3283 template<
typename DT_>
3323 template<
typename EvalTraits_>
3365 return HessianType::null();
3383 template<
typename DataType_,
int dim_>
3436 template<
typename EvalTraits_>
3460 _origin(function.
origin),
3462 _v_max(function.
v_max),
3472 return _v_max * (
DataType(1) - q.norm_euclid_sqr()*_radius_s) * _axis;
3482 grad.set_outer_product(_axis, q);
3491 grad_q.set_outer_product(_axis, _axis);
3492 grad_q.add_scalar_main_diag(-
DataType(1));
3494 at_x_a.set_outer_product(_axis, _axis);
3496 hess.add_vec_mat_outer_product(_axis, grad_q);
3497 hess.add_vec_mat_outer_product(_axis * grad_q, at_x_a, -
DataType(1));
3515 template<
typename DT_>
3535 template<
typename EvalTraits_>
3574 return HessianType::null();
3591 template<
typename DT_>
3611 template<
typename EvalTraits_>
3634 return DataType(0.5) * (point[0]*point[0] + point[1]*point[1]) -
DataType(0.25);
3671 template<
typename DT_>
3691 template<
typename EvalTraits_>
3726 val[0] = point[1]*s2pdi;
3727 val[1] = -point[0]*s2pdi;
3734 const DataType d = point.norm_euclid();
3738 const DataType x(point[0]), y(point[1]);
3743 grad[0][0] = -y*x*s2pdi*di2 +
_pi2*y*x*c2pdi2;
3744 grad[0][1] = -y*y*s2pdi*di2 +
_pi2*y*y*c2pdi2 + s2pdi;
3745 grad[1][0] = x*x*s2pdi*di2 -
_pi2*x*x*c2pdi2 - s2pdi;
3746 grad[1][1] = x*y*s2pdi*di2 -
_pi2*y*x*c2pdi2;
3753 const DataType d = point.norm_euclid();
3757 const DataType x(point[0]), y(point[1]);
3763 hess[0][0][0] = t3*y*x*x*s2pdi3*di2 - t3*
_pi2*y*x*x*c2pdi2*di2 - y*s2pdi3 +
_pi2*y*c2pdi2 -
_pi2*
_pi2*y*x*x*s2pdi3;
3765 hess[0][1][0] = t3*y*y*x*s2pdi3*di2 - x*s2pdi3 - t3*
_pi2*y*y*x*c2pdi2*di2 +
_pi2*x*c2pdi2 -
_pi2*
_pi2*y*y*x*s2pdi3;
3766 hess[0][1][1] = t3*y*y*y*s2pdi3*di2 - t3*y*s2pdi3 - t3*
_pi2*y*y*y*c2pdi2*di2 + t3*
_pi2*y*c2pdi2 -
_pi2*
_pi2*y*y*y*s2pdi3;
3767 hess[1][0][0] = -t3*x*x*x*s2pdi3*di2 + t3*x*s2pdi3 + t3*
_pi2*x*x*x*c2pdi2*di2 - t3*
_pi2*x*c2pdi2 +
_pi2*
_pi2*x*x*x*s2pdi3;
3769 hess[1][1][0] = -t3*y*x*x*s2pdi3*di2 + t3*
_pi2*y*x*x*c2pdi2*di2 + y*s2pdi3 -
_pi2*y*c2pdi2 +
_pi2*
_pi2*y*x*x*s2pdi3;
3770 hess[1][1][1] = -t3*y*y*x*s2pdi3*di2 + x*s2pdi3 + t3*
_pi2*y*y*x*c2pdi2*di2 -
_pi2*x*c2pdi2 +
_pi2*
_pi2*y*y*x*s2pdi3;
3792 template<
typename DT_>
3815 template<
typename EvalTraits_>
3851 const DataType d = point.norm_euclid();
3857 grad[0] = -point[0]*c2pdi;
3858 grad[1] = -point[1]*c2pdi;
3864 return HessianType::null();
3881 template<
typename DT_>
3927 template<
typename EvalTraits_>
3944 const DataType _pi2, _nu, _beta, _theta, _sigma;
3950 _beta(function.beta),
3951 _theta(function.theta),
3952 _sigma(function.sigma)
3963 const DataType x(point[0]), y(point[1]);
3968 val[0] = -_nu*q*y*( _pi2*c2pdq - (_pi2*_pi2*d + q)*s2pdq) - _beta*x*s2pdq*s2pdq + _theta*y*s2pdq - _sigma*x*c2pdq;
3969 val[1] = -_nu*q*x*(-_pi2*c2pdq + (_pi2*_pi2*d + q)*s2pdq) - _beta*y*s2pdq*s2pdq - _theta*x*s2pdq - _sigma*y*c2pdq;
3987 template<
int dim_,
int a_ = 2>
3992 static_assert(a_ >= 1,
"parameter a_ must be >= 1");
3994 static constexpr int domain_dim = dim_;
3996 static constexpr bool can_value =
true;
3997 static constexpr bool can_grad =
true;
3998 static constexpr bool can_hess =
true;
4000 template<
typename Traits_>
4005 typedef typename Traits_::DataType DataType;
4006 typedef typename Traits_::PointType PointType;
4007 typedef typename Traits_::ValueType ValueType;
4008 typedef typename Traits_::GradientType GradientType;
4009 typedef typename Traits_::HessianType HessianType;
4018 ValueType
value(
const PointType& point)
const
4020 return Math::sqrt(DataType(a_) - point.norm_euclid_sqr()) - sa;
4023 GradientType gradient(
const PointType& point)
const
4025 return (DataType(-1) /
Math::sqrt(DataType(a_) - point.norm_euclid_sqr())) * point;
4028 HessianType hessian(
const PointType& point)
const
4030 const DataType s = DataType(1) /
Math::cub(
Math::sqrt(DataType(a_) - point.norm_euclid_sqr()));
4034 for(
int i = 0; i < dim_; ++i)
4036 for(
int j = 0; j < dim_; ++j)
4040 hess[i][j] = DataType(0);
4041 for(
int k = 0; k < dim_; ++k)
4042 hess[i][j] += (k == i ? DataType(-a_) :
Math::sqr(point[k])) * s;
4046 hess[i][j] = -point[i] * point[j] * s;
4082 template<
typename DT_>
4087 typedef DT_ DataType;
4088 static constexpr int domain_dim = 2;
4090 static constexpr bool can_value =
true;
4091 static constexpr bool can_grad =
true;
4092 static constexpr bool can_hess =
true;
4096 DataType alpha, k, offset;
4110 template<
typename Traits_>
4115 typedef typename Traits_::DataType DataType;
4116 typedef typename Traits_::PointType PointType;
4117 typedef typename Traits_::ValueType ValueType;
4118 typedef typename Traits_::GradientType GradientType;
4119 typedef typename Traits_::HessianType HessianType;
4123 const DataType alpha, k, offset;
4127 base_point(func.base_point),
4130 offset(func.offset),
4131 eps(Math::eps<DataType>())
4135 ValueType
value(
const PointType& point)
const
4138 const DataType x = point[0] - base_point[0];
4139 const DataType y = point[1] - base_point[1];
4142 const DataType x_rel = r > DataType(10.)* eps ? x/r : DataType(0);
4144 phi = (y >= DataType(0)) ? phi : DataType(2)*Math::pi<DataType>()-phi;
4148 GradientType gradient(
const PointType& point)
const
4150 const DataType x = point[0] - base_point[0];
4151 const DataType y = point[1] - base_point[1];
4153 const DataType x_rel = r > DataType(10.)* eps ? x/r : DataType(0);
4154 const DataType y_rel = r > DataType(10.)* eps ? y/r : DataType(0);
4160 phi = (y >= DataType(0)) ? phi : DataType(2)*Math::pi<DataType>()-phi;
4161 const DataType ex = k *
Math::pow(r, k-DataType(1));
4162 const DataType sval =
Math::sin(k * (phi - offset));
4163 const DataType cval =
Math::cos(k * (phi - offset));
4165 grad[0] = alpha * ex * (x_rel * sval - y_rel * cval);
4166 grad[1] = alpha * ex * (y_rel * sval + x_rel * cval);
4170 HessianType hessian(
const PointType& point)
const
4172 const DataType x = point[0] - base_point[0];
4173 const DataType y = point[1] - base_point[1];
4175 const DataType x_rel = r > DataType(10.)* eps ? x/r : DataType(0);
4176 const DataType y_rel = r > DataType(10.)* eps ? y/r : DataType(0);
4178 phi = (y >= DataType(0)) ? phi : DataType(2)*Math::pi<DataType>()-phi;
4179 const DataType ex = k * (k - DataType(1)) *
Math::pow(r, k-DataType(2));
4180 const DataType sval =
Math::sin(k * (phi - offset));
4181 const DataType cval =
Math::cos(k * (phi - offset));
4183 hess[0][0] = alpha * ex * ((
Math::sqr(x_rel) -
Math::sqr(y_rel)) * sval - DataType(2) * x_rel * y_rel * cval);
4192 template<
typename DT_>
4197 typedef DT_ DataType;
4198 static constexpr int domain_dim = 2;
4200 static constexpr bool can_value =
true;
4201 static constexpr bool can_grad =
true;
4202 static constexpr bool can_hess =
true;
4212 k(Math::pi<DataType>() / theta_)
4218 k(Math::pi<DataType>() / Math::calc_opening_angle(vec_r[0], vec_r[1], vec_l[0], vec_l[1]))
4221 template<
typename Traits_>
4226 typedef typename Traits_::DataType DataType;
4227 typedef typename Traits_::PointType PointType;
4228 typedef typename Traits_::ValueType ValueType;
4229 typedef typename Traits_::GradientType GradientType;
4230 typedef typename Traits_::HessianType HessianType;
4233 const DataType alpha, k;
4241 ValueType
value(
const PointType& point)
const
4246 GradientType gradient(
const PointType& point)
const
4248 const DataType ex = k *
Math::pow(point[0], k-DataType(1));
4249 const DataType sval =
Math::sin(k * point[1]);
4250 const DataType cval =
Math::cos(k * point[1]);
4252 grad[0] = alpha * ex * sval;
4253 grad[1] = alpha * ex * cval * point[0];
4257 HessianType hessian(
const PointType& point)
const
4259 const DataType ex = k *
Math::pow(point[0], k-DataType(2));
4260 const DataType sval =
Math::sin(k * point[1]);
4261 const DataType cval =
Math::cos(k * point[1]);
4263 hess[0][0] = alpha * ex * (k-DataType(1)) * sval;
4265 hess[0][1] =
hess[1][0] = alpha * ex * k * point[0] * cval;
4272 template<
typename DT_>
4287 template<
typename DT_>
4307 template<
typename EvalTraits_>
4377 explicit FrankesFunction() =
default;
4392 template<
typename DT_>
4412 template<
typename EvalTraits_>
4467 grad[2] = dzexp * franks_val;
4506 explicit Frankes3DVariantFunction() =
default;
4531 template<
int dim_,
typename DataType_>
4536 static_assert((1 <= dim_) && (dim_ <= 3),
"harmonic shell function is only implemented in 1D, 2D and 3D");
4538 static constexpr int domain_dim = dim_;
4540 static constexpr bool can_value =
true;
4541 static constexpr bool can_grad =
true;
4542 static constexpr bool can_hess =
true;
4547 template<
typename EvalTraits_>
4582 if constexpr (dim_ == 1)
4584 else if constexpr(dim_ == 2)
4586 else if constexpr(dim_ == 3)
4596 return GradientType::null();
4599 if constexpr (dim_ == 1)
4601 else if constexpr(dim_ == 2)
4603 else if constexpr(dim_ == 3)
4613 return HessianType::null();
4616 if constexpr(dim_ == 1)
4620 else if constexpr(dim_ == 2)
4627 else if constexpr(dim_ == 3)
4630 for(
int i(0); i < dim_; ++i)
4632 for(
int j(0); j < dim_; ++j)
4636 for(
int k(0); k < dim_; ++k)
4679 template<
int dim_,
typename DataType_>
4684 static constexpr int domain_dim = dim_;
4686 static constexpr bool can_value =
true;
4696 template<
typename Traits_>
4701 typedef typename Traits_::DataType DataType;
4702 typedef typename Traits_::PointType PointType;
4703 typedef typename Traits_::ValueType ValueType;
4705 const DataType _d, _scal;
4710 _scal(DataType(function.v_max) /
Math::pow(_d, DataType_(2*(dim_-1))))
4714 ValueType
value(
const PointType& point)
4718 for(
int i = 1; i < dim_; ++i)
4720 val[0] *= DataType(4) * point[i] * (_d - point[i]);
4721 val[i] = DataType(0);
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
const DataType _value
Function that is being evaluated.
EvalTraits_::PointType PointType
point type
Evaluator(const ConstantFunction &function)
Constructor.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::GradientType GradientType
gradient type
Constant Analytic function.
DataType_ _value
Value of the constant function.
ConstantFunction(DataType_ value=DataType_(0))
Constructor, value defaults to 0.
Evaluator(const ConstantVectorFunction &function)
Constructor.
EvalTraits_::HessianType HessianType
hessian type
const ValueType _value_vec
Function that is being evaluated.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::PointType PointType
point type
Constant vector valued Analytic function.
Tiny::Vector< DataType_, domain_dim > _value_vector
Tiny Vector representing the values of the constant function.
ConstantVectorFunction(DataType_ value=DataType_(0))
ConstantVectorFunction(Tiny::Vector< DataType_, domain_dim > vec)
This constructor sets _value_vec to the given Tiny::Vector vec.
Singularity function for a 2D reentry corner with homogeneous boundary conditions.
radial version of the CornerSingularity function... should be used with the PolarCoordinateWrapper
CornerSingularity2DRadial(const Tiny::Vector< DT_, 2 > &vec_r, const Tiny::Vector< DT_, 2 > &vec_l, DT_ alpha_=DT_(1.))
ctor, theta is the angle required to rotate vec_r into vec_l in a counterclockwise manner
Cosine-Tensor Static function.
static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
3D: function value
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
3D: YY-derivative
static DataType_ der_y(DataType_ x, DataType_ y)
2D: Y-derivative
static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
3D: Z-derivative
static DataType_ der_xx(DataType_ x, DataType_ y)
2D: XX-derivative
static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
3D: XX-derivative
static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
3D: X-derivative
static DataType_ kpi()
Returns k times pi.
static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
3D: ZY-derivative
static DataType_ der_yy(DataType_ x, DataType_ y)
2D: YY-derivative
static DataType_ der_x(DataType_ x)
1D: X-derivative
static DataType_ der_x(DataType_ x, DataType_ y)
2D: X-derivative
static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
3D: Y-derivative
static DataType_ der_xy(DataType_ x, DataType_ y)
2D: XY-derivative
static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
3D: YX-derivative
static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
3D: ZZ-derivative
static DataType_ der_yx(DataType_ x, DataType_ y)
2D: YX-derivative
static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
3D: XZ-derivative
static DataType_ eval(DataType_ x, DataType_ y)
2D: function value
static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
3D: XY-derivative
static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
3D: ZX-derivative
static DataType_ eval(DataType_ x)
1D: function value
static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
3D: YZ-derivative
Steady-State inflow function used in DFG95 flow-around-a-cylinder benchmarks.
Exponential-Bubble scalar Static function.
static DataType_ eval(DataType_ x)
1D: function value
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
static DataType_ der_x(DataType_ x)
1D: X-derivative
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::ValueType ValueType
value type
3D Version of Franke's Function
static constexpr bool can_grad
We can compute the gradient.
DT_ DataType
The floating point type.
static constexpr int domain_dim
The dimension to map from.
static constexpr bool can_value
We can compute the value.
static constexpr bool can_hess
We can compute the Hessian.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::PointType PointType
evaluation point type
Saddle-Point-Gauss type interpolation test function.
static constexpr bool can_hess
We can compute the Hessian.
DT_ DataType
The floating point type.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
static constexpr bool can_grad
We can compute the gradient.
static constexpr int domain_dim
The dimension to map from.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_value
We can compute the value.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::HessianType HessianType
hessian type
const DataType _t
The scaling factor according to the amplitude.
Time dependent divergence free velocity field.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_hess
We can compute the Hessian.
static constexpr bool can_grad
We can compute the gradient.
static constexpr bool can_value
We can compute the value.
DT_ DataType
The floating point type.
GuermondStokesSol(DataType t=DataType(0))
Constructor.
static constexpr int domain_dim
The dimension to map from.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
const DataType _t
The scaling factor according to the amplitude.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::HessianType HessianType
hessian type
Pressure to GuermondStokesSol.
GuermondStokesSolPressure(DataType t=DataType(0))
Constructor.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr int domain_dim
The dimension to map from.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
static constexpr bool can_grad
We can compute the gradient.
static constexpr bool can_hess
We can compute the Hessian.
static constexpr bool can_value
We can compute the value.
DT_ DataType
The floating point type.
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::PointType PointType
evaluation point type
Time dependent divergence free velocity field.
const DataType _reynolds
The Reynolds number of the associated flow with the solution GuermondStokesSol.
static constexpr int domain_dim
The dimension to map from.
static constexpr bool can_hess
We can compute the Hessian.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_grad
We can compute the gradient.
GuermondStokesSolRhs(DataType reynolds, DataType t=DataType(0))
Constructor.
DT_ DataType
The floating point type.
static constexpr bool can_value
We can compute the value.
const PointType _origin
our origin
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::HessianType HessianType
hessian type
Evaluator(const HarmonicShellFunction &function)
Constructor.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::PointType PointType
evaluation point type
HarmonicShellFunction(const PointType &origin)
Constructor.
HarmonicShellFunction()
default constructor
void set_point(const PointType &origin)
Sets point to x0
PointType _origin
Point to calculate the distance from.
EvalTraits_::ValueType ValueType
value type
AnalyticFunctionType1::template Evaluator< EvalTraits_ > _f1_eval
Evaluator for the first AnalyticFunction.
AnalyticFunctionType2::template Evaluator< EvalTraits_ > _f2_eval
Evaluator for the second AnalyticFunction.
Evaluator(const MinOfTwoFunctions &function)
Constructor.
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::DataType DataType
coefficient data type
Function representing the minimum of two analytic functions.
static constexpr bool can_grad
Can compute the function gradient if both AnalyticFunctions can do that.
const AnalyticFunctionType2 & _f2
The second AnalyticFunction.
const AnalyticFunctionType1 & _f1
The first AnalyticFunction.
MinOfTwoFunctions(const AnalyticFunctionType1 &f1_, const AnalyticFunctionType2 &f2_)
Constructor.
static constexpr bool can_hess
Can compute the function hessian if both AnalyticFunctions can do that.
static constexpr int domain_dim
ensure that the two functions have the same dimension
static constexpr bool can_value
Can compute function values if both AnalyticFunctions can do that.
Analytic::Image::Scalar ImageType
our image type
2D Parabolic Profile function base-class
ParProfileBase(DataType_ x0, DataType_ y0, DataType_ x1, DataType_ y1, DataType_ vmax=DataType_(1.0))
Constructor.
ParProfileBase()
Default Constructor.
bool parse(const String &sbc)
Parses the profile parameters from a string.
2D Scalar Parabolic Profile function
2D Vector-Valued Parabolic Profile function
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::PointType PointType
evaluation point type
Parabolic Poiseuille Pipe-Flow velocity field.
PointType axis
The flow axis.
PointType origin
The flow origin.
static constexpr bool can_value
We can compute the value.
PoiseuillePipeFlow(PointType origin_, PointType axis_, DataType radius_=DataType(1), DataType v_max_=DataType(1))
Creates this function.
Tiny::Vector< DataType, domain_dim > PointType
Type to map from.
DataType v_max
the maximum flow velocity
static constexpr int domain_dim
The dimension to map from.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
DataType_ DataType
The floating point type.
static constexpr bool can_hess
We can't compute the Hessian.
static constexpr bool can_grad
We can compute the gradient.
DataType radius
The pipe radius.
std::vector< DataType > _coeff
our polynomial coefficients
Evaluator(const PolynomialFunction1D &function)
Constructor.
1D Polynomial function class template
Index set_coeff(Index degree, DataType_ coeff)
Sets a monomial coefficient.
std::vector< DataType_ > _coeff
the polynomial coefficient vector
static constexpr bool can_hess
we provide function hessians
Analytic::Image::Scalar ImageType
this is a scalar function
PolynomialFunction1D(std::initializer_list< DataType_ > coeff)
Polynomial coefficient constructor.
PolynomialFunction1D()
default constructor
static constexpr bool can_value
we provide function values
static constexpr bool can_grad
we provide function gradients
static constexpr int domain_dim
this is a 1D function
Q2-bubble scalar Static function.
static DataType_ der_xx(DataType_)
1D: XX-derivative
static DataType_ eval(DataType_ x)
1D: function value
static DataType_ der_x(DataType_ x)
1D: X-derivative
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::GradientType GradientType
gradient type
Rigid-Body Vortex pressure function.
static constexpr bool can_grad
We can compute the gradient.
static constexpr bool can_hess
We can compute the Hessian.
static constexpr int domain_dim
The dimension to map from.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
DT_ DataType
The floating point type.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_value
We can compute the value.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::HessianType HessianType
hessian type
Rigid-Body Vortex velocity field.
static constexpr int domain_dim
The dimension to map from.
DT_ DataType
The floating point type.
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
static constexpr bool can_grad
We can compute the gradient.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_hess
We can't compute the Hessian.
static constexpr bool can_value
We can compute the value.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::HessianType HessianType
hessian type
const DataType _t
The scaling factor according to the amplitude.
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::ValueType ValueType
value type
Time dependent divergence free velocity field.
static constexpr bool can_grad
We can compute the gradient.
static constexpr bool can_hess
We can compute the Hessian.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
static constexpr bool can_value
We can compute the value.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
DT_ DataType
The floating point type.
SinYT0(DataType t=DataType(0))
Constructor.
static constexpr int domain_dim
The dimension to map from.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::ValueType ValueType
value type
Time dependent divergence free velocity field.
static constexpr int domain_dim
The dimension to map from.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_hess
We can compute the Hessian.
SinYT0StokesRhs(DataType reynolds, DataType t=DataType(0))
Constructor.
const DataType _reynolds
The Reynolds number of the associated flow with the solution SinYT0.
static constexpr bool can_grad
We can compute the gradient.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
static constexpr bool can_value
We can compute the value.
DT_ DataType
The floating point type.
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
const DataType _pi2
2*pi and 1/pi^2
EvalTraits_::PointType PointType
evaluation point type
Sine-Vortex pressure function on the 2D ring domain with distance [1/2,1] around (0,...
static constexpr bool can_hess
We can compute the Hessian.
static constexpr bool can_grad
We can compute the gradient.
static constexpr int domain_dim
The dimension to map from.
DT_ DataType
The floating point type.
static constexpr bool can_value
We can compute the value.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
DataType mean_shift
the shift of the mean value; defaults to that the pressure has integral mean equal to 0
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::GradientType GradientType
gradient type
Sine-Vortex RHS field on the 2D ring domain with distance [1/2,1] around (0,0)
SineRingVortexRHS2D(DataType nu_=DataType(1), DataType beta_=DataType(0), DataType theta_=DataType(0), DataType sigma_=DataType(1))
Constructor.
static constexpr int domain_dim
The dimension to map from.
static constexpr bool can_hess
We can't compute the Hessian.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_grad
We can compute the gradient.
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
static constexpr bool can_value
We can compute the value.
DT_ DataType
The floating point type.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::PointType PointType
evaluation point type
Sine-Vortex velocity field on the 2D ring domain with distance [1/2,1] around (0,0)
static constexpr int domain_dim
The dimension to map from.
static constexpr bool can_grad
We can compute the gradient.
DT_ DataType
The floating point type.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr bool can_value
We can compute the value.
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
static constexpr bool can_hess
We can't compute the Hessian.
Sine-Tensor Static function.
static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
3D: YY-derivative
static DataType_ der_yy(DataType_ x, DataType_ y)
2D: YY-derivative
static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
3D: XY-derivative
static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
3D: XZ-derivative
static DataType_ der_xx(DataType_ x, DataType_ y)
2D: XX-derivative
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
3D: X-derivative
static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
3D: YZ-derivative
static DataType_ kpi()
returns the constant pi
static DataType_ der_x(DataType_ x, DataType_ y)
2D: X-derivative
static DataType_ eval(DataType_ x, DataType_ y)
2D: function value
static DataType_ der_x(DataType_ x)
1D: X-derivative
static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
3D: Z-derivative
static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
3D: Y-derivative
static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
3D: ZZ-derivative
static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
3D: function value
static DataType_ eval(DataType_ x)
1D: function value
static DataType_ der_y(DataType_ x, DataType_ y)
2D: Y-derivative
static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
3D: ZX-derivative
static DataType_ der_yx(DataType_ x, DataType_ y)
2D: YX-derivative
static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
3D: YX-derivative
static DataType_ der_xy(DataType_ x, DataType_ y)
2D: XY-derivative
static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
3D: XX-derivative
static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
3D: ZY-derivative
Sphere-Cap Function on the 2D unit circle / 3D unit ball.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::GradientType GradientType
gradient type
Sphere-Normalized Sine-Bubble Function.
static constexpr bool can_value
We can compute the value.
static constexpr bool can_grad
We can compute the gradient.
static constexpr bool can_hess
We can compute the Hessian.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
static constexpr int domain_dim
The dimension to map from.
Standing-Vortex function in 2D.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::ValueType ValueType
value type
Taylor-Green Vortex pressure function.
DataType nu
The viscosity parameter.
TaylorGreenVortexPres2D(DataType nu_=DataType(1), DataType t_=DataType(0))
Constructor.
static constexpr bool can_hess
We can compute the Hessian.
static constexpr bool can_value
We can compute the value.
DT_ DataType
The floating point type.
Analytic::Image::Scalar ImageType
What type this mapping maps to.
static constexpr int domain_dim
The dimension to map from.
static constexpr bool can_grad
We can compute the gradient.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
DataType cur_t
The current simulation time.
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::DataType DataType
coefficient data type
Taylor-Green Vortex velocity field.
static constexpr bool can_value
We can compute the value.
TaylorGreenVortexVelo2D(DataType nu_=DataType(1), DataType t_=DataType(0))
Constructor.
static constexpr int domain_dim
The dimension to map from.
DataType nu
The viscosity parameter.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
DataType cur_t
The current simulation time.
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
static constexpr bool can_hess
We can't compute the Hessian.
DT_ DataType
The floating point type.
static constexpr bool can_grad
We can compute the gradient.
Wrapper class for Tensor-Product scalar static functions.
static DataType_ der_xy(DataType_ x, DataType_ y)
2D: XY-derivative
static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
3D: YX-derivative
static DataType_ der_x(DataType_ x)
1D: X-derivative
static DataType_ der_xx(DataType_ x, DataType_ y)
2D: XX-derivative
static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
3D: XX-derivative
static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
3D: Z-derivative
static DataType_ der_yy(DataType_ x, DataType_ y)
2D: YY-derivative
static DataType_ der_yx(DataType_ x, DataType_ y)
2D: YX-derivative
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
static DataType_ der_y(DataType_ x, DataType_ y)
2D: Y-derivative
static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
3D: Y-derivative
static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
3D: ZZ-derivative
static DataType_ eval(DataType_ x)
1D: function value
static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
3D: function value
static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
3D: ZX-derivative
static DataType_ der_x(DataType_ x, DataType_ y)
2D: X-derivative
static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
3D: ZY-derivative
static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
3D: YY-derivative
static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
3D: YZ-derivative
static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
3D: XZ-derivative
static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
3D: X-derivative
static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
3D: XY-derivative
static DataType_ eval(DataType_ x, DataType_ y)
2D: function value
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::ValueType ValueType
value type
const DataType _angular_velocity
The angular velocity.
const PointType & _origin
our origin
EvalTraits_::HessianType HessianType
hessian type
Velocity field for a rigid body rotation in the x,y plane.
const PointType _origin
Point to rotate around.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
XYPlaneRotation(const DataType angular_velocity, const PointType &origin)
Constructor.
const DataType _angular_velocity
The angular velocity.
DT_ DataType
The floating point type.
static constexpr bool can_grad
We can compute the gradient.
static constexpr bool can_hess
We can compute the Hessian.
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
static constexpr int domain_dim
The dimension to map from.
static constexpr bool can_value
We can compute the value.
const std::vector< Tiny::Vector< DataType, 2 > > & _range
The points where the function becomes zero.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::DataType DataType
coefficient data type
DataType _fac
The scaling factor according to the amplitude.
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::GradientType GradientType
gradient type
Velocity field for a parabolic profile in the y,z plane, constant in x.
DT_ DataType
The floating point type.
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
YZPlaneParabolic(const DataType amplitude, const RangeType &range_y)
Constructor.
YZPlaneParabolic(const DataType amplitude, const RangeType &range_y, const RangeType &range_z)
Constructor.
static constexpr int domain_dim
The dimension to map from.
const DataType _amplitude
The maximum value of the parabolic profile.
Tiny::Vector< DT_, 2 > RangeType
Type to map from.
static constexpr bool can_value
We can compute the value.
static constexpr bool can_hess
We can compute the Hessian.
static constexpr bool can_grad
We can compute the gradient.
std::vector< Tiny::Vector< DataType, 2 > > _range
The points where the function becomes zero.
Analytic Function Evaluator base-class template.
ValueType value(const PointType &point)
Computes the function value in a given point.
GradientType gradient(const PointType &point)
Computes the function gradient in a given point.
HessianType hessian(const PointType &point)
Computes the function hessian in a given point.
Analytic Function interface.
This class is a wrapper transforming a polar-basis function to a euclidean base one.
StaticFunction wrapper class template for Analytic::Function interface.
String class implementation.
std::deque< String > split_by_string(const String &delimiter) const
Splits the string by a delimiter substring.
Tiny Vector class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the vector.
CUDA_HOST_DEVICE DataType norm_euclid_sqr() const
Computes the squared euclid norm of this vector.
CUDA_HOST_DEVICE DataType norm_euclid() const
Computes the euclid norm of this vector.
T_ sqrt(T_ x)
Returns the square-root of a value.
T_ abs(T_ x)
Returns the absolute value.
T_ exp(T_ x)
Returns the exponential of a value.
T_ clamp(T_ x, T_ a, T_ b)
Clamps a value to a range.
T_ acos(T_ x)
Returns the arccosine of a value.
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
T_ sin(T_ x)
Returns the sine of a value.
T_ sqr(T_ x)
Returns the square of a value.
T_ min(T_ a, T_ b)
Returns the minimum of two values.
T_ cub(T_ x)
Returns the cube of a value.
T_ signum(T_ x)
Returns the sign of a value.
T_ cos(T_ x)
Returns the cosine of a value.
T_ log(T_ x)
Returns the natural logarithm of a value.
CUDA_HOST_DEVICE T_ dot(const T_ &a, const T_ &b)
Computes the dot-product of two scalars.
CUDA_HOST T_ calculate_opening_angle(const Vector< T_, 2 > &x, const Vector< T_, 2 > &y)
Calculates the counter-clockwise opening angle between two 2D vectors.
__half Half
Half data type.
@ value
specifies whether the space should supply basis function values
@ hess
specifies whether the space should supply basis function hessians
@ grad
specifies whether the space should supply basis function gradients
std::uint64_t Index
Index data type.
Scalar Function Image tag class.
Vector Field Image tag class.