www.mooseframework.org
ComputeResidualThread.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 
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 "libmesh/threads.h"
18 
20  const std::set<TagID> & tags)
21  : NonlinearThread(fe_problem), _tags(tags)
22 {
23 }
24 
25 // Splitting Constructor
27  : NonlinearThread(x, split), _tags(x._tags)
28 {
29 }
30 
32 
33 void
35 {
36  ro.computeResidual();
37 }
38 
39 void
41 {
43 }
44 
45 void
47 {
49 }
50 
51 void
53 {
56 }
57 
58 void
60 {
62  _num_cached++;
63 
64  if (_num_cached % 20 == 0)
65  {
66  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
68  }
69 }
70 
71 void
73 {
74 }
75 
76 void
78 {
79  // If users pass a empty vector or a full size of vector,
80  // we take all kernels
82  {
87  }
88  // If we have one tag only,
89  // We call tag based storage
90  else if (_tags.size() == 1)
91  {
96  }
97  // This one may be expensive
98  else
99  {
104  }
105 
106  if (_fe_problem.haveFV())
107  {
108  _fv_kernels.clear();
110  .query()
111  .template condition<AttribSysNum>(_nl.number())
112  .template condition<AttribSystem>("FVElementalKernel")
113  .template condition<AttribSubdomains>(_subdomain)
114  .template condition<AttribThread>(_tid)
115  .template condition<AttribVectorTags>(_tags)
116  .queryInto(_fv_kernels);
117  }
118 }
void accumulateNeighborLower() override
Add neighbor and lower residual/Jacobian into assembly global data.
virtual void addResidualLower(const THREAD_ID tid) override
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...
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.
void compute(ResidualObject &ro) override
Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived clas...
TheWarehouse & theWarehouse() const
MooseObjectTagWarehouse< KernelBase > & _kernels
virtual void computeResidual()=0
Compute this object&#39;s contribution to the residual.
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:1132
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:173
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