https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeResidualAndJacobianThread.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#include "NonlinearSystem.h"
12#include "Problem.h"
13#include "FEProblem.h"
14#include "KernelBase.h"
15#include "IntegratedBCBase.h"
16#include "DGKernelBase.h"
17#include "InterfaceKernelBase.h"
18#include "Material.h"
19#include "TimeKernel.h"
20#include "SwapBackSentinel.h"
21#include "FVTimeKernel.h"
22#include "HDGKernel.h"
23
24#include "libmesh/threads.h"
25
27 FEProblemBase & fe_problem,
28 const std::set<TagID> & vector_tags,
29 const std::set<TagID> & matrix_tags)
30 : NonlinearThread(fe_problem), _vector_tags(vector_tags), _matrix_tags(matrix_tags)
31{
32}
33
34// Splitting Constructor
37 : NonlinearThread(x, split), _vector_tags(x._vector_tags), _matrix_tags(x._matrix_tags)
38{
39}
40
42
43void
48
49void
55
56void
63
64void
70
71void
84
85void
89
90void
92{
93 // We need to filter out vector tags that don't belong to the current nonlinear system
94 const auto & residual_vector_tags = _fe_problem.getVectorTags(Moose::VECTOR_TAG_RESIDUAL);
95
96 // We would only like to consider the tags that belong to the current system
97 std::set<TagID> filtered_residual_tags;
98 _fe_problem.selectVectorTagsFromSystem(_nl, residual_vector_tags, filtered_residual_tags);
99
100 if (_vector_tags.size() && _vector_tags.size() != filtered_residual_tags.size())
101 mooseError("Can only currently compute the residual and Jacobian together if we are computing "
102 "the full suite of residual tags");
103
104 if (_matrix_tags.size() && _matrix_tags.size() != _fe_problem.numMatrixTags())
105 mooseError("Can only currently compute the residual and Jacobian together if we are computing "
106 "the full suite of Jacobian tags");
107
113
114 if (_fe_problem.haveFV())
115 {
116 _fv_kernels.clear();
118 .query()
119 .template condition<AttribSysNum>(_nl.number())
120 .template condition<AttribSystem>("FVElementalKernel")
121 .template condition<AttribSubdomains>(_subdomain)
122 .template condition<AttribThread>(_tid)
124 }
125}
126
127void
129{
131 "We should not be called if we have no active HDG kernels");
132 for (const auto & hdg_kernel : _hdg_warehouse->getActiveBlockObjects(_subdomain, _tid))
133 hdg_kernel->computeResidualAndJacobianOnSide();
134}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void join(const ComputeResidualAndJacobianThread &)
void compute(ResidualObject &ro) override
Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived clas...
const std::set< TagID > & _vector_tags
the tags denoting the vectors we want our residual objects to fill
void accumulateNeighborLower() override
Add neighbor and lower residual/Jacobian into assembly global data.
void accumulateNeighbor() override
Add neighbor residual/Jacobian into assembly global data.
void accumulateLower() override
Add lower-d residual/Jacobian into assembly global data.
const std::set< TagID > & _matrix_tags
the tags denoting the matrices we want our residual objects to fill
void accumulate() override
Add element residual/Jacobian into assembly global data.
ComputeResidualAndJacobianThread(FEProblemBase &fe_problem, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
void determineObjectWarehouses() override
Determine the objects we will actually compute based on vector/matrix tag information.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void addJacobianLowerD(const THREAD_ID tid) override
virtual void cacheResidual(const THREAD_ID tid) override
virtual void addJacobianNeighbor(const THREAD_ID tid) override
virtual void addResidualLower(const THREAD_ID tid) override
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
virtual void addCachedResidual(const THREAD_ID tid) override
virtual void addResidualNeighbor(const THREAD_ID tid) override
virtual void addCachedJacobian(const THREAD_ID tid) override
virtual void cacheJacobian(const THREAD_ID tid) override
virtual void addJacobianNeighborLowerD(const THREAD_ID tid) override
TheWarehouse & theWarehouse() const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
bool hasActiveBlockObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< HDGKernel > & _hdg_kernels
MooseObjectTagWarehouse< KernelBase > & _kernels
MooseObjectTagWarehouse< IntegratedBCBase > & _integrated_bcs
Reference to BC storage structures.
MooseObjectWarehouse< InterfaceKernelBase > * _ik_warehouse
MooseObjectTagWarehouse< DGKernelBase > & _dg_kernels
Reference to DGKernel storage structure.
unsigned int _num_cached
std::vector< FVElementalKernel * > _fv_kernels
Current subdomain FVElementalKernels.
NonlinearSystemBase & _nl
Reference to the underlying NonlinearSystemBase.
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse
MooseObjectWarehouse< HDGKernel > * _hdg_warehouse
MooseObjectWarehouse< KernelBase > * _tag_kernels
MooseObjectTagWarehouse< InterfaceKernelBase > & _interface_kernels
Reference to interface kernel storage structure.
MooseObjectWarehouse< IntegratedBCBase > * _ibc_warehouse
This is the common base class for objects that give residual contributions.
virtual void computeResidualAndJacobian()
Compute this object's contribution to the residual and Jacobian simultaneously.
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition SubProblem.C:173
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition SubProblem.h:248
static void selectVectorTagsFromSystem(const SystemBase &system, const std::vector< VectorTag > &input_vector_tags, std::set< TagID > &selected_tags)
Select the vector tags which belong to a specific system.
Definition SubProblem.C:290
unsigned int number() const
Gets the number of this system.
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.
SubdomainID _subdomain
The subdomain for the current element.
@ VECTOR_TAG_RESIDUAL