CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
activeTypeWrapper.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://www.scicomp.uni-kl.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://www.scicomp.uni-kl.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include "../config.h"
38#include "../misc/macros.hpp"
39#include "../tapes/interfaces/fullTapeInterface.hpp"
40#include "../traits/realTraits.hpp"
41#include "activeType.hpp"
42#include "assignmentOperators.hpp"
43#include "incrementOperators.hpp"
44#include "lhsExpressionInterface.hpp"
45
47namespace codi {
48
59 template<typename T_ActiveType>
61 : public LhsExpressionInterface<typename T_ActiveType::Real, typename T_ActiveType::Gradient,
62 typename T_ActiveType::Tape, ActiveTypeWrapper<T_ActiveType>>,
63 public AssignmentOperators<typename T_ActiveType::Tape, ActiveTypeWrapper<T_ActiveType>>,
64 public IncrementOperators<typename T_ActiveType::Tape, ActiveTypeWrapper<T_ActiveType>> {
65 public:
66
67 using ActiveType = CODI_DD(T_ActiveType,
69 using Tape = typename ActiveType::Tape;
70
71 using Real = typename Tape::Real;
73 using Identifier = typename Tape::Identifier;
74 using Gradient = typename Tape::Gradient;
75
77
78 private:
79
80 Real& primalValue;
81 Identifier& identifier;
82
83 public:
84
87 CODI_INLINE ActiveTypeWrapper(Real& value, Identifier& identifier) : primalValue(value), identifier(identifier) {
88 // deliberately left empty
89 }
90
94 // deliberately left empty
95 }
96
100 // deliberately left empty
101 }
102
106 return *this;
107 }
109
110 /*******************************************************************************/
113
114 using StoreAs = ActiveTypeWrapper const&;
116
118 /*******************************************************************************/
121
124 return identifier;
125 }
126
129 return identifier;
130 }
131
134 return primalValue;
135 }
136
138 CODI_INLINE Real const& value() const {
139 return primalValue;
140 }
141
144 return ActiveType::getTape();
145 }
146
148 };
149} // end of namespace codi
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition: config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition: macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition: macros.hpp:111
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition: realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition: codi.hpp:90
Creates a pseudo active type from data references. Can be used to overlay existing data with active t...
Definition: activeTypeWrapper.hpp:64
typename ActiveType::ActiveResult ActiveResult
Type into which the expression can be converted. Usually also the type from which it is constructed.
Definition: activeTypeWrapper.hpp:115
typename Tape::Real Real
See LhsExpressionInterface.
Definition: activeTypeWrapper.hpp:71
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition: activeTypeWrapper.hpp:72
typename ActiveType::Tape Tape
See ActiveType.
Definition: activeTypeWrapper.hpp:69
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition: activeTypeWrapper.hpp:73
ActiveTypeWrapper const & StoreAs
" Defines how this expression is stored in an expression tree. "
Definition: activeTypeWrapper.hpp:114
ActiveTypeWrapper< ActiveType > & operator=(ActiveTypeWrapper< ActiveType > const &v)
See LhsExpressionInterface::operator=(ExpressionInterface const&)
Definition: activeTypeWrapper.hpp:104
Identifier const & getIdentifier() const
Definition: activeTypeWrapper.hpp:128
Real const & value() const
Get a constant reference to the lvalue represented by the expression.
Definition: activeTypeWrapper.hpp:138
~ActiveTypeWrapper()
Definition: activeTypeWrapper.hpp:99
Real & value()
Get a reference to the lvalue represented by the expression.
Definition: activeTypeWrapper.hpp:133
ActiveTypeWrapper(Real &value, Identifier &identifier)
Definition: activeTypeWrapper.hpp:87
ActiveTypeWrapper(ActiveType &value)
Definition: activeTypeWrapper.hpp:93
static Tape & getTape()
Get a reference to the tape which manages this expression.
Definition: activeTypeWrapper.hpp:143
typename Tape::Gradient Gradient
See LhsExpressionInterface.
Definition: activeTypeWrapper.hpp:74
T_ActiveType ActiveType
See WritableActiveTypeWrapper.
Definition: activeTypeWrapper.hpp:68
Identifier & getIdentifier()
Definition: activeTypeWrapper.hpp:123
static Tape & getTape()
Get a reference to the tape which manages this expression.
Definition: activeType.hpp:99
Impl ActiveResult
Type into which the expression can be converted. Usually also the type from which it is constructed.
Definition: activeTypeBase.hpp:148
T_Tape Tape
See ActiveType.
Definition: activeType.hpp:55
Implementation of assignment operators for LhsExpressionInterface implementations.
Definition: assignmentOperators.hpp:54
Implementation of increment operators for LhsExpressionInterface implementations.
Definition: incrementOperators.hpp:54
Base class for all CoDiPack lvalue expression.
Definition: lhsExpressionInterface.hpp:63