www.mooseframework.org
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
InitialConditionWarehouse Class Reference

Warehouse for storing initial conditions. More...

#include <InitialConditionWarehouse.h>

Inheritance diagram for InitialConditionWarehouse:
[legend]

Public Member Functions

 InitialConditionWarehouse ()
 
void initialSetup (THREAD_ID tid)
 Initial setup. More...
 
void addObject (std::shared_ptr< InitialCondition > object, THREAD_ID tid)
 Add object to the warehouse. More...
 
std::set< std::string > getDependObjects () const
 Get a list of dependent UserObjects for this exec type. More...
 
std::set< SubdomainIDgetActiveBlocks (THREAD_ID tid=0) const
 Return a set of active SubdomainsIDs. More...
 
virtual void updateActive (THREAD_ID tid=0)
 Updates the active objects storage. More...
 
void sort (THREAD_ID tid=0)
 Sort the objects using the DependencyResolver. More...
 
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. More...
 
const std::vector< std::shared_ptr< InitialCondition > > & getObjects (THREAD_ID tid=0) const
 Retrieve complete vector to the all/block/boundary restricted objects for a given thread. More...
 
const std::map< SubdomainID, std::vector< std::shared_ptr< InitialCondition > > > & getBlockObjects (THREAD_ID tid=0) const
 
const std::vector< std::shared_ptr< InitialCondition > > & getBlockObjects (SubdomainID id, THREAD_ID tid=0) const
 
const std::map< BoundaryID, std::vector< std::shared_ptr< InitialCondition > > > & getBoundaryObjects (THREAD_ID tid=0) const
 
const std::vector< std::shared_ptr< InitialCondition > > & getBoundaryObjects (BoundaryID id, THREAD_ID tid=0) const
 
const std::vector< std::shared_ptr< InitialCondition > > & getActiveObjects (THREAD_ID tid=0) const
 Retrieve complete vector to the active all/block/boundary restricted objects for a given thread. More...
 
const std::map< SubdomainID, std::vector< std::shared_ptr< InitialCondition > > > & getActiveBlockObjects (THREAD_ID tid=0) const
 
const std::vector< std::shared_ptr< InitialCondition > > & getActiveBlockObjects (SubdomainID id, THREAD_ID tid=0) const
 
const std::map< BoundaryID, std::vector< std::shared_ptr< InitialCondition > > > & getActiveBoundaryObjects (THREAD_ID tid=0) const
 
const std::vector< std::shared_ptr< InitialCondition > > & getActiveBoundaryObjects (BoundaryID id, THREAD_ID tid=0) const
 
bool hasActiveObjects (THREAD_ID tid=0) const
 Convenience functions for determining if objects exist. More...
 
bool hasActiveBlockObjects (THREAD_ID tid=0) const
 
bool hasActiveBlockObjects (SubdomainID id, THREAD_ID tid=0) const
 
bool hasActiveBoundaryObjects (THREAD_ID tid=0) const
 
bool hasActiveBoundaryObjects (BoundaryID id, THREAD_ID tid=0) const
 
bool hasActiveObject (const std::string &name, THREAD_ID tid=0) const
 Convenience functions for checking/getting specific objects. More...
 
std::shared_ptr< InitialConditiongetActiveObject (const std::string &name, THREAD_ID tid=0) const
 
