www.mooseframework.org
ComputeElemAuxBcsThread.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 // MOOSE includes
17 #include "AuxiliarySystem.h"
18 #include "FEProblem.h"
19 #include "DisplacedProblem.h"
20 #include "Assembly.h"
21 #include "AuxKernel.h"
22 
23 #include "libmesh/threads.h"
24 
26  const MooseObjectWarehouse<AuxKernel> & storage,
27  bool need_materials)
28  : _problem(problem),
29  _aux_sys(problem.getAuxiliarySystem()),
30  _storage(storage),
31  _need_materials(need_materials)
32 {
33 }
34 
35 // Splitting Constructor
37  Threads::split /*split*/)
38  : _problem(x._problem),
39  _aux_sys(x._aux_sys),
40  _storage(x._storage),
42 {
43 }
44 
45 void
47 {
48  ParallelUniqueId puid;
49  _tid = puid.id;
50 
51  // Reference to all boundary restricted AuxKernels for the current thread
52  const auto & boundary_kernels = _storage.getActiveBoundaryObjects(_tid);
53 
54  for (const auto & belem : range)
55  {
56  const Elem * elem = belem->_elem;
57  unsigned short int side = belem->_side;
58  BoundaryID boundary_id = belem->_bnd_id;
59 
60  if (elem->processor_id() == _problem.processor_id())
61  {
62  // prepare variables
63  for (const auto & it : _aux_sys._elem_vars[_tid])
64  {
65  MooseVariable * var = it.second;
66  var->prepareAux();
67  }
68 
69  // Locate the AuxKernel objects for the current BoundaryID
70  const auto iter = boundary_kernels.find(boundary_id);
71 
72  if (iter != boundary_kernels.end() && !(iter->second.empty()))
73  {
74  _problem.setCurrentSubdomainID(elem, _tid);
75  _problem.prepare(elem, _tid);
76  _problem.reinitElemFace(elem, side, boundary_id, _tid);
77 
78  if (_need_materials)
79  {
80  std::set<unsigned int> needed_mat_props;
81  for (const auto & aux : iter->second)
82  {
83  const std::set<unsigned int> & mp_deps = aux->getMatPropDependencies();
84  needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
85  }
86  _problem.setActiveMaterialProperties(needed_mat_props, _tid);
87  _problem.reinitMaterialsFace(elem->subdomain_id(), _tid);
88  _problem.reinitMaterialsBoundary(boundary_id, _tid);
89  }
90 
91  for (const auto & aux : iter->second)
92  aux->compute();
93 
94  if (_need_materials)
95  {
98  }
99  }
100 
101  // update the solution vector
102  {
103  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
104  for (const auto & it : _aux_sys._elem_vars[_tid])
105  {
106  MooseVariable * var = it.second;
107  var->insert(_aux_sys.solution());
108  }
109  }
110  }
111  }
112 }
113 
114 void
116 {
117 }
virtual void prepare(const Elem *elem, THREAD_ID tid) override
Class for stuff related to variables.
Definition: MooseVariable.h:43
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > ConstBndElemRange
Definition: MooseMesh.h:1185
void join(const ComputeElemAuxBcsThread &)
void operator()(const ConstBndElemRange &range)
static PetscErrorCode Vec x
virtual void reinitMaterialsBoundary(BoundaryID boundary_id, THREAD_ID tid, bool swap_stateful=true)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void setActiveMaterialProperties(const std::set< unsigned int > &mat_prop_ids, THREAD_ID tid) override
Record and set the material properties required by the current computing thread.
std::vector< std::map< std::string, MooseVariable * > > _elem_vars
virtual void clearActiveMaterialProperties(THREAD_ID tid) override
Clear the active material properties.
ComputeElemAuxBcsThread(FEProblemBase &problem, const MooseObjectWarehouse< AuxKernel > &storage, bool need_materials)
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.
virtual NumericVector< Number > & solution() override
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override
virtual void reinitMaterialsFace(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
virtual void setCurrentSubdomainID(const Elem *elem, THREAD_ID tid) override
void insert(NumericVector< Number > &residual)
virtual void swapBackMaterialsFace(THREAD_ID tid)
boundary_id_type BoundaryID
Definition: MooseTypes.h:75