https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
36 Threads::split split)
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
46void
58
59void
60ComputeNodalKernelsThread::onNode(ConstNodeRange::const_iterator & node_it)
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);
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
91
92 if (_num_cached == 20) // Cache 20 nodes worth before adding into the residual
93 {
94 _num_cached = 0;
96 }
97}
98
99void
103
104void
106{
108 return;
109
110 const auto & console = _fe_problem.console();
111 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
112 console << "[DBG] Computing nodal kernels contribution to residual on nodes on " << execute_on
113 << std::endl;
114 console << "[DBG] Nodes at boundaries between blocks will execute lower block ID first"
115 << std::endl;
116 console << "[DBG] Ordering of the nodal kernels on nodes they are defined on:" << std::endl;
117 console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
118}
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
void printGeneralExecutionInformation() const override
Print execution order of object types in the loop.
unsigned int _num_cached
Number of contributions cached up.
ComputeNodalKernelsThread(FEProblemBase &fe_problem, MooseObjectTagWarehouse< NodalKernelBase > &nodal_kernels, const std::set< TagID > &tags)
const std::set< TagID > & _tags
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
virtual void onNode(ConstNodeRange::const_iterator &node_it) override
virtual void pre() override
Called before the node range loop.
void join(const ComputeNodalKernelsThread &)
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void addCachedResidual(const THREAD_ID tid) override
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition MooseMesh.C:1489
A storage container for MooseObjects that inherit from SetupInterface.
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag.
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...
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.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
bool hasActiveObjects(THREAD_ID tid=0) const
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
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
MooseMesh & mesh()
Definition SystemBase.h:100
@ VECTOR_TAG_RESIDUAL