www.mooseframework.org
KernelWarehouse.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 /****************************************************************/
14 
15 #include "KernelWarehouse.h"
16 
17 // MOOSE includes
18 #include "KernelBase.h"
19 #include "MooseVariable.h"
20 #include "TimeDerivative.h"
21 #include "TimeKernel.h"
22 
24 
25 void
26 KernelWarehouse::addObject(std::shared_ptr<KernelBase> object, THREAD_ID tid)
27 {
28  // Add object to the general storage
30 
31  // Add object to the variable based storage
32  _variable_kernel_storage[object->variable().number()].addObject(object, tid);
33 }
34 
35 bool
37  SubdomainID block_id,
38  THREAD_ID tid) const
39 {
40  checkThreadID(tid);
41  std::map<unsigned int, MooseObjectWarehouse<KernelBase>>::const_iterator iter =
42  _variable_kernel_storage.find(variable_id);
43  return (iter != _variable_kernel_storage.end() &&
44  iter->second.hasActiveBlockObjects(block_id, tid));
45 }
46 
47 const std::vector<std::shared_ptr<KernelBase>> &
49  SubdomainID block_id,
50  THREAD_ID tid) const
51 {
52  checkThreadID(tid);
53  const auto iter = _variable_kernel_storage.find(variable_id);
54  mooseAssert(iter != _variable_kernel_storage.end(),
55  "Unable to located variable kernels for the given variable id: " << variable_id
56  << ".");
57  return iter->second.getActiveBlockObjects(block_id, tid);
58 }
59 
60 void
62 {
64 
65  for (auto & it : _variable_kernel_storage)
66  it.second.updateActive(tid);
67 }
const std::vector< std::shared_ptr< KernelBase > > & getActiveVariableBlockObjects(unsigned int variable_id, SubdomainID block_id, THREAD_ID tid=0) const
subdomain_id_type SubdomainID
Definition: MooseTypes.h:77
A storage container for MooseObjects that inherit from SetupInterface.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0)
Adds an object to the storage structure.
void checkThreadID(THREAD_ID tid) const
Calls assert on thread id.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
This is the common base class for the two main kernel types implemented in MOOSE, EigenKernel and Ker...
Definition: KernelBase.h:47
void addObject(std::shared_ptr< KernelBase > object, THREAD_ID tid=0) override
Add Kernel to the storage structure.
bool hasActiveVariableBlockObjects(unsigned int variable_id, SubdomainID block_id, THREAD_ID tid=0) const
Methods for checking/getting variable kernels for a variable and SubdomainID.
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.
unsigned int THREAD_ID
Definition: MooseTypes.h:79
std::map< unsigned int, MooseObjectWarehouse< KernelBase > > _variable_kernel_storage
Variable based storage.