Reference documentation for deal.II version 9.4.1
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
adolc_math.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2016 - 2021 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_differentiation_ad_adolc_math_h
17#define dealii_differentiation_ad_adolc_math_h
18
19#include <deal.II/base/config.h>
20
21#ifdef DEAL_II_WITH_ADOLC
22
23# include <adolc/adouble.h> // Taped double
24# include <adolc/adtl.h> // Tapeless double
25# include <adolc/internal/adolc_settings.h>
26# include <adolc/internal/adubfunc.h> // Taped double math functions
27
28
29# ifndef DOXYGEN
30
39namespace std
40{
44# define DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(func_to, func_from) \
45 inline adouble func_to(const adouble &x) \
46 { \
47 return func_from(static_cast<const badouble &>(x)); \
48 } \
49 inline adtl::adouble func_to(const adtl::adouble &x) \
50 { \
51 return adtl::func_from(x); \
52 }
53
57# define DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(func) \
58 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(func, func)
59
63# define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(func_to, func_from) \
64 inline adouble func_to(const adouble &x, const adouble &y) \
65 { \
66 return func_from(static_cast<const badouble &>(x), \
67 static_cast<const badouble &>(y)); \
68 } \
69 inline adouble func_to(const double x, const adouble &y) \
70 { \
71 return func_from(x, static_cast<const badouble &>(y)); \
72 } \
73 inline adouble func_to(const adouble &x, const double y) \
74 { \
75 return func_from(static_cast<const badouble &>(x), y); \
76 } \
77 inline adtl::adouble func_to(const adtl::adouble &x, \
78 const adtl::adouble &y) \
79 { \
80 return adtl::func_from(x, y); \
81 } \
82 inline adtl::adouble func_to(const double x, const adtl::adouble &y) \
83 { \
84 return adtl::func_from(x, y); \
85 } \
86 inline adtl::adouble func_to(const adtl::adouble &x, const double y) \
87 { \
88 return adtl::func_from(x, y); \
89 }
90
94# define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(func) \
95 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(func, func)
96
100# define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2(func) \
101 inline adouble func(const adouble &x, const adouble &y) \
102 { \
103 return func(static_cast<const badouble &>(x), \
104 static_cast<const badouble &>(y)); \
105 } \
106 inline adtl::adouble func(const adtl::adouble &x, \
107 const adtl::adouble &y) \
108 { \
109 return adtl::func(x, y); \
110 }
111
112 // See
113 // https://gitlab.com/adol-c/adol-c/blob/master/ADOL-C/include/adolc/adouble.h
114 // https://gitlab.com/adol-c/adol-c/blob/master/ADOL-C/include/adolc/internal/paramfunc.h
115
116 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(pow)
117 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(fmax)
118 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(max, fmax)
119 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(fmin)
120 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(min, fmin)
121
122 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(exp)
123 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(log)
124 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(log10)
125 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sqrt)
126# ifdef DEAL_II_ADOLC_WITH_ATRIG_ERF
127 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(erf)
128 inline adouble
129 erfc(const adouble &x)
130 {
131 return 1.0 - std::erf(x);
132 }
133 inline adtl::adouble
134 erfc(const adtl::adouble &x)
135 {
136 return 1.0 - std::erf(x);
137 }
138# endif
139
140 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(fabs)
141 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(abs, fabs)
142 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(ceil)
143 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(floor)
144
145 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sin)
146 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(cos)
147 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(tan)
148 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(asin)
149 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(acos)
150 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(atan)
151 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2(atan2)
152
153 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sinh)
154 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(cosh)
155 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(tanh)
156# ifdef DEAL_II_ADOLC_WITH_ATRIG_ERF
157 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(asinh)
158 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(acosh)
159 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(atanh)
160# endif
161
162# undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2
163# undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION
164# undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY
165# undef DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION
166# undef DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY
167
168} // namespace std
169
170# endif // DOXYGEN
171
172#endif // DEAL_II_WITH_ADOLC
173
174#endif
Expression erfc(const Expression &x)
STL namespace.
::VectorizedArray< Number, width > log(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > exp(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > tan(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)