Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Public Member Functions | Private Attributes | List of all members
AttribSubdomains Class Referenceabstract

#include <Attributes.h>

Inheritance diagram for AttribSubdomains:
[legend]

Public Types

typedef SubdomainID Key
 

Public Member Functions

void setFrom (Key k)
 
 AttribSubdomains (TheWarehouse &w)
 
 AttribSubdomains (TheWarehouse &w, SubdomainID id)
 
virtual void initFrom (const MooseObject *obj) override
 initFrom reads and stores the desired meta-data from obj for later matching comparisons. More...
 
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. More...
 
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. More...
 
 hashfunc (_vals)
 
 clonefunc (AttribSubdomains)
 
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. More...
 
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. More...
 
virtual std::unique_ptr< Attributeclone () const =0
 clone creates and returns and identical (deep) copy of this attribute - i.e. More...
 

Private Attributes

std::vector< SubdomainID_vals
 

Detailed Description

Definition at line 160 of file Attributes.h.

Member Typedef Documentation

◆ Key

Definition at line 163 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttribSubdomains() [1/2]

AttribSubdomains::AttribSubdomains ( TheWarehouse w)
inline

Definition at line 170 of file Attributes.h.

170 : Attribute(w, "subdomains") {}
Attribute(TheWarehouse &w, const std::string name)
Constructs/initializes a new attribute with the specified name for use in warehouse w...
Definition: TheWarehouse.C:36

◆ AttribSubdomains() [2/2]

AttribSubdomains::AttribSubdomains ( TheWarehouse w,
SubdomainID  id 
)
inline

Definition at line 171 of file Attributes.h.

171  : Attribute(w, "subdomains")
172  {
173  _vals.push_back(id);
174  }
std::vector< SubdomainID > _vals
Definition: Attributes.h:182
Attribute(TheWarehouse &w, const std::string name)
Constructs/initializes a new attribute with the specified name for use in warehouse w...
Definition: TheWarehouse.C:36

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

AttribSubdomains::clonefunc ( AttribSubdomains  )

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

AttribSubdomains::hashfunc ( _vals  )

◆ 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 67 of file TheWarehouse.h.

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

67 { return _id; }

◆ initFrom()

void AttribSubdomains::initFrom ( const MooseObject obj)
overridevirtual

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

Implements Attribute.

Definition at line 172 of file Attributes.C.

173 {
174  _vals.clear();
175  auto blk = dynamic_cast<const BlockRestrictable *>(obj);
176  if (blk && blk->blockRestricted())
177  {
178  for (auto id : blk->blockIDs())
179  _vals.push_back(id);
180  }
181  else
182  _vals.push_back(Moose::ANY_BLOCK_ID);
183 }
std::vector< SubdomainID > _vals
Definition: Attributes.h:182
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.

◆ isEqual()

bool AttribSubdomains::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 207 of file Attributes.C.

208 {
209  auto a = dynamic_cast<const AttribSubdomains *>(&other);
210  if (!a || a->_vals.size() != _vals.size())
211  return false;
212 
213  for (size_t i = 0; i < a->_vals.size(); i++)
214  if (a->_vals[i] != _vals[i])
215  return false;
216  return true;
217 }
std::vector< SubdomainID > _vals
Definition: Attributes.h:182

◆ isMatch()

bool AttribSubdomains::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 186 of file Attributes.C.

187 {
188  auto a = dynamic_cast<const AttribSubdomains *>(&other);
189  if (!a || a->_vals.size() < 1)
190  return false;
191 
192  auto cond = a->_vals[0];
193  if (cond == Moose::ANY_BLOCK_ID)
194  return true;
195  else if (cond == Moose::INVALID_BLOCK_ID)
196  return false;
197 
198  for (auto id : _vals)
199  {
200  if (id == cond || id == Moose::ANY_BLOCK_ID)
201  return true;
202  }
203  return false;
204 }
std::vector< SubdomainID > _vals
Definition: Attributes.h:182
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19

◆ operator!=()

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

Definition at line 62 of file TheWarehouse.h.

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

◆ operator==()

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

Definition at line 58 of file TheWarehouse.h.

59  {
60  return _id == other._id && isEqual(other);
61  }
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 AttribSubdomains::setFrom ( Key  k)
inline

Definition at line 164 of file Attributes.h.

165  {
166  _vals.clear();
167  _vals.push_back(k);
168  }
std::vector< SubdomainID > _vals
Definition: Attributes.h:182

Member Data Documentation

◆ _vals

std::vector<SubdomainID> AttribSubdomains::_vals
private

Definition at line 182 of file Attributes.h.

Referenced by AttribSubdomains(), initFrom(), isEqual(), isMatch(), and setFrom().


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