https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
ComputeUserObjectsThread.h File Reference

Go to the source code of this file.

Classes

class  ComputeUserObjectsThread
 Class for threaded computation of UserObjects. More...
 
struct  ComputeUserObjectsThread::BoundaryMaterialReinitCache
 

Namespaces

namespace  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 117 of file ComputeUserObjectsThread.h.

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