www.mooseframework.org
MooseADWrapper.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseTypes.h"
13 
14 #include <vector>
15 
16 template <typename T, bool is_ad>
18 {
19  typedef T type;
20 };
21 
22 template <>
24 {
25  typedef ADReal type;
26 };
27 
28 template <>
29 struct MooseADWrapperStruct<Point, true>
30 {
31  typedef ADPoint type;
32 };
33 
34 template <>
36 {
38 };
39 
40 // W<T> -> W<ADT>, e.g. RankTwoTensorTempl<Real> -> RankTwoTensorTempl<ADReal>
41 template <template <typename> class W, typename T, bool is_ad>
42 struct MooseADWrapperStruct<W<T>, is_ad>
43 {
44  typedef W<typename MooseADWrapperStruct<T, is_ad>::type> type;
45 };
46 
47 // e.g. std::vector<Real> -> std::vector<ADReal>
48 template <typename T, bool is_ad>
49 struct MooseADWrapperStruct<std::vector<T>, is_ad>
50 {
51  typedef std::vector<typename MooseADWrapperStruct<T, is_ad>::type> type;
52 };
53 
54 // std::array and MooseUtils::SemidynamicVector support
55 template <typename T, std::size_t N, bool is_ad>
56 struct MooseADWrapperStruct<std::array<T, N>, is_ad>
57 {
58  typedef std::array<typename MooseADWrapperStruct<T, is_ad>::type, N> type;
59 };
60 
61 namespace MooseUtils
62 {
63 template <typename, std::size_t, bool>
65 }
66 
67 template <typename T, std::size_t N, bool is_ad, bool zero_initialize>
68 struct MooseADWrapperStruct<MooseUtils::SemidynamicVector<T, N, zero_initialize>, is_ad>
69 {
70  typedef MooseUtils::
71  SemidynamicVector<typename MooseADWrapperStruct<T, is_ad>::type, N, zero_initialize>
73 };
74 
75 template <typename T, bool is_ad>
77 
78 template <typename T>
80 {
81  static constexpr bool value = false;
82 };
83 
84 template <>
86 {
87  static constexpr bool value = true;
88 };
89 
90 template <>
92 {
93  static constexpr bool value = true;
94 };
95 
96 template <template <typename> class W, typename T>
97 struct MooseIsADType<W<T>>
98 {
99  static constexpr bool value = MooseIsADType<T>::value;
100 };
101 
102 template <typename T>
103 struct MooseIsADType<std::vector<T>>
104 {
105  static constexpr bool value = MooseIsADType<T>::value;
106 };
107 
108 template <template <typename, std::size_t> class W, typename T, std::size_t N>
109 struct MooseIsADType<W<T, N>>
110 {
111  static constexpr bool value = MooseIsADType<T>::value;
112 };
DualNumber< Real, Real > ChainedReal
Definition: ChainedReal.h:30
std::array< typename MooseADWrapperStruct< T, is_ad >::type, N > type
Utility class template for a semidynamic vector with a maximum size N and a chosen dynamic size...
static constexpr bool value
DualReal ADReal
Definition: ADRealForward.h:14
std::vector< typename MooseADWrapperStruct< T, is_ad >::type > type
MooseUtils::SemidynamicVector< typename MooseADWrapperStruct< T, is_ad >::type, N, zero_initialize > type
typename MooseADWrapperStruct< T, is_ad >::type MooseADWrapper
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
DualNumber< ADReal, ADReal > ChainedADReal
Definition: ChainedADReal.h:15
W< typename MooseADWrapperStruct< T, is_ad >::type > type