www.mooseframework.org
Classes | Namespaces | Functions
ComputeUserObjectsThread.h File Reference

Go to the source code of this file.

Classes

class  libMesh::NumericVector< T >
 
class  ComputeUserObjectsThread
 Class for threaded computation of UserObjects. More...
 

Namespaces

 libMesh
 The following methods are specializations for using the libMesh::Parallel::packed_range_* routines for std::strings.
 

Functions

template<typename T >
void groupUserObjects (TheWarehouse &w, AuxiliarySystem &aux, const ExecFlagEnum &execute_flags, const std::vector< T *> &objs, const std::set< std::string > &ic_deps)
 

Function Documentation

◆ groupUserObjects()

template<typename T >
void groupUserObjects ( TheWarehouse w,
AuxiliarySystem aux,
const ExecFlagEnum execute_flags,
const std::vector< T *> &  objs,
const std::set< std::string > &  ic_deps 
)

Definition at line 100 of file ComputeUserObjectsThread.h.

Referenced by FEProblemBase::initialSetup().

105 {
106  // These flags indicate when a user object will be executed for a given exec flag time.
107  // The attributes are set by this function and their values are queried in
108  // FEProblemBase::computeUserObjectsInternal(). If a UO is found to be in one of the
109  // three groups: PRE_IC, PRE_AUX, or POST_AUX, then that UO is executed with that group.
110  //
111  // PRE_IC objects are run before initial conditions during the "INITIAL" exec flag time.
112  // On any other exec flag time, they are run in POST_AUX by default or if there is
113  // an dependency for some exec flag or if force_preaux is set, they are run in
114  // PRE_AUX
115  //
116  // PRE_AUX objects are run before the dependent AuxKernels exec flag
117  //
118  // POST_AUX objects are run after AuxKernels on any given exec flag time, and is the
119  // default group for UOs. Dependencies that would otherwise move a UO into the
120  // PRE_AUX group can be overridden by specifying the parameter force_postaux
121  //
122  // This function attempts to sort a UO based on any ICs or AuxKernels which depend on
123  // it. Alternatively, a user may select which group to execute their object with by
124  // controlling the force_preic, force_preaux and force_postaux input parameters.
125  //
126 
127  std::map<T *, std::set<int>> pre_aux_dependencies;
128  std::map<T *, std::set<int>> post_aux_dependencies;
129  // This map is used to indicate, after all dependencies have
130  // been looked through, whether the UO has been flagged to
131  // execute on EXEC_INITIAL, either through a dependency or
132  // because force_preic was indicated. If neither of these
133  // are true, the UO needs to be run in POST_AUX for EXEC_INITIAL
134  std::map<T *, bool> is_pre_ic;
135 
136  for (const auto obj : objs)
137  is_pre_ic[obj] = false;
138 
139  for (const ExecFlagType & flag : execute_flags.items())
140  {
141  std::set<std::string> depend_objects_aux = aux.getDependObjects(flag);
142  for (const auto obj : objs)
143  {
144  if (depend_objects_aux.count(obj->name()) > 0)
145  {
146  pre_aux_dependencies[obj].insert(flag);
147  if (flag == EXEC_INITIAL)
148  is_pre_ic.at(obj) = true;
149  }
150  else if (flag != EXEC_INITIAL)
151  // default is for UO to be post_aux. If EXEC_INITIAL, check first if UO
152  // will be dependent on IC or have force_preic before deciding to put in
153  // post_aux
154  post_aux_dependencies[obj].insert(flag);
155  }
156  }
157 
158  for (const auto obj : objs)
159  {
160  if (ic_deps.count(obj->name()) > 0 ||
161  (obj->isParamValid("force_preic") && obj->template getParam<bool>("force_preic")))
162  {
163  w.update(obj, AttribPreIC(w, true));
164  is_pre_ic.at(obj) = true;
165  }
166 
167  if ((obj->isParamValid("force_preaux") && obj->template getParam<bool>("force_preaux")))
168  {
169  post_aux_dependencies[obj].clear();
170  for (const ExecFlagType & flag : execute_flags.items())
171  pre_aux_dependencies[obj].insert(flag);
172  }
173  else if (obj->isParamValid("force_postaux") && obj->template getParam<bool>("force_postaux"))
174  {
175  pre_aux_dependencies[obj].clear();
176  for (const ExecFlagType & flag : execute_flags.items())
177  post_aux_dependencies[obj].insert(flag);
178  }
179  else
180  {
181  // If at this point, then check if the UO has already been set to execute
182  // by either the force_preic param, an IC dependency, or a dependency
183  // already found for exec flage EXEC_INITIAL. If none of these are true,
184  // then is_pre_ic.at(obj) is false and the UO is added to the default
185  // post_aux group for the EXEC_INITIAL flag
186  if (!is_pre_ic.at(obj))
187  post_aux_dependencies[obj].insert(EXEC_INITIAL);
188  }
189  }
190 
191  for (auto & item : pre_aux_dependencies)
192  w.update(item.first, AttribPreAux(w, item.second));
193 
194  for (auto & item : post_aux_dependencies)
195  w.update(item.first, AttribPostAux(w, item.second));
196 }
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
Definition: Attributes.h:313
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
Definition: Attributes.h:294
const std::set< ExecFlagType > & items() const
Reference the all the available items.
Definition: ExecFlagEnum.h:71
std::set< std::string > getDependObjects(ExecFlagType type)
Get a list of dependent UserObjects for this exec type.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
Definition: Attributes.h:344
void update(MooseObject *obj)
update updates the metadata/attribute-info stored for the given object obj that must already exists i...
Definition: TheWarehouse.C:154
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
ExecFlagEnum execute_flags
Storage for the registered execute flags.
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28