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
 
struct  ComputeUserObjectsThread::InternalSideMaterialReinitCache
 
struct  ComputeUserObjectsThread::InterfaceMaterialReinitCache
 

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

148{
149 // These flags indicate when a user object will be executed for a given exec flag time.
150 // The attributes are set by this function and their values are queried in
151 // FEProblemBase::computeUserObjectsInternal(). If a UO is found to be in one of the
152 // three groups: PRE_IC, PRE_AUX, or POST_AUX, then that UO is executed with that group.
153 //
154 // PRE_IC objects are run before initial conditions during the "INITIAL" exec flag time.
155 // On any other exec flag time, they are run in POST_AUX by default or if there is
156 // an dependency for some exec flag or if force_preaux is set, they are run in
157 // PRE_AUX
158 //
159 // PRE_AUX objects are run before the dependent AuxKernels exec flag
160 //
161 // POST_AUX objects are run after AuxKernels on any given exec flag time, and is the
162 // default group for UOs. Dependencies that would otherwise move a UO into the
163 // PRE_AUX group can be overridden by specifying the parameter force_postaux
164 //
165 // This function attempts to sort a UO based on any ICs or AuxKernels which depend on
166 // it. Alternatively, a user may select which group to execute their object with by
167 // controlling the force_preic, force_preaux and force_postaux input parameters.
168 //
169
170 std::map<T *, std::set<int>> pre_aux_dependencies;
171 std::map<T *, std::set<int>> post_aux_dependencies;
172 // This map is used to indicate, after all dependencies have
173 // been looked through, whether the UO has been flagged to
174 // execute on EXEC_INITIAL, either through a dependency or
175 // because force_preic was indicated. If neither of these
176 // are true, the UO needs to be run in POST_AUX for EXEC_INITIAL
177 std::map<T *, bool> is_pre_ic;
178
179 for (const auto obj : objs)
180 is_pre_ic[obj] = false;
181
182 for (const ExecFlagType & flag : execute_flags.items())
183 {
184 std::set<std::string> depend_objects_aux = aux.getDependObjects(flag);
185 for (const auto obj : objs)
186 {
187 if (depend_objects_aux.count(obj->name()) > 0)
188 {
189 pre_aux_dependencies[obj].insert(flag);
190 if (flag == EXEC_INITIAL)
191 is_pre_ic.at(obj) = true;
192 }
193 else if (flag != EXEC_INITIAL)
194 // default is for UO to be post_aux. If EXEC_INITIAL, check first if UO
195 // will be dependent on IC or have force_preic before deciding to put in
196 // post_aux
197 post_aux_dependencies[obj].insert(flag);
198 }
199 }
200
201 for (const auto obj : objs)
202 {
203 if (ic_deps.count(obj->name()) > 0 ||
204 (obj->isParamValid("force_preic") && obj->template getParam<bool>("force_preic")))
205 {
206 w.update(obj, AttribPreIC(w, true));
207 is_pre_ic.at(obj) = true;
208 }
209
210 if ((obj->isParamValid("force_preaux") && obj->template getParam<bool>("force_preaux")))
211 {
212 post_aux_dependencies[obj].clear();
213 for (const ExecFlagType & flag : execute_flags.items())
214 pre_aux_dependencies[obj].insert(flag);
215 }
216 else if (obj->isParamValid("force_postaux") && obj->template getParam<bool>("force_postaux"))
217 {
218 pre_aux_dependencies[obj].clear();
219 for (const ExecFlagType & flag : execute_flags.items())
220 post_aux_dependencies[obj].insert(flag);
221 }
222 else
223 {
224 // If at this point, then check if the UO has already been set to execute
225 // by either the force_preic param, an IC dependency, or a dependency
226 // already found for exec flage EXEC_INITIAL. If none of these are true,
227 // then is_pre_ic.at(obj) is false and the UO is added to the default
228 // post_aux group for the EXEC_INITIAL flag
229 if (!is_pre_ic.at(obj))
230 post_aux_dependencies[obj].insert(EXEC_INITIAL);
231 }
232 }
233
234 for (auto & item : pre_aux_dependencies)
235 w.update(item.first, AttribPreAux(w, item.second));
236
237 for (auto & item : post_aux_dependencies)
238 w.update(item.first, AttribPostAux(w, item.second));
239}
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.