49 virtual void addObject(std::shared_ptr<T>
object,
THREAD_ID tid = 0,
bool recurse =
true);
62 const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
65 const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
78 const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
82 const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
109 const std::set<SubdomainID> &
blocks,
110 std::set<SubdomainID> & blocks_covered,
150 std::set<MooseVariableFieldBase *> & needed_moose_vars,
155 std::set<MooseVariableFieldBase *> & needed_moose_vars,
164 std::set<TagID> & needed_fe_var_vector_tags,
177 std::unordered_set<unsigned int> & needed_mat_props,
182 std::unordered_set<unsigned int> & needed_mat_props,
190 std::set<std::string> & unique_variables,
204 const std::string & prefix =
"[DBG]")
const;
235 const std::vector<std::shared_ptr<T>> & all);
240 static void sortHelper(std::vector<std::shared_ptr<T>> & objects);
246 const std::vector<std::shared_ptr<T>> & objects);
253 const std::vector<std::shared_ptr<T>> & objects);
259 const std::vector<std::shared_ptr<T>> & objects);
269 template <
typename T>
282 template <
typename T>
287 template <
typename T>
295 template <
typename T>
307 bool enabled =
object->enabled();
312 std::shared_ptr<BoundaryRestrictable> bnd =
317 if (bnd && bnd->boundaryRestricted())
319 const std::set<BoundaryID> & ids = bnd->boundaryIDs();
320 for (std::set<BoundaryID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
331 const std::set<SubdomainID> & ids =
332 blk->blockRestricted() ? blk->blockIDs() : blk->meshBlockIDs();
333 for (std::set<SubdomainID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
344 blk->checkVariable(*var);
355 std::string variable_name = parameters.
getMooseType(
"variable");
356 if (variable_name ==
"")
369 template <
typename T>
370 inline const std::vector<std::shared_ptr<T>> &
377 template <
typename T>
378 inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
385 template <
typename T>
393 template <
typename T>
394 const std::vector<std::shared_ptr<T>> &
400 "Unable to located active boundary objects for the given id: " <<
id <<
".");
404 template <
typename T>
405 inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
412 template <
typename T>
413 const std::vector<std::shared_ptr<T>> &
419 "Unable to located active block objects for the given id: " <<
id <<
".");
423 template <
typename T>
424 inline const std::vector<std::shared_ptr<T>> &
431 template <
typename T>
432 inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
439 template <
typename T>
440 const std::vector<std::shared_ptr<T>> &
446 "Unable to located active boundary objects for the given id: " <<
id <<
".");
450 template <
typename T>
451 inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
458 template <
typename T>
459 const std::vector<std::shared_ptr<T>> &
465 "Unable to located active block objects for the given id: " <<
id <<
".");
469 template <
typename T>
477 template <
typename T>
485 template <
typename T>
494 template <
typename T>
497 const std::set<SubdomainID> &
blocks,
498 std::set<SubdomainID> & blocks_covered,
502 blocks_covered.clear();
510 if (blk && blk->hasBlocks(
blocks))
522 for (
const auto & block :
blocks)
523 if (blk->hasBlocks(block))
524 blocks_covered.insert(block);
527 if (blocks_covered.empty())
530 return (
blocks == blocks_covered);
533 template <
typename T>
538 bool has_active_block_objects =
false;
540 has_active_block_objects |= !(object_pair.second.empty());
541 return has_active_block_objects;
544 template <
typename T>
553 template <
typename T>
558 bool has_active_boundary_objects =
false;
560 has_active_boundary_objects |= !(object_pair.second.empty());
561 return has_active_boundary_objects;
564 template <
typename T>
573 template <
typename T>
579 if (object->name() ==
name)
584 template <
typename T>
590 if (object->name() ==
name)
595 template <
typename T>
601 if (object->name() ==
name)
606 template <
typename T>
607 const std::vector<std::shared_ptr<T>> &
614 template <
typename T>
615 std::set<SubdomainID>
619 std::set<SubdomainID> ids;
621 ids.insert(object_pair.first);
625 template <
typename T>
640 template <
typename T>
643 const std::vector<std::shared_ptr<T>> & all)
648 std::copy_if(all.begin(),
650 std::back_inserter(active),
651 [](
const std::shared_ptr<T> & object) {
return object->enabled(); });
654 template <
typename T>
672 template <
typename T>
675 std::set<MooseVariableFieldBase *> & needed_moose_vars,
THREAD_ID tid )
const 681 template <
typename T>
685 std::set<MooseVariableFieldBase *> & needed_moose_vars,
692 template <
typename T>
695 std::set<MooseVariableFieldBase *> & needed_moose_vars,
THREAD_ID tid )
const 699 typename std::map<BoundaryID, std::vector<std::shared_ptr<T>>>::const_iterator it;
705 template <
typename T>
709 std::set<MooseVariableFieldBase *> & needed_moose_vars,
716 template <
typename T>
719 std::set<MooseVariableFieldBase *> & needed_moose_vars,
720 const std::vector<std::shared_ptr<T>> & objects)
722 for (
const auto &
object : objects)
728 needed_moose_vars.insert(mv_deps.begin(), mv_deps.end());
733 template <
typename T>
743 template <
typename T>
753 template <
typename T>
756 std::set<TagID> & needed_fe_var_vector_tags,
const std::vector<std::shared_ptr<T>> & objects)
758 for (
const auto &
object : objects)
760 auto c =
dynamic_cast<const Coupleable *
>(
object.get());
764 needed_fe_var_vector_tags.insert(tag_deps.begin(), tag_deps.end());
769 template <
typename T>
772 std::unordered_set<unsigned int> & needed_mat_props,
THREAD_ID tid )
const 778 template <
typename T>
782 std::unordered_set<unsigned int> & needed_mat_props,
789 template <
typename T>
792 std::unordered_set<unsigned int> & needed_mat_props,
THREAD_ID tid )
const 799 template <
typename T>
803 std::unordered_set<unsigned int> & needed_mat_props,
810 template <
typename T>
813 std::unordered_set<unsigned int> & needed_mat_props,
814 const std::vector<std::shared_ptr<T>> & objects)
816 for (
auto &
object : objects)
822 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
827 template <
typename T>
830 std::set<std::string> & unique_variables,
835 unique_variables.insert(object->variable().name());
836 const auto additional_variables_covered =
object->additionalROVariables();
837 unique_variables.insert(additional_variables_covered.begin(),
838 additional_variables_covered.end());
842 subdomains_covered.insert(object_pair.first);
845 template <
typename T>
848 const THREAD_ID tid ,
const std::string & prefix )
const 850 std::vector<std::string> output;
852 output.push_back(object->name());
856 template <
typename T>
867 DependencyResolverInterface::sort<std::shared_ptr<T>>(objects);
871 DependencyResolverInterface::cyclicDependencyError<std::shared_ptr<T>>(
872 e,
"Cyclic dependency detected in object ordering");
876 template <
typename T>
881 "Attempting to access a thread id (" 882 << tid <<
") greater than the number allowed by the storage item (" virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
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.
std::string join(Iterator begin, Iterator end, const std::string &delimiter)
Python-like join function for strings over an iterator range.
bool hasObjectsForVariableAndBlocks(const VariableName &var_name, const std::set< SubdomainID > &blocks, std::set< SubdomainID > &blocks_covered, THREAD_ID tid) const
Whether there are objects for this variable and the set of blocks passed.
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< VariableName, std::vector< std::shared_ptr< T > > > > _all_variable_objects
All objects with a certain variable selected, as the 'variable' parameter.
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
const std::vector< std::shared_ptr< T > > & getObjectsForVariable(const VariableName &var_name, THREAD_ID tid) const
Getter for objects that have the 'variable' set to a particular variable Note that users should check...
bool hasObjectsForVariable(const VariableName &var_name, THREAD_ID tid) 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)
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.
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.