forked from idaholab/moose
/
ComputeElemAuxBcsThread.C
118 lines (101 loc) · 3.92 KB
/
ComputeElemAuxBcsThread.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
// MOOSE includes
#include "ComputeElemAuxBcsThread.h"
#include "AuxiliarySystem.h"
#include "FEProblem.h"
#include "AuxKernel.h"
// libmesh includes
#include "libmesh/threads.h"
ComputeElemAuxBcsThread::ComputeElemAuxBcsThread(FEProblemBase & problem,
const MooseObjectWarehouse<AuxKernel> & storage,
bool need_materials) :
_problem(problem),
_aux_sys(problem.getAuxiliarySystem()),
_storage(storage),
_need_materials(need_materials)
{
}
// Splitting Constructor
ComputeElemAuxBcsThread::ComputeElemAuxBcsThread(ComputeElemAuxBcsThread & x, Threads::split /*split*/) :
_problem(x._problem),
_aux_sys(x._aux_sys),
_storage(x._storage),
_need_materials(x._need_materials)
{
}
void
ComputeElemAuxBcsThread::operator() (const ConstBndElemRange & range)
{
ParallelUniqueId puid;
_tid = puid.id;
// Reference to all boundary restricted AuxKernels for the current thread
const auto & boundary_kernels = _storage.getActiveBoundaryObjects(_tid);
for (const auto & belem : range)
{
const Elem * elem = belem->_elem;
unsigned short int side = belem->_side;
BoundaryID boundary_id = belem->_bnd_id;
if (elem->processor_id() == _problem.processor_id())
{
// prepare variables
for (const auto & it : _aux_sys._elem_vars[_tid])
{
MooseVariable * var = it.second;
var->prepareAux();
}
// Locate the AuxKernel objects for the current BoundaryID
const auto iter = boundary_kernels.find(boundary_id);
if (iter != boundary_kernels.end() && !(iter->second.empty()) )
{
_problem.prepare(elem, _tid);
_problem.reinitElemFace(elem, side, boundary_id, _tid);
std::set<unsigned int> needed_mat_props;
for (const auto & aux : iter->second)
{
const std::set<unsigned int> & mp_deps = aux->getMatPropDependencies();
needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
}
_problem.setActiveMaterialProperties(needed_mat_props, _tid);
if (_need_materials)
{
_problem.reinitMaterialsFace(elem->subdomain_id(), _tid);
_problem.reinitMaterialsBoundary(boundary_id, _tid);
}
// Set the active boundary id so that BoundaryRestrictable::_boundary_id is correct
_problem.setCurrentBoundaryID(boundary_id);
for (const auto & aux : iter->second)
aux->compute();
if (_need_materials)
_problem.swapBackMaterialsFace(_tid);
// Set active boundary id to invalid
_problem.setCurrentBoundaryID(Moose::INVALID_BOUNDARY_ID);
}
// update the solution vector
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
for (const auto & it : _aux_sys._elem_vars[_tid])
{
MooseVariable * var = it.second;
var->insert(_aux_sys.solution());
}
}
}
}
_problem.clearActiveMaterialProperties(_tid);
}
void
ComputeElemAuxBcsThread::join(const ComputeElemAuxBcsThread & /*y*/)
{
}