www.mooseframework.org
AuxGroupExecuteMooseObjectWarehouse.h
Go to the documentation of this file.
1 
2 /****************************************************************/
3 /* DO NOT MODIFY THIS HEADER */
4 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
5 /* */
6 /* (c) 2010 Battelle Energy Alliance, LLC */
7 /* ALL RIGHTS RESERVED */
8 /* */
9 /* Prepared by Battelle Energy Alliance, LLC */
10 /* Under Contract No. DE-AC07-05ID14517 */
11 /* With the U. S. Department of Energy */
12 /* */
13 /* See COPYRIGHT for full restrictions */
14 /****************************************************************/
15 
16 #ifndef AUXGROUPEXECUTEMOOSEOBJECTWAREHOUSEBASE_H
17 #define AUXGROUPEXECUTEMOOSEOBJECTWAREHOUSEBASE_H
18 
19 // MOOSE includes
21 
22 class UserObject;
23 
27 template <typename T>
29 {
30 
31 public:
37 
41  AuxGroupExecuteMooseObjectWarehouse(bool thread = true);
42 
47 
53  void updateDependObjects(const std::set<std::string> & depend_ic,
54  const std::set<std::string> & depend_aux,
55  THREAD_ID tid = 0);
56 
60  void sort(THREAD_ID tid = 0);
61 
65  virtual void updateActive(THREAD_ID tid = 0) override;
66 
67 protected:
69  std::vector<ExecuteMooseObjectWarehouse<T>> _group_objects;
70 };
71 
72 template <typename T>
74  : ExecuteMooseObjectWarehouse<T>(threaded), _group_objects(3) // initialize group storage
75 {
76 }
77 
78 template <typename T>
81 {
82  if (group == Moose::ALL)
83  return *this;
84  return _group_objects[group];
85 }
86 
87 template <typename T>
88 void
90  const std::set<std::string> & depend_ic,
91  const std::set<std::string> & depend_aux,
92  THREAD_ID tid)
93 {
94  checkThreadID(tid);
95 
96  constexpr std::uint16_t initial_flag_mask = static_cast<std::uint16_t>(EXEC_INITIAL);
97  constexpr std::uint16_t not_initial_flag_mask = ~static_cast<std::uint16_t>(EXEC_INITIAL);
98  constexpr std::uint16_t all_flags = std::numeric_limits<std::uint16_t>::max();
99 
100  for (const auto & object_ptr : _all_objects[tid])
101  {
102  bool already_added = false;
103  if (depend_ic.find(object_ptr->name()) != depend_ic.end())
104  {
105  _group_objects[Moose::PRE_IC].addObjectMask(object_ptr, tid, initial_flag_mask);
106  already_added = !object_ptr->shouldDuplicateInitialExecution();
107  }
108 
109  std::uint16_t remaining_flags = already_added ? not_initial_flag_mask : all_flags;
110  if (depend_aux.find(object_ptr->name()) != depend_aux.end() ||
111  depend_ic.find(object_ptr->name()) != depend_ic.end())
112  _group_objects[Moose::PRE_AUX].addObjectMask(object_ptr, tid, remaining_flags);
113  else
114  _group_objects[Moose::POST_AUX].addObjectMask(object_ptr, tid, remaining_flags);
115  }
116 }
117 
118 template <typename T>
119 void
121 {
123  _group_objects[Moose::PRE_IC].sort(tid);
124  _group_objects[Moose::PRE_AUX].sort(tid);
125  _group_objects[Moose::POST_AUX].sort(tid);
126 }
127 
128 template <typename T>
129 void
131 {
133  _group_objects[Moose::PRE_IC].updateActive(tid);
134  _group_objects[Moose::PRE_AUX].updateActive(tid);
135  _group_objects[Moose::POST_AUX].updateActive(tid);
136 }
137 
138 #endif // AUXGROUPEXECUTEMOOSEOBJECTWAREHOUSEBASE_H
std::vector< ExecuteMooseObjectWarehouse< T > > _group_objects
Storage for the group sorted objects (ALL is stored in the base class)
void addObjectMask(std::shared_ptr< T > object, THREAD_ID tid=0, std::uint16_t flag_mask=std::numeric_limits< std::uint16_t >::max())
void sort(THREAD_ID tid=0)
Performs a sort using the DependencyResolver.
Object is evaluated only once at the beginning of the simulation.
Definition: MooseTypes.h:94
std::vector< std::vector< std::shared_ptr< T > > > _all_objects
Storage container for the ALL pointers (THREAD_ID on outer vector)
A storage container for MooseObjects that inherit from SetupInterface.
void sort(THREAD_ID tid=0)
Performs a sort using the DependencyResolver.
const ExecuteMooseObjectWarehouse< T > & operator[](Moose::AuxGroup group) const
Access the AuxGroup via bracket operator.
A class for storing MooseObjects based on execution flag.
AuxGroup
Flag for AuxKernel related exeuction type.
Definition: MooseTypes.h:140
void checkThreadID(THREAD_ID tid) const
Calls assert on thread id.
General warehouse for storing MooseObjects based on relation to IC and AuxKernel execution.
AuxGroupExecuteMooseObjectWarehouse(bool thread=true)
Constructor.
virtual void updateActive(THREAD_ID tid=0) override
Updates the various active lists of objects.
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.
Base class for user-specific data.
Definition: UserObject.h:42
unsigned int THREAD_ID
Definition: MooseTypes.h:79
void updateDependObjects(const std::set< std::string > &depend_ic, const std::set< std::string > &depend_aux, THREAD_ID tid=0)
Call this to separate the stored objects into the various AuxGroup catagories.