Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ComputeNodalKernelsThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "MooseMesh.h"
16 #include "MooseVariableFE.h"
17 #include "NodalKernelBase.h"
18 
19 #include "libmesh/threads.h"
20 
22  FEProblemBase & fe_problem,
24  const std::set<TagID> & tags)
25  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
26  _fe_problem(fe_problem),
27  _aux_sys(fe_problem.getAuxiliarySystem()),
28  _tags(tags),
29  _nodal_kernels(nodal_kernels),
30  _num_cached(0)
31 {
32 }
33 
34 // Splitting Constructor
37  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
38  _fe_problem(x._fe_problem),
39  _aux_sys(x._aux_sys),
40  _tags(x._tags),
41  _nodal_kernels(x._nodal_kernels),
42  _num_cached(0)
43 {
44 }
45 
46 void
48 {
49  _num_cached = 0;
50 
53  else if (_tags.size() == 1)
55  else
57 }
58 
59 void
61 {
62  const Node * node = *node_it;
63 
64  std::set<const NodalKernelBase *> nks_executed;
65 
66  // prepare variables
67  for (auto * var : _aux_sys._nodal_vars[_tid])
68  var->prepareAux();
69 
71 
72  const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
73  for (const auto block : block_ids)
75  {
76  std::set<TagID> needed_fe_var_vector_tags;
78  block, needed_fe_var_vector_tags, _tid);
79  _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
80 
81  const auto & objects = _nkernel_warehouse->getActiveBlockObjects(block, _tid);
82  for (const auto & nodal_kernel : objects)
83  if (nks_executed.emplace(nodal_kernel.get()).second)
84  {
85  nodal_kernel->setSubdomains(block_ids);
86  nodal_kernel->computeResidual();
87  }
88  }
89 
90  _num_cached++;
91 
92  if (_num_cached == 20) // Cache 20 nodes worth before adding into the residual
93  {
94  _num_cached = 0;
95  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
97  }
98 }
99 
100 void
102 {
103 }
104 
105 void
107 {
109  return;
110 
111  const auto & console = _fe_problem.console();
112  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
113  console << "[DBG] Computing nodal kernels contribution to residual on nodes on " << execute_on
114  << std::endl;
115  console << "[DBG] Nodes at boundaries between blocks will execute lower block ID first"
116  << std::endl;
117  console << "[DBG] Ordering of the nodal kernels on nodes they are defined on:" << std::endl;
118  console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
119 }
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...
MooseMesh & mesh()
Definition: SystemBase.h:99
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
void join(const ComputeNodalKernelsThread &)
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
virtual void onNode(ConstNodeRange::const_iterator &node_it) override
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...
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:1496
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const std::set< TagID > & _tags
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
ComputeNodalKernelsThread(FEProblemBase &fe_problem, MooseObjectTagWarehouse< NodalKernelBase > &nodal_kernels, const std::set< TagID > &tags)
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
tbb::split split
virtual void pre() override
Called before the node range loop.
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
bool hasActiveObjects(THREAD_ID tid=0) const
vec_type::const_iterator const_iterator
unsigned int _num_cached
Number of contributions cached up.
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:196
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
void printGeneralExecutionInformation() const override
Print execution order of object types in the loop.
virtual void addCachedResidual(const THREAD_ID tid) override
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels