16 #ifndef dealii_differentiation_ad_adolc_math_h 17 #define dealii_differentiation_ad_adolc_math_h 19 #include <deal.II/base/config.h> 21 #ifdef DEAL_II_WITH_ADOLC 23 #include <adolc/internal/adolc_settings.h> 24 #include <adolc/internal/adubfunc.h> 26 #include <adolc/adouble.h> 27 #include <adolc/adtl.h> 46 #define DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(func_to, func_from) \ 47 inline adouble func_to(const adouble &x) {return func_from(static_cast<const badouble &>(x));} \ 48 inline adtl::adouble func_to(const adtl::adouble &x) {return adtl::func_from(x);} 53 #define DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(func) \ 54 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(func,func) 59 #define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(func_to,func_from) \ 60 inline adouble func_to(const adouble &x, const adouble &y) {return func_from(static_cast<const badouble &>(x),static_cast<const badouble &>(y));} \ 61 inline adouble func_to(const double &x, const adouble &y) {return func_from(x,static_cast<const badouble &>(y));} \ 62 inline adouble func_to(const adouble &x, const double &y) {return func_from(static_cast<const badouble &>(x),y);} \ 63 inline adtl::adouble func_to(const adtl::adouble &x, const adtl::adouble &y) {return adtl::func_from(x,y);} \ 64 inline adtl::adouble func_to(const double &x, const adtl::adouble &y) {return adtl::func_from(x,y);} \ 65 inline adtl::adouble func_to(const adtl::adouble &x, const double &y) {return adtl::func_from(x,y);} 70 #define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(func) \ 71 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(func,func) 76 #define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2(func) \ 77 inline adouble func(const adouble &x, const adouble &y) {return func(static_cast<const badouble &>(x),static_cast<const badouble &>(y));} \ 78 inline adtl::adouble func(const adtl::adouble &x, const adtl::adouble &y) {return adtl::func(x,y);} 84 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(pow)
85 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(fmax)
86 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(max,fmax)
87 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(fmin)
88 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(min,fmin)
90 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(exp)
91 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(log)
92 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(log10)
93 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sqrt)
94 #if defined(DEAL_II_ADOLC_WITH_ATRIG_ERF) 95 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(erf)
96 inline adouble erfc(
const adouble &x)
98 return 1.0 - std::erf(x);
100 inline adtl::adouble erfc(
const adtl::adouble &x)
102 return 1.0 - std::erf(x);
106 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(fabs)
107 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(abs,fabs)
108 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(ceil)
109 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(floor)
111 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sin)
112 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(cos)
113 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(tan)
114 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(asin)
115 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(acos)
116 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(atan)
117 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2(atan2)
119 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sinh)
120 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(cosh)
121 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(tanh)
122 #if defined(DEAL_II_ADOLC_WITH_ATRIG_ERF) 123 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(asinh)
124 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(acosh)
125 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(atanh)
128 #undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2 129 #undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION 130 #undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY 131 #undef DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION 132 #undef DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY 138 #endif // DEAL_II_WITH_ADOLC