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>
120 template<
typename Node>
123 tape.verifyTag(vi, tagData.
tag);
130 std::swap(
curTag, other.curTag);
154 template<
typename Lhs>
156 return value.
cast().getIdentifier().tag;
160 template<
typename Lhs>
162 value.
cast().getIdentifier().tag = this->
curTag;
166 template<
typename Lhs>
168 value.
cast().getIdentifier().tag =
Tag();
172 template<
typename Lhs>
174 value.
cast().getIdentifier().properties.reset();
178 template<
typename Lhs>
180 value.
cast().getIdentifier().properties.set(flag);
184 template<
typename Lhs>
186 return value.
cast().getIdentifier().properties.test(flag);
269 std::cerr <<
"Property error '" << std::to_string(flag) <<
"' on value. current value: " << currentValue
270 <<
" new value: " << newValue <<
"" << std::endl;
278 std::cerr <<
"Use of variable with bad tag '" << wrongTag <<
"', should be '" << correctTag <<
"'.";
280 std::cerr <<
" The value seems to be a preaccumulation output.";
282 std::cerr <<
" The value seems to be used during a preaccumulation but is not declared as an input.";
284 std::cerr << std::endl;
290 if (lhsValue != rhs) {
299 template<
typename Lhs>
317 template<
typename Lhs>
#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
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
TagFlags
Properties for values.
Definition: tagData.hpp:46
@ DoNotChange
DoNotChange: Value can be assigned, but it should not change.
@ DoNotWrite
DoNotWrite: Value can not be assigned.
Represents a concrete lvalue in the CoDiPack expression tree.
Definition: activeType.hpp:52
A bitset with enum items as flags.
Definition: enumBitset.hpp:64
bool test(Enum pos) const
Test if the bit for the enum is set.
Definition: enumBitset.hpp:93
Implement logic for leaf nodes only.
Definition: forEachLeafLogic.hpp:60
ValidateTags Impl
See ForEachLeafLogic.
Definition: forEachLeafLogic.hpp:63
Base class for all CoDiPack lvalue expression.
Definition: lhsExpressionInterface.hpp:63
Impl & cast()
Cast to the implementation.
Definition: lhsExpressionInterface.hpp:99
EnumBitset< TagFlags > properties
Current properties of the value.
Definition: tagData.hpp:62
Tag tag
Current tag of the value.
Definition: tagData.hpp:61
Base implementation for tagging tapes.
Definition: tagTapeBase.hpp:73
bool isPreaccumulationHandlingEnabled()
If handling for preaccumulation is enabled.
Definition: tagTapeBase.hpp:213
void setTagPropertyOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
Set properties on a CoDiPack active type.
Definition: tagTapeBase.hpp:179
void * tagPropertyErrorUserData
User data in call to callback for lhs value errors.
Definition: tagTapeBase.hpp:95
void setPreaccumulationHandlingEnabled(bool enabled)
Enable or disable specialized handling for preaccumulation. Default: true Uses a special tag to sanit...
Definition: tagTapeBase.hpp:203
void clearTagOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Clear tag on a CoDiPack active type.
Definition: tagTapeBase.hpp:167
T_Gradient Gradient
See TagTapeBase.
Definition: tagTapeBase.hpp:76
T_Tag Tag
See TagTapeBase.
Definition: tagTapeBase.hpp:75
void verifyTag(Tag const &tag) const
Checks if the tag is correct and creates an error.
Definition: tagTapeBase.hpp:237
TagErrorCallback tagErrorCallback
User defined callback for tag errors.
Definition: tagTapeBase.hpp:97
void(*)(Tag const &correctTag, Tag const &wrongTag, void *userData) TagErrorCallback
Callback for a tag error.
Definition: tagTapeBase.hpp:86
Tag curTag
Current tag for new values.
Definition: tagTapeBase.hpp:92
void setTagErrorCallback(TagErrorCallback const &callback, void *userData)
Set the callback and user data for a tag error.
Definition: tagTapeBase.hpp:196
void verifyProperties(ValidationIndicator< Real, Tag > &vi, Real const &value, const EnumBitset< TagFlags > &properties) const
Checks if the tag properties are correct.
Definition: tagTapeBase.hpp:245
void verifyRegisterValue(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, const Identifier &tag)
Verify tag, properties and lhs error.
Definition: tagTapeBase.hpp:318
void resetTag(Tag &tag) const
Reset tag on value.
Definition: tagTapeBase.hpp:335
void setTagOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > const &value)
Set tag on a CoDiPack active type.
Definition: tagTapeBase.hpp:161
bool preaccumulationHandling
Parameter to enable/disable preaccumulation handling.
Definition: tagTapeBase.hpp:100
TagTapeBase()
Constructor.
Definition: tagTapeBase.hpp:106
Tag getTagFromVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Get tag of a CoDiPack active type.
Definition: tagTapeBase.hpp:155
static void defaultPropertyErrorCallback(Real const ¤tValue, Real const &newValue, TagFlags flag, void *userData)
Default callback for TagPropertyErrorCallback.
Definition: tagTapeBase.hpp:265
void clearTagPropertiesOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Clear properties on a CoDiPack active type.
Definition: tagTapeBase.hpp:173
void handleError(ValidationIndicator< Real, Tag > &vi) const
Call tag error callback.
Definition: tagTapeBase.hpp:305
T_Impl Impl
See TagTapeBase.
Definition: tagTapeBase.hpp:77
TagPropertyErrorCallback tagPropertyErrorCallback
User defined callback for lhs value errors.
Definition: tagTapeBase.hpp:94
Tag getPreaccumulationHandlingTag()
The special tag for preaccumulation.
Definition: tagTapeBase.hpp:218
void setTag(Tag &tag) const
Set tag on value.
Definition: tagTapeBase.hpp:330
static Tag constexpr PassiveTag
Tag indicating an inactive value.
Definition: tagTapeBase.hpp:88
void 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:225
void setTagPropertyErrorCallback(TagPropertyErrorCallback const &callback, void *userData)
Set the callback and user data for a property error error.
Definition: tagTapeBase.hpp:190
T_Real Real
See TagTapeBase.
Definition: tagTapeBase.hpp:74
void verifyTagAndProperties(Tag const &tag, Real const &value, const EnumBitset< TagFlags > &properties) const
Checks if the tag and the properties are correct.
Definition: tagTapeBase.hpp:255
static void defaultTagErrorCallback(Tag const &correctTag, Tag const &wrongTag, void *userData)
Default callback for TagErrorCallback.
Definition: tagTapeBase.hpp:274
Tag getCurTag()
Get the current tag of the tape.
Definition: tagTapeBase.hpp:149
bool hasTagPropertyOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
Check properties on a CoDiPack active type.
Definition: tagTapeBase.hpp:185
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 setCurTag(const Tag &tag)
Set the current tag of the tape.
Definition: tagTapeBase.hpp:144
Tag preaccumulationTag
Tag used for preaccumulation specialized handling.
Definition: tagTapeBase.hpp:101
void checkLhsError(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, const Real &rhs) const
Check if the lhs value is changed.
Definition: tagTapeBase.hpp:300
void checkLhsError(Real &lhsValue, Identifier &lhsIdentifier, const Real &rhs) const
Check if a property for the lhs value is triggered.
Definition: tagTapeBase.hpp:288
void setPreaccumulationHandlingTag(Tag tag)
Set the special tag for preaccumulation regions. See setPreaccumulationHandlingEnabled().
Definition: tagTapeBase.hpp:208
void swap(Impl &other)
Swap members.
Definition: tagTapeBase.hpp:129
void * tagErrorUserData
User data in call to callback for tag errors.
Definition: tagTapeBase.hpp:98
void node(Node const &node, Args &&... args)
Called for each node in the expression.
Definition: traversalLogic.hpp:86
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