void updateVariableDependency (std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
 Update variable dependency vector. More...
 
void updateBlockVariableDependency (SubdomainID id, std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
 
void updateBoundaryVariableDependency (std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
 
void updateBoundaryVariableDependency (BoundaryID id, std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
 
void updateMatPropDependency (std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
 Update material property dependency vector. More...
 
void updateBlockMatPropDependency (SubdomainID id, std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
 
void updateBoundaryMatPropDependency (std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
 
void updateBoundaryMatPropDependency (BoundaryID id, std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
 

Protected Member Functions

void checkThreadID (THREAD_ID tid) const
 Calls assert on thread id. More...
 

Static Protected Member Functions

static void updateActiveHelper (std::vector< std::shared_ptr< InitialCondition >> &active, const std::vector< std::shared_ptr< InitialCondition >> &all)
 Helper method for updating active vectors. More...
 
static void sortHelper (std::vector< std::shared_ptr< InitialCondition >> &objects)
 Helper method for sorting vectors of objects. More...
 
static void updateVariableDependencyHelper (std::set< MooseVariable * > &needed_moose_vars, const std::vector< std::shared_ptr< InitialCondition >> &objects)
 Helper method for updating variable dependency vector. More...
 
static void updateMatPropDependencyHelper (std::set< unsigned int > &needed_mat_props, const std::vector< std::shared_ptr< InitialCondition >> &objects)
 Helper method for updating material property dependency vector. More...
 

Protected Attributes

const THREAD_ID _num_threads
 Convenience member storing the number of threads used for storage (1 or libMesh::n_threads) More...
 
std::vector< std::vector< std::shared_ptr< InitialCondition > > > _all_objects
 Storage container for the ALL pointers (THREAD_ID on outer vector) More...
 
std::vector< std::vector< std::shared_ptr< InitialCondition > > > _active_objects
 All active objects (THREAD_ID on outer vector) More...
 
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< InitialCondition > > > > _all_block_objects
 
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< InitialCondition > > > > _active_block_objects
 Active block restricted objects (THREAD_ID on outer vector) More...
 
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< InitialCondition > > > > _all_boundary_objects
 
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< InitialCondition > > > > _active_boundary_objects
 Active boundary restricted objects (THREAD_ID on outer vector) More...
 
std::vector< std::map< std::string, std::set< BoundaryID > > > _boundary_ics
 
std::vector< std::map< std::string, std::set< SubdomainID > > > _block_ics
 

Detailed Description

Warehouse for storing initial conditions.

Definition at line 25 of file InitialConditionWarehouse.h.

Constructor & Destructor Documentation

InitialConditionWarehouse::InitialConditionWarehouse ( )

Definition at line 20 of file InitialConditionWarehouse.C.

22  _boundary_ics(libMesh::n_threads()),
23  _block_ics(libMesh::n_threads())
24 {
25 }
std::vector< std::map< std::string, std::set< BoundaryID > > > _boundary_ics
std::vector< std::map< std::string, std::set< SubdomainID > > > _block_ics

Member Function Documentation

void InitialConditionWarehouse::addObject ( std::shared_ptr< InitialCondition object,
THREAD_ID  tid 
)
virtual

Add object to the warehouse.

Reimplemented from MooseObjectWarehouseBase< InitialCondition >.

Definition at line 36 of file InitialConditionWarehouse.C.

Referenced by FEProblemBase::addInitialCondition().

37 {
38  // Check that when object is boundary restricted that the variable is nodal
39  const MooseVariable & var = object->variable();
40 
41  // Boundary Restricted
42  if (object->boundaryRestricted())
43  {
44  if (!var.isNodal())
45  mooseError("You are trying to set a boundary restricted variable on non-nodal variable. That "
46  "is not allowed.");
47 
48  std::map<std::string, std::set<BoundaryID>>::const_iterator iter =
49  _boundary_ics[tid].find(var.name());
50  if (iter != _boundary_ics[tid].end() && object->hasBoundary(iter->second))
51  mooseError("The initial condition '",
52  object->name(),
53  "' is being defined on a boundary that already has an initial condition defined.");
54  else
55  _boundary_ics[tid][var.name()].insert(object->boundaryIDs().begin(),
56  object->boundaryIDs().end());
57  }
58 
59  // Block Restricted
60  else if (object->blockRestricted())
61  {
62  std::map<std::string, std::set<SubdomainID>>::const_iterator iter =
63  _block_ics[tid].find(var.name());
64  if (iter != _block_ics[tid].end() &&
65  (object->hasBlocks(iter->second) ||
66  (iter->second.find(Moose::ANY_BLOCK_ID) != iter->second.end())))
67  mooseError("The initial condition '",
68  object->name(),
69  "' is being defined on a block that already has an initial condition defined.");
70  else
71  _block_ics[tid][var.name()].insert(object->blockIDs().begin(), object->blockIDs().end());
72  }
73 
74  // Non-restricted
75  else
76  {
77  std::map<std::string, std::set<SubdomainID>>::const_iterator iter =
78  _block_ics[tid].find(var.name());
79  if (iter != _block_ics[tid].end())
80  mooseError("The initial condition '",
81  object->name(),
82  "' is being defined on a block that already has an initial condition defined.");
83  else
84  _block_ics[tid][var.name()].insert(Moose::ANY_BLOCK_ID);
85  }
86 
87  // Add the IC to the storage
89 }
Class for stuff related to variables.
Definition: MooseVariable.h:43
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::vector< std::map< std::string, std::set< BoundaryID > > > _boundary_ics
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0)
Adds an object to the storage structure.
const std::string & name() const
Get the variable name.
virtual bool isNodal() const override
Is this variable nodal.
std::vector< std::map< std::string, std::set< SubdomainID > > > _block_ics
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:117
void MooseObjectWarehouseBase< InitialCondition >::checkThreadID ( THREAD_ID  tid) const
protectedinherited

Calls assert on thread id.

const std::map<SubdomainID, std::vector<std::shared_ptr<InitialCondition > > >& MooseObjectWarehouseBase< InitialCondition >::getActiveBlockObjects ( THREAD_ID  tid = 0) const
inherited
const std::vector<std::shared_ptr<InitialCondition > >& MooseObjectWarehouseBase< InitialCondition >::getActiveBlockObjects ( SubdomainID  id,
THREAD_ID  tid = 0 
) const
inherited
std::set<SubdomainID> MooseObjectWarehouseBase< InitialCondition >::getActiveBlocks ( THREAD_ID  tid = 0) const
inherited

Return a set of active SubdomainsIDs.

const std::map<BoundaryID, std::vector<std::shared_ptr<InitialCondition > > >& MooseObjectWarehouseBase< InitialCondition >::getActiveBoundaryObjects ( THREAD_ID  tid = 0) const
inherited
const std::vector<std::shared_ptr<InitialCondition > >& MooseObjectWarehouseBase< InitialCondition >::getActiveBoundaryObjects ( BoundaryID  id,
THREAD_ID  tid = 0 
) const
inherited
std::shared_ptr<InitialCondition > MooseObjectWarehouseBase< InitialCondition >::getActiveObject ( const std::string &  name,
THREAD_ID  tid = 0 
) const
inherited
const std::vector<std::shared_ptr<InitialCondition > >& MooseObjectWarehouseBase< InitialCondition >::getActiveObjects ( THREAD_ID  tid = 0) const
inherited

Retrieve complete vector to the active all/block/boundary restricted objects for a given thread.

Parameters
tidThe thread id to retrieve objects from

Referenced by getDependObjects().

const std::map<SubdomainID, std::vector<std::shared_ptr<InitialCondition > > >& MooseObjectWarehouseBase< InitialCondition >::getBlockObjects ( THREAD_ID  tid = 0) const
inherited
const std::vector<std::shared_ptr<InitialCondition > >& MooseObjectWarehouseBase< InitialCondition >::getBlockObjects ( SubdomainID  id,
THREAD_ID  tid = 0 
) const
inherited
const std::map<BoundaryID, std::vector<std::shared_ptr<InitialCondition > > >& MooseObjectWarehouseBase< InitialCondition >::getBoundaryObjects ( THREAD_ID  tid = 0) const
inherited
const std::vector<std::shared_ptr<InitialCondition > >& MooseObjectWarehouseBase< InitialCondition >::getBoundaryObjects ( BoundaryID  id,
THREAD_ID  tid = 0 
) const
inherited
std::set< std::string > InitialConditionWarehouse::getDependObjects ( ) const

Get a list of dependent UserObjects for this exec type.

Returns
a set of dependent user objects

Definition at line 92 of file InitialConditionWarehouse.C.

Referenced by FEProblemBase::initialSetup().

93 {
94  std::set<std::string> depend_objects;
95 
96  const auto & ics = getActiveObjects();
97  for (const auto & ic : ics)
98  {
99  const auto & uo = ic->getDependObjects();
100  depend_objects.insert(uo.begin(), uo.end());
101  }
102 
103  return depend_objects;
104 }
const std::vector< std::shared_ptr< InitialCondition > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
const std::vector<std::shared_ptr<InitialCondition > >& MooseObjectWarehouseBase< InitialCondition >::getObjects ( THREAD_ID  tid = 0) const
inherited

Retrieve complete vector to the all/block/boundary restricted objects for a given thread.

Parameters
tidThe thread id to retrieve objects from
bool MooseObjectWarehouseBase< InitialCondition >::hasActiveBlockObjects ( THREAD_ID  tid = 0) const
inherited
bool MooseObjectWarehouseBase< InitialCondition >::hasActiveBlockObjects ( SubdomainID  id,
THREAD_ID  tid = 0 
) const
inherited
bool MooseObjectWarehouseBase< InitialCondition >::hasActiveBoundaryObjects ( THREAD_ID  tid = 0) const
inherited
bool MooseObjectWarehouseBase< InitialCondition >::hasActiveBoundaryObjects ( BoundaryID  id,
THREAD_ID  tid = 0 
) const
inherited
bool MooseObjectWarehouseBase< InitialCondition >::hasActiveObject ( const std::string &  name,
THREAD_ID  tid = 0 
) const
inherited

Convenience functions for checking/getting specific objects.

bool MooseObjectWarehouseBase< InitialCondition >::hasActiveObjects ( THREAD_ID  tid = 0) const
inherited

Convenience functions for determining if objects exist.

void InitialConditionWarehouse::initialSetup ( THREAD_ID  tid)

Initial setup.

Definition at line 28 of file InitialConditionWarehouse.C.

Referenced by FEProblemBase::initialSetup().

29 {
31  for (const auto & ic : _active_objects[tid])
32  ic->initialSetup();
33 }
void sort(THREAD_ID tid=0)
Sort the objects using the DependencyResolver.
std::vector< std::vector< std::shared_ptr< InitialCondition > > > _active_objects
All active objects (THREAD_ID on outer vector)
void MooseObjectWarehouseBase< InitialCondition >::sort ( THREAD_ID  tid = 0)
inherited

Sort the objects using the DependencyResolver.

static void MooseObjectWarehouseBase< InitialCondition >::sortHelper ( std::vector< std::shared_ptr< InitialCondition >> &  objects)
staticprotectedinherited

Helper method for sorting vectors of objects.

void MooseObjectWarehouseBase< InitialCondition >::subdomainsCovered ( std::set< SubdomainID > &  subdomains_covered,
std::set< std::string > &  unique_variables,
THREAD_ID  tid = 0 
) const
inherited

Populates a set of covered subdomains and the associated variable names.

virtual void MooseObjectWarehouseBase< InitialCondition >::updateActive ( THREAD_ID  tid = 0)
virtualinherited

Updates the active objects storage.

static void MooseObjectWarehouseBase< InitialCondition >::updateActiveHelper ( std::vector< std::shared_ptr< InitialCondition >> &  active,
const std::vector< std::shared_ptr< InitialCondition >> &  all 
)
staticprotectedinherited

Helper method for updating active vectors.

void MooseObjectWarehouseBase< InitialCondition >::updateBlockMatPropDependency ( SubdomainID  id,
std::set< unsigned int > &  needed_mat_props,
THREAD_ID  tid = 0 
) const
inherited
void MooseObjectWarehouseBase< InitialCondition >::updateBlockVariableDependency ( SubdomainID  id,
std::set< MooseVariable * > &  needed_moose_vars,
THREAD_ID  tid = 0 
) const
inherited
void MooseObjectWarehouseBase< InitialCondition >::updateBoundaryMatPropDependency ( std::set< unsigned int > &  needed_mat_props,
THREAD_ID  tid = 0 
) const
inherited
void MooseObjectWarehouseBase< InitialCondition >::updateBoundaryMatPropDependency ( BoundaryID  id,
std::set< unsigned int > &  needed_mat_props,
THREAD_ID  tid = 0 
) const
inherited
void MooseObjectWarehouseBase< InitialCondition >::updateBoundaryVariableDependency ( std::set< MooseVariable * > &  needed_moose_vars,
THREAD_ID  tid = 0 
) const
inherited
void MooseObjectWarehouseBase< InitialCondition >::updateBoundaryVariableDependency ( BoundaryID  id,
std::set< MooseVariable * > &  needed_moose_vars,
THREAD_ID  tid = 0 
) const
inherited
void MooseObjectWarehouseBase< InitialCondition >::updateMatPropDependency ( std::set< unsigned int > &  needed_mat_props,
THREAD_ID  tid = 0 
) const
inherited

Update material property dependency vector.

static void MooseObjectWarehouseBase< InitialCondition >::updateMatPropDependencyHelper ( std::set< unsigned int > &  needed_mat_props,
const std::vector< std::shared_ptr< InitialCondition >> &  objects 
)
staticprotectedinherited

Helper method for updating material property dependency vector.

void MooseObjectWarehouseBase< InitialCondition >::updateVariableDependency ( std::set< MooseVariable * > &  needed_moose_vars,
THREAD_ID  tid = 0 
) const
inherited

Update variable dependency vector.

static void MooseObjectWarehouseBase< InitialCondition >::updateVariableDependencyHelper ( std::set< MooseVariable * > &  needed_moose_vars,
const std::vector< std::shared_ptr< InitialCondition >> &  objects 
)
staticprotectedinherited

Helper method for updating variable dependency vector.

Member Data Documentation

std::vector<std::map<SubdomainID, std::vector<std::shared_ptr<InitialCondition > > > > MooseObjectWarehouseBase< InitialCondition >::_active_block_objects
protectedinherited

Active block restricted objects (THREAD_ID on outer vector)

Definition at line 171 of file MooseObjectWarehouseBase.h.

std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<InitialCondition > > > > MooseObjectWarehouseBase< InitialCondition >::_active_boundary_objects
protectedinherited

Active boundary restricted objects (THREAD_ID on outer vector)

Definition at line 177 of file MooseObjectWarehouseBase.h.

std::vector<std::vector<std::shared_ptr<InitialCondition > > > MooseObjectWarehouseBase< InitialCondition >::_active_objects
protectedinherited

All active objects (THREAD_ID on outer vector)

Definition at line 165 of file MooseObjectWarehouseBase.h.

Referenced by initialSetup().

std::vector<std::map<SubdomainID, std::vector<std::shared_ptr<InitialCondition > > > > MooseObjectWarehouseBase< InitialCondition >::_all_block_objects
protectedinherited

Definition at line 168 of file MooseObjectWarehouseBase.h.

std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<InitialCondition > > > > MooseObjectWarehouseBase< InitialCondition >::_all_boundary_objects
protectedinherited

Definition at line 174 of file MooseObjectWarehouseBase.h.

std::vector<std::vector<std::shared_ptr<InitialCondition > > > MooseObjectWarehouseBase< InitialCondition >::_all_objects
protectedinherited

Storage container for the ALL pointers (THREAD_ID on outer vector)

Definition at line 162 of file MooseObjectWarehouseBase.h.

std::vector<std::map<std::string, std::set<SubdomainID> > > InitialConditionWarehouse::_block_ics
protected

Definition at line 50 of file InitialConditionWarehouse.h.

Referenced by addObject().

std::vector<std::map<std::string, std::set<BoundaryID> > > InitialConditionWarehouse::_boundary_ics
protected

Variable name to block/boundary IDs for error checking

Definition at line 49 of file InitialConditionWarehouse.h.

Referenced by addObject().

const THREAD_ID MooseObjectWarehouseBase< InitialCondition >::_num_threads
protectedinherited

Convenience member storing the number of threads used for storage (1 or libMesh::n_threads)

Definition at line 159 of file MooseObjectWarehouseBase.h.


The documentation for this class was generated from the following files: