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>
121 template<
typename Node>
125 tape.verifyProperties(
vi,
node.getValue(),
tagData.properties);
131 std::swap(
curTag, other.curTag);
155 template<
typename Lhs>
157 return value.
cast().getIdentifier().tag;
161 template<
typename Lhs>
163 value.
cast().getIdentifier().tag = this->
curTag;
167 template<
typename Lhs>
169 value.
cast().getIdentifier().tag =
Tag();
173 template<
typename Lhs>
175 value.
cast().getIdentifier().properties.reset();
179 template<
typename Lhs>
181 value.
cast().getIdentifier().properties.set(flag);
185 template<
typename Lhs>
187 return value.
cast().getIdentifier().properties.test(flag);
270 std::cerr <<
"Property error '" << std::to_string(flag) <<
"' on value. current value: " << currentValue
271 <<
" new value: " << newValue <<
"" << std::endl;
279 std::cerr <<
"Use of variable with bad tag '" << wrongTag <<
"', should be '" << correctTag <<
"'.";
281 std::cerr <<
" The value seems to be a preaccumulation output.";
283 std::cerr <<
" The value seems to be used during a preaccumulation but is not declared as an input.";
285 std::cerr << std::endl;
291 if (lhsValue != rhs) {
300 template<
typename Lhs>
318 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:214
void setTagPropertyOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
Set properties on a CoDiPack active type.
Definition tagTapeBase.hpp:180
void * tagPropertyErrorUserData
User data in call to callback for lhs value errors.
Definition tagTapeBase.hpp:96
void setPreaccumulationHandlingEnabled(bool enabled)
Enable or disable specialized handling for preaccumulation. Default: true Uses a special tag to sanit...
Definition tagTapeBase.hpp:204
void clearTagOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Clear tag on a CoDiPack active type.
Definition tagTapeBase.hpp:168
void verifyTag(Tag const &tag) const
Checks if the tag is correct and creates an error.
Definition tagTapeBase.hpp:238
TagErrorCallback tagErrorCallback
User defined callback for tag errors.
Definition tagTapeBase.hpp:98
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:86
Tag curTag
Current tag for new values.
Definition tagTapeBase.hpp:93
void setTagErrorCallback(TagErrorCallback const &callback, void *userData)
Set the callback and user data for a tag error.
Definition tagTapeBase.hpp:197
T_Tag Tag
See TagTapeBase.
Definition tagTapeBase.hpp:75
void verifyProperties(ValidationIndicator< Real, Tag > &vi, Real const &value, const EnumBitset< TagFlags > &properties) const
Checks if the tag properties are correct.
Definition tagTapeBase.hpp:246
void verifyRegisterValue(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, const Identifier &tag)
Verify tag, properties and lhs error.
Definition tagTapeBase.hpp:319
void resetTag(Tag &tag) const
Reset tag on value.
Definition tagTapeBase.hpp:336
void setTagOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > const &value)
Set tag on a CoDiPack active type.
Definition tagTapeBase.hpp:162
bool preaccumulationHandling
Parameter to enable/disable preaccumulation handling.
Definition tagTapeBase.hpp:101
TagTapeBase()
Constructor.
Definition tagTapeBase.hpp:107
Tag getTagFromVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Get tag of a CoDiPack active type.
Definition tagTapeBase.hpp:156
static void defaultPropertyErrorCallback(Real const ¤tValue, Real const &newValue, TagFlags flag, void *userData)
Default callback for TagPropertyErrorCallback.
Definition tagTapeBase.hpp:266
T_Real Real
See TagTapeBase.
Definition tagTapeBase.hpp:74
void clearTagPropertiesOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Clear properties on a CoDiPack active type.
Definition tagTapeBase.hpp:174
void handleError(ValidationIndicator< Real, Tag > &vi) const
Call tag error callback.
Definition tagTapeBase.hpp:306
TagPropertyErrorCallback tagPropertyErrorCallback
User defined callback for lhs value errors.
Definition tagTapeBase.hpp:95
Tag getPreaccumulationHandlingTag()
The special tag for preaccumulation.
Definition tagTapeBase.hpp:219
void setTag(Tag &tag) const
Set tag on value.
Definition tagTapeBase.hpp:331
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:226
void setTagPropertyErrorCallback(TagPropertyErrorCallback const &callback, void *userData)
Set the callback and user data for a property error error.
Definition tagTapeBase.hpp:191
T_Gradient Gradient
See TagTapeBase.
Definition tagTapeBase.hpp:76
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:256
static void defaultTagErrorCallback(Tag const &correctTag, Tag const &wrongTag, void *userData)
Default callback for TagErrorCallback.
Definition tagTapeBase.hpp:275
static Tag constexpr InvalidTag
Tag indicating an invalid value.
Definition tagTapeBase.hpp:89
Tag getCurTag()
Get the current tag of the tape.
Definition tagTapeBase.hpp:150
bool hasTagPropertyOnVariable(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
Check properties on a CoDiPack active type.
Definition tagTapeBase.hpp:186
void setCurTag(const Tag &tag)
Set the current tag of the tape.
Definition tagTapeBase.hpp:145
Tag preaccumulationTag
Tag used for preaccumulation specialized handling.
Definition tagTapeBase.hpp:102
void checkLhsError(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, const Real &rhs) const
Check if the lhs value is changed.
Definition tagTapeBase.hpp:301
void checkLhsError(Real &lhsValue, Identifier &lhsIdentifier, const Real &rhs) const
Check if a property for the lhs value is triggered.
Definition tagTapeBase.hpp:289
void setPreaccumulationHandlingTag(Tag tag)
Set the special tag for preaccumulation regions. See setPreaccumulationHandlingEnabled().
Definition tagTapeBase.hpp:209
void swap(Impl &other)
Swap members.
Definition tagTapeBase.hpp:130
void(*)(Real const ¤tValue, Real const &newValue, TagFlags flag, void *userData) TagPropertyErrorCallback
Callback for a change in a lhs value.
Definition tagTapeBase.hpp:82
void * tagErrorUserData
User data in call to callback for tag errors.
Definition tagTapeBase.hpp:99
void node(Node const &node, Args &&... args)
Called for each node in the expression.
Definition traversalLogic.hpp:86
void link(Child const &child, Root const &root, Args &&... args)
Called for all links in the expression.
Definition traversalLogic.hpp:110
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