www.mooseframework.org
InitialConditionWarehouse.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* Do NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
15 
16 // MOOSE includes
17 #include "InitialCondition.h"
18 #include "MooseVariable.h"
19 
22  _boundary_ics(libMesh::n_threads()),
23  _block_ics(libMesh::n_threads())
24 {
25 }
26 
27 void
29 {
31  for (const auto & ic : _active_objects[tid])
32  ic->initialSetup();
33 }
34 
35 void
36 InitialConditionWarehouse::addObject(std::shared_ptr<InitialCondition> object, THREAD_ID tid)
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 }
90 
91 std::set<std::string>
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 }
void sort(THREAD_ID tid=0)
Sort the objects using the DependencyResolver.
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.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const std::string & name() const
Get the variable name.
InitialConditions are objects that set the initial value of variables.
virtual bool isNodal() const override
Is this variable nodal.
void initialSetup(THREAD_ID tid)
Initial setup.
std::vector< std::map< std::string, std::set< SubdomainID > > > _block_ics
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:117
std::set< std::string > getDependObjects() const
Get a list of dependent UserObjects for this exec type.
std::vector< std::vector< std::shared_ptr< InitialCondition > > > _active_objects
All active objects (THREAD_ID on outer vector)
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...
A base storage container for MooseObjects.
unsigned int THREAD_ID
Definition: MooseTypes.h:79
void addObject(std::shared_ptr< InitialCondition > object, THREAD_ID tid)
Add object to the warehouse.