CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
staticContextActiveType.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://scicomp.rptu.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://scicomp.rptu.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/gradientAccessTapeInterface.hpp"
40#include "../../tapes/interfaces/internalStatementRecordingTapeInterface.hpp"
41#include "../../traits/realTraits.hpp"
42#include "../expressionInterface.hpp"
43
45namespace codi {
46
55 template<typename T_Tape>
56 struct StaticContextActiveType : public ExpressionInterface<typename T_Tape::Real, StaticContextActiveType<T_Tape>> {
57 public:
58
59 using Tape = CODI_DD(
62
63 using Real = CODI_DD(typename Tape::Real, double);
64 using Identifier = typename Tape::Identifier;
65
67
68 private:
69
70 Real const primal;
71 Identifier const identifier;
72
73 public:
74
76 CODI_INLINE StaticContextActiveType(Real const& primal, Identifier const& identifier)
77 : primal(primal), identifier(identifier) {}
78
81 : Base(static_cast<Base const&>(other)), primal(other.primal), identifier(other.identifier) {}
82
83 /*******************************************************************************/
86
89 return identifier;
90 }
91
93 /*******************************************************************************/
96
99
101 CODI_INLINE Real const getValue() const {
102 return primal;
103 }
104
106 template<size_t argNumber>
108 return Real();
109 }
110
112 /*******************************************************************************/
115
116 static bool constexpr EndPoint = true;
117
119 template<typename Logic, typename... Args>
120 CODI_INLINE void forEachLink(TraversalLogic<Logic>& logic, Args&&... args) const {
121 CODI_UNUSED(logic, args...);
122 }
123
125 template<typename Logic, typename... Args>
126 CODI_INLINE static typename Logic::ResultType constexpr forEachLinkConstExpr(Args&&... CODI_UNUSED_ARG(args)) {
127 return Logic::NeutralElement;
128 }
129
131
132 private:
133 StaticContextActiveType& operator=(StaticContextActiveType const&) = delete;
134 };
135}
#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_UNUSED_ARG(arg)
Used in a constexpr context, where using CODI_UNUSED spoils the constexpr.
Definition macros.hpp:49
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:59
Allow for a direct access to the gradient information computed by the tape.
Definition gradientAccessTapeInterface.hpp:67
Internal tape interface that is used by active types to trigger the storing of an expression.
Definition internalStatementRecordingTapeInterface.hpp:65
Replacement type of LhsExpressionInterface types in ConstructStaticContext.
Definition staticContextActiveType.hpp:56
Identifier const & getIdentifier() const
Definition staticContextActiveType.hpp:88
StaticContextActiveType(Real const &primal, Identifier const &identifier)
Constructor.
Definition staticContextActiveType.hpp:76
static bool constexpr EndPoint
If this expression is handled as a leaf in the tree.
Definition staticContextActiveType.hpp:116
typename Tape::Identifier Identifier
See TapeTypesInterface.
Definition staticContextActiveType.hpp:64
void forEachLink(TraversalLogic< Logic > &logic, Args &&... args) const
Definition staticContextActiveType.hpp:120
typename Tape::Real Real
See TapeTypesInterface.
Definition staticContextActiveType.hpp:63
T_Tape Tape
See StaticContextActiveType.
Definition staticContextActiveType.hpp:59
static Logic::ResultType constexpr forEachLinkConstExpr(Args &&...)
Definition staticContextActiveType.hpp:126
StaticContextActiveType(StaticContextActiveType const &other)
Constructor.
Definition staticContextActiveType.hpp:80
Real const getValue() const
Compute the primal value that is usually evaluated by the statement/expression.
Definition staticContextActiveType.hpp:101
Real getJacobian() const
Definition staticContextActiveType.hpp:107
Traversal of CoDiPack expressions.
Definition traversalLogic.hpp:56