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

AttribBoundaries tracks all boundary IDs associated with an object. More...

#include <Attributes.h>

Inheritance diagram for AttribBoundaries:
[legend]

Public Types

typedef std::tuple< BoundaryID, bool > Key
 

Public Member Functions

void setFrom (Key k)
 
 AttribBoundaries (TheWarehouse &w)
 
 AttribBoundaries (TheWarehouse &w, BoundaryID id, bool must_be_restricted=false)
 
 AttribBoundaries (TheWarehouse &w, const std::set< BoundaryID > &ids, bool must_be_restricted=false)
 
 AttribBoundaries (TheWarehouse &w, const std::vector< BoundaryID > &ids, bool must_be_restricted=false)
 
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, _must_be_restricted)
 
 clonefunc (AttribBoundaries)
 
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.
 

Private Attributes

std::vector< BoundaryID_vals
 
bool _must_be_restricted = false
 
int _id = -1
 

Detailed Description

AttribBoundaries tracks all boundary IDs associated with an object.

When running queries, an object matches true if it has at least one boundary id in common with the boundary IDs in the query attribute.

Definition at line 189 of file Attributes.h.

Member Typedef Documentation

◆ Key

typedef std::tuple<BoundaryID, bool> AttribBoundaries::Key

Definition at line 192 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttribBoundaries() [1/4]

AttribBoundaries::AttribBoundaries ( TheWarehouse w)
inline

Definition at line 200 of file Attributes.h.

200: Attribute(w, "boundaries") {}
Attribute is an abstract class that can be implemented in order to track custom metadata about MooseO...

◆ AttribBoundaries() [2/4]

AttribBoundaries::AttribBoundaries ( TheWarehouse w,
BoundaryID  id,
bool  must_be_restricted = false 
)
inline

Definition at line 201 of file Attributes.h.

202 : Attribute(w, "boundaries"), _must_be_restricted(must_be_restricted)
203 {
204 _vals.push_back(id);
205 }
std::vector< BoundaryID > _vals
Definition Attributes.h:230

◆ AttribBoundaries() [3/4]

AttribBoundaries::AttribBoundaries ( TheWarehouse w,
const std::set< BoundaryID > &  ids,
bool  must_be_restricted = false 
)
inline

Definition at line 206 of file Attributes.h.

209 : Attribute(w, "boundaries"), _must_be_restricted(must_be_restricted)
210 {
211 for (auto id : ids)
212 _vals.push_back(id);
213 }
unsigned int id() const
returns the unique attribute ID associated with all attributes that have the same (mose derived) clas...

◆ AttribBoundaries() [4/4]

AttribBoundaries::AttribBoundaries ( TheWarehouse w,
const std::vector< BoundaryID > &  ids,
bool  must_be_restricted = false 
)
inline

Definition at line 214 of file Attributes.h.

217 : Attribute(w, "boundaries"), _must_be_restricted(must_be_restricted)
218 {
219 _vals.reserve(ids.size());
220 for (auto id : ids)
221 _vals.push_back(id);
222 }

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()

AttribBoundaries::clonefunc ( AttribBoundaries  )

◆ 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()

AttribBoundaries::hashfunc ( _vals  ,
_must_be_restricted   
)

◆ 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 AttribBoundaries::initFrom ( const MooseObject obj)
overridevirtual

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

Implements Attribute.

Definition at line 223 of file Attributes.C.

224{
225 _vals.clear();
226 auto bnd = dynamic_cast<const BoundaryRestrictable *>(obj);
227 if (bnd && bnd->boundaryRestricted())
228 {
229 for (auto & bound : bnd->boundaryIDs())
230 _vals.push_back(bound);
231 }
232 else
233 _vals.push_back(Moose::ANY_BOUNDARY_ID);
234}
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
const BoundaryID ANY_BOUNDARY_ID
Definition MooseTypes.C:21

◆ isEqual()

bool AttribBoundaries::isEqual ( const Attribute other) const
overridevirtual

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 257 of file Attributes.C.

258{
259 auto a = dynamic_cast<const AttribBoundaries *>(&other);
260 if (!a || a->_vals.size() != _vals.size())
261 return false;
262
263 for (size_t i = 0; i < a->_vals.size(); i++)
264 if (a->_vals[i] != _vals[i])
265 return false;
266 return true;
267}
AttribBoundaries tracks all boundary IDs associated with an object.
Definition Attributes.h:190

◆ isMatch()

bool AttribBoundaries::isMatch ( const Attribute other) const
overridevirtual

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 237 of file Attributes.C.

238{
239 auto a = dynamic_cast<const AttribBoundaries *>(&other);
240 if (!a || a->_vals.size() < 1)
241 return false;
242
243 // return true if a single tag matches between the two attribute objects
244 for (auto val : _vals)
245 {
246 if (!a->_must_be_restricted && (val == Moose::ANY_BOUNDARY_ID))
247 return true;
248 if (std::find(a->_vals.begin(), a->_vals.end(), val) != a->_vals.end())
249 return true;
250 else if (std::find(a->_vals.begin(), a->_vals.end(), Moose::ANY_BOUNDARY_ID) != a->_vals.end())
251 return true;
252 }
253 return false;
254}

◆ 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 AttribBoundaries::setFrom ( Key  k)
inline

Definition at line 193 of file Attributes.h.

194 {
195 _vals.clear();
196 _vals.push_back(std::get<0>(k));
197 _must_be_restricted = std::get<1>(k);
198 }

Member Data Documentation

◆ _id

int Attribute::_id = -1
privateinherited

Definition at line 93 of file TheWarehouse.h.

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

◆ _must_be_restricted

bool AttribBoundaries::_must_be_restricted = false
private

Definition at line 231 of file Attributes.h.

Referenced by setFrom().

◆ _vals

std::vector<BoundaryID> AttribBoundaries::_vals
private

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