TheWarehouse is a container for MooseObjects that allows querying/filtering over various customizeable attributes. More...
#include <TheWarehouse.h>
Classes | |
class | QueryCache |
QueryCache is a convenient way to construct and pass around (possible partially constructed) warehouse queries. More... | |
Public Types | |
template<typename T > | |
using | KeyType = typename T::Key |
template<typename T > | |
using | AttribType = T * |
using | Query = QueryCache<> |
Public Member Functions | |
TheWarehouse () | |
~TheWarehouse () | |
template<typename T , typename... Args> | |
unsigned int | registerAttribute (const std::string &name, Args... dummy_args) |
registers a new "tracked" attribute of type T for the warehouse. More... | |
unsigned int | attribID (const std::string &name) |
Returns a unique ID associated with the given attribute name - i.e. More... | |
void | add (std::shared_ptr< MooseObject > obj) |
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/filtering. More... | |
void | update (MooseObject *obj) |
update updates the metadata/attribute-info stored for the given object obj that must already exists in the warehouse. More... | |
void | update (MooseObject *obj, const Attribute &extra) |
update updates the metadata/attribute-info stored for the given object obj that must already exists in the warehouse. More... | |
Query | query () |
query creates and returns an initialized a query object for querying objects from the warehouse. More... | |
std::size_t | count (const std::vector< std::unique_ptr< Attribute >> &conds) |
count returns the number of objects that match the provided query conditions. More... | |
template<typename T > | |
std::vector< T * > & | queryInto (const std::vector< std::unique_ptr< Attribute >> &conds, std::vector< T *> &results) |
queryInto takes the given conditions (i.e. More... | |
std::size_t | queryID (const std::vector< std::unique_ptr< Attribute >> &conds) |
template<typename T > | |
std::vector< T * > & | queryInto (int query_id, std::vector< T *> &results, bool show_all=false) |
Private Member Functions | |
int | prepare (std::vector< std::unique_ptr< Attribute >> conds) |
prepares a query and returns an associated query_id (i.e. for use with the query function). More... | |
const std::vector< MooseObject * > & | query (int query_id) |
callers of this function must lock _obj_cache_mutex as long as a reference to the returned vector is being used. More... | |
void | readAttribs (const MooseObject *obj, std::vector< std::unique_ptr< Attribute >> &attribs) |
Private Attributes | |
std::unique_ptr< WarehouseStorage > | _store |
std::vector< std::shared_ptr< MooseObject > > | _objects |
std::unordered_map< MooseObject *, std::size_t > | _obj_ids |
std::vector< std::vector< MooseObject * > > | _obj_cache |
std::unordered_map< std::vector< std::unique_ptr< Attribute > >, int > | _query_cache |
std::unordered_map< std::string, unsigned int > | _attrib_ids |
std::vector< std::unique_ptr< Attribute > > | _attrib_list |
std::mutex | _obj_mutex |
std::mutex | _query_cache_mutex |
std::mutex | _obj_cache_mutex |
TheWarehouse is a container for MooseObjects that allows querying/filtering over various customizeable attributes.
The meta-data about the objects is read/stored when the objects are added to the warehouse - updates to objects' state will not be reflected in query results unless the object is explicitly updated through the warehouse interface. The warehouse object can safely be queried concurrently from multiple threads.
Once Query and Attribute objects have been constructed, they are tied to the specific warehouse they were created with. They must not be used for different warehouses or the attribute ID they store internally will be wrong and that is bad.
Definition at line 185 of file TheWarehouse.h.
using TheWarehouse::AttribType = T * |
Definition at line 191 of file TheWarehouse.h.
using TheWarehouse::KeyType = typename T::Key |
Definition at line 189 of file TheWarehouse.h.
using TheWarehouse::Query = QueryCache<> |
Definition at line 409 of file TheWarehouse.h.
TheWarehouse::TheWarehouse | ( | ) |
Definition at line 110 of file TheWarehouse.C.
TheWarehouse::~TheWarehouse | ( | ) |
Definition at line 111 of file TheWarehouse.C.
void TheWarehouse::add | ( | std::shared_ptr< MooseObject > | obj | ) |
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/filtering.
The warehouse will maintain a pointer to the object indefinitely.
Definition at line 116 of file TheWarehouse.C.
Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addDGKernel(), NonlinearSystemBase::addDiracKernel(), NonlinearSystemBase::addHDGKernel(), NonlinearSystemBase::addInterfaceKernel(), NonlinearSystemBase::addKernel(), NonlinearSystemBase::addNodalKernel(), FEProblemBase::addObject(), NonlinearSystemBase::addScalarKernel(), NonlinearSystemBase::addSplit(), and FEProblemBase::addUserObject().
|
inline |
Returns a unique ID associated with the given attribute name - i.e.
an attribute and name that were previously registered via calls to registerAttribute. Users should generally not need to use this function.
Definition at line 443 of file TheWarehouse.h.
std::size_t TheWarehouse::count | ( | const std::vector< std::unique_ptr< Attribute >> & | conds | ) |
count returns the number of objects that match the provided query conditions.
This requires executing a full query operation (i.e. as if calling queryInto). A Query object should generally be used via the query() member function instead.
Definition at line 263 of file TheWarehouse.C.
Referenced by TheWarehouse::QueryCache< AttribThread, AttribBoundaries, AttribInterfaces >::count().
prepares a query and returns an associated query_id (i.e. for use with the query function).
Definition at line 166 of file TheWarehouse.C.
Referenced by queryID().
|
inline |
query creates and returns an initialized a query object for querying objects from the warehouse.
Definition at line 466 of file TheWarehouse.h.
Referenced by CheckFVBCAction::act(), NonlinearSystemBase::checkKernelCoverage(), FEProblemBase::checkUserObjectJacobianRequirement(), FEProblemBase::checkUserObjects(), NonlinearSystemBase::computeJacobianInternal(), NonlinearSystemBase::computeResidualAndJacobianInternal(), NonlinearSystemBase::computeResidualInternal(), FEProblemBase::computeUserObjectByName(), FEProblemBase::computeUserObjects(), LinearSystem::containsTimeKernel(), count(), NonlinearSystemBase::customSetup(), FEProblemBase::customSetup(), ComputeResidualThread::determineObjectWarehouses(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), FEProblemBase::executeSamplers(), ComputeLinearFVElementalThread::fetchBlockSystemContributionObjects(), ComputeLinearFVFaceThread::fetchBlockSystemContributionObjects(), FEProblemBase::getDistribution(), FEProblemBase::getMortarUserObjects(), FEProblemBase::getPositionsObject(), FEProblemBase::getSampler(), CompositionDT::getTimeSteppers(), FEProblemBase::getUserObject(), FEProblemBase::getUserObjectBase(), FEProblemBase::hasUserObject(), SideFVFluxBCIntegral::initialSetup(), ExplicitTimeIntegrator::initialSetup(), LinearSystem::initialSetup(), NonlinearSystemBase::initialSetup(), FEProblemBase::initialSetup(), AdvancedOutput::initPostprocessorOrVectorPostprocessorLists(), MooseVariableDataFV< OutputType >::MooseVariableDataFV(), FEProblemBase::needBoundaryMaterialOnSide(), FEProblemBase::needInterfaceMaterialOnSide(), FEProblemBase::needSubdomainMaterialOnSide(), JSONOutput::outputReporters(), BlockRestrictionDebugOutput::printBlockRestrictionMap(), queryInto(), ComputeLinearFVElementalThread::setupSystemContributionObjects(), ComputeLinearFVFaceThread::setupSystemContributionObjects(), NonlinearThread::subdomainChanged(), NonlinearSystemBase::timestepSetup(), and FEProblemBase::timestepSetup().
|
private |
callers of this function must lock _obj_cache_mutex as long as a reference to the returned vector is being used.
Definition at line 238 of file TheWarehouse.C.
std::size_t TheWarehouse::queryID | ( | const std::vector< std::unique_ptr< Attribute >> & | conds | ) |
Definition at line 246 of file TheWarehouse.C.
Referenced by count(), JSONOutput::outputReporters(), queryInto(), and TheWarehouse::QueryCache< AttribThread, AttribBoundaries, AttribInterfaces >::queryIntoHelper().
|
inline |
queryInto takes the given conditions (i.e.
Attributes holding the values to filter/match over) and filters all objects in the warehouse that match all conditions (i.e. "and"ing the conditions together) and stores them in the results vector. All result objects must be castable to the templated type T. This function filters out disabled objects on the fly - only returning enabled ones.
Definition at line 477 of file TheWarehouse.h.
Referenced by JSONOutput::outputReporters(), and TheWarehouse::QueryCache< AttribThread, AttribBoundaries, AttribInterfaces >::queryIntoHelper().
|
inline |
Definition at line 486 of file TheWarehouse.h.
|
private |
Definition at line 276 of file TheWarehouse.C.
Referenced by add(), and update().
|
inline |
registers a new "tracked" attribute of type T for the warehouse.
args are all arguments necessary to create an instance of the T class excluding the warehouse reference/pointer which is assumed to be first and automatically inserted. An instance of every registered attribute will be created for and initialized to each object added to the warehouse allowing queries to be executed over specific values the attribute may take on. Attributes must be registered before objects are added to the warehouse. A unique ID associated with the registered attribute is returned - which is generally not needed used by users.
As an example, to register a class with the constructor "YourAttribute(TheWarehouse& w, int foo)", you would call "registerAttribute<YourAttribute>("your_attrib_name", constructor_arg1, ...)". Custom attribute classes are required to pass an attribute name (i.e. "your_attrib_name") to the Attribute base class. The dummy args are forwarded to the attrib class' constructor. The name passed here into registerAttribute must be the same string as the name passed to the Attribute base class's constructor.
Definition at line 429 of file TheWarehouse.h.
void TheWarehouse::update | ( | MooseObject * | obj | ) |
update updates the metadata/attribute-info stored for the given object obj that must already exists in the warehouse.
Call this if an object's state has changed in such a way that its warehouse attributes have become stale/incorrect.
Definition at line 154 of file TheWarehouse.C.
Referenced by groupUserObjects().
void TheWarehouse::update | ( | MooseObject * | obj, |
const Attribute & | extra | ||
) |
update updates the metadata/attribute-info stored for the given object obj that must already exists in the warehouse.
Call this if an object's state has changed in such a way that its warehouse attributes have become stale/incorrect. Any attribute specified in extra overwrites/trumps one read from the object's current state.
Definition at line 142 of file TheWarehouse.C.
|
private |
Definition at line 530 of file TheWarehouse.h.
Referenced by attribID(), and registerAttribute().
|
private |
Definition at line 531 of file TheWarehouse.h.
Referenced by readAttribs(), and registerAttribute().
|
private |
|
private |
Definition at line 535 of file TheWarehouse.h.
Referenced by count(), prepare(), and queryInto().
|
private |
Definition at line 520 of file TheWarehouse.h.
|
private |
Definition at line 533 of file TheWarehouse.h.
|
private |
Definition at line 519 of file TheWarehouse.h.
|
private |
Definition at line 534 of file TheWarehouse.h.
|
private |
Definition at line 518 of file TheWarehouse.h.