48 virtual void addObject(std::shared_ptr<T>
object,
THREAD_ID tid = 0,
bool recurse =
true);
61 const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
64 const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
77 const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
81 const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
131 std::set<MooseVariableFieldBase *> & needed_moose_vars,
136 std::set<MooseVariableFieldBase *> & needed_moose_vars,
145 std::set<TagID> & needed_fe_var_vector_tags,
158 std::unordered_set<unsigned int> & needed_mat_props,
163 std::unordered_set<unsigned int> & needed_mat_props,
171 std::set<std::string> & unique_variables,
185 const std::string & prefix =
"[DBG]")
const;
213 const std::vector<std::shared_ptr<T>> & all);
218 static void sortHelper(std::vector<std::shared_ptr<T>> & objects);
224 const std::vector<std::shared_ptr<T>> & objects);
231 const std::vector<std::shared_ptr<T>> & objects);
237 const std::vector<std::shared_ptr<T>> & objects);
247 template <
typename T>
259 template <
typename T>
264 template <
typename T>
272 template <
typename T>
284 bool enabled =
object->enabled();
289 std::shared_ptr<BoundaryRestrictable> bnd =
294 if (bnd && bnd->boundaryRestricted())
296 const std::set<BoundaryID> & ids = bnd->boundaryIDs();
297 for (std::set<BoundaryID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
308 const std::set<SubdomainID> & ids =
309 blk->blockRestricted() ? blk->blockIDs() : blk->meshBlockIDs();
310 for (std::set<SubdomainID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
321 blk->checkVariable(*var);
332 std::string variable_name = parameters.
getMooseType(
"variable");
333 if (variable_name ==
"")
344 template <
typename T>
345 inline const std::vector<std::shared_ptr<T>> &
352 template <
typename T>
353 inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
360 template <
typename T>
368 template <
typename T>
369 const std::vector<std::shared_ptr<T>> &
375 "Unable to located active boundary objects for the given id: " <<
id <<
".");
379 template <
typename T>
380 inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
387 template <
typename T>
388 const std::vector<std::shared_ptr<T>> &
394 "Unable to located active block objects for the given id: " <<
id <<
".");
398 template <
typename T>
399 inline const std::vector<std::shared_ptr<T>> &
406 template <
typename T>
407 inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
414 template <
typename T>
415 const std::vector<std::shared_ptr<T>> &
421 "Unable to located active boundary objects for the given id: " <<
id <<
".");
425 template <
typename T>
426 inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
433 template <
typename T>
434 const std::vector<std::shared_ptr<T>> &
440 "Unable to located active block objects for the given id: " <<
id <<
".");
444 template <
typename T>
452 template <
typename T>
460 template <
typename T>
465 bool has_active_block_objects =
false;
467 has_active_block_objects |= !(object_pair.second.empty());
468 return has_active_block_objects;
471 template <
typename T>
480 template <
typename T>
485 bool has_active_boundary_objects =
false;
487 has_active_boundary_objects |= !(object_pair.second.empty());
488 return has_active_boundary_objects;
491 template <
typename T>
500 template <
typename T>
506 if (object->name() ==
name)
511 template <
typename T>
517 if (object->name() ==
name)
522 template <
typename T>
528 if (object->name() ==
name)
533 template <
typename T>
534 std::set<SubdomainID>
538 std::set<SubdomainID> ids;
540 ids.insert(object_pair.first);
544 template <
typename T>
559 template <
typename T>
562 const std::vector<std::shared_ptr<T>> & all)
567 std::copy_if(all.begin(),
569 std::back_inserter(active),
570 [](
const std::shared_ptr<T> & object) {
return object->enabled(); });
573 template <
typename T>
591 template <
typename T>
594 std::set<MooseVariableFieldBase *> & needed_moose_vars,
THREAD_ID tid )
const 600 template <
typename T>
604 std::set<MooseVariableFieldBase *> & needed_moose_vars,
611 template <
typename T>
614 std::set<MooseVariableFieldBase *> & needed_moose_vars,
THREAD_ID tid )
const 618 typename std::map<BoundaryID, std::vector<std::shared_ptr<T>>>::const_iterator it;
624 template <
typename T>
628 std::set<MooseVariableFieldBase *> & needed_moose_vars,
635 template <
typename T>
638 std::set<MooseVariableFieldBase *> & needed_moose_vars,
639 const std::vector<std::shared_ptr<T>> & objects)
641 for (
const auto &
object : objects)
647 needed_moose_vars.insert(mv_deps.begin(), mv_deps.end());
652 template <
typename T>
662 template <
typename T>
672 template <
typename T>
675 std::set<TagID> & needed_fe_var_vector_tags,
const std::vector<std::shared_ptr<T>> & objects)
677 for (
const auto &
object : objects)
679 auto c =
dynamic_cast<const Coupleable *
>(
object.get());
683 needed_fe_var_vector_tags.insert(tag_deps.begin(), tag_deps.end());
688 template <
typename T>
691 std::unordered_set<unsigned int> & needed_mat_props,
THREAD_ID tid )
const 697 template <
typename T>
701 std::unordered_set<unsigned int> & needed_mat_props,
708 template <
typename T>
711 std::unordered_set<unsigned int> & needed_mat_props,
THREAD_ID tid )
const 718 template <
typename T>
722 std::unordered_set<unsigned int> & needed_mat_props,
729 template <
typename T>
732 std::unordered_set<unsigned int> & needed_mat_props,
733 const std::vector<std::shared_ptr<T>> & objects)
735 for (
auto &
object : objects)
741 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
746 template <
typename T>
749 std::set<std::string> & unique_variables,
753 unique_variables.insert(object->variable().name());
756 subdomains_covered.insert(object_pair.first);
759 template <
typename T>
762 const THREAD_ID tid ,
const std::string & prefix )
const 764 std::vector<std::string> output;
766 output.push_back(object->name());
770 template <
typename T>
781 DependencyResolverInterface::sort<std::shared_ptr<T>>(objects);
785 DependencyResolverInterface::cyclicDependencyError<std::shared_ptr<T>>(
786 e,
"Cyclic dependency detected in object ordering");
790 template <
typename T>
795 "Attempting to access a thread id (" 796 << tid <<
") greater than the number allowed by the storage item (" std::string name(const ElemQuality q)
void updateVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
std::string activeObjectsToFormattedString(THREAD_ID tid=0, const std::string &prefix="[DBG]") const
Output the active content of the warehouse to a string, meant to be output to the console...
void sort(THREAD_ID tid=0)
Sort the objects using the DependencyResolver.
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
bool hasObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _all_block_objects
std::vector< std::vector< std::shared_ptr< T > > > _all_objects
Storage container for the ALL pointers (THREAD_ID on outer vector)
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _active_block_objects
Active block restricted objects (THREAD_ID on outer vector)
void checkThreadID(THREAD_ID tid) const
Calls assert on thread id.
virtual ~MooseObjectWarehouseBase()
Destructor.
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
MooseObjectWarehouseBase(bool threaded=true)
Constructor.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
This class provides an interface for common operations on field variables of both FE and FV types wit...
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
void updateBoundaryFEVariableCoupledVectorTagDependency(BoundaryID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
static void updateFEVariableCoupledVectorTagDependencyHelper(std::set< TagID > &needed_fe_var_vector_tags, const std::vector< std::shared_ptr< T >> &objects)
Helper method for updating FE variable coupleable vector tag vector.
bool hasBoundaryObjects(BoundaryID id, THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _active_boundary_objects
Active boundary restricted objects (THREAD_ID on outer vector)
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
std::set< SubdomainID > getActiveBlocks(THREAD_ID tid=0) const
Return a set of active SubdomainsIDs.
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
const std::vector< std::shared_ptr< T > > & getObjects(THREAD_ID tid=0) const
Retrieve complete vector to the all/block/boundary restricted objects for a given thread...
std::shared_ptr< T > getObject(const std::string &name, THREAD_ID tid=0) const
static void updateMatPropDependencyHelper(std::unordered_set< unsigned int > &needed_mat_props, const std::vector< std::shared_ptr< T >> &objects)
Helper method for updating material property dependency vector.
static void sortHelper(std::vector< std::shared_ptr< T >> &objects)
Helper method for sorting vectors of objects.
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
boundary_id_type BoundaryID
static void updateVariableDependencyHelper(std::set< MooseVariableFieldBase *> &needed_moose_vars, const std::vector< std::shared_ptr< T >> &objects)
Helper method for updating variable dependency vector.
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
virtual void updateActive(THREAD_ID tid=0)
Update the active status of Kernels.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getBlockObjects(THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getBoundaryObjects(THREAD_ID tid=0) const
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _all_boundary_objects
void updateBoundaryMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
void updateMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
Update material property dependency vector.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
const THREAD_ID _num_threads
Convenience member storing the number of threads used for storage (1 or libMesh::n_threads) ...
Interface for objects that needs coupling capabilities.
void updateBlockMatPropDependency(SubdomainID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
Generic class for solving transient nonlinear problems.
bool hasActiveObject(const std::string &name, THREAD_ID tid=0) const
Convenience functions for checking/getting specific objects.
bool hasActiveObjects(THREAD_ID tid=0) const
An interface for accessing Materials.
An interface that restricts an object to subdomains via the 'blocks' input parameter.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.
std::vector< std::vector< std::shared_ptr< T > > > _active_objects
All active objects (THREAD_ID on outer vector)
const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
void updateBoundaryVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
THREAD_ID numThreads() const
Return the number of threads.
A base storage container for MooseObjects.
std::set< TagID > & getFEVariableCoupleableVectorTags()
static void updateActiveHelper(std::vector< std::shared_ptr< T >> &active, const std::vector< std::shared_ptr< T >> &all)
Helper method for updating active vectors.
std::string join(const T &strings, const std::string &delimiter)
Python like join function for strings.
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.