FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
common.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
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>
13
14// includes, system
15#include <initializer_list>
16#include <deque>
17#include <vector>
18
19namespace FEAT
20{
21 namespace Analytic
22 {
29 namespace Common
30 {
46 template<typename Scalar_, typename DataType_>
48 {
49 public:
51 static DataType_ eval(DataType_ x)
52 {
53 return Scalar_::eval(x);
54 }
55
57 static DataType_ der_x(DataType_ x)
58 {
59 return Scalar_::der_x(x);
60 }
61
63 static DataType_ der_xx(DataType_ x)
64 {
65 return Scalar_::der_xx(x);
66 }
67
69 static DataType_ eval(DataType_ x, DataType_ y)
70 {
71 return Scalar_::eval(x) * Scalar_::eval(y);
72 }
73
75 static DataType_ der_x(DataType_ x, DataType_ y)
76 {
77 return Scalar_::der_x(x) * Scalar_::eval(y);
78 }
79
81 static DataType_ der_y(DataType_ x, DataType_ y)
82 {
83 return Scalar_::eval(x) * Scalar_::der_x(y);
84 }
85
87 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
88 {
89 return Scalar_::eval(x) * Scalar_::eval(y) * Scalar_::eval(z);
90 }
91
93 static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
94 {
95 return Scalar_::der_x(x) * Scalar_::eval(y) * Scalar_::eval(z);
96 }
97
99 static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
100 {
101 return Scalar_::eval(x) * Scalar_::der_x(y) * Scalar_::eval(z);
102 }
103
105 static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
106 {
107 return Scalar_::eval(x) * Scalar_::eval(y) * Scalar_::der_x(z);
108 }
109
111 static DataType_ der_xx(DataType_ x, DataType_ y)
112 {
113 return Scalar_::der_xx(x) * Scalar_::eval(y);
114 }
115
117 static DataType_ der_yy(DataType_ x, DataType_ y)
118 {
119 return Scalar_::eval(x) * Scalar_::der_xx(y);
120 }
121
123 static DataType_ der_xy(DataType_ x, DataType_ y)
124 {
125 return Scalar_::der_x(x) * Scalar_::der_x(y);
126 }
127
129 static DataType_ der_yx(DataType_ x, DataType_ y)
130 {
131 return Scalar_::der_x(x) * Scalar_::der_x(y);
132 }
133
135 static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
136 {
137 return Scalar_::der_xx(x) * Scalar_::eval(y) * Scalar_::eval(z);
138 }
139
141 static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
142 {
143 return Scalar_::eval(x) * Scalar_::der_xx(y) * Scalar_::eval(z);
144 }
145
147 static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
148 {
149 return Scalar_::eval(x) * Scalar_::eval(y) * Scalar_::der_xx(z);
150 }
151
153 static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
154 {
155 return Scalar_::der_x(x) * Scalar_::der_x(y) * Scalar_::eval(z);
156 }
157
159 static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
160 {
161 return Scalar_::der_x(x) * Scalar_::der_x(y) * Scalar_::eval(z);
162 }
163
165 static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
166 {
167 return Scalar_::der_x(x) * Scalar_::eval(y) * Scalar_::der_x(z);
168 }
169
171 static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
172 {
173 return Scalar_::der_x(x) * Scalar_::eval(y) * Scalar_::der_x(z);
174 }
175
177 static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
178 {
179 return Scalar_::eval(x) * Scalar_::der_x(y) * Scalar_::der_x(z);
180 }
181
183 static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
184 {
185 return Scalar_::eval(x) * Scalar_::der_x(y) * Scalar_::der_x(z);
186 }
187 }; // class TensorStatic<...>
188
205 template<typename DataType_, int k_ = 1>
207 {
208 static_assert(k_ > 0, "parameter k_ must be a positive integer");
209
210 public:
212 static DataType_ kpi()
213 {
214 return DataType_(k_) * Math::pi<DataType_>();
215 }
216
218 static DataType_ eval(DataType_ x)
219 {
220 return Math::sin(kpi() * x);
221 }
222
224 static DataType_ eval(DataType_ x, DataType_ y)
225 {
226 return Math::sin(kpi() * x) * Math::sin(kpi() * y);
227 }
228
230 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
231 {
232 return Math::sin(kpi() * x) * Math::sin(kpi() * y) * Math::sin(kpi() * z);
233 }
234
236 static DataType_ der_x(DataType_ x)
237 {
238 return kpi() * Math::cos(kpi() * x);
239 }
240
242 static DataType_ der_x(DataType_ x, DataType_ y)
243 {
244 return kpi() * Math::cos(kpi() * x) * Math::sin(kpi() * y);
245 }
246
248 static DataType_ der_y(DataType_ x, DataType_ y)
249 {
250 return kpi() * Math::sin(kpi() * x) * Math::cos(kpi() * y);
251 }
252
254 static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
255 {
256 return kpi() * Math::cos(kpi() * x) * Math::sin(kpi() * y) * Math::sin(kpi() * z);
257 }
258
260 static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
261 {
262 return kpi() * Math::sin(kpi() * x) * Math::cos(kpi() * y) * Math::sin(kpi() * z);
263 }
264
266 static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
267 {
268 return kpi() * Math::sin(kpi() * x) * Math::sin(kpi() * y) * Math::cos(kpi() * z);
269 }
270
272 static DataType_ der_xx(DataType_ x)
273 {
274 return -Math::sqr(kpi()) * Math::sin(kpi() * x);
275 }
276
278 static DataType_ der_xx(DataType_ x, DataType_ y)
279 {
280 return -Math::sqr(kpi()) * Math::sin(kpi() * x) * Math::sin(kpi() * y);
281 }
282
284 static DataType_ der_yy(DataType_ x, DataType_ y)
285 {
286 return der_xx(x, y);
287 }
288
290 static DataType_ der_xy(DataType_ x, DataType_ y)
291 {
292 return Math::sqr(kpi()) * Math::cos(kpi() * x) * Math::cos(kpi() * y);
293 }
294
296 static DataType_ der_yx(DataType_ x, DataType_ y)
297 {
298 return der_xy(x, y);
299 }
300
302 static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
303 {
304 return -Math::sqr(kpi()) * Math::sin(kpi() * x) * Math::sin(kpi() * y) * Math::sin(kpi() * z);
305 }
306
308 static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
309 {
310 return der_xx(x, y, z);
311 }
312
314 static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
315 {
316 return der_xx(x, y, z);
317 }
318
320 static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
321 {
322 return Math::sqr(kpi()) * Math::cos(kpi() * x) * Math::cos(kpi() * y) * Math::sin(kpi() * z);
323 }
324
326 static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
327 {
328 return der_xy(x, y, z);
329 }
330
332 static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
333 {
334 return Math::sqr(kpi()) * Math::cos(kpi() * x) * Math::sin(kpi() * y) * Math::cos(kpi() * z);
335 }
336
338 static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
339 {
340 return der_xz(x, y, z);
341 }
342
344 static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
345 {
346 return Math::sqr(kpi()) * Math::sin(kpi() * x) * Math::cos(kpi() * y) * Math::cos(kpi() * z);
347 }
348
350 static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
351 {
352 return der_yz(x, y, z);
353 }
354 }; // class SineTensorStatic<...>
355
357 template<typename DataType_>
358 using SineBubbleStatic = SineTensorStatic<DataType_, 1>;
360
375 template<int dim_>
377
395 template<typename DataType_, int k_ = 1>
397 {
398 static_assert(k_ > 0, "parameter k_ must be a positive integer");
399
400 public:
402 static DataType_ kpi()
403 {
404 return DataType_(k_) * Math::pi<DataType_>();
405 }
406
408 static DataType_ eval(DataType_ x)
409 {
410 return Math::cos(kpi() * x);
411 }
412
414 static DataType_ eval(DataType_ x, DataType_ y)
415 {
416 return Math::cos(kpi() * x) * Math::cos(kpi() * y);
417 }
418
420 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
421 {
422 return Math::cos(kpi() * x) * Math::cos(kpi() * y) * Math::cos(kpi() * z);
423 }
424
426 static DataType_ der_x(DataType_ x)
427 {
428 return -kpi() * Math::sin(kpi() * x);
429 }
430
432 static DataType_ der_x(DataType_ x, DataType_ y)
433 {
434 return -kpi() * Math::sin(kpi() * x) * Math::cos(kpi() * y);
435 }
436
438 static DataType_ der_y(DataType_ x, DataType_ y)
439 {
440 return -kpi() * Math::cos(kpi() * x) * Math::sin(kpi() * y);
441 }
442
444 static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
445 {
446 return -kpi() * Math::sin(kpi() * x) * Math::cos(kpi() * y) * Math::cos(kpi() * z);
447 }
448
450 static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
451 {
452 return -kpi() * Math::cos(kpi() * x) * Math::sin(kpi() * y) * Math::cos(kpi() * z);
453 }
454
456 static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
457 {
458 return -kpi() * Math::cos(kpi() * x) * Math::cos(kpi() * y) * Math::sin(kpi() * z);
459 }
460
462 static DataType_ der_xx(DataType_ x)
463 {
464 return -Math::sqr(kpi()) * Math::cos(kpi() * x);
465 }
466
468 static DataType_ der_xx(DataType_ x, DataType_ y)
469 {
470 return -Math::sqr(kpi()) * Math::cos(kpi() * x) * Math::cos(kpi() * y);
471 }
472
474 static DataType_ der_yy(DataType_ x, DataType_ y)
475 {
476 return der_xx(x, y);
477 }
478
480 static DataType_ der_xy(DataType_ x, DataType_ y)
481 {
482 return Math::sqr(kpi()) * Math::sin(kpi() * x) * Math::sin(kpi() * y);
483 }
484
486 static DataType_ der_yx(DataType_ x, DataType_ y)
487 {
488 return der_xy(x, y);
489 }
490
492 static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
493 {
494 return -Math::sqr(kpi()) * Math::cos(kpi() * x) * Math::cos(kpi() * y) * Math::cos(kpi() * z);
495 }
496
498 static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
499 {
500 return der_xx(x, y, z);
501 }
502
504 static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
505 {
506 return der_xx(x, y, z);
507 }
508
510 static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
511 {
512 return Math::sqr(kpi()) * Math::sin(kpi() * x) * Math::sin(kpi() * y) * Math::cos(kpi() * z);
513 }
514
516 static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
517 {
518 return der_xy(x, y, z);
519 }
520
522 static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
523 {
524 return Math::sqr(kpi()) * Math::sin(kpi() * x) * Math::cos(kpi() * y) * Math::sin(kpi() * z);
525 }
526
528 static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
529 {
530 return der_xz(x, y, z);
531 }
532
534 static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
535 {
536 return Math::sqr(kpi()) * Math::cos(kpi() * x) * Math::sin(kpi() * y) * Math::sin(kpi() * z);
537 }
538
540 static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
541 {
542 return der_yz(x, y, z);
543 }
544 }; // class CosineTensorStatic<...>
545
547 template<typename DataType_>
548 using CosineWaveStatic = CosineTensorStatic<DataType_, 1>;
550
566 template<int dim_>
568
579 template<typename DataType_>
581 {
582 public:
584 static DataType_ eval(DataType_ x)
585 {
586 return (Math::exp(-Math::sqr(DataType_(2)*x - DataType_(1))) - Math::exp(-DataType_(1))) / (DataType_(1) - Math::exp(-DataType_(1)));
587 }
588
590 static DataType_ der_x(DataType_ x)
591 {
592 return (DataType_(8)*x - DataType_(4))*Math::exp(-Math::sqr(DataType_(2)*x - DataType_(1))) / (Math::exp(-DataType_(1)) - DataType_(1));
593 }
594
596 static DataType_ der_xx(DataType_ x)
597 {
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));
599 }
600 }; // class ExpBubbleScalarStatic<...>
601
603 template<typename DataType_>
604 using ExpBubbleStatic = TensorStatic<ExpBubbleScalarStatic<DataType_>, DataType_>;
606
621 template<int dim_>
623
634 template<typename DataType_>
636 {
637 public:
639 static DataType_ eval(DataType_ x)
640 {
641 return DataType_(4) * x * (DataType_(1) - x);
642 }
643
645 static DataType_ der_x(DataType_ x)
646 {
647 return DataType_(4) * (DataType_(1) - DataType_(2) * x);
648 }
649
651 static DataType_ der_xx(DataType_)
652 {
653 return -DataType_(8);
654 }
655 }; // class Q2BubbleScalarStatic<...>
656
658 template<typename DataType_>
659 using Q2BubbleStatic = TensorStatic<Q2BubbleScalarStatic<DataType_>, DataType_>;
661
676 template<int dim_>
678
688 template<int dim_, typename DataType_ = Real>
690 public Analytic::Function
691 {
692 public:
693 static constexpr int domain_dim = dim_;
695
696 static constexpr bool can_value = true;
697 static constexpr bool can_grad = true;
698 static constexpr bool can_hess = true;
699
701 template<typename EvalTraits_>
702 class Evaluator :
703 public Analytic::Function::Evaluator<EvalTraits_>
704 {
705 public:
707 typedef typename EvalTraits_::DataType DataType;
709 typedef typename EvalTraits_::PointType PointType;
711 typedef typename EvalTraits_::ValueType ValueType;
713 typedef typename EvalTraits_::GradientType GradientType;
715 typedef typename EvalTraits_::HessianType HessianType;
716
717 private:
720
721 public:
723 explicit Evaluator(const ConstantFunction& function) :
724 _value(DataType(function._value))
725 {
726 }
727
728 ValueType value(const PointType& DOXY(point))
729 {
730 return _value;
731 }
732
733 GradientType gradient(const PointType& DOXY(point))
734 {
735 return GradientType::null();
736 }
737
738 HessianType hessian(const PointType& DOXY(point))
739 {
740 return HessianType::null();
741 }
742 }; // class ConstantFunction::Evaluator<...>
743
744 private:
746 DataType_ _value;
747
748 public:
750 explicit ConstantFunction(DataType_ value = DataType_(0)) :
752 {
753 }
754 }; // class ConstantFunction
755
765 template<int dim_, typename DataType_ = Real>
767 public Analytic::Function
768 {
769 public:
770 static constexpr int domain_dim = dim_;
772
773 static constexpr bool can_value = true;
774 static constexpr bool can_grad = true;
775 static constexpr bool can_hess = true;
776
778 template<typename EvalTraits_>
779 class Evaluator :
780 public Analytic::Function::Evaluator<EvalTraits_>
781 {
782 public:
784 typedef typename EvalTraits_::DataType DataType;
786 typedef typename EvalTraits_::PointType PointType;
788 typedef typename EvalTraits_::ValueType ValueType;
790 typedef typename EvalTraits_::GradientType GradientType;
792 typedef typename EvalTraits_::HessianType HessianType;
793
794 private:
797
798 public:
800 explicit Evaluator(const ConstantVectorFunction& function) :
801 _value_vec(function._value_vector)
802 {
803 }
804
805 ValueType value(const PointType& DOXY(point))
806 {
807 return _value_vec;
808 }
809
810 GradientType gradient(const PointType& DOXY(point))
811 {
812 return GradientType::null();
813 }
814
815 HessianType hessian(const PointType& DOXY(point))
816 {
817 return HessianType::null();
818 }
819 }; // class ConstantVectorFunction::Evaluator<...>
820
821 private:
824
825 public:
828 explicit ConstantVectorFunction(DataType_ value = DataType_(0)) :
829 _value_vector(Tiny::Vector<DataType_, domain_dim>(value))
830 {
831 }
832
835 _value_vector(vec)
836 {
837 }
838
839 explicit ConstantVectorFunction(DataType_ value_x, DataType_ value_y) :
841 {
842 _value_vector[0] = value_x;
843 if constexpr(dim_ > 1)
844 _value_vector[1] = value_y;
845 }
846
847 explicit ConstantVectorFunction(DataType_ value_x, DataType_ value_y, DataType_ value_z) :
849 {
850 _value_vector[0] = value_x;
851 if constexpr(dim_ > 1)
852 _value_vector[1] = value_y;
853 if constexpr(dim_ > 2)
854 _value_vector[2] = value_z;
855 }
856 }; // class ConstantVectorFunction
857
876 template<typename AnalyticFunctionType1, typename AnalyticFunctionType2>
878 public Analytic::Function
879 {
880 public:
882 static_assert(AnalyticFunctionType1::domain_dim == AnalyticFunctionType2::domain_dim, "domain dimension mismatch");
883
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");
887
889 static constexpr int domain_dim = AnalyticFunctionType1::domain_dim;
892
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);
899
900 public:
902 template<typename EvalTraits_>
903 class Evaluator :
904 public Analytic::Function::Evaluator<EvalTraits_>
905 {
906 public:
908 typedef typename EvalTraits_::DataType DataType;
910 typedef typename EvalTraits_::PointType PointType;
912 typedef typename EvalTraits_::ValueType ValueType;
914 typedef typename EvalTraits_::GradientType GradientType;
916 typedef typename EvalTraits_::HessianType HessianType;
917
918 private:
920 typename AnalyticFunctionType1::template Evaluator<EvalTraits_> _f1_eval;
922 typename AnalyticFunctionType2::template Evaluator<EvalTraits_> _f2_eval;
923
924 const DataType _eps;
925
926 public:
928 explicit Evaluator(const MinOfTwoFunctions& function) :
929 _f1_eval(function._f1),
930 _f2_eval(function._f2),
931 _eps(Math::eps<DataType>())
932 {
933 }
934
935 ValueType value(const PointType& point)
936 {
937 return Math::min(_f1_eval.value(point), _f2_eval.value(point));
938 }
939
940 GradientType gradient(const PointType& point)
941 {
942 ValueType val1 = _f1_eval.value(point);
943 ValueType val2 = _f2_eval.value(point);
944
945 if(Math::abs(val1-val2) < _eps)
946 return GradientType::null();
947 else if(val1 < val2)
948 return _f1_eval.gradient(point);
949 else
950 return _f2_eval.gradient(point);
951 }
952
953 HessianType hessian(const PointType& point)
954 {
955 ValueType val1 = _f1_eval.value(point);
956 ValueType val2 = _f2_eval.value(point);
957
958 if(Math::abs(val1-val2) < _eps)
959 return HessianType::null();
960 else if(val1 < val2)
961 return _f1_eval.hessian(point);
962 else
963 return _f2_eval.hessian(point);
964 }
965 }; // class MinOfTwoFunctions::Evaluator<...>
966
967 private:
969 const AnalyticFunctionType1& _f1;
971 const AnalyticFunctionType2& _f2;
972
973 public:
975 explicit MinOfTwoFunctions(const AnalyticFunctionType1& f1_, const AnalyticFunctionType2& f2_) :
976 _f1(f1_),
977 _f2(f2_)
978 {
979 }
980 }; // class MinOfTwoFunctions
981
983
1002 template<typename DataType_>
1003 class HeavisideStatic
1004 {
1005 public:
1006
1008 static DataType_ eval(DataType_ x)
1009 {
1010 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(1);
1011 }
1012
1014 static DataType_ eval(DataType_ x, DataType_ y)
1015 {
1016 return eval(x)*eval(y);
1017 }
1018
1020 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
1021 {
1022 return eval(x)*eval(y)*eval(z);
1023 }
1024
1025 }; // class HeavisideStatic<...>
1027
1047 template<int dim_>
1049
1051
1071 template<typename DataType_>
1072 class HeavisideRegStatic
1073 {
1074 public:
1075
1077 static DataType_ eval(DataType_ x)
1078 {
1079 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(2)*(Math::cosh(x) - DataType_(1));
1080 }
1081
1083 static DataType_ eval(DataType_ x, DataType_ y)
1084 {
1085 return eval(x)*eval(y);
1086 }
1087
1089 static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
1090 {
1091 return eval(x)*eval(y)*eval(z);
1092 }
1093
1095 static DataType_ der_x(DataType_ x)
1096 {
1097 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(2)*Math::sinh(x);
1098 }
1099
1101 static DataType_ der_x(DataType_ x, DataType_ y)
1102 {
1103 return der_x(x)*eval(y);
1104 }
1105
1107 static DataType_ der_y(DataType_ x, DataType_ y)
1108 {
1109 return eval(x)*der_x(y);
1110 }
1111
1113 static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
1114 {
1115 return der_x(x)*eval(y)*eval(z);
1116 }
1117
1119 static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
1120 {
1121 return eval(x)*der_x(y)*eval(z);
1122 }
1123
1125 static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
1126 {
1127 return eval(x)*eval(y)*der_x(z);
1128 }
1129
1131 static DataType_ der_xx(DataType_ x)
1132 {
1133 return ( x < DataType_(0) ) ? DataType_(0) : DataType_(2)*Math::cosh(x);
1134 }
1135
1137 static DataType_ der_xx(DataType_ x, DataType_ y)
1138 {
1139 return der_xx(x)*eval(y);
1140 }
1141
1143 static DataType_ der_yy(DataType_ x, DataType_ y)
1144 {
1145 return eval(x)*der_xx(y);
1146 }
1147
1149 static DataType_ der_xy(DataType_ x, DataType_ y)
1150 {
1151 return der_x(x)*der_x(y);
1152 }
1153
1155 static DataType_ der_yx(DataType_ x, DataType_ y)
1156 {
1157 return der_xy(x, y);
1158 }
1159
1161 static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
1162 {
1163 return der_xx(x)*eval(y)*eval(z);
1164 }
1165
1167 static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
1168 {
1169 return eval(x)*der_xx(y)*eval(z);
1170 }
1171
1173 static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
1174 {
1175 return eval(x)*eval(y)*der_xx(z);
1176 }
1177
1179 static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
1180 {
1181 return der_x(x)*der_x(y)*eval(z);
1182 }
1183
1185 static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
1186 {
1187 return der_x(x)*der_x(y)*eval(z);
1188 }
1189
1191 static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
1192 {
1193 return der_x(x)*eval(y)*der_x(z);
1194 }
1195
1197 static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
1198 {
1199 return der_xz(x, y, z);
1200 }
1201
1203 static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
1204 {
1205 return eval(x)*der_x(y)*der_x(z);
1206 }
1207
1209 static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
1210 {
1211 return der_yz(x, y, z);
1212 }
1213
1214 }; // class HeavisideRegStatic<...>
1216
1237 template<int dim_>
1239
1251 template<typename DataType_>
1253 public Analytic::Function
1254 {
1255 public:
1257 static constexpr int domain_dim = 1;
1261 static constexpr bool can_value = true;
1263 static constexpr bool can_grad = true;
1265 static constexpr bool can_hess = true;
1266
1268 template<typename EvalTraits_>
1270 public Analytic::Function::Evaluator<EvalTraits_>
1271 {
1272 public:
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;
1278
1279 private:
1281 std::vector<DataType> _coeff;
1282
1283 public:
1285 explicit Evaluator(const PolynomialFunction1D& function)
1286 {
1287 for(auto it = function._coeff.begin(); it != function._coeff.end(); ++it)
1288 _coeff.push_back(DataType(*it));
1289 }
1290
1291 ValueType value(const PointType& point) const
1292 {
1293 // evaluate polynomial via horner scheme
1294 DataType x = point[0];
1295 DataType y = DataType(0);
1296 for(std::size_t k(_coeff.size()); k > std::size_t(0); )
1297 y = x * y + _coeff[--k];
1298
1299 return y;
1300 }
1301
1302 GradientType gradient(const PointType& point) const
1303 {
1304 std::size_t k = _coeff.size();
1305 if(k <= std::size_t(0))
1306 return GradientType::null();
1307
1308 // evaluate polynomial via horner scheme
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));
1313
1314 return GradientType(y);
1315 }
1316
1317 HessianType hessian(const PointType& point) const
1318 {
1319 std::size_t k = _coeff.size();
1320 if(k <= std::size_t(1))
1321 return HessianType::null();
1322
1323 // evaluate polynomial via horner scheme
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)));
1328
1329 return HessianType(y);
1330 }
1331 }; // class PolynomialFunction1D::Evaluator
1332
1333 private:
1335 std::vector<DataType_> _coeff;
1336
1337 public:
1340 _coeff()
1341 {
1342 }
1343
1350 explicit PolynomialFunction1D(std::initializer_list<DataType_> coeff) :
1351 _coeff(coeff)
1352 {
1353 }
1354
1367 Index set_coeff(Index degree, DataType_ coeff)
1368 {
1369 // check degree
1370 if(Index(_coeff.size()) <= degree)
1371 _coeff.resize(std::size_t(degree+1), DataType_(0));
1372
1373 // set coefficient
1374 _coeff.at(std::size_t(degree)) = coeff;
1375
1376 // return degree+1
1377 return Index(_coeff.size());
1378 }
1379 }; // class PolynomialFunction1D
1380
1382
1397 template<typename DataType_>
1398 class BazaraaShettyStatic
1399 {
1400 public:
1402 static DataType_ eval(DataType_ x, DataType_ y)
1403 {
1404 return Math::sqr(Math::sqr(x - DataType_(2))) + Math::sqr(x - DataType_(2)*y);
1405 }
1406
1408 static DataType_ der_x(DataType_ x, DataType_ y)
1409 {
1410 return DataType_(4)*(x - DataType_(2))*Math::sqr(x - DataType_(2)) + DataType_(2)*(x - DataType_(2)*y);
1411 }
1412
1414 static DataType_ der_y(DataType_ x, DataType_ y)
1415 {
1416 return DataType_(4)*(DataType_(2)*y - x);
1417 }
1418
1420 static DataType_ der_xx(DataType_ x, DataType_ DOXY(y))
1421 {
1422 return DataType_(12)*Math::sqr(x - DataType_(2)) + DataType_(2);
1423 }
1424
1426 static DataType_ der_yy(DataType_ DOXY(x), DataType_ DOXY(y))
1427 {
1428 return DataType_(8);
1429 }
1430
1432 static DataType_ der_xy(DataType_ DOXY(x), DataType_ DOXY(y))
1433 {
1434 return DataType_(-4);
1435 }
1436
1438 static DataType_ der_yx(DataType_ x, DataType_ y)
1439 {
1440 return der_xy(x,y);
1441 }
1442
1443 }; // class BazaraaShettyStatic<...>
1445
1447
1463 template<typename DataType_>
1464 class GoldsteinPriceStatic
1465 {
1466 public:
1468 static DataType_ eval(DataType_ x, DataType_ y)
1469 {
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)));
1471 }
1472
1474 static DataType_ der_x(DataType_ x, DataType_ y)
1475 {
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)));
1477 }
1478
1480 static DataType_ der_y(DataType_ x, DataType_ y)
1481 {
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)));
1483 }
1484
1486 static DataType_ der_xx(DataType_ x, DataType_ y)
1487 {
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))));
1489 }
1490
1492 static DataType_ der_yy(DataType_ x, DataType_ y)
1493 {
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)));
1495 }
1496
1498 static DataType_ der_xy(DataType_ x, DataType_ y)
1499 {
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)));
1501 }
1502
1504 static DataType_ der_yx(DataType_ x, DataType_ y)
1505 {
1506 return der_xy(x, y);
1507 }
1508
1509 }; // class GoldsteinPriceStatic<...>
1511
1528
1542
1544
1568 template<typename DataType_>
1569 class HimmelblauStatic
1570 {
1571 public:
1573 static DataType_ eval(DataType_ x, DataType_ y)
1574 {
1575 return Math::sqr(Math::sqr(x) + y - DataType_(11))
1576 + Math::sqr( x + Math::sqr(y) - DataType_(7));
1577 }
1578
1580 static DataType_ der_x(DataType_ x, DataType_ y)
1581 {
1582 return DataType_(4)*x*(Math::sqr(x) + y - DataType_(11)) + DataType_(2)*(x + Math::sqr(y) - DataType_(7));
1583 }
1584
1586 static DataType_ der_y(DataType_ x, DataType_ y)
1587 {
1588 return DataType_(2)* (Math::sqr(x) + y - DataType_(11)) + DataType_(4)*y*(x + Math::sqr(y) - DataType_(7));
1589 }
1590
1592 static DataType_ der_xx(DataType_ x, DataType_ y)
1593 {
1594 return DataType_(12)*Math::sqr(x) + DataType_(4)*y - DataType_(42);
1595 }
1596
1598 static DataType_ der_yy(DataType_ x, DataType_ y)
1599 {
1600 return DataType_(4)*x + DataType_(12)*Math::sqr(y) - DataType_(26);
1601 }
1602
1604 static DataType_ der_xy(DataType_ x, DataType_ y)
1605 {
1606 return DataType_(4)*(x + y);
1607 }
1608
1610 static DataType_ der_yx(DataType_ x, DataType_ y)
1611 {
1612 return der_xy(x,y);
1613 }
1614
1615 }; // class HimmelblauStatic<...>
1617
1640
1642 template<typename DataType_>
1643 class RosenbrockStatic
1644 {
1645 public:
1647 static DataType_ eval(DataType_ x, DataType_ y)
1648 {
1649 return DataType_(100)*Math::sqr( y - Math::sqr(x)) + Math::sqr(DataType_(1) - x);
1650 }
1651
1653 static DataType_ der_x(DataType_ x, DataType_ y)
1654 {
1655 return -DataType_(400)*x*(y - Math::sqr(x) ) + DataType_(2)*(x - DataType_(1));
1656 }
1657
1659 static DataType_ der_y(DataType_ x, DataType_ y)
1660 {
1661 return DataType_(200)*(y - Math::sqr(x));
1662 }
1663
1665 static DataType_ der_xx(DataType_ x, DataType_ y)
1666 {
1667 return DataType_(1200)*Math::sqr(x) - DataType_(400)*y + DataType_(2);
1668 }
1669
1671 static DataType_ der_yy(DataType_ DOXY(x), DataType_ DOXY(y))
1672 {
1673 return DataType_(200);
1674 }
1675
1677 static DataType_ der_xy(DataType_ x, DataType_ DOXY(y))
1678 {
1679 return -DataType_(400)*x;
1680 }
1681
1683 static DataType_ der_yx(DataType_ x, DataType_ y)
1684 {
1685 return der_xy(x,y);
1686 }
1687
1688 }; // class RosenbrockStatic<...>
1690
1706
1719 template<typename DataType_>
1721 public Analytic::Function
1722 {
1723 public:
1724 static constexpr int domain_dim = 2;
1726 static constexpr bool can_value = true;
1727
1728 protected:
1729 // coordinates of line segment
1730 DataType_ _x0, _y0, _x1, _y1;
1731 // maximum value
1732 DataType_ _vmax;
1733
1734 public:
1742 _x0(0.0), _y0(0.0), _x1(0.0), _y1(1.0), _vmax(1.0)
1743 {
1744 }
1745
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)
1760 {
1761 }
1762
1780 bool parse(const String& sbc)
1781 {
1782 auto li = sbc.find_first_of('(');
1783 auto ri = sbc.find_last_of(')');
1784 if((li == sbc.npos) || (ri == sbc.npos))
1785 return false;
1786
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)))
1789 return false;
1790
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;
1795
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;
1800
1801 if((sv.size() == std::size_t(3)) && !sv.back().parse(_vmax))
1802 return false;
1803
1804 return true;
1805 }
1806 }; // class ParProfileBase
1807
1816 template<typename DataType_>
1818 public ParProfileBase<DataType_>
1819 {
1820 public:
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;
1826
1827 using ParProfileBase<DataType_>::ParProfileBase;
1828
1829 template<typename Traits_>
1831 public Analytic::Function::Evaluator<Traits_>
1832 {
1833 protected:
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;
1839
1840 PointType _vo, _ve;
1841 DataType _den, _vmax;
1842
1843 public:
1844 explicit Evaluator(const ParProfileScalar& function)
1845 {
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);
1852 }
1853
1854 ValueType value(const PointType& point)
1855 {
1856 // project point onto line segment
1857 const DataType x = Math::clamp(Tiny::dot(point - _vo, _ve) * _den, DataType(0), DataType(1));
1858 // compute function value
1859 return _vmax * DataType(4) * x * (DataType(1) - x);
1860 }
1861
1862 GradientType gradient(const PointType& point)
1863 {
1864 // project point onto line segment
1865 const DataType x = Tiny::dot(point - _vo, _ve) * _den;
1866
1867 // Note: the gradient has a singularity at x=0 and x=1
1868 if((x < DataType(0)) || (x > DataType(1)))
1869 return GradientType::null();
1870
1871 return (_vmax * _den * DataType(4) * (DataType(1) - DataType(2)*x)) * _ve;
1872 }
1873
1874 HessianType hessian(const PointType& point)
1875 {
1876 // project point onto line segment
1877 const DataType x = Tiny::dot(point - _vo, _ve) * _den;
1878
1879 // Note: the hessian has a singularity at x=0 and x=1
1880 if((x < DataType(0)) || (x > DataType(1)))
1881 return HessianType::null();
1882
1883 HessianType hess;
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];
1888 return hess;
1889 }
1890 };
1891 }; // class ParProfileScalar
1892
1901 template<typename DataType_>
1903 public ParProfileBase<DataType_>
1904 {
1905 public:
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;
1911
1912 using ParProfileBase<DataType_>::ParProfileBase;
1913
1914 template<typename Traits_>
1916 public Analytic::Function::Evaluator<Traits_>
1917 {
1918 protected:
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;
1924
1925 PointType _vo, _ve, _vn;
1926 DataType _den, _vmax;
1927
1928 public:
1929 explicit Evaluator(const ParProfileVector& function)
1930 {
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);
1935 _vn[0] = _ve[1];
1936 _vn[1] = -_ve[0];
1937 _vn.normalize();
1938 _den = DataType(1) / Tiny::dot(_ve, _ve);
1939 _vmax = DataType(function._vmax);
1940 }
1941
1942 ValueType value(const PointType& point)
1943 {
1944 // project point onto line segment
1945 const DataType x = Math::clamp(Tiny::dot(point - _vo, _ve) * _den, DataType(0), DataType(1));
1946 // compute function value
1947 const DataType v = _vmax * DataType(4) * x * (DataType(1) - x);
1948 ValueType val;
1949 val[0] = _vn[0] * v;
1950 val[1] = _vn[1] * v;
1951 return val;
1952 }
1953
1954 GradientType gradient(const PointType& point)
1955 {
1956 // project point onto line segment
1957 const DataType x = Tiny::dot(point - _vo, _ve) * _den;
1958
1959 // Note: the gradient has a singularity at x=0 and x=1
1960 if((x < DataType(0)) || (x > DataType(1)))
1961 return GradientType::null();
1962
1963 const DataType v = _vmax * _den * DataType(4) * (DataType(1) - DataType(2)*x);
1964 GradientType grad;
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];
1969 return grad;
1970 }
1971
1972 HessianType hessian(const PointType& point)
1973 {
1974 // project point onto line segment
1975 const DataType x = Tiny::dot(point - _vo, _ve) * _den;
1976
1977 // Note: the hessian has a singularity at x=0 and x=1
1978 if((x < DataType(0)) || (x > DataType(1)))
1979 return HessianType::null();
1980
1981 const DataType v = -DataType(8) * _vmax * _den * _den;
1982 HessianType hess;
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];
1989 return hess;
1990 }
1991 };
1992 }; // class ParProfileVector
1993
1994 template<typename DT_>
1996 {
1997 public:
1998 static constexpr DT_ p = DT_(10);
1999
2000 static DT_ eval(DT_ x)
2001 {
2002 return (Math::exp(p) - Math::exp(p*x*x)) / (Math::exp(p) - DT_(1));
2003 }
2004
2005 static DT_ der_x(DT_ x)
2006 {
2007 return -DT_(2)*p*x*Math::exp(p*x*x)/(Math::exp(p)-DT_(1));
2008 }
2009
2010 static DT_ der_xx(DT_ x)
2011 {
2012 return -DT_(2)*p*Math::exp(p*x*x)*(DT_(2)*p*x*x+DT_(1))/(Math::exp(p)-DT_(1));
2013 }
2014 };
2015
2016 #ifdef FEAT_HAVE_HALFMATH
2017 template<>
2019 {
2020 public:
2021 typedef Half DT_;
2022 static DT_ eval(DT_ x)
2023 {
2024 return (Math::exp(DT_(10)) - Math::exp(DT_(10)*x*x)) / (Math::exp(DT_(10)) - DT_(1));
2025 }
2026
2027 static DT_ der_x(DT_ x)
2028 {
2029 return -DT_(2)*DT_(10)*x*Math::exp(DT_(10)*x*x)/(Math::exp(DT_(10))-DT_(1));
2030 }
2031
2032 static DT_ der_xx(DT_ x)
2033 {
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));
2035 }
2036 };
2037 #endif
2038
2040 template<typename DataType_>
2043
2055 template<int dim_>
2057
2074 template<typename DT_, int dim_>
2076 {
2077 public:
2079 typedef DT_ DataType;
2083 static constexpr int domain_dim = dim_;
2085 static constexpr bool can_value = true;
2087 static constexpr bool can_grad = true;
2089 static constexpr bool can_hess = true;
2092
2094 template<typename EvalTraits_>
2096 public Analytic::Function::Evaluator<EvalTraits_>
2097 {
2098 public:
2100 typedef typename EvalTraits_::DataType DataType;
2102 typedef typename EvalTraits_::PointType PointType;
2104 typedef typename EvalTraits_::ValueType ValueType;
2106 typedef typename EvalTraits_::GradientType GradientType;
2108 typedef typename EvalTraits_::HessianType HessianType;
2109
2110 private:
2115
2116 public:
2117 explicit Evaluator(const XYPlaneRotation& function) :
2119 _origin(function._origin)
2120 {
2121 }
2122
2123 ValueType value(const PointType& point)
2124 {
2125 ValueType val;
2126 val.format();
2127 val[0] = _angular_velocity*(-(point[1] - _origin[1]));
2128 val[1] = _angular_velocity*( (point[0] - _origin[0]));
2129 return val;
2130 }
2131
2132 GradientType gradient(const PointType& DOXY(point)) const
2133 {
2135 grad.format();
2136 grad[0][1] = -_angular_velocity;
2137 grad[1][0] = _angular_velocity;
2138 return grad;
2139 }
2140
2141 HessianType hessian(const PointType& DOXY(point)) const
2142 {
2143 return HessianType::null();
2144 }
2145
2146 }; // class XYPlaneRotation::Evaluator<...>
2147
2148 public:
2153
2154 public:
2165 explicit XYPlaneRotation(const DataType angular_velocity, const PointType& origin) :
2166 _angular_velocity(angular_velocity),
2167 _origin(origin)
2168 {
2169 }
2170 }; // class XYPlaneRotation
2171
2192 template<typename DT_, int dim_>
2194 {
2195 public:
2197 typedef DT_ DataType;
2201 static constexpr int domain_dim = dim_;
2203 static constexpr bool can_value = true;
2205 static constexpr bool can_grad = true;
2207 static constexpr bool can_hess = false;
2210
2212 template<typename EvalTraits_>
2214 public Analytic::Function::Evaluator<EvalTraits_>
2215 {
2216 public:
2218 typedef typename EvalTraits_::DataType DataType;
2220 typedef typename EvalTraits_::PointType PointType;
2222 typedef typename EvalTraits_::ValueType ValueType;
2224 typedef typename EvalTraits_::GradientType GradientType;
2226 typedef typename EvalTraits_::HessianType HessianType;
2227
2228 private:
2232 const std::vector<Tiny::Vector<DataType, 2>>& _range;
2233
2234 public:
2235 explicit Evaluator(const YZPlaneParabolic& function) :
2236 _fac(function._amplitude),
2237 _range(function._range)
2238
2239 {
2240 XASSERT(_range.size() == size_t(domain_dim-1));
2241
2242 for (int d(1); d < domain_dim; ++d)
2243 {
2244 _fac *= DataType(4)/Math::sqr(_range.at(std::size_t(d-1))[1]-_range.at(std::size_t(d-1))[0]);
2245 }
2246 }
2247
2248 ValueType value(const PointType& point)
2249 {
2250 ValueType val;
2251 val.format();
2252 val(0) = _fac;
2253
2254 for (int d(1); d < domain_dim; ++d)
2255 {
2256 val(0) *= (point[d] - _range.at(std::size_t(d-1))[0])*(_range.at(std::size_t(d-1))[1] - point[d]);
2257 }
2258
2259 return val;
2260 }
2261
2262 GradientType gradient(const PointType& point) const
2263 {
2265 grad.format();
2266 for(int d(1); d < domain_dim; ++d)
2267 {
2268 grad[d][0] = _fac*(_range.at(std::size_t(d-1))[0] + _range.at(std::size_t(d-1))[1] - DataType(2)*point(d));
2269
2270 for (int q(1); q < domain_dim; ++q)
2271 {
2272 if (q != 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]);
2274 }
2275 }
2276 return grad;
2277 }
2278
2279 HessianType hessian(const PointType& DOXY(point)) const
2280 {
2281 return HessianType::null();
2282 }
2283
2284 }; // class YZPlaneParabolic::Evaluator<...>
2285
2286 public:
2290 std::vector<Tiny::Vector<DataType, 2>> _range;
2291
2292 public:
2303 explicit YZPlaneParabolic(const DataType amplitude, const RangeType& range_y) :
2304 _amplitude(amplitude),
2305 _range(1)
2306 {
2307 _range.at(0) = range_y;
2308 }
2309
2323 explicit YZPlaneParabolic(const DataType amplitude, const RangeType& range_y, const RangeType& range_z) :
2324 _amplitude(amplitude),
2325 _range(2)
2326 {
2327 _range.at(0) = range_y;
2328 _range.at(1) = range_z;
2329 }
2330 }; // class YZPlaneParabolic
2331
2342 template<typename DT_, int dim_>
2344 {
2345 public:
2347 typedef DT_ DataType;
2351 static constexpr int domain_dim = dim_;
2353 static constexpr bool can_value = true;
2355 static constexpr bool can_grad = true;
2357 static constexpr bool can_hess = false;
2360
2362 template<typename EvalTraits_>
2364 public Analytic::Function::Evaluator<EvalTraits_>
2365 {
2366 public:
2368 typedef typename EvalTraits_::DataType DataType;
2370 typedef typename EvalTraits_::PointType PointType;
2372 typedef typename EvalTraits_::ValueType ValueType;
2374 typedef typename EvalTraits_::GradientType GradientType;
2376 typedef typename EvalTraits_::HessianType HessianType;
2377
2378 private:
2381
2382 public:
2383 explicit Evaluator(const SinYT0& function) :
2384 _t(function._t)
2385
2386 {
2387 XASSERT(_t >= DataType(0));
2388 }
2389
2390 ValueType value(const PointType& point)
2391 {
2392 ValueType val;
2393 val.format();
2394 val(0) = Math::sin(_t*point[1]);
2395 return val;
2396 }
2397
2398 GradientType gradient(const PointType& point) const
2399 {
2401 grad.format();
2402 grad[0][1] = _t*Math::cos(_t*point[1]);
2403 return grad;
2404 }
2405
2406 HessianType hessian(const PointType& DOXY(point)) const
2407 {
2408 return HessianType::null();
2409 }
2410
2411 }; // class SinYT0::Evaluator<...>
2412
2413 private:
2416
2417 public:
2422 explicit SinYT0(DataType t = DataType(0)) :
2423 _t(t)
2424 {
2425 }
2426
2427 void set_time(const DataType t)
2428 {
2429 _t = t;
2430 }
2431
2432 };
2433
2444 template<typename DT_, int dim_>
2446 {
2447 public:
2449 typedef DT_ DataType;
2453 static constexpr int domain_dim = dim_;
2455 static constexpr bool can_value = true;
2457 static constexpr bool can_grad = false;
2459 static constexpr bool can_hess = false;
2462
2464 template<typename EvalTraits_>
2466 public Analytic::Function::Evaluator<EvalTraits_>
2467 {
2468 public:
2470 typedef typename EvalTraits_::DataType DataType;
2472 typedef typename EvalTraits_::PointType PointType;
2474 typedef typename EvalTraits_::ValueType ValueType;
2476 typedef typename EvalTraits_::GradientType GradientType;
2478 typedef typename EvalTraits_::HessianType HessianType;
2479
2480 private:
2481 const DataType _t;
2482 const DataType _fac;
2483
2484 public:
2485 explicit Evaluator(const SinYT0StokesRhs& function) :
2486 _t(function._t),
2487 _fac(DataType(1)/function._reynolds)
2488
2489 {
2490 XASSERT(_t >= DataType(0));
2491 }
2492
2493 ValueType value(const PointType& point)
2494 {
2495 ValueType val;
2496 val.format();
2497 val(0) = point[1]*Math::cos(_t*point[1]) + _fac*Math::sqr(_t)*Math::sin(point[1]*_t);
2498 return val;
2499 }
2500
2501 GradientType gradient(const PointType& DOXY(point)) const
2502 {
2503 return GradientType::null();
2504 }
2505
2506 HessianType hessian(const PointType& DOXY(point)) const
2507 {
2508 return HessianType::null();
2509 }
2510
2511 }; // class SinYT0StokesRhs::Evaluator<...>
2512
2513 private:
2518
2519 public:
2524 explicit SinYT0StokesRhs(DataType reynolds, DataType t = DataType(0)) :
2525 _reynolds(reynolds),
2526 _t(t)
2527 {
2528 XASSERT(reynolds > DataType(0));
2529 }
2530
2531 void set_time(const DataType t)
2532 {
2533 _t = t;
2534 }
2535 };
2536
2547 template<typename DT_, int dim_>
2549 {
2550 public:
2552 typedef DT_ DataType;
2556 static constexpr int domain_dim = dim_;
2558 static constexpr bool can_value = true;
2560 static constexpr bool can_grad = true;
2562 static constexpr bool can_hess = false;
2565
2567 template<typename EvalTraits_>
2569 public Analytic::Function::Evaluator<EvalTraits_>
2570 {
2571 public:
2573 typedef typename EvalTraits_::DataType DataType;
2575 typedef typename EvalTraits_::PointType PointType;
2577 typedef typename EvalTraits_::ValueType ValueType;
2579 typedef typename EvalTraits_::GradientType GradientType;
2581 typedef typename EvalTraits_::HessianType HessianType;
2582
2583 private:
2586
2587 public:
2588 explicit Evaluator(const GuermondStokesSolPressure& function) :
2589 _t(function._t)
2590
2591 {
2592 XASSERT(_t >= DataType(0));
2593 }
2594
2595 ValueType value( const PointType& point)
2596 {
2597 ValueType val;
2598 val = Math::sin(point[0] - point[1] + _t);
2599 // To make it mean value 0 on [0,1]x[0,1]
2600 val -= (DataType(2)*Math::sin(_t) - Math::sin(DataType(1)+_t) - Math::sin(-DataType(1) + _t));
2601 return val;
2602 }
2603
2604 GradientType gradient(const PointType& point) const
2605 {
2607 grad.format();
2608 grad[0] = Math::cos(point[0] - point[1] + _t);
2609 grad[1] = -grad[0];
2610 return grad;
2611 }
2612
2613 HessianType hessian(const PointType& DOXY(point)) const
2614 {
2615 return HessianType::null();
2616 }
2617 }; // class GuermondStokesSolPressure::Evaluator<...>
2618
2619 private:
2622
2623 public:
2629 _t(t)
2630 {
2631 }
2632
2633 void set_time(const DataType t)
2634 {
2635 _t = t;
2636 }
2637
2638 };
2639
2650 template<typename DT_, int dim_>
2652 {
2653 public:
2655 typedef DT_ DataType;
2659 static constexpr int domain_dim = dim_;
2661 static constexpr bool can_value = true;
2663 static constexpr bool can_grad = true;
2665 static constexpr bool can_hess = false;
2668
2670 template<typename EvalTraits_>
2672 public Analytic::Function::Evaluator<EvalTraits_>
2673 {
2674 public:
2676 typedef typename EvalTraits_::DataType DataType;
2678 typedef typename EvalTraits_::PointType PointType;
2680 typedef typename EvalTraits_::ValueType ValueType;
2682 typedef typename EvalTraits_::GradientType GradientType;
2684 typedef typename EvalTraits_::HessianType HessianType;
2685
2686 private:
2689
2690 public:
2691 explicit Evaluator(const GuermondStokesSol& function) :
2692 _t(function._t)
2693 {
2694 XASSERT(_t >= DataType(0));
2695 }
2696
2697 ValueType value(const PointType& point)
2698 {
2699 ValueType val;
2700 val.format();
2701 val(0) = Math::sin(point[0] + _t)*Math::sin(point[1] + _t);
2702 val(1) = Math::cos(point[0] + _t)*Math::cos(point[1] + _t);
2703 return val;
2704 }
2705
2706 GradientType gradient(const PointType& point) const
2707 {
2709 grad.format();
2710
2711 grad[0][0] = Math::cos(point[0] + _t)*Math::sin(point[1] + _t);
2712 grad[0][1] = Math::sin(point[0] + _t)*Math::cos(point[1] + _t);
2713
2714 grad[1][0] = -Math::sin(point[0] + _t)*Math::cos(point[1] + _t);
2715 grad[1][1] = -Math::cos(point[0] + _t)*Math::sin(point[1] + _t);
2716 return grad;
2717 }
2718
2719 HessianType hessian(const PointType& DOXY(point)) const
2720 {
2721 return HessianType::null();
2722 }
2723
2724 }; // class GuermondStokesSol::Evaluator<...>
2725
2726 private:
2729
2730 public:
2736 _t(t)
2737 {
2738 }
2739
2740 void set_time(const DataType t)
2741 {
2742 _t = t;
2743 }
2744
2745 };
2746
2757 template<typename DT_, int dim_>
2759 {
2760 public:
2762 typedef DT_ DataType;
2766 static constexpr int domain_dim = dim_;
2768 static constexpr bool can_value = true;
2770 static constexpr bool can_grad = false;
2772 static constexpr bool can_hess = false;
2775
2777 template<typename EvalTraits_>
2779 public Analytic::Function::Evaluator<EvalTraits_>
2780 {
2781 public:
2783 typedef typename EvalTraits_::DataType DataType;
2785 typedef typename EvalTraits_::PointType PointType;
2787 typedef typename EvalTraits_::ValueType ValueType;
2789 typedef typename EvalTraits_::GradientType GradientType;
2791 typedef typename EvalTraits_::HessianType HessianType;
2792
2793 private:
2794 const DataType _t;
2795 const DataType _fac;
2796
2797 public:
2798 explicit Evaluator(const GuermondStokesSolRhs& function) :
2799 _t(function._t),
2800 _fac(DataType(1)/function._reynolds)
2801
2802 {
2803 XASSERT(_t >= DataType(0));
2804 }
2805
2806 ValueType value(const PointType& point)
2807 {
2808 ValueType val;
2809 val.format();
2810
2811 // Stationary
2812 //val(0) = _fac*DataType(2)*Math::sin(point[0]+_t)*Math::sin(point[1]+_t) + Math::cos(point[0]-point[1]+_t);
2813 //val(1) = _fac*DataType(2)*Math::cos(point[0]+_t)*Math::cos(point[1]+_t) - Math::cos(point[0]-point[1]+_t);
2814
2815 val(0) = Math::cos(point[0]+_t)*Math::sin(point[1]+_t) + Math::sin(point[0]+_t)*Math::cos(point[1]+_t)
2816 + _fac*DataType(2)*Math::sin(point[0]+_t)*Math::sin(point[1]+_t) + Math::cos(point[0]-point[1]+_t);
2817 val(1) = -Math::sin(point[0]+_t)*Math::cos(point[1]+_t) - Math::cos(point[0]+_t)*Math::sin(point[1]+_t)
2818 + _fac*DataType(2)*Math::cos(point[0]+_t)*Math::cos(point[1]+_t) - Math::cos(point[0]-point[1]+_t);
2819 return val;
2820 }
2821
2822 GradientType gradient(const PointType& DOXY(point)) const
2823 {
2824 return GradientType::null();
2825 }
2826
2827 HessianType hessian(const PointType& DOXY(point)) const
2828 {
2829 return HessianType::null();
2830 }
2831
2832 }; // class GuermondStokesSolRhs::Evaluator<...>
2833
2834 private:
2839
2840 public:
2845 explicit GuermondStokesSolRhs(DataType reynolds, DataType t = DataType(0)) :
2846 _reynolds(reynolds),
2847 _t(t)
2848 {
2849 XASSERT(reynolds > DataType(0));
2850 }
2851
2852 void set_time(const DataType t)
2853 {
2854 _t = t;
2855 }
2856 };
2857
2858
2872 {
2873 public:
2877 static constexpr int domain_dim = 3;
2879 static constexpr bool can_value = true;
2881 static constexpr bool can_grad = true;
2883 static constexpr bool can_hess = true;
2884
2886 template<typename EvalTraits_>
2888 public Analytic::Function::Evaluator<EvalTraits_>
2889 {
2890 public:
2892 typedef typename EvalTraits_::DataType DataType;
2894 typedef typename EvalTraits_::PointType PointType;
2896 typedef typename EvalTraits_::ValueType ValueType;
2898 typedef typename EvalTraits_::GradientType GradientType;
2900 typedef typename EvalTraits_::HessianType HessianType;
2901
2902 private:
2903 const DataType pi;
2904
2905 public:
2906 explicit Evaluator(const SphereSinBubbleFunction&) :
2907 pi(Math::pi<DataType>())
2908 {
2909 }
2910
2911 ValueType value(const PointType& point)
2912 {
2913 const DataType re = pi / point.norm_euclid();
2914 return Math::sin(re*point[0]) * Math::sin(re*point[1]) * Math::sin(re*point[2]);
2915 }
2916
2917 GradientType gradient(const PointType& point) const
2918 {
2919 const DataType x = point[0];
2920 const DataType y = point[1];
2921 const DataType z = point[2];
2922 const DataType re = DataType(1) / point.norm_euclid();
2923 const DataType cx = Math::cos(pi * re * x);
2924 const DataType cy = Math::cos(pi * re * y);
2925 const DataType cz = Math::cos(pi * re * z);
2926 const DataType sx = Math::sin(pi * re * x);
2927 const DataType sy = Math::sin(pi * re * y);
2928 const DataType sz = Math::sin(pi * re * z);
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);
2933 return grad;
2934 }
2935
2936 HessianType hessian(const PointType& point) const
2937 {
2938 const DataType x = point[0];
2939 const DataType y = point[1];
2940 const DataType z = point[2];
2941 const DataType di = Math::sqrt(x*x + y*y + z*z);
2942 const DataType re = DataType(1) / di;
2943 const DataType qo = DataType(1) / Math::cub(x*x + y*y + z*z);
2944 const DataType cx = Math::cos(pi * re * x);
2945 const DataType cy = Math::cos(pi * re * y);
2946 const DataType cz = Math::cos(pi * re * z);
2947 const DataType sx = Math::sin(pi * re * x);
2948 const DataType sy = Math::sin(pi * re * y);
2949 const DataType sz = Math::sin(pi * re * z);
2951 hess[0][0] = -pi*qo*(
2952 DataType(2)*cx*sy*cz*pi*x*y*y*z +
2953 DataType(2)*cx*sy*cz*pi*x*z*z*z +
2954 DataType(2)*cx*sz*cy*pi*x*y*y*y +
2955 DataType(2)*cx*sz*cy*pi*x*y*z*z +
2956 DataType(2)*sy*sz*sx*pi*y*y*z*z +
2957 -DataType(2)*sx*y*x*x*cy*sz*di +
2958 -DataType(2)*sx*y*pi*x*x*cy*z*cz +
2959 -DataType(2)*sx*sy*z*x*x*cz*di +
2960 DataType(3)*cx*sy*sz*x*di*y*y +
2961 DataType(3)*cx*sy*sz*x*di*z*z +
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 +
2966 sy*cz*sx*di*y*y*z +
2967 sy*cz*sx*di*z*z*z +
2968 sz*cy*sx*di*y*y*y +
2969 sz*cy*sx*di*y*z*z);
2970 hess[1][1] = -pi*qo*(
2971 DataType(2)*cx*sz*cy*pi*x*x*x*y +
2972 DataType(2)*cx*sz*cy*pi*x*y*z*z +
2973 DataType(2)*sx*sy*z*z*pi*x*x*sz +
2974 DataType(2)*sx*y*pi*x*x*cy*z*cz +
2975 DataType(2)*sx*cy*cz*pi*y*z*z*z +
2976 -DataType(2)*cx*sy*cz*pi*x*y*y*z +
2977 -DataType(2)*cx*sy*sz*x*di*y*y +
2978 -DataType(2)*sy*cz*sx*di*y*y*z +
2979 DataType(3)*sx*y*x*x*cy*sz*di +
2980 DataType(3)*sz*cy*sx*di*y*z*z +
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 +
2985 di*cx*sy*sz*x*x*x +
2986 cx*sy*sz*x*di*z*z +
2987 sx*sy*z*x*x*cz*di +
2988 sy*cz*sx*di*z*z*z);
2989 hess[2][2] = -pi*qo*(
2990 DataType(2)*cx*sy*cz*pi*x*x*x*z +
2991 DataType(2)*cx*sy*cz*pi*x*y*y*z +
2992 DataType(2)*sx*y*y*pi*x*x*sy*sz +
2993 DataType(2)*sx*y*pi*x*x*cy*z*cz +
2994 DataType(2)*sx*cy*cz*pi*y*y*y*z +
2995 -DataType(2)*cx*sy*sz*x*di*z*z +
2996 -DataType(2)*cx*sz*cy*pi*x*y*z*z +
2997 -DataType(2)*sz*cy*sx*di*y*z*z +
2998 DataType(3)*sx*sy*z*x*x*cz*di +
2999 DataType(3)*sy*cz*sx*di*y*y*z +
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 +
3004 di*cx*sy*sz*x*x*x +
3005 cx*sy*sz*x*di*y*y +
3006 sx*y*x*x*cy*sz*di +
3007 sz*cy*sx*di*y*y*y);
3008 hess[0][1] = hess[1][0] = pi*qo*(
3009 DataType(2)*y*y*pi*x*x*cx*cy*sz +
3010 DataType(2)*di*cx*sy*sz*x*x*y +
3011 DataType(2)*sx*y*y*x*cy*sz*di +
3012 DataType(3)*sx*sy*z*x*cz*y*di +
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);
3029 hess[0][2] = hess[2][0] = pi*qo*(
3030 DataType(2)*z*z*pi*x*x*cx*sy*cz +
3031 DataType(2)*sx*sy*z*z*x*cz*di +
3032 DataType(2)*di*cx*sy*sz*x*x*z +
3033 DataType(3)*sx*y*x*cy*sz*z*di +
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);
3050 hess[1][2] = hess[2][1] = pi*qo*(
3051 DataType(2)*sx*y*y*pi*z*z*cy*cz +
3052 DataType(2)*sx*sy*z*z*y*cz*di +
3053 DataType(2)*di*sz*sx*cy*y*y*z +
3054 DataType(3)*y*x*cx*sy*sz*z*di +
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);
3071 return hess;
3072 }
3073 }; // class SphereSinBubbleFunction::Evaluator<...>
3074 }; // class SphereSinBubbleFunction
3075
3090 public Analytic::Function
3091 {
3092 public:
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;
3098
3099 template<typename Traits_>
3101 public Analytic::Function::Evaluator<Traits_>
3102 {
3103 protected:
3104 typedef typename Traits_::DataType DataType;
3105 typedef typename Traits_::PointType PointType;
3106 typedef typename Traits_::ValueType ValueType;
3107 typedef typename Traits_::GradientType GradientType;
3108
3109 public:
3110 explicit Evaluator(const StandingVortexFunction2D&)
3111 {
3112 }
3113
3114 ValueType value(const PointType& point) const
3115 {
3116 ValueType val(DataType(0));
3117 const DataType x = point[0] - DataType(0.5);
3118 const DataType y = point[1] - DataType(0.5);
3119 const DataType r = Math::sqrt(x*x + y*y);
3120 if (r < DataType(0.2))
3121 {
3122 val[0] = DataType(5)*y;
3123 val[1] = -DataType(5)*x;
3124 }
3125 else if (r < DataType(0.4))
3126 {
3127 val[0] = ( DataType(2)/r - DataType(5))*y;
3128 val[1] = (-DataType(2)/r + DataType(5))*x;
3129 }
3130 return val;
3131 }
3132
3133 GradientType gradient(const PointType& point) const
3134 {
3135 GradientType grad(DataType(0));
3136 const DataType x = point[0] - DataType(0.5);
3137 const DataType y = point[1] - DataType(0.5);
3138 const DataType r = Math::sqrt(x*x + y*y);
3139 if (r < DataType(0.2))
3140 {
3141 grad[0][1] = DataType(5);
3142 grad[1][0] = -DataType(5);
3143 }
3144 else if (r < DataType(0.4))
3145 {
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;
3151 }
3152 return grad;
3153 }
3154 };
3155 }; // class StandingVortexFunction2D
3156
3170 template<typename DT_>
3172 {
3173 public:
3175 typedef DT_ DataType;
3179 static constexpr int domain_dim = 2;
3181 static constexpr bool can_value = true;
3183 static constexpr bool can_grad = true;
3185 static constexpr bool can_hess = true;
3188
3193
3204 nu(nu_),
3205 cur_t(t_)
3206 {
3207 }
3208
3210 template<typename EvalTraits_>
3212 public Analytic::Function::Evaluator<EvalTraits_>
3213 {
3214 public:
3216 typedef typename EvalTraits_::DataType DataType;
3218 typedef typename EvalTraits_::PointType PointType;
3220 typedef typename EvalTraits_::ValueType ValueType;
3222 typedef typename EvalTraits_::GradientType GradientType;
3224 typedef typename EvalTraits_::HessianType HessianType;
3225
3226 private:
3227 const DataType _pi;
3228 const DataType _fac;
3229
3230 public:
3231 explicit Evaluator(const TaylorGreenVortexVelo2D& function) :
3232 _pi(Math::pi<DataType>()),
3233 _fac(Math::exp(-DataType(2)*_pi*_pi*function.nu*function.cur_t))
3234 {
3235 }
3236
3237 ValueType value(const PointType& point)
3238 {
3239 ValueType val = ValueType::null();
3240 val[0] = +_fac * Math::sin(_pi*point[0]) * Math::cos(_pi*point[1]);
3241 val[1] = -_fac * Math::cos(_pi*point[0]) * Math::sin(_pi*point[1]);
3242 return val;
3243 }
3244
3245 GradientType gradient(const PointType& point) const
3246 {
3247 GradientType grad = GradientType::null();
3248 grad[0][0] = +_fac * _pi * Math::cos(_pi*point[0]) * Math::cos(_pi*point[1]);
3249 grad[0][1] = -_fac * _pi * Math::sin(_pi*point[0]) * Math::sin(_pi*point[1]);
3250 grad[1][0] = +_fac * _pi * Math::sin(_pi*point[0]) * Math::sin(_pi*point[1]);
3251 grad[1][1] = -_fac * _pi * Math::cos(_pi*point[0]) * Math::cos(_pi*point[1]);
3252 return grad;
3253 }
3254
3255 HessianType hessian(const PointType& point) const
3256 {
3257 HessianType hess = HessianType::null();
3258 hess[0][0][0] = -_fac * _pi*_pi * Math::sin(_pi*point[0]) * Math::cos(_pi*point[1]);
3259 hess[0][0][1] = -_fac * _pi*_pi * Math::cos(_pi*point[0]) * Math::sin(_pi*point[1]);
3260 hess[0][1][0] = -_fac * _pi*_pi * Math::cos(_pi*point[0]) * Math::sin(_pi*point[1]);
3261 hess[0][1][1] = -_fac * _pi*_pi * Math::sin(_pi*point[0]) * Math::cos(_pi*point[1]);
3262 hess[1][0][0] = +_fac * _pi*_pi * Math::cos(_pi*point[0]) * Math::sin(_pi*point[1]);
3263 hess[1][0][1] = +_fac * _pi*_pi * Math::sin(_pi*point[0]) * Math::cos(_pi*point[1]);
3264 hess[1][1][0] = +_fac * _pi*_pi * Math::sin(_pi*point[0]) * Math::cos(_pi*point[1]);
3265 hess[1][1][1] = +_fac * _pi*_pi * Math::cos(_pi*point[0]) * Math::sin(_pi*point[1]);
3266 return hess;
3267 }
3268 }; // class TaylorGreenVortexVelo::Evaluator<...>
3269 }; // class TaylorGreenVortexVelo<...>
3270
3283 template<typename DT_>
3285 {
3286 public:
3288 typedef DT_ DataType;
3292 static constexpr int domain_dim = 2;
3294 static constexpr bool can_value = true;
3296 static constexpr bool can_grad = true;
3298 static constexpr bool can_hess = false;
3301
3306
3317 nu(nu_),
3318 cur_t(t_)
3319 {
3320 }
3321
3323 template<typename EvalTraits_>
3325 public Analytic::Function::Evaluator<EvalTraits_>
3326 {
3327 public:
3329 typedef typename EvalTraits_::DataType DataType;
3331 typedef typename EvalTraits_::PointType PointType;
3333 typedef typename EvalTraits_::ValueType ValueType;
3335 typedef typename EvalTraits_::GradientType GradientType;
3337 typedef typename EvalTraits_::HessianType HessianType;
3338
3339 private:
3340 const DataType _pi;
3341 const DataType _fac;
3342
3343 public:
3344 explicit Evaluator(const TaylorGreenVortexPres2D& function) :
3345 _pi(Math::pi<DataType>()),
3346 _fac(Math::exp(-DataType(4)*_pi*_pi*function.nu*function.cur_t) * DataType(0.5))
3347 {
3348 }
3349
3350 ValueType value(const PointType& point)
3351 {
3352 return ValueType(_fac * (Math::sqr(Math::cos(_pi*point[0])) + Math::sqr(Math::cos(_pi*point[1])) - DataType(1)));
3353 }
3354
3355 GradientType gradient(const PointType& point) const
3356 {
3357 GradientType grad = GradientType::null();
3358 grad[0] = -DataType(2) * _pi * _fac * Math::sin(_pi*point[0]) * Math::cos(_pi*point[0]);
3359 grad[1] = -DataType(2) * _pi * _fac * Math::sin(_pi*point[1]) * Math::cos(_pi*point[1]);
3360 return grad;
3361 }
3362
3363 HessianType hessian(const PointType& DOXY(point)) const
3364 {
3365 return HessianType::null();
3366 }
3367 }; // class TaylorGreenVortexPres::Evaluator<...>
3368 }; // class TaylorGreenVortexPres<...>
3369
3383 template<typename DataType_, int dim_>
3385 public Analytic::Function
3386 {
3387 public:
3389 typedef DataType_ DataType;
3393 static constexpr int domain_dim = dim_;
3395 static constexpr bool can_value = true;
3397 static constexpr bool can_grad = true;
3399 static constexpr bool can_hess = true;
3402
3411
3427 explicit PoiseuillePipeFlow(PointType origin_, PointType axis_, DataType radius_ = DataType(1), DataType v_max_ = DataType(1)) :
3428 origin(origin_),
3429 axis(axis_),
3430 radius(radius_),
3431 v_max(v_max_)
3432 {
3433 }
3434
3436 template<typename EvalTraits_>
3438 public Analytic::Function::Evaluator<EvalTraits_>
3439 {
3440 public:
3442 typedef typename EvalTraits_::DataType DataType;
3444 typedef typename EvalTraits_::PointType PointType;
3446 typedef typename EvalTraits_::ValueType ValueType;
3448 typedef typename EvalTraits_::GradientType GradientType;
3450 typedef typename EvalTraits_::HessianType HessianType;
3451
3452 private:
3453 const PointType _origin;
3454 const PointType _axis;
3455 const DataType _v_max;
3456 const DataType _radius_s;
3457
3458 public:
3459 explicit Evaluator(const PoiseuillePipeFlow& function) :
3460 _origin(function.origin),
3461 _axis(PointType(function.axis).normalize()),
3462 _v_max(function.v_max),
3463 _radius_s(DataType(1) / Math::sqr(function.radius))
3464 {
3465 }
3466
3467 ValueType value(const PointType& point)
3468 {
3469 // compute ray to project point onto axis
3470 const PointType q = _origin + Tiny::dot(point - _origin, _axis) * _axis - point;
3471 // compute velocity based on distance to axis and in direction of axis
3472 return _v_max * (DataType(1) - q.norm_euclid_sqr()*_radius_s) * _axis;
3473 }
3474
3475 GradientType gradient(const PointType& point) const
3476 {
3477 // compute ray to project point onto axis
3478 const PointType q = _origin + Tiny::dot(point - _origin, _axis) * _axis - point;
3479 // compute gradient
3480 GradientType grad = GradientType::null();
3481 //grad.add_outer_product(_axis, Tiny::dot(_axis, q)*_axis - q, -DataType(2) * _radius_s * _v_max);
3482 grad.set_outer_product(_axis, q);
3483 grad.add_outer_product(_axis, _axis, -Tiny::dot(_axis, q));
3484 return DataType(2) * _radius_s * _v_max * grad;
3485 }
3486
3487 HessianType hessian(const PointType&) const
3488 {
3489 // seriously, getting this mumbo jumbo below right was mostly a lucky guess...
3490 GradientType grad_q = GradientType::null();
3491 grad_q.set_outer_product(_axis, _axis);
3492 grad_q.add_scalar_main_diag(-DataType(1));
3493 GradientType at_x_a;
3494 at_x_a.set_outer_product(_axis, _axis);
3495 HessianType hess = HessianType::null();
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));
3498 return DataType(2) * _radius_s * _v_max * hess;
3499 }
3500 }; // class PoiseuillePipeFlow::Evaluator<...>
3501 }; // class PoiseuillePipeFlow
3502
3515 template<typename DT_>
3517 {
3518 public:
3520 typedef DT_ DataType;
3524 static constexpr int domain_dim = 2;
3526 static constexpr bool can_value = true;
3528 static constexpr bool can_grad = true;
3530 static constexpr bool can_hess = true;
3533
3535 template<typename EvalTraits_>
3537 public Analytic::Function::Evaluator<EvalTraits_>
3538 {
3539 public:
3541 typedef typename EvalTraits_::DataType DataType;
3543 typedef typename EvalTraits_::PointType PointType;
3545 typedef typename EvalTraits_::ValueType ValueType;
3547 typedef typename EvalTraits_::GradientType GradientType;
3549 typedef typename EvalTraits_::HessianType HessianType;
3550
3551 public:
3552 explicit Evaluator(const RigidBodyVortexVelo2D&)
3553 {
3554 }
3555
3556 ValueType value(const PointType& point)
3557 {
3558 ValueType val = ValueType::null();
3559 val[0] = -point[1];
3560 val[1] = point[0];
3561 return val;
3562 }
3563
3564 GradientType gradient(const PointType& DOXY(point)) const
3565 {
3566 GradientType grad = GradientType::null();
3567 grad[0][1] = -DataType(1);
3568 grad[1][0] = DataType(1);
3569 return grad;
3570 }
3571
3572 HessianType hessian(const PointType& DOXY(point)) const
3573 {
3574 return HessianType::null();
3575 }
3576 }; // class RigidBodyVortexVelo2D::Evaluator<...>
3577 }; // class RigidBodyVortexVelo2D<...>
3578
3591 template<typename DT_>
3593 {
3594 public:
3596 typedef DT_ DataType;
3600 static constexpr int domain_dim = 2;
3602 static constexpr bool can_value = true;
3604 static constexpr bool can_grad = true;
3606 static constexpr bool can_hess = false;
3609
3611 template<typename EvalTraits_>
3613 public Analytic::Function::Evaluator<EvalTraits_>
3614 {
3615 public:
3617 typedef typename EvalTraits_::DataType DataType;
3619 typedef typename EvalTraits_::PointType PointType;
3621 typedef typename EvalTraits_::ValueType ValueType;
3623 typedef typename EvalTraits_::GradientType GradientType;
3625 typedef typename EvalTraits_::HessianType HessianType;
3626
3627 public:
3628 explicit Evaluator(const RigidBodyVortexPres2D&)
3629 {
3630 }
3631
3632 ValueType value(const PointType& point)
3633 {
3634 return DataType(0.5) * (point[0]*point[0] + point[1]*point[1]) - DataType(0.25);
3635 }
3636
3637 GradientType gradient(const PointType& point) const
3638 {
3639 GradientType grad = GradientType::null();
3640 grad[0] = point[0];
3641 grad[1] = point[1];
3642 return grad;
3643 }
3644
3645 HessianType hessian(const PointType& DOXY(point)) const
3646 {
3647 HessianType hess = HessianType::null();
3648 hess[0][0] = DataType(1);
3649 hess[1][1] = DataType(1);
3650 return hess;
3651 }
3652 }; // class RigidBodyVortexPres2D::Evaluator<...>
3653 }; // class RigidBodyVortexPres2D<...>
3654
3671 template<typename DT_>
3673 {
3674 public:
3676 typedef DT_ DataType;
3680 static constexpr int domain_dim = 2;
3682 static constexpr bool can_value = true;
3684 static constexpr bool can_grad = true;
3686 static constexpr bool can_hess = true;
3689
3691 template<typename EvalTraits_>
3693 public Analytic::Function::Evaluator<EvalTraits_>
3694 {
3695 public:
3697 typedef typename EvalTraits_::DataType DataType;
3699 typedef typename EvalTraits_::PointType PointType;
3701 typedef typename EvalTraits_::ValueType ValueType;
3703 typedef typename EvalTraits_::GradientType GradientType;
3705 typedef typename EvalTraits_::HessianType HessianType;
3706
3707 private:
3710
3711 public:
3712 explicit Evaluator(const SineRingVortexVelo2D&) :
3713 _pi2(DataType(2) * Math::pi<DataType>())
3714 {
3715 }
3716
3717 ValueType value(const PointType& point)
3718 {
3719 ValueType val = ValueType::null();
3720 const DataType d = point.norm_euclid();
3721 if(d < DataType(1E-3))
3722 return val;
3723
3724 const DataType s2pdi = Math::sin(_pi2 * d) / d;
3725
3726 val[0] = point[1]*s2pdi;
3727 val[1] = -point[0]*s2pdi;
3728 return val;
3729 }
3730
3731 GradientType gradient(const PointType& point) const
3732 {
3733 GradientType grad = GradientType::null();
3734 const DataType d = point.norm_euclid();
3735 if(d < DataType(1E-3))
3736 return grad;
3737
3738 const DataType x(point[0]), y(point[1]);
3739 const DataType di2 = DataType(1) / (d*d);
3740 const DataType s2pdi = Math::sin(_pi2 * d) / d;
3741 const DataType c2pdi2 = Math::cos(_pi2 * d) * di2;
3742
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;
3747 return grad;
3748 }
3749
3750 HessianType hessian(const PointType& point) const
3751 {
3752 HessianType hess = HessianType::null();
3753 const DataType d = point.norm_euclid();
3754 if(d < DataType(1E-3))
3755 return hess;
3756
3757 const DataType x(point[0]), y(point[1]);
3758 const DataType di2 = DataType(1) / (d*d);
3759 const DataType s2pdi3 = Math::sin(_pi2 * d) * di2 / d;
3760 const DataType c2pdi2 = Math::cos(_pi2 * d) * di2;
3761 const DataType t3 = DataType(3);
3762
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;
3764 hess[0][0][1] =
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;
3768 hess[1][0][1] =
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;
3771 return hess;
3772 }
3773 }; // class SineRingVortexVelo2D::Evaluator<...>
3774 }; // class SineRingVortexVelo2D<...>
3775
3792 template<typename DT_>
3794 {
3795 public:
3797 typedef DT_ DataType;
3801 static constexpr int domain_dim = 2;
3803 static constexpr bool can_value = true;
3805 static constexpr bool can_grad = true;
3807 static constexpr bool can_hess = false;
3810
3812 DataType mean_shift = DataType(1) / Math::sqr(Math::pi<DataType>());
3813
3815 template<typename EvalTraits_>
3817 public Analytic::Function::Evaluator<EvalTraits_>
3818 {
3819 public:
3821 typedef typename EvalTraits_::DataType DataType;
3823 typedef typename EvalTraits_::PointType PointType;
3825 typedef typename EvalTraits_::ValueType ValueType;
3827 typedef typename EvalTraits_::GradientType GradientType;
3829 typedef typename EvalTraits_::HessianType HessianType;
3830
3831 private:
3833 const DataType _pi2, _spi;
3834
3835 public:
3836 explicit Evaluator(const SineRingVortexPres2D& func) :
3837 _pi2(DataType(2) * Math::pi<DataType>()),
3838 _spi(func.mean_shift)
3839 {
3840 }
3841
3842 ValueType value(const PointType& point)
3843 {
3844 const DataType d = point.norm_euclid();
3845 return -Math::sin(_pi2*d) / _pi2 - _spi;
3846 }
3847
3848 GradientType gradient(const PointType& point) const
3849 {
3850 GradientType grad = GradientType::null();
3851 const DataType d = point.norm_euclid();
3852 if(d < DataType(1E-3))
3853 return grad;
3854
3855 const DataType c2pdi = Math::cos(_pi2 * d) / d;
3856
3857 grad[0] = -point[0]*c2pdi;
3858 grad[1] = -point[1]*c2pdi;
3859 return grad;
3860 }
3861
3862 HessianType hessian(const PointType& DOXY(point)) const
3863 {
3864 return HessianType::null();
3865 }
3866 }; // class SineRingVortexPres2D::Evaluator<...>
3867 }; // class SineRingVortexPres2D<...>
3868
3881 template<typename DT_>
3883 {
3884 public:
3886 typedef DT_ DataType;
3890 static constexpr int domain_dim = 2;
3892 static constexpr bool can_value = true;
3894 static constexpr bool can_grad = false;
3896 static constexpr bool can_hess = false;
3899
3901 DataType nu, beta, theta, sigma;
3902
3918 explicit SineRingVortexRHS2D(DataType nu_ = DataType(1), DataType beta_ = DataType(0), DataType theta_ = DataType(0), DataType sigma_ = DataType(1)) :
3919 nu(nu_),
3920 beta(beta_),
3921 theta(theta_),
3922 sigma(sigma_)
3923 {
3924 }
3925
3927 template<typename EvalTraits_>
3929 public Analytic::Function::Evaluator<EvalTraits_>
3930 {
3931 public:
3933 typedef typename EvalTraits_::DataType DataType;
3935 typedef typename EvalTraits_::PointType PointType;
3937 typedef typename EvalTraits_::ValueType ValueType;
3939 typedef typename EvalTraits_::GradientType GradientType;
3941 typedef typename EvalTraits_::HessianType HessianType;
3942
3943 private:
3944 const DataType _pi2, _nu, _beta, _theta, _sigma;
3945
3946 public:
3947 explicit Evaluator(const SineRingVortexRHS2D& function) :
3948 _pi2(DataType(2) * Math::pi<DataType>()),
3949 _nu(function.nu),
3950 _beta(function.beta),
3951 _theta(function.theta),
3952 _sigma(function.sigma)
3953 {
3954 }
3955
3956 ValueType value(const PointType& point)
3957 {
3958 ValueType val = ValueType::null();
3959 const DataType d = point.norm_euclid();
3960 if(d < DataType(1E-3))
3961 return val;
3962
3963 const DataType x(point[0]), y(point[1]);
3964 const DataType q = DataType(1) / d;
3965 const DataType s2pdq = Math::sin(_pi2 * d) * q;
3966 const DataType c2pdq = Math::cos(_pi2 * d) * q;
3967
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;
3970 return val;
3971 }
3972 }; // class SineRingVortexRHS2D::Evaluator<...>
3973 }; // class SineRingVortexRHS2D<...>
3974
3987 template<int dim_, int a_ = 2>
3989 public Analytic::Function
3990 {
3991 public:
3992 static_assert(a_ >= 1, "parameter a_ must be >= 1");
3993
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;
3999
4000 template<typename Traits_>
4002 public Analytic::Function::Evaluator<Traits_>
4003 {
4004 public:
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;
4010
4011 const DataType sa;
4012
4013 explicit Evaluator(const SphereCapFunction&) :
4014 sa(Math::sqrt(DataType(a_) - DataType(1)))
4015 {
4016 }
4017
4018 ValueType value(const PointType& point) const
4019 {
4020 return Math::sqrt(DataType(a_) - point.norm_euclid_sqr()) - sa;
4021 }
4022
4023 GradientType gradient(const PointType& point) const
4024 {
4025 return (DataType(-1) / Math::sqrt(DataType(a_) - point.norm_euclid_sqr())) * point;
4026 }
4027
4028 HessianType hessian(const PointType& point) const
4029 {
4030 const DataType s = DataType(1) / Math::cub(Math::sqrt(DataType(a_) - point.norm_euclid_sqr()));
4031 //const DataType s = DataType(1) / Math::pow(a - point.norm_euclid_sqr(), DataType(1.5));
4032 HessianType hess;
4033 hess.format();
4034 for(int i = 0; i < dim_; ++i)
4035 {
4036 for(int j = 0; j < dim_; ++j)
4037 {
4038 if(i == j)
4039 {
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;
4043 }
4044 else
4045 {
4046 hess[i][j] = -point[i] * point[j] * s;
4047 }
4048 }
4049 }
4050 return hess;
4051 }
4052 }; // class SphereCapFunction::Evaluator<...>
4053 }; // class SphereCapFunction
4054
4082 template<typename DT_>
4084 public Analytic::Function
4085 {
4086 public:
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;
4093
4094 private:
4095 Tiny::Vector<DataType, 2> base_point;
4096 DataType alpha, k, offset;
4097
4098 public:
4099 CornerSingularity2D() = delete;
4100
4101 CornerSingularity2D(const Tiny::Vector<DT_, 2>& center, Tiny::Vector<DT_, 2> v_1, Tiny::Vector<DT_, 2> v_2, DT_ alpha_ = DT_(1.)) :
4102 base_point(center),
4103 alpha(alpha_)
4104 {
4105 ASSERTM((v_1.norm_euclid_sqr() > Math::eps<DataType>()) && (v_2.norm_euclid_sqr() > Math::eps<DataType>()), "Spanvectors are zero length");
4106 k = Math::pi<DataType>() / Tiny::calculate_opening_angle(v_1,v_2);
4107 offset = Tiny::calculate_opening_angle(Tiny::Vector<DT_, 2>{DataType(1.0), DataType(0.)}, v_1);
4108 }
4109
4110 template<typename Traits_>
4112 public Analytic::Function::Evaluator<Traits_>
4113 {
4114 public:
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;
4120
4121
4122 Tiny::Vector<DataType, 2> base_point;
4123 const DataType alpha, k, offset;
4124 const DataType eps;
4125
4126 explicit Evaluator(const CornerSingularity2D& func) :
4127 base_point(func.base_point),
4128 alpha(func.alpha),
4129 k(func.k),
4130 offset(func.offset),
4131 eps(Math::eps<DataType>())
4132 {
4133 }
4134
4135 ValueType value(const PointType& point) const
4136 {
4137 //first calculate radius
4138 const DataType x = point[0] - base_point[0];
4139 const DataType y = point[1] - base_point[1];
4140 const DataType r = Math::sqrt(Math::sqr(x) + Math::sqr(y));
4141 //TODO: Set x_rel to zero if r is very small?? <- Better conditioning?
4142 const DataType x_rel = r > DataType(10.)* eps ? x/r : DataType(0);
4143 DataType phi = Math::acos(x_rel);
4144 phi = (y >= DataType(0)) ? phi : DataType(2)*Math::pi<DataType>()-phi;
4145 return alpha * Math::pow(r, k) * Math::sin(k * (phi - offset));
4146 }
4147
4148 GradientType gradient(const PointType& point) const
4149 {
4150 const DataType x = point[0] - base_point[0];
4151 const DataType y = point[1] - base_point[1];
4152 const DataType r = Math::sqrt(Math::sqr(x) + Math::sqr(y));
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);
4155 //Note: While in practice we use a rotated coordinate system to express our polar-coordinate
4156 //based function, we have to use the "real" cos(phi) and sin(phi) values
4157 //for our base transformation, which are conveniently x_rel and y_rel
4158 //TODO: This could be badly conditioned for r -> 0, have to test this...
4159 DataType phi = Math::acos(x_rel);
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));
4164 GradientType grad;
4165 grad[0] = alpha * ex * (x_rel * sval - y_rel * cval);
4166 grad[1] = alpha * ex * (y_rel * sval + x_rel * cval);
4167 return grad;
4168 }
4169
4170 HessianType hessian(const PointType& point) const
4171 {
4172 const DataType x = point[0] - base_point[0];
4173 const DataType y = point[1] - base_point[1];
4174 const DataType r = Math::sqrt(Math::sqr(x) + Math::sqr(y));
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);
4177 DataType phi = Math::acos(x_rel);
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));
4182 HessianType hess;
4183 hess[0][0] = alpha * ex * ((Math::sqr(x_rel) - Math::sqr(y_rel)) * sval - DataType(2) * x_rel * y_rel * cval);
4184 hess[1][1] = -hess[0][0];
4185 hess[0][1] = hess[1][0] = alpha * ex * (DataType(2) * y_rel * x_rel * sval + (Math::sqr(x_rel) - Math::sqr(y_rel)) * cval);
4186 return hess;
4187 }
4188 }; // class CornerSingularity2D::Evaluator<...>
4189 }; // CornerSingularity2D
4190
4192 template<typename DT_>
4194 public Analytic::Function
4195 {
4196 public:
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;
4203
4204 private:
4205 DataType alpha, k;
4206
4207 public:
4208 CornerSingularity2DRadial() = delete;
4209
4210 CornerSingularity2DRadial(DT_ theta_, DT_ alpha_ = DT_(1.)) :
4211 alpha(alpha_),
4212 k(Math::pi<DataType>() / theta_)
4213 {}
4214
4216 CornerSingularity2DRadial(const Tiny::Vector<DT_, 2>& vec_r, const Tiny::Vector<DT_, 2>& vec_l, DT_ alpha_ = DT_(1.)) :
4217 alpha(alpha_),
4218 k(Math::pi<DataType>() / Math::calc_opening_angle(vec_r[0], vec_r[1], vec_l[0], vec_l[1]))
4219 {}
4220
4221 template<typename Traits_>
4223 public Analytic::Function::Evaluator<Traits_>
4224 {
4225 public:
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;
4231
4232
4233 const DataType alpha, k;
4234
4235 explicit Evaluator(const CornerSingularity2DRadial& func) :
4236 alpha(func.alpha),
4237 k(func.k)
4238 {
4239 }
4240
4241 ValueType value(const PointType& point) const
4242 {
4243 return alpha * Math::pow(point[0], k) * Math::sin(k * point[1]);
4244 }
4245
4246 GradientType gradient(const PointType& point) const
4247 {
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]);
4251 GradientType grad;
4252 grad[0] = alpha * ex * sval;
4253 grad[1] = alpha * ex * cval * point[0];
4254 return grad;
4255 }
4256
4257 HessianType hessian(const PointType& point) const
4258 {
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]);
4262 HessianType hess;
4263 hess[0][0] = alpha * ex * (k-DataType(1)) * sval;
4264 hess[1][1] = - alpha * ex * Math::sqr(point[0]) * k * sval;
4265 hess[0][1] = hess[1][0] = alpha * ex * k * point[0] * cval;
4266 return hess;
4267 }
4268 }; // class CornerSingularity2DRadial::Evaluator<...>
4269
4270 }; // class CornerSingularity2DRadial
4271
4272 template<typename DT_>
4274
4287 template<typename DT_>
4289 {
4290 public:
4292 typedef DT_ DataType;
4296 static constexpr int domain_dim = 2;
4298 static constexpr bool can_value = true;
4300 static constexpr bool can_grad = true;
4302 static constexpr bool can_hess = true;
4305
4307 template<typename EvalTraits_>
4309 public Analytic::Function::Evaluator<EvalTraits_>
4310 {
4311 public:
4313 typedef typename EvalTraits_::DataType DataType;
4315 typedef typename EvalTraits_::PointType PointType;
4317 typedef typename EvalTraits_::ValueType ValueType;
4319 typedef typename EvalTraits_::GradientType GradientType;
4321 typedef typename EvalTraits_::HessianType HessianType;
4322
4323 public:
4324 explicit Evaluator(const FrankesFunction&)
4325 {
4326 }
4327
4328 ValueType value(const PointType& point)
4329 {
4330 const DataType x = point[0];
4331 const DataType y = point[1];
4332
4333 DataType val = (DataType(3) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(4) - Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) / DataType(5) +(DataType(3) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) -
4334 Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(4) + Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) / DataType(2);
4335
4336 return val;
4337 }
4338
4339 GradientType gradient(const PointType& point) const
4340 {
4342 const DataType x = point[0];
4343 const DataType y = point[1];
4344 grad.format();
4345 grad[0] = (Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * x - DataType(72))) / DataType(5) -(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(9))) / DataType(4) -
4346 (Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2))) / DataType(2) -(DataType(3) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) /
4347 DataType(10)) *((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(4);
4348 grad[1] = (Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * y - DataType(126))) / DataType(5) -(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) *((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) -
4349 (Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(DataType(27) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) /
4350 DataType(10)))) / DataType(40);
4351 return grad;
4352 }
4353
4354 HessianType hessian(const PointType& point) const
4355 {
4357 const DataType x = point[0];
4358 const DataType y = point[1];
4359 hess.format();
4360 hess[0][0] = (DataType(162) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))))) / DataType(5) -(DataType(243) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(98) -(DataType(243) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) /
4361 DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(8) -(DataType(81) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)))) / DataType(4) +(DataType(3) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) /
4362 DataType(49) - DataType(1) / DataType(10)) * Math::sqr((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(4) +(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) * Math::sqr((DataType(81) * x) / DataType(2) - DataType(9))) / DataType(4) +(Math::exp(-
4363 Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) * Math::sqr((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2))) / DataType(2) -(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) * Math::sqr(DataType(162) * x - DataType(72))) / DataType(5);
4364 hess[0][1] = hess[1][0] = (DataType(27) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)) *((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(40) +(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) /
4365 DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(9)) *((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) +(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2)) *((DataType(81) *
4366 y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * x - DataType(72)) *(DataType(162) * y - DataType(126))) / DataType(5);
4367 hess[1][1] = (DataType(243) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(400) +(DataType(162) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))))) / DataType(5) -(DataType(243) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) /
4368 DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(8) -(DataType(81) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)))) / DataType(4) +(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y -
4369 DataType(2)) / DataType(4)) * Math::sqr((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) +(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) * Math::sqr((DataType(81) * y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(Math::exp(- Math::sqr(DataType(9) * x -
4370 DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) * Math::sqr(DataType(162) * y - DataType(126))) / DataType(5);
4371 return hess;
4372 }
4373
4374 }; // class FrankesFunction::Evaluator<...>
4375
4376 public:
4377 explicit FrankesFunction() = default;
4378 }; // class FrankesFunction
4379
4392 template<typename DT_>
4394 {
4395 public:
4397 typedef DT_ DataType;
4401 static constexpr int domain_dim = 3;
4403 static constexpr bool can_value = true;
4405 static constexpr bool can_grad = true;
4407 static constexpr bool can_hess = true;
4410
4412 template<typename EvalTraits_>
4414 public Analytic::Function::Evaluator<EvalTraits_>
4415 {
4416 public:
4418 typedef typename EvalTraits_::DataType DataType;
4420 typedef typename EvalTraits_::PointType PointType;
4422 typedef typename EvalTraits_::ValueType ValueType;
4424 typedef typename EvalTraits_::GradientType GradientType;
4426 typedef typename EvalTraits_::HessianType HessianType;
4427
4428 public:
4429 explicit Evaluator(const Frankes3DVariantFunction&)
4430 {
4431 }
4432
4433 ValueType value(const PointType& point)
4434 {
4435 const DataType x = point[0];
4436 const DataType y = point[1];
4437 const DataType z = point[2];
4438
4439 DataType val = (DataType(3) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(4) - Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) / DataType(5) +(DataType(3) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) -
4440 Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(4) + Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) / DataType(2);
4441 val *= Math::exp(-Math::sqr(DataType(2)*z-DataType(0.4)));
4442
4443 return val;
4444 }
4445
4446 GradientType gradient(const PointType& point) const
4447 {
4449 const DataType x = point[0];
4450 const DataType y = point[1];
4451 const DataType z = point[2];
4452
4453 const DataType franks_val = (DataType(3) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(4) - Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) / DataType(5) +(DataType(3) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) -
4454 Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(4) + Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) / DataType(2);
4455
4456
4457 const DataType zexp = Math::exp(-Math::sqr(DataType(2)*z-DataType(0.4)));
4458 const DataType dzexp = -DataType(4)*(DataType(2)*z - DataType(0.4)) * zexp;
4459
4460 grad.format();
4461 grad[0] = zexp * ((Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * x - DataType(72))) / DataType(5) -(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(9))) / DataType(4) -
4462 (Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2))) / DataType(2) -(DataType(3) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) /
4463 DataType(10)) *((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(4));
4464 grad[1] = zexp * ((Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * y - DataType(126))) / DataType(5) -(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) *((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) -
4465 (Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(DataType(27) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) /
4466 DataType(10)))) / DataType(40));
4467 grad[2] = dzexp * franks_val;
4468 return grad;
4469 }
4470
4471 HessianType hessian(const PointType& point) const
4472 {
4474 const DataType x = point[0];
4475 const DataType y = point[1];
4476 const DataType z = point[2];
4477 const DataType zexp = Math::exp(-Math::sqr(DataType(2)*z-DataType(0.4)));
4478 const DataType dzexp = -DataType(4)*(DataType(2)*z - DataType(0.4)) * zexp;
4479 const DataType franks_val = (DataType(3) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(4) - Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) / DataType(5) +(DataType(3) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) -
4480 Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(4) + Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) / DataType(2);
4481 hess.format();
4482 hess[0][0] = zexp * ((DataType(162) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))))) / DataType(5) -(DataType(243) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(98) -(DataType(243) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) /
4483 DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(8) -(DataType(81) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)))) / DataType(4) +(DataType(3) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) /
4484 DataType(49) - DataType(1) / DataType(10)) * Math::sqr((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(4) +(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) * Math::sqr((DataType(81) * x) / DataType(2) - DataType(9))) / DataType(4) +(Math::exp(-
4485 Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) * Math::sqr((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2))) / DataType(2) -(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) * Math::sqr(DataType(162) * x - DataType(72))) / DataType(5));
4486 hess[0][1] = hess[1][0] = zexp * ((DataType(27) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)) *((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(40) +(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) /
4487 DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(9)) *((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) +(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2)) *((DataType(81) *
4488 y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * x - DataType(72)) *(DataType(162) * y - DataType(126))) / DataType(5));
4489 hess[1][1] = zexp * ((DataType(243) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) / DataType(10)))) / DataType(400) +(DataType(162) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))))) / DataType(5) -(DataType(243) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) /
4490 DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)))) / DataType(8) -(DataType(81) *(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)))) / DataType(4) +(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y -
4491 DataType(2)) / DataType(4)) * Math::sqr((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) +(Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) * Math::sqr((DataType(81) * y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(Math::exp(- Math::sqr(DataType(9) * x -
4492 DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) * Math::sqr(DataType(162) * y - DataType(126))) / DataType(5));
4493 hess[0][2] = hess[2][0] = dzexp * ((Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * x - DataType(72))) / DataType(5) -(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(9))) / DataType(4) -
4494 (Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * x) / DataType(2) - DataType(63) / DataType(2))) / DataType(2) -(DataType(3) * Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) /
4495 DataType(10)) *((DataType(162) * x) / DataType(49) + DataType(18) / DataType(49))) / DataType(4));
4496 hess[1][2] = hess[2][1] = dzexp * ((Math::exp(- Math::sqr(DataType(9) * x - DataType(4)) - Math::sqr(DataType(9) * y - DataType(7))) *(DataType(162) * y - DataType(126))) / DataType(5) -(DataType(3) * Math::exp(- Math::sqr(DataType(9) * x - DataType(2)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(2)) / DataType(4)) *((DataType(81) * y) / DataType(2) - DataType(9))) / DataType(4) -
4497 (Math::exp(- Math::sqr(DataType(9) * x - DataType(7)) / DataType(4) - Math::sqr(DataType(9) * y - DataType(3)) / DataType(4)) *((DataType(81) * y) / DataType(2) - DataType(27) / DataType(2))) / DataType(2) -(DataType(27) *(Math::exp(-(DataType(9) * y) / DataType(10) - Math::sqr(DataType(9) * x + DataType(1)) / DataType(49) - DataType(1) /
4498 DataType(10)))) / DataType(40));
4499 hess[2][2] = franks_val * (Math::sqr(DataType(4)*(DataType(2)*z - DataType(0.4))) - DataType(8)) * zexp;
4500 return hess;
4501 }
4502
4503 }; // class Frankes3DVariantFunction::Evaluator<...>
4504
4505 public:
4506 explicit Frankes3DVariantFunction() = default;
4507 }; // class FrankesFunction
4508
4531 template<int dim_, typename DataType_>
4533 public Analytic::Function
4534 {
4535 public:
4536 static_assert((1 <= dim_) && (dim_ <= 3), "harmonic shell function is only implemented in 1D, 2D and 3D");
4537
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;
4543
4545
4547 template<typename EvalTraits_>
4549 public Analytic::Function::Evaluator<EvalTraits_>
4550 {
4551 public:
4553 typedef typename EvalTraits_::DataType DataType;
4555 typedef typename EvalTraits_::PointType PointType;
4557 typedef typename EvalTraits_::ValueType ValueType;
4559 typedef typename EvalTraits_::GradientType GradientType;
4561 typedef typename EvalTraits_::HessianType HessianType;
4562
4563 private:
4566 const DataType _eps;
4567 const DataType _ln2; // = ln(2)
4568 const DataType _i2ln2; // = 1 /(2*ln(2))
4569
4570 public:
4572 explicit Evaluator(const HarmonicShellFunction& function) :
4573 _origin(function._origin),
4574 _eps(Math::eps<DataType>()),
4575 _ln2(Math::log(DataType(2))),
4576 _i2ln2(DataType(0.5)/_ln2)
4577 {
4578 }
4579
4580 ValueType value(const PointType& point) const
4581 {
4582 if constexpr (dim_ == 1)
4583 return DataType(3) - DataType(2) * Math::abs(point[0] - _origin[0]);
4584 else if constexpr(dim_ == 2)
4585 return DataType(1) - _i2ln2 * Math::log((point - _origin).norm_euclid_sqr());
4586 else if constexpr(dim_ == 3)
4587 return DataType(1) / (point - _origin).norm_euclid();
4588 else
4589 return DataType(0);
4590 }
4591
4592 GradientType gradient(const PointType& point) const
4593 {
4594 const DataType norm_sqr = (point - _origin).norm_euclid_sqr();
4595 if(norm_sqr < _eps)
4596 return GradientType::null();
4597
4599 if constexpr (dim_ == 1)
4600 grad[0] = DataType(-2) * Math::signum(point[0] - _origin[0]);
4601 else if constexpr(dim_ == 2)
4602 grad = (DataType(-1) / (_ln2 * norm_sqr)) * (point - _origin);
4603 else if constexpr(dim_ == 3)
4604 grad = (DataType(1) / Math::pow(norm_sqr, DataType(1.5))) * (_origin - point);
4605
4606 return grad;
4607 }
4608
4609 HessianType hessian(const PointType& point) const
4610 {
4611 const DataType norm_sqr = (point - _origin).norm_euclid_sqr();
4612 if(norm_sqr < _eps)
4613 return HessianType::null();
4614
4616 if constexpr(dim_ == 1)
4617 {
4618 // 1D hessian is null
4619 }
4620 else if constexpr(dim_ == 2)
4621 {
4622 const DataType denom = DataType(1) / (_ln2 * Math::sqr(norm_sqr));
4623 hess[0][0] = denom * (Math::sqr(point[0] - _origin[0]) - Math::sqr(point[1] - _origin[1]));
4624 hess[1][1] = denom * (Math::sqr(point[1] - _origin[1]) - Math::sqr(point[0] - _origin[0]));
4625 hess[0][1] = hess[1][0] = denom * DataType(2) * (point[0] - _origin[0]) * (point[1] - _origin[1]);
4626 }
4627 else if constexpr(dim_ == 3)
4628 {
4629 const DataType denom = DataType(1) / Math::pow(norm_sqr, DataType(2.5));
4630 for(int i(0); i < dim_; ++i)
4631 {
4632 for(int j(0); j < dim_; ++j)
4633 {
4634 if(i == j)
4635 {
4636 for(int k(0); k < dim_; ++k)
4637 hess[i][j] += DataType(k == i ? 2 : -1) * Math::sqr(point[k] - _origin[k]) * denom;
4638 }
4639 else
4640 {
4641 hess[i][j] = DataType(3) * (point[i] - _origin[i]) * (point[j] - _origin[j]) * denom;
4642 }
4643 }
4644 }
4645 }
4646 return hess;
4647 }
4648 }; // class HarmonicShellFunction::Evaluator<...>
4649
4650 public:
4653
4654 public:
4657 {
4658 _origin.format();
4659 }
4660
4662 explicit HarmonicShellFunction(const PointType& origin) :
4663 _origin(origin)
4664 {
4665 }
4666
4668 void set_point(const PointType& origin)
4669 {
4670 _origin = origin;
4671 }
4672 }; // class HarmonicShellFunction
4673
4679 template<int dim_, typename DataType_>
4681 public Analytic::Function
4682 {
4683 public:
4684 static constexpr int domain_dim = dim_;
4686 static constexpr bool can_value = true;
4687
4688 DataType_ v_max;
4689
4690 public:
4691 explicit DFG95SteadyInflowFunction(DataType_ vmax) :
4692 v_max(vmax)
4693 {
4694 }
4695
4696 template<typename Traits_>
4698 public Analytic::Function::Evaluator<Traits_>
4699 {
4700 protected:
4701 typedef typename Traits_::DataType DataType;
4702 typedef typename Traits_::PointType PointType;
4703 typedef typename Traits_::ValueType ValueType;
4704
4705 const DataType _d, _scal;
4706
4707 public:
4708 explicit Evaluator(const DFG95SteadyInflowFunction& function) :
4709 _d(DataType(0.41)),
4710 _scal(DataType(function.v_max) / Math::pow(_d, DataType_(2*(dim_-1))))
4711 {
4712 }
4713
4714 ValueType value(const PointType& point)
4715 {
4716 ValueType val;
4717 val[0] = _scal;
4718 for(int i = 1; i < dim_; ++i)
4719 {
4720 val[0] *= DataType(4) * point[i] * (_d - point[i]);
4721 val[i] = DataType(0);
4722 }
4723 return val;
4724 }
4725 };
4726 }; // class DFG95SteadyInflowFunction
4727 } // namespace Common
4728 } // namespace Analytic
4729} // namespace FEAT
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
Definition: assertion.hpp:230
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
const DataType _value
Function that is being evaluated.
Definition: common.hpp:719
EvalTraits_::PointType PointType
point type
Definition: common.hpp:709
Evaluator(const ConstantFunction &function)
Constructor.
Definition: common.hpp:723
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:711
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:707
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:715
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:713
Constant Analytic function.
Definition: common.hpp:691
DataType_ _value
Value of the constant function.
Definition: common.hpp:746
ConstantFunction(DataType_ value=DataType_(0))
Constructor, value defaults to 0.
Definition: common.hpp:750
Evaluator(const ConstantVectorFunction &function)
Constructor.
Definition: common.hpp:800
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:792
const ValueType _value_vec
Function that is being evaluated.
Definition: common.hpp:796
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:784
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:790
Constant vector valued Analytic function.
Definition: common.hpp:768
Tiny::Vector< DataType_, domain_dim > _value_vector
Tiny Vector representing the values of the constant function.
Definition: common.hpp:823
ConstantVectorFunction(DataType_ value=DataType_(0))
Definition: common.hpp:828
ConstantVectorFunction(Tiny::Vector< DataType_, domain_dim > vec)
This constructor sets _value_vec to the given Tiny::Vector vec.
Definition: common.hpp:834
Singularity function for a 2D reentry corner with homogeneous boundary conditions.
Definition: common.hpp:4085
radial version of the CornerSingularity function... should be used with the PolarCoordinateWrapper
Definition: common.hpp:4195
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
Definition: common.hpp:4216
Cosine-Tensor Static function.
Definition: common.hpp:397
static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
3D: function value
Definition: common.hpp:420
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
Definition: common.hpp:462
static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
3D: YY-derivative
Definition: common.hpp:498
static DataType_ der_y(DataType_ x, DataType_ y)
2D: Y-derivative
Definition: common.hpp:438
static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
3D: Z-derivative
Definition: common.hpp:456
static DataType_ der_xx(DataType_ x, DataType_ y)
2D: XX-derivative
Definition: common.hpp:468
static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
3D: XX-derivative
Definition: common.hpp:492
static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
3D: X-derivative
Definition: common.hpp:444
static DataType_ kpi()
Returns k times pi.
Definition: common.hpp:402
static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
3D: ZY-derivative
Definition: common.hpp:540
static DataType_ der_yy(DataType_ x, DataType_ y)
2D: YY-derivative
Definition: common.hpp:474
static DataType_ der_x(DataType_ x)
1D: X-derivative
Definition: common.hpp:426
static DataType_ der_x(DataType_ x, DataType_ y)
2D: X-derivative
Definition: common.hpp:432
static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
3D: Y-derivative
Definition: common.hpp:450
static DataType_ der_xy(DataType_ x, DataType_ y)
2D: XY-derivative
Definition: common.hpp:480
static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
3D: YX-derivative
Definition: common.hpp:516
static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
3D: ZZ-derivative
Definition: common.hpp:504
static DataType_ der_yx(DataType_ x, DataType_ y)
2D: YX-derivative
Definition: common.hpp:486
static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
3D: XZ-derivative
Definition: common.hpp:522
static DataType_ eval(DataType_ x, DataType_ y)
2D: function value
Definition: common.hpp:414
static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
3D: XY-derivative
Definition: common.hpp:510
static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
3D: ZX-derivative
Definition: common.hpp:528
static DataType_ eval(DataType_ x)
1D: function value
Definition: common.hpp:408
static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
3D: YZ-derivative
Definition: common.hpp:534
Steady-State inflow function used in DFG95 flow-around-a-cylinder benchmarks.
Definition: common.hpp:4682
Exponential-Bubble scalar Static function.
Definition: common.hpp:581
static DataType_ eval(DataType_ x)
1D: function value
Definition: common.hpp:584
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
Definition: common.hpp:596
static DataType_ der_x(DataType_ x)
1D: X-derivative
Definition: common.hpp:590
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:4420
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:4418
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:4426
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:4424
3D Version of Franke's Function
Definition: common.hpp:4394
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:4405
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:4401
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:4403
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:4407
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:4399
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:4409
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:4319
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:4321
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:4313
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:4317
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:4315
Saddle-Point-Gauss type interpolation test function.
Definition: common.hpp:4289
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:4302
DT_ DataType
The floating point type.
Definition: common.hpp:4292
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:4294
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:4300
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:4296
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:4304
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:4298
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:2680
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2678
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2682
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2676
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2684
const DataType _t
The scaling factor according to the amplitude.
Definition: common.hpp:2688
Time dependent divergence free velocity field.
Definition: common.hpp:2652
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:2667
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2665
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2663
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2661
DT_ DataType
The floating point type.
Definition: common.hpp:2655
GuermondStokesSol(DataType t=DataType(0))
Constructor.
Definition: common.hpp:2735
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2659
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:2657
const DataType _t
The scaling factor according to the amplitude.
Definition: common.hpp:2585
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2573
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2575
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2579
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2581
GuermondStokesSolPressure(DataType t=DataType(0))
Constructor.
Definition: common.hpp:2628
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:2564
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2556
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:2554
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2560
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2562
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2558
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2789
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2783
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:2787
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2791
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2785
Time dependent divergence free velocity field.
Definition: common.hpp:2759
const DataType _reynolds
The Reynolds number of the associated flow with the solution GuermondStokesSol.
Definition: common.hpp:2836
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2766
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2772
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:2764
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:2774
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2770
GuermondStokesSolRhs(DataType reynolds, DataType t=DataType(0))
Constructor.
Definition: common.hpp:2845
DT_ DataType
The floating point type.
Definition: common.hpp:2762
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2768
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:4553
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:4561
Evaluator(const HarmonicShellFunction &function)
Constructor.
Definition: common.hpp:4572
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:4559
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:4555
HarmonicShellFunction(const PointType &origin)
Constructor.
Definition: common.hpp:4662
void set_point(const PointType &origin)
Sets point to x0
Definition: common.hpp:4668
PointType _origin
Point to calculate the distance from.
Definition: common.hpp:4652
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:912
AnalyticFunctionType1::template Evaluator< EvalTraits_ > _f1_eval
Evaluator for the first AnalyticFunction.
Definition: common.hpp:920
AnalyticFunctionType2::template Evaluator< EvalTraits_ > _f2_eval
Evaluator for the second AnalyticFunction.
Definition: common.hpp:922
Evaluator(const MinOfTwoFunctions &function)
Constructor.
Definition: common.hpp:928
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:914
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:910
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:916
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:908
Function representing the minimum of two analytic functions.
Definition: common.hpp:879
static constexpr bool can_grad
Can compute the function gradient if both AnalyticFunctions can do that.
Definition: common.hpp:896
const AnalyticFunctionType2 & _f2
The second AnalyticFunction.
Definition: common.hpp:971
const AnalyticFunctionType1 & _f1
The first AnalyticFunction.
Definition: common.hpp:969
MinOfTwoFunctions(const AnalyticFunctionType1 &f1_, const AnalyticFunctionType2 &f2_)
Constructor.
Definition: common.hpp:975
static constexpr bool can_hess
Can compute the function hessian if both AnalyticFunctions can do that.
Definition: common.hpp:898
static constexpr int domain_dim
ensure that the two functions have the same dimension
Definition: common.hpp:889
static constexpr bool can_value
Can compute function values if both AnalyticFunctions can do that.
Definition: common.hpp:894
Analytic::Image::Scalar ImageType
our image type
Definition: common.hpp:891
2D Parabolic Profile function base-class
Definition: common.hpp:1722
ParProfileBase(DataType_ x0, DataType_ y0, DataType_ x1, DataType_ y1, DataType_ vmax=DataType_(1.0))
Constructor.
Definition: common.hpp:1758
ParProfileBase()
Default Constructor.
Definition: common.hpp:1741
bool parse(const String &sbc)
Parses the profile parameters from a string.
Definition: common.hpp:1780
2D Scalar Parabolic Profile function
Definition: common.hpp:1819
2D Vector-Valued Parabolic Profile function
Definition: common.hpp:1904
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3442
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3448
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3450
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:3446
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3444
Parabolic Poiseuille Pipe-Flow velocity field.
Definition: common.hpp:3386
PointType origin
The flow origin.
Definition: common.hpp:3404
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3395
PoiseuillePipeFlow(PointType origin_, PointType axis_, DataType radius_=DataType(1), DataType v_max_=DataType(1))
Creates this function.
Definition: common.hpp:3427
Tiny::Vector< DataType, domain_dim > PointType
Type to map from.
Definition: common.hpp:3401
DataType v_max
the maximum flow velocity
Definition: common.hpp:3410
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3393
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:3391
DataType_ DataType
The floating point type.
Definition: common.hpp:3389
static constexpr bool can_hess
We can't compute the Hessian.
Definition: common.hpp:3399
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3397
std::vector< DataType > _coeff
our polynomial coefficients
Definition: common.hpp:1281
Evaluator(const PolynomialFunction1D &function)
Constructor.
Definition: common.hpp:1285
1D Polynomial function class template
Definition: common.hpp:1254
Index set_coeff(Index degree, DataType_ coeff)
Sets a monomial coefficient.
Definition: common.hpp:1367
std::vector< DataType_ > _coeff
the polynomial coefficient vector
Definition: common.hpp:1335
static constexpr bool can_hess
we provide function hessians
Definition: common.hpp:1265
Analytic::Image::Scalar ImageType
this is a scalar function
Definition: common.hpp:1259
PolynomialFunction1D(std::initializer_list< DataType_ > coeff)
Polynomial coefficient constructor.
Definition: common.hpp:1350
static constexpr bool can_value
we provide function values
Definition: common.hpp:1261
static constexpr bool can_grad
we provide function gradients
Definition: common.hpp:1263
static constexpr int domain_dim
this is a 1D function
Definition: common.hpp:1257
Q2-bubble scalar Static function.
Definition: common.hpp:636
static DataType_ der_xx(DataType_)
1D: XX-derivative
Definition: common.hpp:651
static DataType_ eval(DataType_ x)
1D: function value
Definition: common.hpp:639
static DataType_ der_x(DataType_ x)
1D: X-derivative
Definition: common.hpp:645
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3625
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3617
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3619
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3623
Rigid-Body Vortex pressure function.
Definition: common.hpp:3593
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3604
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:3606
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3600
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:3598
DT_ DataType
The floating point type.
Definition: common.hpp:3596
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3608
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3602
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3541
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3547
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3543
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3549
Rigid-Body Vortex velocity field.
Definition: common.hpp:3517
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3524
DT_ DataType
The floating point type.
Definition: common.hpp:3520
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
Definition: common.hpp:3522
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3528
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3532
static constexpr bool can_hess
We can't compute the Hessian.
Definition: common.hpp:3530
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3526
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2368
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2376
const DataType _t
The scaling factor according to the amplitude.
Definition: common.hpp:2380
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2370
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2374
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:2372
Time dependent divergence free velocity field.
Definition: common.hpp:2344
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2355
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2357
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:2349
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2353
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:2359
DT_ DataType
The floating point type.
Definition: common.hpp:2347
SinYT0(DataType t=DataType(0))
Constructor.
Definition: common.hpp:2422
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2351
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2470
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2472
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2476
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2478
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:2474
Time dependent divergence free velocity field.
Definition: common.hpp:2446
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2453
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:2461
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2459
SinYT0StokesRhs(DataType reynolds, DataType t=DataType(0))
Constructor.
Definition: common.hpp:2524
const DataType _reynolds
The Reynolds number of the associated flow with the solution SinYT0.
Definition: common.hpp:2515
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2457
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:2451
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2455
DT_ DataType
The floating point type.
Definition: common.hpp:2449
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3827
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3829
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3821
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:3825
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3823
Sine-Vortex pressure function on the 2D ring domain with distance [1/2,1] around (0,...
Definition: common.hpp:3794
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:3807
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3805
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3801
DT_ DataType
The floating point type.
Definition: common.hpp:3797
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3803
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:3799
DataType mean_shift
the shift of the mean value; defaults to that the pressure has integral mean equal to 0
Definition: common.hpp:3812
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3809
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3941
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3935
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3933
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:3937
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3939
Sine-Vortex RHS field on the 2D ring domain with distance [1/2,1] around (0,0)
Definition: common.hpp:3883
SineRingVortexRHS2D(DataType nu_=DataType(1), DataType beta_=DataType(0), DataType theta_=DataType(0), DataType sigma_=DataType(1))
Constructor.
Definition: common.hpp:3918
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3890
static constexpr bool can_hess
We can't compute the Hessian.
Definition: common.hpp:3896
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3898
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3894
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
Definition: common.hpp:3888
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3892
DT_ DataType
The floating point type.
Definition: common.hpp:3886
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:3701
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3703
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3697
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3705
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3699
Sine-Vortex velocity field on the 2D ring domain with distance [1/2,1] around (0,0)
Definition: common.hpp:3673
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3680
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3684
DT_ DataType
The floating point type.
Definition: common.hpp:3676
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3688
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3682
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
Definition: common.hpp:3678
static constexpr bool can_hess
We can't compute the Hessian.
Definition: common.hpp:3686
Sine-Tensor Static function.
Definition: common.hpp:207
static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
3D: YY-derivative
Definition: common.hpp:308
static DataType_ der_yy(DataType_ x, DataType_ y)
2D: YY-derivative
Definition: common.hpp:284
static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
3D: XY-derivative
Definition: common.hpp:320
static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
3D: XZ-derivative
Definition: common.hpp:332
static DataType_ der_xx(DataType_ x, DataType_ y)
2D: XX-derivative
Definition: common.hpp:278
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
Definition: common.hpp:272
static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
3D: X-derivative
Definition: common.hpp:254
static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
3D: YZ-derivative
Definition: common.hpp:344
static DataType_ kpi()
returns the constant pi
Definition: common.hpp:212
static DataType_ der_x(DataType_ x, DataType_ y)
2D: X-derivative
Definition: common.hpp:242
static DataType_ eval(DataType_ x, DataType_ y)
2D: function value
Definition: common.hpp:224
static DataType_ der_x(DataType_ x)
1D: X-derivative
Definition: common.hpp:236
static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
3D: Z-derivative
Definition: common.hpp:266
static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
3D: Y-derivative
Definition: common.hpp:260
static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
3D: ZZ-derivative
Definition: common.hpp:314
static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
3D: function value
Definition: common.hpp:230
static DataType_ eval(DataType_ x)
1D: function value
Definition: common.hpp:218
static DataType_ der_y(DataType_ x, DataType_ y)
2D: Y-derivative
Definition: common.hpp:248
static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
3D: ZX-derivative
Definition: common.hpp:338
static DataType_ der_yx(DataType_ x, DataType_ y)
2D: YX-derivative
Definition: common.hpp:296
static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
3D: YX-derivative
Definition: common.hpp:326
static DataType_ der_xy(DataType_ x, DataType_ y)
2D: XY-derivative
Definition: common.hpp:290
static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
3D: XX-derivative
Definition: common.hpp:302
static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
3D: ZY-derivative
Definition: common.hpp:350
Sphere-Cap Function on the 2D unit circle / 3D unit ball.
Definition: common.hpp:3990
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2892
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2894
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2900
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2898
Sphere-Normalized Sine-Bubble Function.
Definition: common.hpp:2872
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2879
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2881
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2883
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:2875
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2877
Standing-Vortex function in 2D.
Definition: common.hpp:3091
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3329
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3331
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3337
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3335
Taylor-Green Vortex pressure function.
Definition: common.hpp:3285
DataType nu
The viscosity parameter.
Definition: common.hpp:3303
TaylorGreenVortexPres2D(DataType nu_=DataType(1), DataType t_=DataType(0))
Constructor.
Definition: common.hpp:3316
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:3298
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3294
DT_ DataType
The floating point type.
Definition: common.hpp:3288
Analytic::Image::Scalar ImageType
What type this mapping maps to.
Definition: common.hpp:3290
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3292
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3296
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3300
DataType cur_t
The current simulation time.
Definition: common.hpp:3305
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:3222
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:3218
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:3224
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:3216
Taylor-Green Vortex velocity field.
Definition: common.hpp:3172
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:3181
TaylorGreenVortexVelo2D(DataType nu_=DataType(1), DataType t_=DataType(0))
Constructor.
Definition: common.hpp:3203
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:3179
DataType nu
The viscosity parameter.
Definition: common.hpp:3190
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:3187
DataType cur_t
The current simulation time.
Definition: common.hpp:3192
Analytic::Image::Vector< 2 > ImageType
What type this mapping maps to.
Definition: common.hpp:3177
static constexpr bool can_hess
We can't compute the Hessian.
Definition: common.hpp:3185
DT_ DataType
The floating point type.
Definition: common.hpp:3175
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:3183
Wrapper class for Tensor-Product scalar static functions.
Definition: common.hpp:48
static DataType_ der_xy(DataType_ x, DataType_ y)
2D: XY-derivative
Definition: common.hpp:123
static DataType_ der_yx(DataType_ x, DataType_ y, DataType_ z)
3D: YX-derivative
Definition: common.hpp:159
static DataType_ der_x(DataType_ x)
1D: X-derivative
Definition: common.hpp:57
static DataType_ der_xx(DataType_ x, DataType_ y)
2D: XX-derivative
Definition: common.hpp:111
static DataType_ der_xx(DataType_ x, DataType_ y, DataType_ z)
3D: XX-derivative
Definition: common.hpp:135
static DataType_ der_z(DataType_ x, DataType_ y, DataType_ z)
3D: Z-derivative
Definition: common.hpp:105
static DataType_ der_yy(DataType_ x, DataType_ y)
2D: YY-derivative
Definition: common.hpp:117
static DataType_ der_yx(DataType_ x, DataType_ y)
2D: YX-derivative
Definition: common.hpp:129
static DataType_ der_xx(DataType_ x)
1D: XX-derivative
Definition: common.hpp:63
static DataType_ der_y(DataType_ x, DataType_ y)
2D: Y-derivative
Definition: common.hpp:81
static DataType_ der_y(DataType_ x, DataType_ y, DataType_ z)
3D: Y-derivative
Definition: common.hpp:99
static DataType_ der_zz(DataType_ x, DataType_ y, DataType_ z)
3D: ZZ-derivative
Definition: common.hpp:147
static DataType_ eval(DataType_ x)
1D: function value
Definition: common.hpp:51
static DataType_ eval(DataType_ x, DataType_ y, DataType_ z)
3D: function value
Definition: common.hpp:87
static DataType_ der_zx(DataType_ x, DataType_ y, DataType_ z)
3D: ZX-derivative
Definition: common.hpp:171
static DataType_ der_x(DataType_ x, DataType_ y)
2D: X-derivative
Definition: common.hpp:75
static DataType_ der_zy(DataType_ x, DataType_ y, DataType_ z)
3D: ZY-derivative
Definition: common.hpp:183
static DataType_ der_yy(DataType_ x, DataType_ y, DataType_ z)
3D: YY-derivative
Definition: common.hpp:141
static DataType_ der_yz(DataType_ x, DataType_ y, DataType_ z)
3D: YZ-derivative
Definition: common.hpp:177
static DataType_ der_xz(DataType_ x, DataType_ y, DataType_ z)
3D: XZ-derivative
Definition: common.hpp:165
static DataType_ der_x(DataType_ x, DataType_ y, DataType_ z)
3D: X-derivative
Definition: common.hpp:93
static DataType_ der_xy(DataType_ x, DataType_ y, DataType_ z)
3D: XY-derivative
Definition: common.hpp:153
static DataType_ eval(DataType_ x, DataType_ y)
2D: function value
Definition: common.hpp:69
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2106
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2100
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2102
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:2104
const DataType _angular_velocity
The angular velocity.
Definition: common.hpp:2112
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2108
Velocity field for a rigid body rotation in the x,y plane.
Definition: common.hpp:2076
const PointType _origin
Point to rotate around.
Definition: common.hpp:2152
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:2081
XYPlaneRotation(const DataType angular_velocity, const PointType &origin)
Constructor.
Definition: common.hpp:2165
const DataType _angular_velocity
The angular velocity.
Definition: common.hpp:2150
DT_ DataType
The floating point type.
Definition: common.hpp:2079
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2087
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2089
Tiny::Vector< DT_, domain_dim > PointType
Type to map from.
Definition: common.hpp:2091
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2083
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2085
const std::vector< Tiny::Vector< DataType, 2 > > & _range
The points where the function becomes zero.
Definition: common.hpp:2232
EvalTraits_::ValueType ValueType
value type
Definition: common.hpp:2222
EvalTraits_::DataType DataType
coefficient data type
Definition: common.hpp:2218
DataType _fac
The scaling factor according to the amplitude.
Definition: common.hpp:2230
EvalTraits_::PointType PointType
evaluation point type
Definition: common.hpp:2220
EvalTraits_::HessianType HessianType
hessian type
Definition: common.hpp:2226
EvalTraits_::GradientType GradientType
gradient type
Definition: common.hpp:2224
Velocity field for a parabolic profile in the y,z plane, constant in x.
Definition: common.hpp:2194
DT_ DataType
The floating point type.
Definition: common.hpp:2197
Analytic::Image::Vector< dim_ > ImageType
What type this mapping maps to.
Definition: common.hpp:2199
YZPlaneParabolic(const DataType amplitude, const RangeType &range_y)
Constructor.
Definition: common.hpp:2303
YZPlaneParabolic(const DataType amplitude, const RangeType &range_y, const RangeType &range_z)
Constructor.
Definition: common.hpp:2323
static constexpr int domain_dim
The dimension to map from.
Definition: common.hpp:2201
const DataType _amplitude
The maximum value of the parabolic profile.
Definition: common.hpp:2288
Tiny::Vector< DT_, 2 > RangeType
Type to map from.
Definition: common.hpp:2209
static constexpr bool can_value
We can compute the value.
Definition: common.hpp:2203
static constexpr bool can_hess
We can compute the Hessian.
Definition: common.hpp:2207
static constexpr bool can_grad
We can compute the gradient.
Definition: common.hpp:2205
std::vector< Tiny::Vector< DataType, 2 > > _range
The points where the function becomes zero.
Definition: common.hpp:2290
Analytic Function Evaluator base-class template.
Definition: function.hpp:157
ValueType value(const PointType &point)
Computes the function value in a given point.
Definition: function.hpp:224
GradientType gradient(const PointType &point)
Computes the function gradient in a given point.
Definition: function.hpp:237
HessianType hessian(const PointType &point)
Computes the function hessian in a given point.
Definition: function.hpp:250
Analytic Function interface.
Definition: function.hpp:112
This class is a wrapper transforming a polar-basis function to a euclidean base one.
Definition: wrappers.hpp:434
StaticFunction wrapper class template for Analytic::Function interface.
String class implementation.
Definition: string.hpp:46
std::deque< String > split_by_string(const String &delimiter) const
Splits the string by a delimiter substring.
Definition: string.hpp:539
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.
Definition: math.hpp:300
T_ abs(T_ x)
Returns the absolute value.
Definition: math.hpp:275
T_ exp(T_ x)
Returns the exponential of a value.
Definition: math.hpp:550
T_ clamp(T_ x, T_ a, T_ b)
Clamps a value to a range.
Definition: math.hpp:216
T_ acos(T_ x)
Returns the arccosine of a value.
Definition: math.hpp:967
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
Definition: math.hpp:643
T_ sin(T_ x)
Returns the sine of a value.
Definition: math.hpp:344
T_ sqr(T_ x)
Returns the square of a value.
Definition: math.hpp:95
T_ min(T_ a, T_ b)
Returns the minimum of two values.
Definition: math.hpp:123
T_ cub(T_ x)
Returns the cube of a value.
Definition: math.hpp:109
T_ signum(T_ x)
Returns the sign of a value.
Definition: math.hpp:250
T_ cos(T_ x)
Returns the cosine of a value.
Definition: math.hpp:386
T_ log(T_ x)
Returns the natural logarithm of a value.
Definition: math.hpp:580
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.
FEAT namespace.
Definition: adjactor.hpp:12
__half Half
Half data type.
Definition: half.hpp:25
@ 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.
Definition: function.hpp:28
Vector Field Image tag class.
Definition: function.hpp:47