-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathactiveType.hpp
110 lines (90 loc) · 3.41 KB
/
activeType.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* CoDiPack, a Code Differentiation Package
*
* Copyright (C) 2015-2025 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
* Homepage: http://scicomp.rptu.de
* Contact: Prof. Nicolas R. Gauger ([email protected])
*
* Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
*
* This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
*
* CoDiPack is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* CoDiPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
* You should have received a copy of the GNU
* General Public License along with CoDiPack.
* If not, see <http://www.gnu.org/licenses/>.
*
* For other licensing options please contact us.
*
* Authors:
* - SciComp, University of Kaiserslautern-Landau:
* - Max Sagebaum
* - Johannes Blühdorn
* - Former members:
* - Tim Albring
*/
#pragma once
#include "activeTypeBase.hpp"
/** \copydoc codi::Namespace */
namespace codi {
/**
* @brief Represents a concrete lvalue in the CoDiPack expression tree.
*
* See ActiveTypeBase.
*
* This active type implements a static tape.
*
* @tparam T_Tape The tape that manages all expressions created with this type.
*/
template<typename T_Tape>
struct ActiveType : public ActiveTypeBase<T_Tape, ActiveType<T_Tape>> {
public:
using Tape = CODI_DD(T_Tape, CODI_DEFAULT_TAPE); ///< See ActiveType.
using Base = ActiveTypeBase<T_Tape, ActiveType>; ///< Base class abbreviation.
using typename Base::Gradient; ///< See ActiveTypeBase.
using typename Base::Identifier; ///< See ActiveTypeBase.
using typename Base::PassiveReal; ///< See ActiveTypeBase.
using typename Base::Real; ///< See ActiveTypeBase.
using typename Base::ActiveResult; ///< See ActiveTypeBase.
using typename Base::StoreAs; ///< See ActiveTypeBase.
private:
static Tape tape;
public:
/// Constructor
CODI_INLINE ActiveType(ActiveType<Tape> const& v) : Base(static_cast<Base const&>(v)) {}
using Base::Base; // Use constructors from base class.
/// Destructor
CODI_INLINE ~ActiveType() {}
/*******************************************************************************/
/// @name Assignment operators (all forwarding to the base class)
/// @{
/// See ActiveTypeBase::operator=(ActiveTypeBase const&).
CODI_INLINE ActiveType& operator=(ActiveType const& v) {
static_cast<Base&>(*this) = static_cast<Base const&>(v);
return *this;
}
using Base::operator=;
/// @}
/*******************************************************************************/
/// @name Implementation of LhsExpressionInterface
/// @{
/// \copydoc codi::LhsExpressionInterface::getTape()
static CODI_INLINE Tape& getTape() {
return tape;
}
/// @}
};
// clang-format off
template<typename Tape>
CODI_DD(Tape, CODI_DEFAULT_TAPE) ActiveType<Tape>::tape{};
// clang-format on
}