www.mooseframework.org
Attributes.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseHashing.h"
13 #include "TheWarehouse.h"
14 
15 enum class Interfaces
16 {
17  UserObject = 1 << 1,
18  ElementUserObject = 1 << 2,
19  SideUserObject = 1 << 3,
20  InternalSideUserObject = 1 << 4,
21  NodalUserObject = 1 << 5,
22  GeneralUserObject = 1 << 6,
24  ShapeElementUserObject = 1 << 8,
25  ShapeSideUserObject = 1 << 9,
26  Postprocessor = 1 << 10,
27  VectorPostprocessor = 1 << 11,
28  InterfaceUserObject = 1 << 12,
29 };
30 
31 template <>
32 struct enable_bitmask_operators<Interfaces>
33 {
34  static const bool enable = true;
35 };
36 
37 #define clonefunc(T) \
38  virtual std::unique_ptr<Attribute> clone() const override \
39  { \
40  return std::unique_ptr<Attribute>(new T(*this)); \
41  }
42 
43 #define hashfunc(...) \
44  virtual size_t hash() const override \
45  { \
46  size_t h = 0; \
47  Moose::hash_combine(h, __VA_ARGS__); \
48  return h; \
49  }
50 
51 class AttribTagBase : public Attribute
52 {
53 public:
54  AttribTagBase(TheWarehouse & w, unsigned int tag, const std::string & attrib_name)
55  : Attribute(w, attrib_name)
56  {
57  _vals.push_back(tag);
58  }
59 
60  virtual bool isMatch(const Attribute & other) const override;
61  virtual bool isEqual(const Attribute & other) const override;
62  hashfunc(_vals);
63 
64 protected:
65  std::vector<unsigned int> _vals;
66 };
67 
69 {
70 public:
71  AttribMatrixTags(TheWarehouse & w, unsigned int tag) : AttribTagBase(w, tag, "matrix_tags") {}
72  virtual void initFrom(const MooseObject * obj) override;
74 };
75 
77 {
78 public:
80 
81  AttribVectorTags(TheWarehouse & w, unsigned int tag) : AttribTagBase(w, tag, "vector_tags") {}
82  virtual void initFrom(const MooseObject * obj) override;
83 };
84 
85 class AttribExecOns : public Attribute
86 {
87 public:
88  AttribExecOns(TheWarehouse & w, unsigned int exec_flag) : Attribute(w, "exec_ons")
89  {
90  _vals.push_back(exec_flag);
91  }
92  virtual void initFrom(const MooseObject * obj) override;
93  virtual bool isMatch(const Attribute & other) const override;
94  virtual bool isEqual(const Attribute & other) const override;
95  hashfunc(_vals);
97 
98 private:
99  std::vector<unsigned int> _vals;
100 };
101 
103 {
104 public:
106  {
107  _vals.push_back(id);
108  }
109  virtual void initFrom(const MooseObject * obj) override;
110  virtual bool isMatch(const Attribute & other) const override;
111  virtual bool isEqual(const Attribute & other) const override;
112  hashfunc(_vals);
114 
115 private:
116  std::vector<SubdomainID> _vals;
117 };
118 
120 {
121 public:
122  AttribBoundaries(TheWarehouse & w, BoundaryID id, bool must_be_restricted = false)
123  : Attribute(w, "boundaries"), _must_be_restricted(must_be_restricted)
124  {
125  _vals.push_back(id);
126  }
127  virtual void initFrom(const MooseObject * obj) override;
128  virtual bool isMatch(const Attribute & other) const override;
129  virtual bool isEqual(const Attribute & other) const override;
132 
133 private:
134  std::vector<BoundaryID> _vals;
136 };
137 
138 class AttribThread : public Attribute
139 {
140 public:
141  AttribThread(TheWarehouse & w, THREAD_ID t) : Attribute(w, "thread"), _val(t) {}
142  virtual void initFrom(const MooseObject * obj) override;
143  virtual bool isMatch(const Attribute & other) const override;
144  virtual bool isEqual(const Attribute & other) const override;
145  hashfunc(_val);
147 
148 private:
150 };
151 
153 class AttribPreIC : public Attribute
154 {
155 public:
156  AttribPreIC(TheWarehouse & w, bool pre_ic) : Attribute(w, "pre_ic"), _val(pre_ic) {}
157  virtual void initFrom(const MooseObject * obj) override;
158  virtual bool isMatch(const Attribute & other) const override;
159  virtual bool isEqual(const Attribute & other) const override;
160  hashfunc(_val);
162 
163 private:
164  bool _val;
165 };
166 
168 class AttribPreAux : public Attribute
169 {
170 public:
171  AttribPreAux(TheWarehouse & w, bool pre_aux) : Attribute(w, "pre_aux"), _val(pre_aux) {}
172  virtual void initFrom(const MooseObject * obj) override;
173  virtual bool isMatch(const Attribute & other) const override;
174  virtual bool isEqual(const Attribute & other) const override;
175  hashfunc(_val);
177 
178 private:
179  bool _val;
180 };
181 
182 class AttribName : public Attribute
183 {
184 public:
185  AttribName(TheWarehouse & w, const std::string & name) : Attribute(w, "name"), _val(name) {}
186  virtual void initFrom(const MooseObject * obj) override;
187  virtual bool isMatch(const Attribute & other) const override;
188  virtual bool isEqual(const Attribute & other) const override;
189  hashfunc(_val);
191 
192 private:
193  std::string _val;
194 };
195 
196 class AttribSystem : public Attribute
197 {
198 public:
199  AttribSystem(TheWarehouse & w, const std::string & system) : Attribute(w, "system"), _val(system)
200  {
201  }
202  virtual void initFrom(const MooseObject * obj) override;
203  virtual bool isMatch(const Attribute & other) const override;
204  virtual bool isEqual(const Attribute & other) const override;
205  hashfunc(_val);
207 
208 private:
209  std::string _val;
210 };
211 
212 class AttribVar : public Attribute
213 {
214 public:
215  AttribVar(TheWarehouse & w, int var) : Attribute(w, "variable"), _val(var) {}
216  virtual void initFrom(const MooseObject * obj) override;
217  virtual bool isMatch(const Attribute & other) const override;
218  virtual bool isEqual(const Attribute & other) const override;
219  hashfunc(_val);
221 
222 private:
223  int _val = -1;
224 };
225 
227 {
228 public:
230  : Attribute(w, "interfaces"), _val(static_cast<uint64_t>(mask))
231  {
232  }
233  AttribInterfaces(TheWarehouse & w, unsigned int mask) : Attribute(w, "interfaces"), _val(mask) {}
234  virtual void initFrom(const MooseObject * obj) override;
235  virtual bool isMatch(const Attribute & other) const override;
236  virtual bool isEqual(const Attribute & other) const override;
237  hashfunc(_val);
239 
240 private:
241  uint64_t _val = 0;
242 };
243 
244 #undef clonefunc
245 #undef hashfunc
246 
hashfunc(_val)
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:69
std::vector< SubdomainID > _vals
Definition: Attributes.h:116
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...
Definition: Attributes.C:44
AttribMatrixTags(TheWarehouse &w, unsigned int tag)
Definition: Attributes.h:71
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:231
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...
Definition: Attributes.C:30
std::string _val
Definition: Attributes.h:193
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...
Definition: Attributes.C:270
Attribute is an abstract class that can be implemented in order to track custom metadata about MooseO...
Definition: TheWarehouse.h:31
bool _must_be_restricted
Definition: Attributes.h:135
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:214
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:300
AttribInterfaces(TheWarehouse &w, Interfaces mask)
Definition: Attributes.h:229
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...
Definition: Attributes.C:111
clonefunc(AttribSystem)
clonefunc(AttribVectorTags)
AttribInterfaces(TheWarehouse &w, unsigned int mask)
Definition: Attributes.h:233
std::vector< BoundaryID > _vals
Definition: Attributes.h:134
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
Definition: Attributes.h:168
clonefunc(AttribVar)
AttribExecOns(TheWarehouse &w, unsigned int exec_flag)
Definition: Attributes.h:88
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:81
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...
Definition: Attributes.C:156
AttribVar(TheWarehouse &w, int var)
Definition: Attributes.h:215
AttribTagBase(TheWarehouse &w, unsigned int tag, const std::string &attrib_name)
Definition: Attributes.h:54
Interfaces
Definition: Attributes.h:15
AttribSystem(TheWarehouse &w, const std::string &system)
Definition: Attributes.h:199
clonefunc(AttribInterfaces)
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...
Definition: Attributes.C:138
AttribSubdomains(TheWarehouse &w, SubdomainID id)
Definition: Attributes.h:105
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:265
hashfunc(_vals, _must_be_restricted)
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...
Definition: Attributes.C:201
A user object that runs over all the nodes and does an aggregation step to compute a single value...
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...
Definition: Attributes.C:314
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
Definition: Attributes.h:153
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...
Definition: Attributes.C:219
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:283
AttribBoundaries(TheWarehouse &w, BoundaryID id, bool must_be_restricted=false)
Definition: Attributes.h:122
AttribThread(TheWarehouse &w, THREAD_ID t)
Definition: Attributes.h:141
nl system()
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...
Definition: Attributes.C:183
std::vector< unsigned int > _vals
Definition: Attributes.h:99
clonefunc(AttribPreIC)
AttribPreIC(TheWarehouse &w, bool pre_ic)
Definition: Attributes.h:156
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
ElementUserObject class in which the _phi and _grad_phi shape function data is available and correctl...
AttribVectorTags(TheWarehouse &w, unsigned int tag)
Definition: Attributes.h:81
boundary_id_type BoundaryID
TheWarehouse is a container for MooseObjects that allows querying/filtering over various customizeabl...
Definition: TheWarehouse.h:119
clonefunc(AttribThread)
clonefunc(AttribName)
clonefunc(AttribSubdomains)
clonefunc(AttribMatrixTags)
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...
Definition: Attributes.C:252
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...
Definition: Attributes.C:340
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...
Definition: Attributes.C:287
Base class for all Postprocessors.
Definition: Postprocessor.h:29
subdomain_id_type SubdomainID
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...
Definition: Attributes.C:347
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:57
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:169
clonefunc(AttribPreAux)
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...
Definition: Attributes.C:95
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...
Definition: Attributes.C:235
std::vector< unsigned int > _vals
Definition: Attributes.h:65
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...
Definition: Attributes.C:225
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...
Definition: Attributes.C:277
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...
Definition: Attributes.C:242
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:320
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...
Definition: Attributes.C:307
clonefunc(AttribBoundaries)
clonefunc(AttribExecOns)
Base class for implementing interface user objects.
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...
Definition: Attributes.C:294
AttribName(TheWarehouse &w, const std::string &name)
Definition: Attributes.h:185
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:248
std::string _val
Definition: Attributes.h:209
Base class for Postprocessors that produce a vector of values.
hashfunc(_val)
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...
Definition: Attributes.C:259
virtual void initFrom(const MooseObject *obj) override
initFrom reads and stores the desired meta-data from obj for later matching comparisons.
Definition: Attributes.C:124
Base class for user-specific data.
Definition: UserObject.h:37
hashfunc(_val)
SideUserObject class in which the _phi and _grad_phi shape function data is available and correctly i...
unsigned int THREAD_ID
Definition: MooseTypes.h:161
THREAD_ID _val
Definition: Attributes.h:149
An instance of this object type has one copy per thread that runs on each thread. ...
AttribPreAux(TheWarehouse &w, bool pre_aux)
Definition: Attributes.h:171