https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeNodalKernelBCJacobiansThread.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 "Assembly.h"
14#include "AuxiliarySystem.h"
15#include "FEProblem.h"
16#include "MooseVariableFE.h"
17#include "NodalKernelBase.h"
18#include "NonlinearSystemBase.h"
19
20#include "libmesh/threads.h"
21
23 FEProblemBase & fe_problem,
26 const std::set<TagID> & tags)
27 : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
28 _fe_problem(fe_problem),
29 _nl(nl),
30 _aux_sys(fe_problem.getAuxiliarySystem()),
31 _tags(tags),
32 _nodal_kernels(nodal_kernels),
33 _num_cached(0)
34{
35}
36
37// Splitting Constructor
40 : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
41 _fe_problem(x._fe_problem),
42 _nl(x._nl),
43 _aux_sys(x._aux_sys),
44 _tags(x._tags),
45 _nodal_kernels(x._nodal_kernels),
46 _num_cached(0)
47{
48}
49
50void
62
63void
65{
66 const BndNode * bnode = *node_it;
67
68 BoundaryID boundary_id = bnode->_bnd_id;
69
71 for (const auto & it : ce)
72 {
73 MooseVariableFEBase & ivariable = *(it.first);
74 MooseVariableFEBase & jvariable = *(it.second);
75
76 unsigned int ivar = ivariable.number();
77 unsigned int jvar = jvariable.number();
78
79 // The NodalKernels that are active and are coupled to the jvar in question
80 std::vector<std::shared_ptr<NodalKernelBase>> active_involved_kernels;
81
83 {
84 // Loop over each NodalKernel to see if it's involved with the jvar
85 const auto & objects = _nkernel_warehouse->getActiveBoundaryObjects(boundary_id, _tid);
86 for (const auto & nodal_kernel : objects)
87 {
88 if (nodal_kernel->variable().number() == ivar)
89 {
90 // If this NodalKernel is acting on the jvar add it to the list and short-circuit the
91 // loop
92 if (nodal_kernel->variable().number() == jvar)
93 {
94 active_involved_kernels.push_back(nodal_kernel);
95 continue;
96 }
97
98 // See if this NodalKernel is coupled to the jvar
99 const std::vector<MooseVariableFEBase *> & coupled_vars =
100 nodal_kernel->getCoupledMooseVars();
101 for (const auto & var : coupled_vars)
102 {
103 if (var->number() == jvar)
104 {
105 active_involved_kernels.push_back(nodal_kernel);
106 break; // It only takes one
107 }
108 }
109 }
110 }
111 }
112
113 // Did we find any NodalKernels coupled to this jvar?
114 if (!active_involved_kernels.empty())
115 {
116 // prepare variables
117 for (auto * var : _aux_sys._nodal_vars[_tid])
118 var->prepareAux();
119
121 {
122 Node * node = bnode->_node;
123 if (node->processor_id() == _fe_problem.processor_id())
124 {
125 _fe_problem.reinitNodeFace(node, boundary_id, _tid);
126 for (const auto & nodal_kernel : active_involved_kernels)
127 {
128 nodal_kernel->setSubdomains(Moose::NodeArg::undefined_subdomain_connection);
129 nodal_kernel->computeOffDiagJacobian(jvar);
130 }
131
132 _num_cached++;
133 }
134 }
135
136 if (_num_cached == 20) // cache 20 nodes worth before adding into the jacobian
137 {
138 _num_cached = 0;
140 }
141 }
142 }
143}
144
145void
149
150void
152{
154 return;
155
156 const auto & console = _fe_problem.console();
157 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
158 console << "[DBG] Computing nodal kernel & boundary conditions contribution to the Jacobian on "
159 "boundary nodes on "
160 << execute_on << std::endl;
161 console << "[DBG] Ordering on boundaries they are defined on:" << std::endl;
162 console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
163}
boundary_id_type BoundaryID
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
unsigned int _num_cached
Number of contributions cached up.
virtual void onNode(ConstBndNodeRange::const_iterator &node_it) override
void printGeneralExecutionInformation() const override
Print information about the loop, mostly order of execution of objects.
virtual void pre() override
Called before the node range loop.
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
void join(const ComputeNodalKernelBCJacobiansThread &)
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels
ComputeNodalKernelBCJacobiansThread(FEProblemBase &fe_problem, NonlinearSystemBase &nl, MooseObjectTagWarehouse< NodalKernelBase > &nodal_kernels, const std::set< TagID > &tags)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void addCachedJacobian(const THREAD_ID tid) override
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableFieldBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
A storage container for MooseObjects that inherit from SetupInterface.
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags.
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag.
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< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
unsigned int number() const
Get variable number coming from libMesh.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Nonlinear system to be solved.
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition SubProblem.h:248
unsigned int number() const
Gets the number of this system.
processor_id_type processor_id() const
vec_type::const_iterator const_iterator
BoundaryID _bnd_id
boundary id for the node
Definition BndNode.h:26
libMesh::Node * _node
pointer to the node
Definition BndNode.h:24
static const std::set< SubdomainID > undefined_subdomain_connection
A static member that can be used when the connection of a node to subdomains is unknown.