Loading [MathJax]/extensions/TeX/newcommand.js
Reference documentation for deal.II version 9.2.0
\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\}}
Main Page
Tutorial
Code gallery
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
i
l
m
n
o
p
r
s
t
u
v
w
z
Typedefs
a
b
c
g
i
l
m
o
p
s
t
v
Enumerations
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
v
w
Enumerations
a
b
c
d
e
f
g
i
m
o
p
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Related Functions
:
a
b
c
d
f
g
h
i
l
m
o
p
r
s
t
u
v
Related Pages
Files
File List
File Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
s
t
u
v
z
Variables
a
c
d
f
g
i
l
m
p
q
s
t
u
v
Typedefs
Enumerations
Enumerator
m
u
Macros
a
b
d
e
h
i
m
s
t
dealii.org
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
source
differentiation
ad
adolc_number_types.cc
Go to the documentation of this file.
1
// ---------------------------------------------------------------------
2
//
3
// Copyright (C) 2017 - 2019 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
17
#include <
deal.II/base/config.h
>
18
19
#ifdef DEAL_II_WITH_ADOLC
20
21
# include <
deal.II/differentiation/ad/ad_number_traits.h
>
22
# include <
deal.II/differentiation/ad/adolc_number_types.h
>
23
24
# include <functional>
25
# include <utility>
26
27
DEAL_II_NAMESPACE_OPEN
28
29
30
# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
31
32
namespace
numbers
33
{
34
namespace
internal
35
{
36
namespace
37
{
38
// Apply some comparator and extract the boolean result of the operation,
39
// instead of the "adub" return type tpyically returned by ADOL-C for
40
// such a comparison. This is implemented as a general function so that
41
// the list of implemented comparative operations can be easily extended.
42
bool
43
adouble_boolean_comparator(
44
const
adouble &value_1,
45
const
adouble &value_2,
46
const
std::function<adouble(
const
adouble &,
const
adouble &)>
47
&comparator)
48
{
49
using
ad_type
=
typename
Differentiation::AD::NumberTraits
<
50
double
,
51
Differentiation::AD::NumberTypes::adolc_taped
>
::ad_type
;
52
static_assert(
53
std::is_same<adouble, ad_type>::value
,
54
"The type of the AD number is not that which was expected."
);
55
const
ad_type
result = comparator(value_1, value_2);
56
return
!(
Differentiation::AD::ADNumberTraits<ad_type>::get_scalar_value
(
57
result) == 0.0);
58
}
59
}
// namespace
60
}
// namespace internal
61
62
bool
63
values_are_equal
(
const
adouble &value_1,
const
adouble &value_2)
64
{
65
return
internal::adouble_boolean_comparator(
66
value_1, value_2, [](
const
adouble &a,
const
adouble &
b
) -> adouble {
67
return ::internal::NumberType<adouble>::value
(a ==
b
);
68
});
69
}
70
71
bool
72
value_is_less_than
(
const
adouble &value_1,
const
adouble &value_2)
73
{
74
return
internal::adouble_boolean_comparator(
75
value_1, value_2, [](
const
adouble &a,
const
adouble &
b
) -> adouble {
76
return ::internal::NumberType<adouble>::value
(a <
b
);
77
});
78
}
79
}
// namespace numbers
80
81
# endif
82
83
84
/*---------------------- Explicit Instantiations ----------------------*/
85
86
# include "adolc_number_types.inst"
87
88
DEAL_II_NAMESPACE_CLOSE
89
90
#endif
adolc_number_types.h
numbers::values_are_equal
constexpr bool values_are_equal(const Number1 &value_1, const Number2 &value_2)
Definition:
numbers.h:925
double
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition:
config.h:358
Physics::Elasticity::Kinematics::b
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
numbers
Definition:
numbers.h:207
Differentiation::AD::NumberTypes::adolc_taped
@ adolc_taped
value
static const bool value
Definition:
dof_tools_constraints.cc:433
ad_number_traits.h
Differentiation::AD::ADNumberTraits
Definition:
ad_number_traits.h:72
ad_type
config.h
internal
Definition:
aligned_vector.h:369
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition:
config.h:359
Differentiation::AD::NumberTraits
Definition:
ad_number_traits.h:53
numbers::value_is_less_than
bool value_is_less_than(const Number1 &value_1, const Number2 &value_2)
Definition:
numbers.h:949
Generated by
1.8.17