37#include "../../expressions/logic/helpers/forEachLeafLogic.hpp"
38#include "../../misc/enumBitset.hpp"
39#include "../indices/indexManagerInterface.hpp"
40#include "../interfaces/fullTapeInterface.hpp"
41#include "../misc/adjointVectorAccess.hpp"
48 template<
typename Real,
typename Tag>
72 template<
typename T_Real,
typename T_Tag,
typename T_Gradient,
typename T_Impl>
126 template<
typename Node>
129 tape.verifyTag(vi, tagData.
tag);
136 std::swap(
curTag, other.curTag);
172 template<
typename Real>
179 template<
typename Real>
184 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
189 int constexpr Elements = AggregatedTraits::Elements;
193 Aggregated
real = rhs.
cast().getValue();
196 ValidateTags validate;
205 if (vi[i.value].isActive) {
210 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
216 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
223 template<
typename Lhs,
typename Rhs>
225 ValidateTags validate;
228 validate.eval(rhs, vi, cast());
240 lhs.
cast().value() = rhs.
cast().getValue();
244 template<
typename Lhs,
typename Rhs>
251 template<
typename Lhs>
257 lhs.
cast().value() = rhs;
276 template<
typename Lhs>
278 return value.
cast().getTapeData().tag;
282 template<
typename Lhs>
284 value.
cast().getTapeData().tag = this->curTag;
288 template<
typename Lhs>
290 value.
cast().getTapeData().tag =
Tag();
294 template<
typename Lhs>
296 value.
cast().getTapeData().properties.reset();
300 template<
typename Lhs>
302 value.
cast().getTapeData().properties.set(flag);
306 template<
typename Lhs>
308 return value.
cast().getTapeData().properties.test(flag);
391 std::cerr <<
"Property error '" << std::to_string(flag) <<
"' on value. current value: " << currentValue
392 <<
" new value: " << newValue <<
"" << std::endl;
400 std::cerr <<
"Use of variable with bad tag '" << wrongTag <<
"', should be '" << correctTag <<
"'.";
402 std::cerr <<
" The value seems to be a preaccumulation output.";
404 std::cerr <<
" The value seems to be used during a preaccumulation but is not declared as an input.";
406 std::cerr << std::endl;
412 if (lhsValue != rhs) {
421 template<
typename Lhs>
439 template<
typename Lhs>
465 return static_cast<Impl&
>(*this);
#define CODI_LAMBDA_INLINE
See codi::Config::ForcedInlines.
Definition config.h:473
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:97
CoDiPack - Code Differentiation Package.
Definition codi.hpp:97
inlinevoid static_for(F func, Args &&... args)
Static for with i = 0 .. (N - 1). See CompileTimeLoop for details.
Definition compileTimeLoop.hpp:110
typename ArrayAccessExpressionImpl< Aggregated, element >::template Expression< Arg > ArrayAccessExpression
Expression that performs a[element] in a compile time context.
Definition arrayAccessExpression.hpp:98
inlineauto real(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:55
TagFlags
Properties for values.
Definition tagData.hpp:46
@ DoNotChange
DoNotChange: Value can be assigned, but it should not change.
Definition tagData.hpp:47
@ DoNotWrite
DoNotWrite: Value can not be assigned.
Definition tagData.hpp:48
@ DoNotUse
Definition tagData.hpp:49
InnerActiveType values[Elements]
Array representation.
Definition aggregatedActiveType.hpp:75
Represents a concrete aggregated lvalue int the CoDiPack expression tree.
Definition aggregatedActiveType.hpp:164
A bitset with enum items as flags.
Definition enumBitset.hpp:64
inlinebool test(Enum pos) const
Test if the bit for the enum is set.
Definition enumBitset.hpp:93
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
inlineImpl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:76
Implement logic for leaf nodes only.
Definition forEachLeafLogic.hpp:60
ValidateTags Impl
Definition forEachLeafLogic.hpp:63
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:103
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:233
Data for a tag.
Definition tagData.hpp:56
EnumBitset< TagFlags > properties
Current properties of the value.
Definition tagData.hpp:62
Tag tag
Current tag of the value.
Definition tagData.hpp:61
void setTagPropertyOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
Set properties on a CoDiPack active type.
Definition tagTapeBase.hpp:301
inlinevoid setTag(Tag &tag) const
Set tag on value.
Definition tagTapeBase.hpp:452
void * tagPropertyErrorUserData
Definition tagTapeBase.hpp:97
inlineTag getPreaccumulationHandlingTag()
The special tag for preaccumulation.
Definition tagTapeBase.hpp:340
Identifier tempIdentifier
Definition tagTapeBase.hpp:105
void clearTagOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Clear tag on a CoDiPack active type.
Definition tagTapeBase.hpp:289
static bool constexpr AllowJacobianOptimization
Definition tagTapeBase.hpp:169
TagErrorCallback tagErrorCallback
Definition tagTapeBase.hpp:99
void destroyTapeData(Real &value, ActiveTypeTapeData &data)
Do nothing.
Definition tagTapeBase.hpp:180
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
Verify all tags of the rhs and the lhs properties.
Definition tagTapeBase.hpp:224
T_Impl Impl
See TagTapeBase.
Definition tagTapeBase.hpp:77
void(*)(Tag const &correctTag, Tag const &wrongTag, void *userData) TagErrorCallback
Callback for a tag error.
Definition tagTapeBase.hpp:87
Tag curTag
Definition tagTapeBase.hpp:94
inlinevoid checkLhsError(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs) const
Check if the lhs value is changed.
Definition tagTapeBase.hpp:422
void setTagErrorCallback(TagErrorCallback const &callback, void *userData)
Set the callback and user data for a tag error.
Definition tagTapeBase.hpp:318
inlinevoid handleError(ValidationIndicator< Real, Tag > &vi) const
Call tag error callback.
Definition tagTapeBase.hpp:427
T_Tag Tag
See TagTapeBase.
Definition tagTapeBase.hpp:75
inlinevoid verifyTag(ValidationIndicator< Real, Tag > &vi, Tag const &tag) const
Checks if the tag is correct. Errors are set on the ValidationIndicator object.
Definition tagTapeBase.hpp:347
inlinevoid checkLhsError(Real &lhsValue, ActiveTypeTapeData &lhsData, const Real &rhs) const
Check if a property for the lhs value is triggered.
Definition tagTapeBase.hpp:410
void setTagOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > const &value)
Set tag on a CoDiPack active type.
Definition tagTapeBase.hpp:283
inlinebool isPreaccumulationHandlingEnabled()
If handling for preaccumulation is enabled.
Definition tagTapeBase.hpp:335
bool preaccumulationHandling
Definition tagTapeBase.hpp:102
inlineIdentifier const & getIdentifier(ActiveTypeTapeData const &data)
Definition tagTapeBase.hpp:150
TagTapeBase()
Constructor.
Definition tagTapeBase.hpp:112
Tag getTagFromVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Get tag of a CoDiPack active type.
Definition tagTapeBase.hpp:277
inlinevoid setPreaccumulationHandlingTag(Tag tag)
Set the special tag for preaccumulation regions. See setPreaccumulationHandlingEnabled().
Definition tagTapeBase.hpp:330
static void defaultPropertyErrorCallback(Real const ¤tValue, Real const &newValue, TagFlags flag, void *userData)
Definition tagTapeBase.hpp:387
inlinevoid verifyProperties(ValidationIndicator< Real, Tag > &vi, Real const &value, const EnumBitset< TagFlags > &properties) const
Checks if the tag properties are correct.
Definition tagTapeBase.hpp:367
T_Real Real
See TagTapeBase.
Definition tagTapeBase.hpp:74
inlinevoid resetTag(Tag &tag) const
Reset tag on value.
Definition tagTapeBase.hpp:457
void clearTagPropertiesOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Clear properties on a CoDiPack active type.
Definition tagTapeBase.hpp:295
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, Impl, Rhs > const &rhs)
Verify all tags of the rhs and the lhs properties.
Definition tagTapeBase.hpp:245
TagPropertyErrorCallback tagPropertyErrorCallback
Definition tagTapeBase.hpp:96
inlinevoid setPreaccumulationHandlingEnabled(bool enabled)
Enable or disable specialized handling for preaccumulation. Default: true Uses a special tag to sanit...
Definition tagTapeBase.hpp:325
Identifier const activeIdentifier
Definition tagTapeBase.hpp:106
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, AggregatedActiveType< Aggregated, Type, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition tagTapeBase.hpp:217
static Tag constexpr PassiveTag
Definition tagTapeBase.hpp:89
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs)
Verify the lhs properties.
Definition tagTapeBase.hpp:252
Identifier const passiveIdentifier
Definition tagTapeBase.hpp:107
void setTagPropertyErrorCallback(TagPropertyErrorCallback const &callback, void *userData)
Set the callback and user data for a property error error.
Definition tagTapeBase.hpp:312
T_Gradient Gradient
See TagTapeBase.
Definition tagTapeBase.hpp:76
int Identifier
See TapeTypesInterface.
Definition tagTapeBase.hpp:79
static void defaultTagErrorCallback(Tag const &correctTag, Tag const &wrongTag, void *userData)
Definition tagTapeBase.hpp:396
void initTapeData(Real &value, ActiveTypeTapeData &data)
Do nothing.
Definition tagTapeBase.hpp:173
inlinevoid verifyTag(Tag const &tag) const
Checks if the tag is correct and creates an error.
Definition tagTapeBase.hpp:359
static Tag constexpr InvalidTag
Definition tagTapeBase.hpp:90
Tag getCurTag()
Get the current tag of the tape.
Definition tagTapeBase.hpp:271
TagData< Tag > ActiveTypeTapeData
See TapeTypesInterface.
Definition tagTapeBase.hpp:80
inlineIdentifier & getIdentifier(ActiveTypeTapeData &data)
Definition tagTapeBase.hpp:159
bool hasTagPropertyOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
Check properties on a CoDiPack active type.
Definition tagTapeBase.hpp:307
void setCurTag(const Tag &tag)
Set the current tag of the tape.
Definition tagTapeBase.hpp:266
inlinevoid verifyRegisterValue(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, ActiveTypeTapeData const &tag)
Verify tag, properties and lhs error.
Definition tagTapeBase.hpp:440
Tag preaccumulationTag
Definition tagTapeBase.hpp:103
inlinevoid verifyTagAndProperties(Tag const &tag, Real const &value, const EnumBitset< TagFlags > &properties) const
Checks if the tag and the properties are correct.
Definition tagTapeBase.hpp:377
void swap(Impl &other)
Swap members.
Definition tagTapeBase.hpp:135
void(*)(Real const ¤tValue, Real const &newValue, TagFlags flag, void *userData) TagPropertyErrorCallback
Callback for a change in a lhs value.
Definition tagTapeBase.hpp:83
void * tagErrorUserData
Definition tagTapeBase.hpp:100
inlinevoid node(Node const &node, Args &&... args)
Definition traversalLogic.hpp:87
Helper class for statement validation.
Definition tagTapeBase.hpp:49
bool hasError
true if an error is detected.
Definition tagTapeBase.hpp:51
Tag errorTag
Value of the wrong tag.
Definition tagTapeBase.hpp:54
ValidationIndicator()
Constructor.
Definition tagTapeBase.hpp:58
Real value
Primal value of the value with the tag error.
Definition tagTapeBase.hpp:55
bool hasUseError
true if a value is used in the wrong way.
Definition tagTapeBase.hpp:53
bool isActive
true if an active rhs is detected. tag != 0
Definition tagTapeBase.hpp:50
bool hasTagError
true if a tag not the current required tag.
Definition tagTapeBase.hpp:52