https://mooseframework.inl.gov
ComputeResidualThread.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 
10 #include "ComputeResidualThread.h"
11 #include "NonlinearSystemBase.h"
12 #include "KernelBase.h"
13 #include "DGKernelBase.h"
14 #include "IntegratedBCBase.h"
15 #include "FVElementalKernel.h"
16 #include "InterfaceKernelBase.h"
17 #include "HDGKernel.h"
18 #include "libmesh/threads.h"
19 
21  const std::set<TagID> & tags)
22  : NonlinearThread(fe_problem), _tags(tags)
23 {
24 }
25 
26 // Splitting Constructor
28  : NonlinearThread(x, split), _tags(x._tags)
29 {
30 }
31 
33 
34 void
36 {
37  ro.computeResidual();
38 }
39 
40 void
42 {
44 }
45 
46 void
48 {
50 }
51 
52 void
54 {
57 }
58 
59 void
61 {
63  _num_cached++;
64 
65  if (_num_cached % 20 == 0)
66  {
67  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
69  }
70 }
71 
72 void
74 {
75 }
76 
77 void
79 {
80  // If users pass a empty vector or a full size of vector,
81  // we take all kernels
83  {
89  }
90  // If we have one tag only,
91  // We call tag based storage
92  else if (_tags.size() == 1)
93  {
99  }
100  // This one may be expensive
101  else
102  {
108  }
109 
110  if (_fe_problem.haveFV())
111  {
112  _fv_kernels.clear();
114  .query()
115  .template condition<AttribSysNum>(_nl.number())
116  .template condition<AttribSystem>("FVElementalKernel")
117  .template condition<AttribSubdomains>(_subdomain)
118  .template condition<AttribThread>(_tid)
119  .template condition<AttribVectorTags>(_tags)
120  .queryInto(_fv_kernels);
121  }
122 }
123 
124 void
126 {
128  "We should not be called if we have no active HDG kernels");
129  for (const auto & hdg_kernel : _hdg_warehouse->getActiveBlockObjects(_subdomain, _tid))
130  {
131  mooseAssert(
132  hdg_kernel->hasBlocks(_subdomain),
133  "We queried the warehouse for active blocks on this subdomain, so this better be active");
134  mooseAssert(
136  "We should have set a valid neighbor subdomain ID if we made it in side this method");
137  if (hdg_kernel->hasBlocks(_neighbor_subdomain))
138  hdg_kernel->computeResidualOnSide();
139  }
140 }
void accumulateNeighborLower() override
Add neighbor and lower residual/Jacobian into assembly global data.
virtual void addResidualLower(const THREAD_ID tid) override
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< InterfaceKernelBase > * _ik_warehouse
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
MooseObjectTagWarehouse< IntegratedBCBase > & _integrated_bcs
Reference to BC storage structures.
unsigned int _num_cached
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...
MooseObjectTagWarehouse< HDGKernel > & _hdg_kernels
void join(const ComputeResidualThread &)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void accumulateLower() override
Add lower-d residual/Jacobian into assembly global data.
void accumulateNeighbor() override
Add neighbor residual/Jacobian into assembly global data.
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
virtual void compute(ResidualObject &ro) override
Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived clas...
MooseObjectWarehouse< HDGKernel > * _hdg_warehouse
TheWarehouse & theWarehouse() const
MooseObjectTagWarehouse< KernelBase > & _kernels
virtual void computeResidual()=0
Compute this object&#39;s contribution to the residual.
virtual void computeOnInternalFace() override
virtual void cacheResidual(const THREAD_ID tid) override
virtual void addResidualNeighbor(const THREAD_ID tid) override
void determineObjectWarehouses() override
Determine the objects we will actually compute based on vector/matrix tag information.
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1159
NonlinearSystemBase & _nl
void accumulate() override
Add element residual/Jacobian into assembly global data.
tbb::split split
MooseObjectWarehouse< IntegratedBCBase > * _ibc_warehouse
This is the common base class for objects that give residual contributions.
ComputeResidualThread(FEProblemBase &fe_problem, const std::set< TagID > &tags)
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
const std::set< TagID > & _tags
the tags denoting the vectors we want our residual objects to fill
MooseObjectTagWarehouse< InterfaceKernelBase > & _interface_kernels
Reference to interface kernel storage structure.
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:195
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
SubdomainID _subdomain
The subdomain for the current element.
MooseObjectWarehouse< KernelBase > * _tag_kernels
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse
std::vector< FVElementalKernel * > _fv_kernels
Current subdomain FVElementalKernels.
MooseObjectTagWarehouse< DGKernelBase > & _dg_kernels
Reference to DGKernel storage structure.
virtual void addCachedResidual(const THREAD_ID tid) override
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.