https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Private Attributes | List of all members
AttribVectorTags Class Referenceabstract

#include <Attributes.h>

Inheritance diagram for AttribVectorTags:
[legend]

Public Types

typedef unsigned int Key
 

Public Member Functions

 clonefunc (AttribVectorTags)
 
void setFrom (Key k)
 
 AttribVectorTags (TheWarehouse &w)
 
 AttribVectorTags (TheWarehouse &w, TagID tag)
 
 AttribVectorTags (TheWarehouse &w, const std::set< TagID > &tags)
 
virtual void initFrom (const MooseObject *obj) override
 initFrom reads and stores the desired meta-data from obj for later matching comparisons.
 
virtual bool isMatch (const Attribute &other) const override
 isMatch returns true if the meta-data stored in this attribute is equivalent to that stored in other.
 
virtual bool isEqual (const Attribute &other) const override
 isEqual returns true if the meta-data stored in this attribute is identical to that stored in other.
 
 hashfunc (_vals)
 
bool operator== (const Attribute &other) const
 
bool operator!= (const Attribute &other) const
 
unsigned int id () const
 returns the unique attribute ID associated with all attributes that have the same (mose derived) class as this object.
 
virtual std::size_t hash () const =0
 This function must return a deterministic value that is uniquely determined by the data the attribute holds (i.e.
 
virtual std::unique_ptr< Attributeclone () const =0
 clone creates and returns and identical (deep) copy of this attribute - i.e.
 

Protected Attributes

std::vector< TagID_vals
 

Private Attributes

int _id = -1
 

Detailed Description

Definition at line 111 of file Attributes.h.

Member Typedef Documentation

◆ Key

typedef unsigned int AttribVectorTags::Key

Definition at line 116 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttribVectorTags() [1/3]

AttribVectorTags::AttribVectorTags ( TheWarehouse w)
inline

Definition at line 123 of file Attributes.h.

123: AttribTagBase(w, "vector_tags") {}
AttribTagBase tracks all (vector or matrix) tags associated with an object.
Definition Attributes.h:68

◆ AttribVectorTags() [2/3]

AttribVectorTags::AttribVectorTags ( TheWarehouse w,
TagID  tag 
)
inline

Definition at line 124 of file Attributes.h.

124: AttribTagBase(w, tag, "vector_tags") {}

◆ AttribVectorTags() [3/3]

AttribVectorTags::AttribVectorTags ( TheWarehouse w,
const std::set< TagID > &  tags 
)
inline

Definition at line 125 of file Attributes.h.

126 : AttribTagBase(w, tags, "vector_tags")
127 {
128 }

Member Function Documentation

◆ clone()

virtual std::unique_ptr< Attribute > Attribute::clone ( ) const
pure virtualinherited

clone creates and returns and identical (deep) copy of this attribute - i.e.

the result of clone should return true if passed into isMatch.

Referenced by TheWarehouse::update().

◆ clonefunc()

AttribVectorTags::clonefunc ( AttribVectorTags  )

◆ hash()

virtual std::size_t Attribute::hash ( ) const
pure virtualinherited

This function must return a deterministic value that is uniquely determined by the data the attribute holds (i.e.

is initialized with). Ideally, the data should be uniformly and randomly distributed across the domain of size_t values - e.g. 1 and 2 should hash to completely unrelated values. Use of std::hash for POD is encouraged. A convenience hash_combine function is also provided to combine the results an existing hash with one or more other values.

Referenced by std::hash< Attribute >::operator()().

◆ hashfunc()

AttribTagBase::hashfunc ( _vals  )
inherited

◆ id()

unsigned int Attribute::id ( ) const
inlineinherited

returns the unique attribute ID associated with all attributes that have the same (mose derived) class as this object.

This ID is determined at construction time this

Definition at line 68 of file TheWarehouse.h.

68{ return _id; }

Referenced by std::hash< Attribute >::operator()().

◆ initFrom()

void AttribVectorTags::initFrom ( const MooseObject obj)
overridevirtual

initFrom reads and stores the desired meta-data from obj for later matching comparisons.

Implements Attribute.

Definition at line 121 of file Attributes.C.

122{
123 _vals.clear();
124 auto t = dynamic_cast<const TaggingInterface *>(obj);
125 if (t)
126 {
127 for (auto & tag : t->getVectorTags({}))
128 _vals.push_back(static_cast<int>(tag));
129 }
130}
std::vector< TagID > _vals
Definition Attributes.h:88

◆ isEqual()

bool AttribTagBase::isEqual ( const Attribute other) const
overridevirtualinherited

isEqual returns true if the meta-data stored in this attribute is identical to that stored in other.

isEqual does not need to check/compare the values from the instances' id() functions.

Implements Attribute.

Definition at line 96 of file Attributes.C.

97{
98 auto a = dynamic_cast<const AttribTagBase *>(&other);
99 if (!a || a->_vals.size() != _vals.size())
100 return false;
101
102 for (size_t i = 0; i < a->_vals.size(); i++)
103 if (a->_vals[i] != _vals[i])
104 return false;
105 return true;
106}

◆ isMatch()

bool AttribTagBase::isMatch ( const Attribute other) const
overridevirtualinherited

isMatch returns true if the meta-data stored in this attribute is equivalent to that stored in other.

This is is for query matching - not exact equivalence. isMatch does not need to check/compare the values from the instances' id() functions.

Implements Attribute.

Definition at line 80 of file Attributes.C.

81{
82 auto a = dynamic_cast<const AttribTagBase *>(&other);
83 if (!a)
84 return false;
85 if (a->_vals.size() == 0)
86 return true; // the condition is empty tags - which we take to mean any tag should match
87
88 // return true if any single tag matches between the two attribute objects
89 for (auto val : _vals)
90 if (std::find(a->_vals.begin(), a->_vals.end(), val) != a->_vals.end())
91 return true;
92 return false;
93}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition KokkosUtils.h:40

◆ operator!=()

bool Attribute::operator!= ( const Attribute other) const
inlineinherited

Definition at line 63 of file TheWarehouse.h.

63{ return !(*this == other); }

◆ operator==()

bool Attribute::operator== ( const Attribute other) const
inlineinherited

Definition at line 59 of file TheWarehouse.h.

60 {
61 return _id == other._id && isEqual(other);
62 }
virtual bool isEqual(const Attribute &other) const =0
isEqual returns true if the meta-data stored in this attribute is identical to that stored in other.

◆ setFrom()

void AttribVectorTags::setFrom ( Key  k)
inline

Definition at line 117 of file Attributes.h.

118 {
119 _vals.clear();
120 _vals.push_back(k);
121 }

Member Data Documentation

◆ _id

int Attribute::_id = -1
privateinherited

Definition at line 93 of file TheWarehouse.h.

Referenced by Attribute::id(), and Attribute::operator==().

◆ _vals

std::vector<TagID> AttribTagBase::_vals
protectedinherited

The documentation for this class was generated from the following files: