www.mooseframework.org
ComputeNodalKernelBcsThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
12 // MOOSE includes
13 #include "AuxiliarySystem.h"
14 #include "FEProblem.h"
15 #include "MooseVariableFE.h"
16 #include "NodalKernelBase.h"
17 
18 #include "libmesh/threads.h"
19 
21  FEProblemBase & fe_problem,
23  const std::set<TagID> & tags)
24  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
25  _fe_problem(fe_problem),
26  _aux_sys(fe_problem.getAuxiliarySystem()),
27  _tags(tags),
28  _nodal_kernels(nodal_kernels),
29  _num_cached(0)
30 {
31 }
32 
33 // Splitting Constructor
35  Threads::split split)
37  _fe_problem(x._fe_problem),
38  _aux_sys(x._aux_sys),
39  _tags(x._tags),
40  _nodal_kernels(x._nodal_kernels),
41  _num_cached(0)
42 {
43 }
44 
45 void
47 {
48  _num_cached = 0;
49 
52  else if (_tags.size() == 1)
54  else
56 }
57 
58 void
59 ComputeNodalKernelBcsThread::onNode(ConstBndNodeRange::const_iterator & node_it)
60 {
61  const BndNode * bnode = *node_it;
62 
63  BoundaryID boundary_id = bnode->_bnd_id;
64 
65  // prepare variables
66  for (auto * var : _aux_sys._nodal_vars[_tid])
67  var->prepareAux();
68 
70  {
71  Node * node = bnode->_node;
72  if (node->processor_id() == _fe_problem.processor_id())
73  {
74  std::set<TagID> needed_fe_var_vector_tags;
76  boundary_id, needed_fe_var_vector_tags, _tid);
77  _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
78 
79  _fe_problem.reinitNodeFace(node, boundary_id, _tid);
80  const auto & objects = _nkernel_warehouse->getActiveBoundaryObjects(boundary_id, _tid);
81  for (const auto & nodal_kernel : objects)
82  nodal_kernel->computeResidual();
83 
84  _num_cached++;
85  }
86  }
87 
88  if (_num_cached == 20) // cache 20 nodes worth before adding into the residual
89  {
90  _num_cached = 0;
91  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
93  }
94 }
95 
96 void
98 {
99 }
100 
101 void
103 {
105  return;
106 
107  const auto & console = _fe_problem.console();
108  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
109  console << "[DBG] Executing nodal kernels contribution to residual on nodes on " << execute_on
110  << std::endl;
111  console << "[DBG] Ordering of the nodal kernels on the nodes they are defined on:" << std::endl;
112  console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
113 }
std::string activeObjectsToFormattedString(THREAD_ID tid=0, const std::string &prefix="[DBG]") const
Output the active content of the warehouse to a string, meant to be output to the console...
virtual void pre() override
Called before the node range loop.
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
virtual void onNode(ConstBndNodeRange::const_iterator &node_it) override
Called for each node.
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:26
Node * _node
pointer to the node
Definition: BndNode.h:24
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void updateBoundaryFEVariableCoupledVectorTagDependency(BoundaryID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
boundary_id_type BoundaryID
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
void printGeneralExecutionInformation() const override
Print information about the loop, mostly order of execution of objects.
tbb::split split
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
ComputeNodalKernelBcsThread(FEProblemBase &fe_problem, MooseObjectTagWarehouse< NodalKernelBase > &nodal_kernels, const std::set< TagID > &tags)
bool hasActiveObjects(THREAD_ID tid=0) const
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:172
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
void join(const ComputeNodalKernelBcsThread &)
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void addCachedResidual(const THREAD_ID tid) override
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels