https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ComputeJacobianBlocksThread Class Reference

Specialization for filling multiple "small" preconditioning matrices simulatenously. More...

#include <ComputeJacobianBlocksThread.h>

Inheritance diagram for ComputeJacobianBlocksThread:
[legend]

Public Member Functions

 ComputeJacobianBlocksThread (FEProblemBase &fe_problem, std::vector< JacobianBlock * > &blocks, const std::set< TagID > &tags)
 
 ComputeJacobianBlocksThread (ComputeJacobianBlocksThread &x, Threads::split split)
 
virtual ~ComputeJacobianBlocksThread ()
 
void join (const ComputeJacobianThread &)
 
virtual void operator() (const ConstElemRange &range, bool bypass_threading=false) override
 
virtual void operator() (const RangeType &range, bool bypass_threading=false)
 
virtual void subdomainChanged () override
 Called every time the current subdomain changes (i.e.
 
virtual void onElement (const Elem *elem) override
 Assembly of the element (not including surface assembly)
 
virtual void onBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
 Called when doing boundary assembling.
 
virtual void onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id) override
 Called when doing interface assembling.
 
virtual void onInternalSide (const Elem *elem, unsigned int side) override
 Called when doing internal edge assembling.
 
virtual void onExternalSide (const Elem *elem, unsigned int side) override
 Called when iterating over external sides (no side neighbor)
 
virtual void post () override
 Called after the element range loop.
 
bool shouldComputeInternalSide (const Elem &elem, const Elem &neighbor) const override
 Whether to compute the internal side for the provided element-neighbor pair.
 
virtual void caughtMooseException (MooseException &e) override
 Called if a MooseException is caught anywhere during the computation.
 
virtual bool keepGoing () override
 Whether or not the loop should continue.
 
virtual void preElement (const Elem *elem) override
 Called before the element assembly.
 
virtual void preInternalSide (const Elem *elem, unsigned int side) override
 Called before evaluations on an element internal side.
 
virtual void preBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
 Called before the boundary assembly.
 
virtual void neighborSubdomainChanged () override
 Called every time the neighbor subdomain changes (i.e.
 
virtual void pre ()
 Called before the element range loop.
 

Protected Member Functions

virtual void postElement (const Elem *elem) override
 Called after the element assembly is done (including surface assembling)
 
virtual void postInternalSide (const Elem *elem, unsigned int side) override
 Called after evaluations on an element internal side.
 
virtual void computeOnElement () override
 
virtual void computeOnBoundary (BoundaryID bnd_id, const Elem *lower_d_elem) override
 
virtual void computeOnInternalFace (const Elem *neighbor) override
 
virtual void computeOnInternalFace () override
 
virtual void computeOnInterface (BoundaryID bnd_id) override
 
void determineObjectWarehouses () override
 Determine the objects we will actually compute based on vector/matrix tag information.
 
void accumulateNeighbor () override
 Add neighbor residual/Jacobian into assembly global data.
 
virtual void accumulateNeighborLower () override
 Add neighbor and lower residual/Jacobian into assembly global data.
 
virtual void accumulateLower () override
 Add lower-d residual/Jacobian into assembly global data.
 
virtual void accumulate () override
 Add element residual/Jacobian into assembly global data.
 
virtual void compute (ResidualObject &) override
 Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived class.
 
void compute (KernelBase &kernel) override
 
void compute (FVElementalKernel &kernel) override
 
void compute (IntegratedBCBase &bc) override
 
void compute (DGKernelBase &dg, const Elem *neighbor) override
 
void compute (InterfaceKernelBase &ik) override
 
std::string objectType () const override
 Return what the loops is meant to compute.
 
void prepareFace (const Elem *elem, unsigned int side, BoundaryID bnd_id=Moose::INVALID_BOUNDARY_ID, const Elem *lower_d_elem=nullptr)
 Reinitialize variables and materials on a face.
 
void onInterfaceWithHRefinementMismatch (const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *fine_neighbor)
 Compute and accumulate the interface kernel contribution from a single active fine neighbor when elem's own neighbor_ptr(side) is an inactive ancestor, i.e.
 
void printGeneralExecutionInformation () const override
 Print information about the loop, mostly order of execution of objects.
 
void printBlockExecutionInformation () const override
 Print list of specific objects executed on each block and in which order.
 
void printBoundaryExecutionInformation (const unsigned int bid) const override
 Print list of specific objects executed on each boundary and in which order.
 
void prepareElement (const Elem *elem)
 
void clearVarsAndMaterials ()
 
void getRequiredBoundaryMaterials (const std::vector< const MaterialPropertyInterface * > &material_consumers, BoundaryID bnd_id, SubdomainID subdomain_id, std::deque< MaterialBase * > &required_face_materials, std::deque< MaterialBase * > &required_boundary_materials) const
 Determine the face and boundary materials required by material property consumers.
 
void printExecutionOrdering (const std::vector< T * > &objs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 Routine to output the ordering of objects within a vector of pointers to these objects.
 
void printExecutionOrdering (const std::vector< std::shared_ptr< T > > &objs_ptrs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 
void resetExecPrintedSets () const
 Resets the set of blocks and boundaries visited.
 

Protected Attributes

std::vector< JacobianBlock * > _blocks
 
const std::set< TagID > & _tags
 
NonlinearSystemBase & _nl
 Reference to the underlying NonlinearSystemBase.
 
unsigned int _num_cached
 
MooseObjectTagWarehouse< IntegratedBCBase > & _integrated_bcs
 Reference to BC storage structures.
 
MooseObjectWarehouse< IntegratedBCBase > * _ibc_warehouse
 
MooseObjectTagWarehouse< DGKernelBase > & _dg_kernels
 Reference to DGKernel storage structure.
 
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse
 
MooseObjectTagWarehouse< InterfaceKernelBase > & _interface_kernels
 Reference to interface kernel storage structure.
 
MooseObjectWarehouse< InterfaceKernelBase > * _ik_warehouse
 
std::vector< FVElementalKernel * > _fv_kernels
 Current subdomain FVElementalKernels.
 
const bool _has_active_objects
 Whether there are any active residual objects; otherwise we will do an early return.
 
FEProblemBase & _fe_problem
 
MooseMesh & _mesh
 
THREAD_ID _tid
 
SubdomainID _subdomain
 The subdomain for the current element.
 
SubdomainID _old_subdomain
 The subdomain for the last element.
 
SubdomainID _neighbor_subdomain
 The subdomain for the current neighbor.
 
SubdomainID _old_neighbor_subdomain
 The subdomain for the last neighbor.
 
std::set< SubdomainID > _blocks_exec_printed
 Keep track of which blocks were visited.
 
std::set< BoundaryID > _boundaries_exec_printed
 Keep track of which boundaries were visited.
 
MooseObjectTagWarehouse< KernelBase > & _kernels
 
MooseObjectWarehouse< KernelBase > * _tag_kernels
 
MooseObjectTagWarehouse< HDGKernel > & _hdg_kernels
 
MooseObjectWarehouse< HDGKernel > * _hdg_warehouse
 

Private Attributes

std::vector< dof_id_type > _dof_indices
 
std::vector< dof_id_type > _dof_neighbor_indices
 
bool _should_execute_dg
 Whether DG kernels should be executed for a given elem-neighbor pairing.
 
bool _subdomain_has_dg
 Whether the subdomain has DGKernels.
 
bool _subdomain_has_hdg
 Whether the subdomain has HDGKernels.
 
libMesh::ElemSideBuilder _elem_side_builder
 Builds (and caches) the side element for elem/side pairs in onInterfaceWithHRefinementMismatch.
 

Detailed Description

Specialization for filling multiple "small" preconditioning matrices simulatenously.

Definition at line 39 of file ComputeJacobianBlocksThread.h.

Constructor & Destructor Documentation

◆ ComputeJacobianBlocksThread() [1/2]

ComputeJacobianBlocksThread::ComputeJacobianBlocksThread ( FEProblemBase &  fe_problem,
std::vector< JacobianBlock * > &  blocks,
const std::set< TagID > &  tags 
)

Definition at line 21 of file ComputeJacobianBlocksThread.C.

24 : ComputeFullJacobianThread(fe_problem, tags), _blocks(blocks)
25{
26}
char ** blocks
std::vector< JacobianBlock * > _blocks

◆ ComputeJacobianBlocksThread() [2/2]

ComputeJacobianBlocksThread::ComputeJacobianBlocksThread ( ComputeJacobianBlocksThread &  x,
Threads::split  split 
)

Definition at line 29 of file ComputeJacobianBlocksThread.C.

32{
33}

◆ ~ComputeJacobianBlocksThread()

ComputeJacobianBlocksThread::~ComputeJacobianBlocksThread ( )
virtual

Definition at line 35 of file ComputeJacobianBlocksThread.C.

35{}

Member Function Documentation

◆ accumulate()

virtual void ComputeJacobianThread::accumulate ( )
inlineoverrideprotectedvirtualinherited

Add element residual/Jacobian into assembly global data.

Implements NonlinearThread.

Definition at line 47 of file ComputeJacobianThread.h.

47{}

◆ accumulateLower()

void ComputeJacobianThread::accumulateLower ( )
overrideprotectedvirtualinherited

Add lower-d residual/Jacobian into assembly global data.

Implements NonlinearThread.

Definition at line 134 of file ComputeJacobianThread.C.

135{
137}
virtual void addJacobianLowerD(const THREAD_ID tid) override

◆ accumulateNeighbor()

void ComputeJacobianThread::accumulateNeighbor ( )
overrideprotectedvirtualinherited

Add neighbor residual/Jacobian into assembly global data.

Implements NonlinearThread.

Definition at line 146 of file ComputeJacobianThread.C.

147{
149}
virtual void addJacobianNeighbor(const THREAD_ID tid) override

◆ accumulateNeighborLower()

void ComputeJacobianThread::accumulateNeighborLower ( )
overrideprotectedvirtualinherited

Add neighbor and lower residual/Jacobian into assembly global data.

Implements NonlinearThread.

Definition at line 140 of file ComputeJacobianThread.C.

141{
143}
virtual void addJacobianNeighborLowerD(const THREAD_ID tid) override

◆ caughtMooseException()

void ThreadedElementLoop< ConstElemRange >::caughtMooseException ( MooseException &  e)
overridevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 44 of file ThreadedElementLoop.h.

113{
114 Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
115
116 std::string what(e.what());
118}
static Threads::spin_mutex threaded_element_mutex
This mutex is used by all derived classes of the ThreadedElementLoop.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
virtual const char * what() const
Get out the error message.

◆ clearVarsAndMaterials()

void ThreadedElementLoop< ConstElemRange >::clearVarsAndMaterials ( )
protectedinherited

Definition at line 61 of file ThreadedElementLoop.h.

203{
206}
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.

◆ compute() [1/6]

void ComputeJacobianThread::compute ( DGKernelBase &  dg,
const Elem *  neighbor 
)
overrideprotectedvirtualinherited

Reimplemented from NonlinearThread.

Definition at line 77 of file ComputeJacobianThread.C.

78{
79 if (dg.isImplicit())
80 {
81 dg.prepareShapes(dg.variable().number());
83 if (dg.hasBlocks(neighbor->subdomain_id()))
84 dg.computeJacobian();
85 }
86}
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
virtual void computeJacobian() override
Computes the jacobian for the current side.
void prepareShapes(unsigned int var_num) override final
Prepare shape functions.
unsigned int number() const
Get variable number coming from libMesh.
void prepareNeighborShapes(unsigned int var_num)
Prepare neighbor shape functions.
virtual const MooseVariableBase & variable() const =0
Returns the variable that this object operates on.

◆ compute() [2/6]

void ComputeJacobianThread::compute ( FVElementalKernel &  kernel)
overrideprotectedvirtualinherited

Reimplemented from NonlinearThread.

Definition at line 56 of file ComputeJacobianThread.C.

57{
58 if (fvkernel.isImplicit())
59 fvkernel.computeJacobian();
60}

◆ compute() [3/6]

void ComputeJacobianThread::compute ( IntegratedBCBase &  bc)
overrideprotectedvirtualinherited

Reimplemented from NonlinearThread.

Definition at line 63 of file ComputeJacobianThread.C.

64{
65 if (bc.shouldApply() && bc.isImplicit())
66 {
67 bc.prepareShapes(bc.variable().number());
68 bc.computeJacobian();
70 mooseError("Nonlocal boundary conditions only supported for non-diagonal coupling. Please "
71 "specify an SMP preconditioner, with appropriate row-column coupling or specify "
72 "full = true.");
73 }
74}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we're computing the scaling jacobian.
virtual bool checkNonlocalCouplingRequirement() const override
void prepareShapes(unsigned int var_num) override final
Prepare shape functions.
virtual bool shouldApply() const override
Hook for turning the boundary condition on and off.
virtual void computeJacobian()=0
Compute this object's contribution to the diagonal Jacobian entries.

◆ compute() [4/6]

void ComputeJacobianThread::compute ( InterfaceKernelBase &  ik)
overrideprotectedvirtualinherited

Reimplemented from NonlinearThread.

Definition at line 89 of file ComputeJacobianThread.C.

90{
91 if (intk.isImplicit())
92 {
93 intk.prepareShapes(intk.variable().number());
94 intk.prepareNeighborShapes(intk.neighborVariable().number());
95 intk.computeJacobian();
96 }
97}

◆ compute() [5/6]

void ComputeJacobianThread::compute ( KernelBase &  kernel)
overrideprotectedvirtualinherited

Defaults to forwarding to the residual object class

Reimplemented from NonlinearThread.

Definition at line 43 of file ComputeJacobianThread.C.

44{
45 if (kernel.isImplicit())
46 {
47 kernel.prepareShapes(kernel.variable().number());
48 kernel.computeJacobian();
50 mooseError("Nonlocal kernels only supported for non-diagonal coupling. Please specify an SMP "
51 "preconditioner, with appropriate row-column coupling or specify full = true.");
52 }
53}
virtual void prepareShapes(unsigned int var_num)
Prepare shape functions.

◆ compute() [6/6]

virtual void ComputeJacobianThread::compute ( ResidualObject &  ro)
inlineoverrideprotectedvirtualinherited

Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived class.

Implements NonlinearThread.

Definition at line 49 of file ComputeJacobianThread.h.

49{ mooseError("Not implemented"); };

◆ computeOnBoundary()

void ComputeFullJacobianThread::computeOnBoundary ( BoundaryID  bnd_id,
const Elem *  lower_d_elem 
)
overrideprotectedvirtualinherited

done only when nonlocal integrated_bcs exist in the system

Reimplemented from NonlinearThread.

Definition at line 140 of file ComputeFullJacobianThread.C.

141{
142 auto & ce = _fe_problem.couplingEntries(_tid, _nl.number());
143 for (const auto & it : ce)
144 {
145 MooseVariableFieldBase & ivariable = *(it.first);
146 MooseVariableFieldBase & jvariable = *(it.second);
147
148 // We don't currently support coupling with FV variables
149 if (ivariable.isFV() || jvariable.isFV())
150 continue;
151
152 const auto ivar = ivariable.number();
153 const auto jvar = jvariable.number();
154
155 if (!ivariable.activeOnSubdomain(_subdomain))
156 continue;
157
158 // only if there are dofs for j-variable (if it is subdomain restricted var, there may not be
159 // any)
160 if (lower_d_elem)
161 {
162 auto lower_d_subdomain = lower_d_elem->subdomain_id();
163 if (!jvariable.activeOnSubdomain(_subdomain) &&
164 !jvariable.activeOnSubdomain(lower_d_subdomain))
165 continue;
166 }
167 else
168 {
169 if (!jvariable.activeOnSubdomain(_subdomain))
170 continue;
171 }
172
174 continue;
175
176 const auto & bcs = _ibc_warehouse->getActiveBoundaryObjects(bnd_id, _tid);
177 for (const auto & bc : bcs)
178 if (bc->shouldApply() && bc->variable().number() == ivar && bc->isImplicit())
179 {
180 bc->prepareShapes(jvar);
181 bc->computeOffDiagJacobian(jvar);
182 }
183 }
184
187 {
189 for (const auto & it : cne)
190 {
191 MooseVariableFieldBase & ivariable = *(it.first);
192 MooseVariableFieldBase & jvariable = *(it.second);
193
194 if (ivariable.isFV())
195 continue;
196
197 unsigned int ivar = ivariable.number();
198 unsigned int jvar = jvariable.number();
199
200 if (ivariable.activeOnSubdomain(_subdomain) && jvariable.activeOnSubdomain(_subdomain) &&
202 {
203 const std::vector<std::shared_ptr<IntegratedBCBase>> & integrated_bcs =
205 for (const auto & integrated_bc : integrated_bcs)
206 {
207 std::shared_ptr<NonlocalIntegratedBC> nonlocal_integrated_bc =
208 std::dynamic_pointer_cast<NonlocalIntegratedBC>(integrated_bc);
209 if (nonlocal_integrated_bc)
210 if ((integrated_bc->variable().number() == ivar) && integrated_bc->isImplicit())
211 {
212 integrated_bc->prepareShapes(jvar);
213 integrated_bc->computeNonlocalOffDiagJacobian(jvar);
214 }
215 }
216 }
217 }
218 }
219
220 const std::vector<MooseVariableScalar *> & scalar_vars = _nl.getScalarVariables(_tid);
221 if (scalar_vars.size() > 0)
222 {
223 // go over nl-variables (non-scalar)
224 const std::vector<MooseVariableFieldBase *> & vars = _nl.getVariables(_tid);
225 for (const auto & ivar : vars)
226 if (ivar->activeOnSubdomain(_subdomain) > 0 &&
227 _ibc_warehouse->hasActiveBoundaryObjects(bnd_id, _tid))
228 {
229 // for each variable get the list of active kernels
230 const auto & bcs = _ibc_warehouse->getActiveBoundaryObjects(bnd_id, _tid);
231 for (const auto & bc : bcs)
232 if (bc->variable().number() == ivar->number() && bc->isImplicit())
233 {
234 // now, get the list of coupled scalar vars and compute their off-diag jacobians
235 const std::vector<MooseVariableScalar *> coupled_scalar_vars =
236 bc->getCoupledMooseScalarVars();
237
238 // Do: dvar / dscalar_var, only want to process only nl-variables (not aux ones), and
239 // only if this coupling is being used by the preconditioner (otherwise the value is
240 // zero)
241 for (const auto & jvar : coupled_scalar_vars)
242 if (_nl.hasScalarVariable(jvar->name()) &&
243 _fe_problem.areCoupled(ivar->number(), jvar->number(), _nl.number()))
244 bc->computeOffDiagJacobianScalar(jvar->number());
245 }
246 }
247 }
248}
char ** vars
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableFieldBase * > > & nonlocalCouplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableFieldBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getBoundaryObjects(THREAD_ID tid=0) const
bool activeOnSubdomain(SubdomainID subdomain) const
Is the variable active on the subdomain?
This class provides an interface for common operations on field variables of both FE and FV types wit...
NonlinearSystemBase & _nl
Reference to the underlying NonlinearSystemBase.
MooseObjectWarehouse< IntegratedBCBase > * _ibc_warehouse
unsigned int number() const
Gets the number of this system.
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition SystemBase.h:782
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition SystemBase.h:789
SubdomainID _subdomain
The subdomain for the current element.
std::string name(const ElemQuality q)

◆ computeOnElement()

void ComputeFullJacobianThread::computeOnElement ( )
overrideprotectedvirtualinherited

Base class version just calls compute on each object for the element

done only when nonlocal kernels exist in the system

Reimplemented from NonlinearThread.

Reimplemented in ComputeJacobianForScalingThread.

Definition at line 41 of file ComputeFullJacobianThread.C.

42{
44 for (const auto & it : ce)
45 {
46 MooseVariableFieldBase & ivariable = *(it.first);
47 MooseVariableFieldBase & jvariable = *(it.second);
48
49 if (ivariable.isFV())
50 continue;
51
52 unsigned int ivar = ivariable.number();
53 unsigned int jvar = jvariable.number();
54
55 if (ivariable.activeOnSubdomain(_subdomain) && jvariable.activeOnSubdomain(_subdomain) &&
57 {
58 // only if there are dofs for j-variable (if it is subdomain restricted var, there may not be
59 // any)
60 const auto & kernels = _tag_kernels->getActiveVariableBlockObjects(ivar, _subdomain, _tid);
61 for (const auto & kernel : kernels)
62 if ((kernel->variable().number() == ivar) && kernel->isImplicit())
63 {
64 kernel->prepareShapes(jvar);
65 kernel->computeOffDiagJacobian(jvar);
66 }
67 }
68 }
69
72 {
74 for (const auto & it : cne)
75 {
76 MooseVariableFieldBase & ivariable = *(it.first);
77 MooseVariableFieldBase & jvariable = *(it.second);
78
79 if (ivariable.isFV())
80 continue;
81
82 unsigned int ivar = ivariable.number();
83 unsigned int jvar = jvariable.number();
84
85 if (ivariable.activeOnSubdomain(_subdomain) && jvariable.activeOnSubdomain(_subdomain) &&
87 {
88 const auto & kernels = _tag_kernels->getActiveVariableBlockObjects(ivar, _subdomain, _tid);
89 for (const auto & kernel : kernels)
90 {
91 std::shared_ptr<NonlocalKernel> nonlocal_kernel =
92 std::dynamic_pointer_cast<NonlocalKernel>(kernel);
93 if (nonlocal_kernel)
94 if ((kernel->variable().number() == ivar) && kernel->isImplicit())
95 {
96 kernel->prepareShapes(jvar);
97 kernel->computeNonlocalOffDiagJacobian(jvar);
98 }
99 }
100 }
101 }
102 }
103
104 const std::vector<MooseVariableScalar *> & scalar_vars = _nl.getScalarVariables(_tid);
105 if (scalar_vars.size() > 0)
106 {
107 // go over nl-variables (non-scalar)
108 const std::vector<MooseVariableFieldBase *> & vars = _nl.getVariables(_tid);
109 for (const auto & ivariable : vars)
110 if (ivariable->activeOnSubdomain(_subdomain) > 0 &&
111 _tag_kernels->hasActiveVariableBlockObjects(ivariable->number(), _subdomain, _tid))
112 {
113 // for each variable get the list of active kernels
114 const auto & kernels =
116 for (const auto & kernel : kernels)
117 if (kernel->isImplicit())
118 {
119 // now, get the list of coupled scalar vars and compute their off-diag jacobians
120 const auto & coupled_scalar_vars = kernel->getCoupledMooseScalarVars();
121
122 // Do: dvar / dscalar_var, only want to process only nl-variables (not aux ones), and
123 // only if this coupling is being used by the preconditioner (otherwise the value is
124 // zero)
125 for (const auto & jvariable : coupled_scalar_vars)
126 if (_nl.hasScalarVariable(jvariable->name()) &&
127 _fe_problem.areCoupled(ivariable->number(), jvariable->number(), _nl.number()))
128 kernel->computeOffDiagJacobianScalar(jvariable->number());
129 }
130 }
131 }
132
133 if (_fe_problem.haveFV())
134 for (auto fv_kernel : _fv_kernels)
135 if (fv_kernel->isImplicit())
136 fv_kernel->computeOffDiagJacobian();
137}
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
bool hasActiveVariableBlockObjects(unsigned int variable_id, SubdomainID block_id, THREAD_ID tid=0) const
Methods for checking/getting variable kernels for a variable and SubdomainID.
const std::vector< std::shared_ptr< T > > & getActiveVariableBlockObjects(unsigned int variable_id, SubdomainID block_id, THREAD_ID tid=0) const
std::vector< FVElementalKernel * > _fv_kernels
Current subdomain FVElementalKernels.
MooseObjectWarehouse< KernelBase > * _tag_kernels

Referenced by ComputeJacobianForScalingThread::computeOnElement().

◆ computeOnInterface()

void ComputeFullJacobianThread::computeOnInterface ( BoundaryID  bnd_id)
overrideprotectedvirtualinherited

Reimplemented from NonlinearThread.

Definition at line 251 of file ComputeFullJacobianThread.C.

252{
254 {
255 const auto & ce = _fe_problem.couplingEntries(_tid, _nl.number());
256 for (const auto & it : ce)
257 {
258 MooseVariableFieldBase & ivariable = *(it.first);
259 MooseVariableFieldBase & jvariable = *(it.second);
260
261 if (ivariable.isFV())
262 continue;
263
264 unsigned int ivar = ivariable.number();
265 unsigned int jvar = jvariable.number();
266
267 const auto & int_ks = _ik_warehouse->getActiveBoundaryObjects(bnd_id, _tid);
268 for (const auto & interface_kernel : int_ks)
269 {
270 if (!interface_kernel->isImplicit())
271 continue;
272
273 interface_kernel->prepareShapes(jvar);
274 interface_kernel->prepareNeighborShapes(jvar);
275
276 if (interface_kernel->variable().number() == ivar)
277 interface_kernel->computeElementOffDiagJacobian(jvar);
278
279 if (interface_kernel->neighborVariable().number() == ivar)
280 interface_kernel->computeNeighborOffDiagJacobian(jvar);
281 }
282 }
283 }
284}
MooseObjectWarehouse< InterfaceKernelBase > * _ik_warehouse

◆ computeOnInternalFace() [1/2]

void ComputeFullJacobianThread::computeOnInternalFace ( )
overrideprotectedvirtualinherited

Reimplemented from ComputeJacobianThread.

Definition at line 322 of file ComputeFullJacobianThread.C.

323{
325 "We should not be called if we have no active HDG kernels");
326 for (const auto & hdg_kernel : _hdg_warehouse->getActiveBlockObjects(_subdomain, _tid))
327 {
328 mooseAssert(
329 hdg_kernel->hasBlocks(_subdomain),
330 "We queried the warehouse for active blocks on this subdomain, so this better be active");
331 mooseAssert(
333 "We should have set a valid neighbor subdomain ID if we made it in side this method");
334 if (hdg_kernel->hasBlocks(_neighbor_subdomain))
335 hdg_kernel->computeJacobianOnSide();
336 }
337}
bool hasActiveBlockObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< HDGKernel > * _hdg_warehouse
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20

◆ computeOnInternalFace() [2/2]

void ComputeFullJacobianThread::computeOnInternalFace ( const Elem *  neighbor)
overrideprotectedvirtualinherited

Reimplemented from NonlinearThread.

Definition at line 287 of file ComputeFullJacobianThread.C.

288{
290 {
291 const auto & ce = _fe_problem.couplingEntries(_tid, _nl.number());
292 for (const auto & it : ce)
293 {
294 MooseVariableFieldBase & ivariable = *(it.first);
295 MooseVariableFieldBase & jvariable = *(it.second);
296
297 if (ivariable.isFV())
298 continue;
299
300 unsigned int ivar = ivariable.number();
301 unsigned int jvar = jvariable.number();
302
303 const auto & dgks = _dg_warehouse->getActiveBlockObjects(_subdomain, _tid);
304 for (const auto & dg : dgks)
305 {
306 // this check may skip some couplings...
307 if (dg->variable().number() == ivar && dg->isImplicit() &&
308 dg->hasBlocks(neighbor->subdomain_id()) &&
309 (jvariable.activeOnSubdomain(_subdomain) ||
311 {
312 dg->prepareShapes(jvar);
313 dg->prepareNeighborShapes(jvar);
314 dg->computeOffDiagJacobian(jvar);
315 }
316 }
317 }
318 }
319}
virtual MooseMesh & mesh() override
const std::set< SubdomainID > & interiorLowerDBlocks() const
Definition MooseMesh.h:1550
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
bool activeOnSubdomains(const std::set< SubdomainID > &subdomains) const
Is the variable active on the subdomains?
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse

◆ determineObjectWarehouses()

void ComputeJacobianThread::determineObjectWarehouses ( )
overrideprotectedvirtualinherited

Determine the objects we will actually compute based on vector/matrix tag information.

Implements NonlinearThread.

Definition at line 100 of file ComputeJacobianThread.C.

101{
102 // If users pass a empty vector or a full size of vector,
103 // we take all kernels
104 if (!_tags.size() || _tags.size() == _fe_problem.numMatrixTags())
105 {
111 }
112 // If we have one tag only,
113 // We call tag based storage
114 else if (_tags.size() == 1)
115 {
121 }
122 // This one may be expensive, and hopefully we do not use it so often
123 else
124 {
130 }
131}
const std::set< TagID > & _tags
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.
MooseObjectTagWarehouse< HDGKernel > & _hdg_kernels
MooseObjectTagWarehouse< KernelBase > & _kernels
MooseObjectTagWarehouse< IntegratedBCBase > & _integrated_bcs
Reference to BC storage structures.
MooseObjectTagWarehouse< DGKernelBase > & _dg_kernels
Reference to DGKernel storage structure.
MooseObjectTagWarehouse< InterfaceKernelBase > & _interface_kernels
Reference to interface kernel storage structure.
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition SubProblem.h:251

◆ getRequiredBoundaryMaterials()

void ThreadedElementLoop< ConstElemRange >::getRequiredBoundaryMaterials ( const std::vector< const MaterialPropertyInterface * > &  material_consumers,
BoundaryID  bnd_id,
SubdomainID  subdomain_id,
std::deque< MaterialBase * > &  required_face_materials,
std::deque< MaterialBase * > &  required_boundary_materials 
) const
protectedinherited

Determine the face and boundary materials required by material property consumers.

Definition at line 63 of file ThreadedElementLoop.h.

216{
217 required_face_materials.clear();
218 required_boundary_materials.clear();
219
220 std::unordered_set<unsigned int> needed_face_props;
221 for (const auto * const consumer : material_consumers)
222 {
223 const auto & dependencies = consumer->getMatPropDependencies();
224 needed_face_props.insert(dependencies.begin(), dependencies.end());
225 }
226
227 const auto & materials = _fe_problem.getRegularMaterialsWarehouse();
228 // Resolve boundary materials first. A boundary material can depend on a property supplied by a
229 // face material, while a property supplied by the boundary-material chain does not also need a
230 // face producer.
231 if (!material_consumers.empty() && materials.hasActiveBoundaryObjects(bnd_id, this->_tid))
232 required_boundary_materials = MaterialBase::buildRequiredMaterials(
233 material_consumers, materials.getActiveBoundaryObjects(bnd_id, this->_tid), true);
234 for (const auto * const material : required_boundary_materials)
235 {
236 const auto & dependencies = material->getMatPropDependencies();
237 needed_face_props.insert(dependencies.begin(), dependencies.end());
238 }
239 // The boundary-material chain has already satisfied these properties. Removing them prevents a
240 // face material that happens to declare the same property from being selected unnecessarily.
241 for (const auto * const material : required_boundary_materials)
242 for (const auto supplied_prop : material->getSuppliedPropIDs())
243 needed_face_props.erase(supplied_prop);
244
245 struct MaterialDependencyConsumer
246 {
247 const std::unordered_set<unsigned int> & dependencies;
248 const std::unordered_set<unsigned int> & getMatPropDependencies() const { return dependencies; }
249 };
250 if (!needed_face_props.empty())
251 {
252 const auto & face_materials = materials[Moose::FACE_MATERIAL_DATA];
253 if (face_materials.hasActiveBlockObjects(subdomain_id, this->_tid))
254 {
255 const MaterialDependencyConsumer face_consumer{needed_face_props};
256 const std::vector<const MaterialDependencyConsumer *> face_consumers{&face_consumer};
257 required_face_materials = MaterialBase::buildRequiredMaterials(
258 face_consumers, face_materials.getActiveBlockObjects(subdomain_id, this->_tid), true);
259 }
260 }
261}
for(PetscInt i=0;i< nvars;++i)
const MaterialWarehouse & getRegularMaterialsWarehouse() const
static std::deque< MaterialBase * > buildRequiredMaterials(const Consumers &mat_consumers, const std::vector< std::shared_ptr< MaterialBase > > &mats, const bool allow_stateful)
Build the materials required by a set of consumer objects.
@ FACE_MATERIAL_DATA
Definition MooseTypes.h:749

◆ join()

void ComputeJacobianBlocksThread::join ( const ComputeJacobianThread &  )
inline

Definition at line 51 of file ComputeJacobianBlocksThread.h.

51{}

◆ keepGoing()

virtual bool ThreadedElementLoop< ConstElemRange >::keepGoing ( )
inlineoverridevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 46 of file ThreadedElementLoop.h.

46{ return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.

◆ neighborSubdomainChanged()

void ThreadedElementLoop< ConstElemRange >::neighborSubdomainChanged ( )
overridevirtualinherited

Called every time the neighbor subdomain changes (i.e.

the subdomain of this neighbor is not the same as the subdomain of the last neighbor). Beware of over-using this! You might think that you can do some expensive stuff in here and get away with it... but there are applications that have TONS of subdomains....

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 57 of file ThreadedElementLoop.h.

147{
150}
virtual void neighborSubdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
Base class for assembly-like calculations.

◆ objectType()

std::string ComputeJacobianThread::objectType ( ) const
inlineoverrideprotectedvirtualinherited

Return what the loops is meant to compute.

Reimplemented from NonlinearThread.

Definition at line 58 of file ComputeJacobianThread.h.

58{ return "Jacobian"; }

◆ onBoundary()

void NonlinearThread::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  lower_d_elem = nullptr 
)
overridevirtualinherited

Called when doing boundary assembling.

Parameters
elem- The element we are checking is on the boundary.
side- The side of the element in question.
bnd_id- ID of the boundary we are at
lower_d_elem- Lower dimensional element (e.g. Mortar)

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 164 of file NonlinearThread.C.

168{
170 {
171 // Set up Sentinel class so that, after we swap in reinitMaterialsFace in prepareFace, even if
172 // one of our callees throws we remember to swap back during stack unwinding. We put our
173 // sentinel here as opposed to in prepareFace because we certainly don't want our materials
174 // swapped back before we proceed to residual/Jacobian computation
176
177 prepareFace(elem, side, bnd_id, lower_d_elem);
178 computeOnBoundary(bnd_id, lower_d_elem);
179
180 if (lower_d_elem)
182 }
183}
virtual void swapBackMaterialsFace(const THREAD_ID tid)
void prepareFace(const Elem *elem, unsigned int side, BoundaryID bnd_id=Moose::INVALID_BOUNDARY_ID, const Elem *lower_d_elem=nullptr)
Reinitialize variables and materials on a face.
virtual void computeOnBoundary(BoundaryID bnd_id, const Elem *lower_d_elem)
virtual void accumulateLower()=0
Add lower-d residual/Jacobian into assembly global data.
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,...

◆ onElement()

void NonlinearThread::onElement ( const Elem *  elem)
overridevirtualinherited

Assembly of the element (not including surface assembly)

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 133 of file NonlinearThread.C.

134{
135 // Set up Sentinel class so that, even if reinitMaterials() throws in prepareElement, we
136 // still remember to swap back during stack unwinding.
138
139 prepareElement(elem);
140
141 if (dynamic_cast<ComputeJacobianThread *>(this))
142 if (_nl.getScalarVariables(_tid).size() > 0)
144
146}
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
virtual void swapBackMaterials(const THREAD_ID tid)
virtual void computeOnElement()

Referenced by ComputeJacobianForScalingThread::operator()().

◆ onExternalSide()

void NonlinearThread::onExternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtualinherited

Called when iterating over external sides (no side neighbor)

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 368 of file NonlinearThread.C.

369{
370 // Check that we don't have any interface kernels defined on this boundary
371 const auto boundary_ids = _mesh.getBoundaryIDs(elem, side);
372
373 bool has_interface_kernels = false;
374 for (const auto bid : boundary_ids)
375 if (_ik_warehouse && _ik_warehouse->hasActiveBoundaryObjects(bid, _tid))
376 has_interface_kernels = true;
377
378 if (has_interface_kernels)
379 mooseError("Element ",
380 elem->id(),
381 " on side ",
382 side,
383 " is missing a neighbor (hence identified as an external side) but "
384 "has interface kernel(s) defined on the boundary.");
385}
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side.
Definition MooseMesh.C:2990

◆ onInterface()

void NonlinearThread::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
overridevirtualinherited

Called when doing interface assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'
bnd_id- ID of the interface we are at

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 195 of file NonlinearThread.C.

196{
198 {
199
200 // Pointer to the neighbor we are currently working on.
201 const Elem * neighbor = elem->neighbor_ptr(side);
202
203 if (neighbor->active())
204 {
205 _fe_problem.reinitNeighbor(elem, side, _tid);
206
207 // Set up Sentinels so that, even if one of the reinitMaterialsXXX() calls throws, we
208 // still remember to swap back during stack unwinding. Note that face, boundary, and interface
209 // all operate with the same MaterialData object
211 _fe_problem.reinitMaterialsFaceOnBoundary(bnd_id, elem->subdomain_id(), _tid);
213
215 _fe_problem.reinitMaterialsNeighborOnBoundary(bnd_id, neighbor->subdomain_id(), _tid);
216
217 // Has to happen after face and neighbor properties have been computed. Note that we don't use
218 // a sentinel here because FEProblem::swapBackMaterialsFace is going to handle face materials,
219 // boundary materials, and interface materials (e.g. it queries the boundary material data
220 // with the current element and side
222
223 computeOnInterface(bnd_id);
224
226 }
227 else
228 {
229 // elem's neighbor across this side is an inactive ancestor: elem is on the coarser side of
230 // an interface with h-refinement on the other side.
231 // The real geometric neighbors are the active children of this ancestor, so visit each of
232 // them individually instead of silently skipping the whole face.
233 std::vector<const Elem *> fine_neighbors;
234 neighbor->active_family_tree_by_neighbor(fine_neighbors, elem);
235 for (const Elem * fine_neighbor : fine_neighbors)
236 onInterfaceWithHRefinementMismatch(elem, side, bnd_id, fine_neighbor);
237 }
238 }
239}
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid)
void reinitMaterialsFaceOnBoundary(const BoundaryID boundary_id, const SubdomainID blk_id, const THREAD_ID tid, const bool swap_stateful=true, const std::deque< MaterialBase * > *const reinit_mats=nullptr)
reinit materials on element faces on a boundary (internal or external) This specific routine helps us...
void reinitMaterialsBoundary(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on a boundary
void reinitMaterialsNeighborOnBoundary(const BoundaryID boundary_id, const SubdomainID blk_id, const THREAD_ID tid, const bool swap_stateful=true, const std::deque< MaterialBase * > *const reinit_mats=nullptr)
reinit materials on neighbor element (usually faces) on a boundary (internal or external) This specif...
void reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
void onInterfaceWithHRefinementMismatch(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *fine_neighbor)
Compute and accumulate the interface kernel contribution from a single active fine neighbor when elem...
virtual void accumulateNeighbor()=0
Add neighbor residual/Jacobian into assembly global data.
virtual void computeOnInterface(BoundaryID bnd_id)

◆ onInterfaceWithHRefinementMismatch()

void NonlinearThread::onInterfaceWithHRefinementMismatch ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  fine_neighbor 
)
protectedinherited

Compute and accumulate the interface kernel contribution from a single active fine neighbor when elem's own neighbor_ptr(side) is an inactive ancestor, i.e.

elem is on the coarser side of an interface with h-refinement on the other side. variable 's dofs stay bound to elem (so the primary/boundary side's variable is unaffected by refinement direction), while elem 's face is reinitialized at the physical quadrature points of fine_neighbor with a Jacobian-rescaled weight so the integration measure matches fine_neighbor's true physical face area.

elem's own residual/Jacobian contribution must accumulate additively across every active fine neighbor of a given (elem, side) visit, since each one only covers a fraction of elem's face. That local storage was already correctly prepared and zeroed exactly once for elem by FEProblemBase::prepare() before this side loop ever started, so elem's face is reinitialized directly through Assembly/SystemBase here rather than through the FEProblemBase::reinitElemFaceRef() convenience bundle, which would unconditionally (re-)zero that storage - discarding the prior fine neighbors' contributions as well as every contribution already accumulated earlier in elem's visit (volumetric Kernels, IntegratedBCs and InterfaceKernels on other sides, etc.).

Definition at line 242 of file NonlinearThread.C.

246{
248 mooseError("InterfaceKernel '",
249 _ik_warehouse->getActiveBoundaryObjects(bnd_id, _tid)[0]->name(),
250 "' is defined on boundary ",
251 bnd_id,
252 ", whose primary (boundary-tagged) side is coarser than its paired side. This "
253 "case is not supported with a displaced mesh problem: the displaced problem's "
254 "assembly is not reinitialized on these faces, and the borrowed integration "
255 "weight used to handle the mismatched refinement is not AD-differentiable with "
256 "respect to mesh displacement.");
257
258 const unsigned int fine_side = fine_neighbor->which_neighbor_am_i(elem);
259
260 // Measure the fine neighbor's own natural face quadrature: these physical points and weights
261 // are the correct integration measure for the portion of elem's face that fine_neighbor
262 // actually covers. Call this directly on the Assembly object (not through FEProblemBase) so no
263 // variable/dof binding happens for fine_neighbor in the "elem" role.
265 current_assembly.reinitElemFaceRef(fine_neighbor, fine_side, TOLERANCE, nullptr, nullptr);
266 const auto fine_phys_points = current_assembly.qPointsFace().stdVector();
267 const auto fine_phys_JxW = current_assembly.JxWFace().stdVector();
268
269 // Find elem's own side-local reference coordinates for those same physical points.
270 const Elem & elem_side_elem = _elem_side_builder(*elem, side);
271 std::vector<Point> elem_side_ref_points;
273 elem_side_elem.dim(), &elem_side_elem, fine_phys_points, elem_side_ref_points);
274
275 // Measure elem's own local Jacobian at those points using dummy unit weights, then rescale so
276 // that elem's face JxW, once bound for real below, exactly matches fine_neighbor's physical
277 // weight computed above.
278 current_assembly.reinitElemFaceRef(elem, side, TOLERANCE, &elem_side_ref_points, nullptr);
279 const auto elem_dummy_JxW = current_assembly.JxWFace().stdVector();
280 std::vector<Real> elem_ref_weights(fine_phys_JxW.size());
281 for (const auto qp : index_range(elem_ref_weights))
282 elem_ref_weights[qp] = fine_phys_JxW[qp] / elem_dummy_JxW[qp];
283
284 // Bind elem's (primary side) variable to its own dofs, with the face reinitialized at the
285 // corrected points/weights above. elem's residual/Jacobian contribution must accumulate
286 // additively across every fine neighbor of this (elem, side) visit, since each one only covers
287 // a fraction of elem's face; that local storage was already correctly prepared and zeroed
288 // exactly once for this element by FEProblemBase::prepare() before this side loop ever started.
289 // The loop below calls Assembly::reinitElemFaceRef() directly rather than the
290 // FEProblemBase/SubProblem method of the same name: that convenience bundle also calls
291 // Assembly::prepareResidual()/prepareJacobianBlock(), which would unconditionally re-zero elem's
292 // local residual/Jacobian storage, discarding the prior fine neighbors' contributions as well as
293 // every contribution already accumulated earlier in this element's visit (volumetric Kernels,
294 // IntegratedBCs and InterfaceKernels on other sides, etc.). elem's dof indices don't change
295 // across fine neighbors, so reinitializing the face at the new points/weights and recomputing
296 // variable values from them is all that is needed; no further dof preparation step is required.
297 for (const auto sys_num : make_range(_fe_problem.numNonlinearSystems()))
298 {
299 _fe_problem.assembly(_tid, sys_num)
300 .reinitElemFaceRef(elem, side, TOLERANCE, &elem_side_ref_points, &elem_ref_weights);
302 }
303 // Auxiliary variables use the system 0 assembly reinitialized above
305
307 _fe_problem.reinitMaterialsFaceOnBoundary(bnd_id, elem->subdomain_id(), _tid);
309
310 // Bind the neighbor variable to fine_neighbor's own dofs at the matching physical points.
312 _fe_problem.reinitNeighborPhys(fine_neighbor, fine_side, fine_phys_points, _tid);
313
315 _fe_problem.reinitMaterialsNeighborOnBoundary(bnd_id, fine_neighbor->subdomain_id(), _tid);
316
318
319 computeOnInterface(bnd_id);
320
322}
Keeps track of stuff related to assembling.
Definition Assembly.h:102
void reinitElemFaceRef(const Elem *elem, unsigned int elem_side, Real tolerance, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for the given element on the given side, optionally with a given set of referenc...
Definition Assembly.C:2058
const MooseArray< Point > & qPointsFace() const
Returns the reference to the current quadrature being used.
Definition Assembly.h:337
const MooseArray< Real > & JxWFace() const
Returns the reference to the transformed jacobian weights on a current face.
Definition Assembly.h:343
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid) override
Reinit assembly info for a side of an element.
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
AuxiliarySystem & getAuxiliarySystem()
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
virtual unsigned int currentNlSysNum() const override
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
std::vector< T > stdVector() const
Extremely inefficient way to produce a std::vector from a MooseArray!
Definition MooseArray.h:344
libMesh::ElemSideBuilder _elem_side_builder
Builds (and caches) the side element for elem/side pairs in onInterfaceWithHRefinementMismatch.
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
Definition SystemBase.C:368
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
auto index_range(const T &sizable)
IntRange< T > make_range(T beg, T end)

Referenced by NonlinearThread::onInterface().

◆ onInternalSide()

void NonlinearThread::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtualinherited

Called when doing internal edge assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 333 of file NonlinearThread.C.

334{
336 {
337 // Pointer to the neighbor we are currently working on.
338 const Elem * neighbor = elem->neighbor_ptr(side);
339
341
342 // Set up Sentinels so that, even if one of the reinitMaterialsXXX() calls throws, we
343 // still remember to swap back during stack unwinding.
345 _fe_problem.reinitMaterialsFace(elem->subdomain_id(), _tid);
346
348 _fe_problem.reinitMaterialsNeighbor(neighbor->subdomain_id(), _tid);
349
350 computeOnInternalFace(neighbor);
351
353 }
355 {
356 // Set up Sentinel class so that, after we swap in reinitMaterialsFace in prepareFace, even if
357 // one of our callees throws we remember to swap back during stack unwinding. We put our
358 // sentinel here as opposed to in prepareFace because we certainly don't want our materials
359 // swapped back before we proceed to residual/Jacobian computation
361
362 prepareFace(elem, side, Moose::INVALID_BOUNDARY_ID, nullptr);
364 }
365}
void reinitMaterialsFace(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on element faces
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid) override
void reinitMaterialsNeighbor(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on the neighboring element face
virtual void accumulateNeighborLower()=0
Add neighbor and lower residual/Jacobian into assembly global data.
virtual void computeOnInternalFace()=0
bool _subdomain_has_hdg
Whether the subdomain has HDGKernels.
bool _should_execute_dg
Whether DG kernels should be executed for a given elem-neighbor pairing.
const BoundaryID INVALID_BOUNDARY_ID
Definition MooseTypes.C:22

◆ operator()() [1/2]

void NonlinearThread::operator() ( const ConstElemRange &  range,
bool  bypass_threading = false 
)
overridevirtualinherited

Definition at line 65 of file NonlinearThread.C.

66{
69}
const bool _has_active_objects
Whether there are any active residual objects; otherwise we will do an early return.
virtual void operator()(const RangeType &range, bool bypass_threading=false)

◆ operator()() [2/2]

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::operator() ( const RangeType &  range,
bool  bypass_threading = false 
)
virtualinherited

Definition at line 226 of file ThreadedElementLoopBase.h.

227{
228 try
229 {
230 try
231 {
232 ParallelUniqueId puid;
233 _tid = bypass_threading ? 0 : puid.id;
234
235 pre();
237
240 typename RangeType::const_iterator el = range.begin();
241 for (el = range.begin(); el != range.end(); ++el)
242 {
243 if (!keepGoing())
244 break;
245
246 const Elem * elem = *el;
247
248 preElement(elem);
249
251 _subdomain = elem->subdomain_id();
253 {
256 }
257
258 onElement(elem);
259
260 if (_mesh.interiorLowerDBlocks().count(elem->subdomain_id()) > 0 ||
261 _mesh.boundaryLowerDBlocks().count(elem->subdomain_id()) > 0)
262 {
263 postElement(elem);
264 continue;
265 }
266
267 const auto elem_boundary_ids = _mesh.getBoundaryIDs(elem);
268 for (unsigned int side = 0; side < elem->n_sides(); side++)
269 {
270 const auto & boundary_ids = elem_boundary_ids[side];
271 const Elem * lower_d_elem = _mesh.getLowerDElem(elem, side);
272
273 for (const auto bnd_id : boundary_ids)
274 {
275 preBoundary(elem, side, bnd_id, lower_d_elem);
277 onBoundary(elem, side, bnd_id, lower_d_elem);
278 }
279
280 const Elem * neighbor = elem->neighbor_ptr(side);
281 if (neighbor)
282 {
283 preInternalSide(elem, side);
284
286 _neighbor_subdomain = neighbor->subdomain_id();
289
290 if (shouldComputeInternalSide(*elem, *neighbor))
291 onInternalSide(elem, side);
292
293 for (const auto bnd_id : boundary_ids)
294 onInterface(elem, side, bnd_id);
295
296 postInternalSide(elem, side);
297 }
298 else
299 onExternalSide(elem, side);
300 } // sides
301
302 postElement(elem);
303 } // range
304
305 post();
307 }
308 catch (MetaPhysicL::LogicError & e)
309 {
311 }
312 catch (std::exception & e)
313 {
314 // Continue if we find a libMesh degenerate map exception, but
315 // just re-throw for any real error
316 if (!strstr(e.what(), "Jacobian") && !strstr(e.what(), "singular") &&
317 !strstr(e.what(), "det != 0"))
318 throw; // not "throw e;" - that destroys type info!
319
320 mooseException("We caught a libMesh degeneracy exception in ThreadedElementLoopBase:\n",
321 e.what());
322 }
323 }
324 catch (MooseException & e)
325 {
327 }
328}
Provides a way for users to bail out of the current solve.
const Elem * getLowerDElem(const Elem *, unsigned short int) const
Returns a const pointer to a lower dimensional element that corresponds to a side of a higher dimensi...
Definition MooseMesh.C:1648
const std::set< SubdomainID > & boundaryLowerDBlocks() const
Definition MooseMesh.h:1554
virtual void onExternalSide(const Elem *elem, unsigned int side)
Called when iterating over external sides (no side neighbor)
virtual void caughtMooseException(MooseException &)
Called if a MooseException is caught anywhere during the computation.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr)
Called when doing boundary assembling.
virtual void printBoundaryExecutionInformation(const unsigned int) const
Print information about the particular ordering of objects on each boundary.
virtual void neighborSubdomainChanged()
Called every time the neighbor subdomain changes (i.e.
virtual void printGeneralExecutionInformation() const
Print information about the loop ordering.
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id)
Called when doing interface assembling.
virtual bool keepGoing()
Whether or not the loop should continue.
void resetExecPrintedSets() const
Resets the set of blocks and boundaries visited.
SubdomainID _old_subdomain
The subdomain for the last element.
virtual void preInternalSide(const Elem *elem, unsigned int side)
Called before evaluations on an element internal side.
virtual void postInternalSide(const Elem *elem, unsigned int side)
Called after evaluations on an element internal side.
virtual void subdomainChanged()
Called every time the current subdomain changes (i.e.
virtual void onInternalSide(const Elem *elem, unsigned int side)
Called when doing internal edge assembling.
virtual void preBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr)
Called before the boundary assembly.
virtual void onElement(const Elem *elem)
Assembly of the element (not including surface assembly)
virtual void postElement(const Elem *elem)
Called after the element assembly is done (including surface assembling)
virtual void preElement(const Elem *elem)
Called before the element assembly.
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
virtual void printBlockExecutionInformation() const
Print information about the particular ordering of objects on each block.
virtual void post()
Called after the element range loop.
virtual void pre()
Called before the element range loop.
virtual bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const
Whether to compute the internal side for the provided element-neighbor pair.
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition MooseError.C:153

Referenced by NonlinearThread::operator()().

◆ post()

void NonlinearThread::post ( )
overridevirtualinherited

Called after the element range loop.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 433 of file NonlinearThread.C.

Referenced by ComputeJacobianForScalingThread::operator()().

◆ postElement()

void ComputeJacobianBlocksThread::postElement ( const Elem *  elem)
overrideprotectedvirtual

Called after the element assembly is done (including surface assembling)

Parameters
elem- active element

Reimplemented from ComputeJacobianThread.

Definition at line 38 of file ComputeJacobianBlocksThread.C.

39{
40 _dof_indices.clear();
41
42 for (const auto & block : _blocks)
43 {
44 const auto & dof_map = block->_precond_system.get_dof_map();
45 dof_map.dof_indices(elem, _dof_indices);
46
48 block->_jacobian, block->_ivar, block->_jvar, dof_map, _dof_indices, _tags, _tid);
49 }
50}
std::vector< dof_id_type > _dof_indices
virtual void addJacobianBlockTags(libMesh::SparseMatrix< libMesh::Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, std::vector< dof_id_type > &dof_indices, const std::set< TagID > &tags, const THREAD_ID tid)

◆ postInternalSide()

void ComputeJacobianBlocksThread::postInternalSide ( const Elem *  elem,
unsigned int  side 
)
overrideprotectedvirtual

Called after evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 53 of file ComputeJacobianBlocksThread.C.

54{
56 {
57 _dof_indices.clear();
59
60 // Pointer to the neighbor we are currently working on.
61 const Elem * neighbor = elem->neighbor_ptr(side);
62
63 // Get the global id of the element and the neighbor
64 const auto elem_id = elem->id(), neighbor_id = neighbor->id();
65
66 if ((neighbor->active() && (neighbor->level() == elem->level()) && (elem_id < neighbor_id)) ||
67 (neighbor->level() < elem->level()))
68 for (const auto & block : _blocks)
69 {
70 const auto & dof_map = block->_precond_system.get_dof_map();
71 dof_map.dof_indices(elem, _dof_indices);
72 dof_map.dof_indices(neighbor, _dof_neighbor_indices);
73
74 _fe_problem.addJacobianNeighbor(block->_jacobian,
75 block->_ivar,
76 block->_jvar,
77 dof_map,
80 _tags,
81 _tid);
82 }
83 }
84}
std::vector< dof_id_type > _dof_neighbor_indices

◆ pre()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::pre ( )
virtualinherited

Called before the element range loop.

Reimplemented in ComputeDiracThread.

Definition at line 332 of file ThreadedElementLoopBase.h.

333{
334}

Referenced by ComputeJacobianForScalingThread::operator()().

◆ preBoundary()

void ThreadedElementLoop< ConstElemRange >::preBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  lower_d_elem = nullptr 
)
overridevirtualinherited

Called before the boundary assembly.

Parameters
elem- The element we are checking is on the boundary.
side- The side of the element in question.
bnd_id- ID of the boundary we are at
lower_d_elem- Lower dimensional element (e.g. Mortar)

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 52 of file ThreadedElementLoop.h.

140{
142}
virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid) override
sets the current boundary ID in assembly

◆ preElement()

void ThreadedElementLoop< ConstElemRange >::preElement ( const Elem *  elem)
overridevirtualinherited

Called before the element assembly.

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 48 of file ThreadedElementLoop.h.

123{
125}
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override

◆ preInternalSide()

void ThreadedElementLoop< ConstElemRange >::preInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtualinherited

Called before evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 50 of file ThreadedElementLoop.h.

◆ prepareElement()

void ThreadedElementLoop< ConstElemRange >::prepareElement ( const Elem *  elem)
protectedinherited

Definition at line 60 of file ThreadedElementLoop.h.

194{
195 _fe_problem.prepare(elem, this->_tid);
196 _fe_problem.reinitElem(elem, this->_tid);
198}
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void prepare(const Elem *elem, const THREAD_ID tid) override

◆ prepareFace()

void NonlinearThread::prepareFace ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id = Moose::INVALID_BOUNDARY_ID,
const Elem *  lower_d_elem = nullptr 
)
protectedinherited

Reinitialize variables and materials on a face.

Parameters
fe_problemThe finite element problem to call reinit methods on
tidThe thread ID for which we should reinit variables and materials
elemThe element we are reiniting
sideThe element side corresponding to the face we are reiniting
bnd_idIf provided, materials associated with this boundary ID will be reinit'd
lower_d_elemIf provided, lower dimensional variables coincident with the element face will be reinit'd

Definition at line 535 of file NonlinearThread.C.

539{
540 _fe_problem.reinitElemFace(elem, side, _tid);
541
542 // Needed to use lower-dimensional variables on Materials
543 if (lower_d_elem)
544 _fe_problem.reinitLowerDElem(lower_d_elem, _tid);
545
546 if (bnd_id != Moose::INVALID_BOUNDARY_ID)
547 {
548 _fe_problem.reinitMaterialsFaceOnBoundary(bnd_id, elem->subdomain_id(), _tid);
550 }
551 // Currently only used by HDG
552 else
553 _fe_problem.reinitMaterialsFace(elem->subdomain_id(), _tid);
554}
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
virtual void reinitLowerDElem(const Elem *lower_d_elem, const THREAD_ID tid, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override

Referenced by NonlinearThread::onBoundary(), and NonlinearThread::onInternalSide().

◆ printBlockExecutionInformation()

void NonlinearThread::printBlockExecutionInformation ( ) const
overrideprotectedvirtualinherited

Print list of specific objects executed on each block and in which order.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 459 of file NonlinearThread.C.

460{
461 // Number of objects executing is approximated by size of warehouses
462 const int num_objects = _kernels.size() + _fv_kernels.size() + _integrated_bcs.size() +
464 const auto & console = _fe_problem.console();
465 const auto block_name = _mesh.getSubdomainName(_subdomain);
466
467 if (_fe_problem.shouldPrintExecution(_tid) && num_objects > 0)
468 {
470 return;
471 console << "[DBG] Ordering of " + objectType() + " Objects on block " << block_name << " ("
472 << _subdomain << ")" << std::endl;
474 {
475 console << "[DBG] Ordering of kernels:" << std::endl;
476 console << _kernels.activeObjectsToFormattedString() << std::endl;
477 }
478 if (_fv_kernels.size())
479 {
480 console << "[DBG] Ordering of FV elemental kernels:" << std::endl;
481 std::string fvkernels =
482 std::accumulate(_fv_kernels.begin() + 1,
483 _fv_kernels.end(),
484 _fv_kernels[0]->name(),
485 [](const std::string & str_out, FVElementalKernel * kernel)
486 { return str_out + " " + kernel->name(); });
487 console << ConsoleUtils::formatString(fvkernels, "[DBG]") << std::endl;
488 }
490 {
491 console << "[DBG] Ordering of DG kernels:" << std::endl;
492 console << _dg_kernels.activeObjectsToFormattedString() << std::endl;
493 }
494 }
495 else if (_fe_problem.shouldPrintExecution(_tid) && num_objects == 0 &&
497 console << "[DBG] No Active " + objectType() + " Objects on block " << block_name << " ("
498 << _subdomain << ")" << std::endl;
499
501}
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
FVElemental is used for calculating residual contributions from volume integral terms of a PDE where ...
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition MooseMesh.C:1714
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
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.
virtual std::string objectType() const
Return what the loops is meant to compute.
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...

◆ printBoundaryExecutionInformation()

void NonlinearThread::printBoundaryExecutionInformation ( const unsigned int  bid) const
overrideprotectedvirtualinherited

Print list of specific objects executed on each boundary and in which order.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 504 of file NonlinearThread.C.

505{
509 return;
510
511 const auto & console = _fe_problem.console();
512 const auto b_name = _mesh.getBoundaryName(bid);
513 console << "[DBG] Ordering of " + objectType() + " Objects on boundary " << b_name << " (" << bid
514 << ")" << std::endl;
515
517 {
518 console << "[DBG] Ordering of integrated boundary conditions:" << std::endl;
519 console << _integrated_bcs.activeObjectsToFormattedString() << std::endl;
520 }
521
522 // We have not checked if we have a neighbor. This could be premature for saying we are executing
523 // interface kernels. However, we should assume the execution will happen on another side of the
524 // same boundary
526 {
527 console << "[DBG] Ordering of interface kernels:" << std::endl;
528 console << _interface_kernels.activeObjectsToFormattedString() << std::endl;
529 }
530
531 _boundaries_exec_printed.insert(bid);
532}
const std::string & getBoundaryName(const BoundaryID boundary_id) const
Return the name of the boundary given the id.
Definition MooseMesh.C:1743
std::set< BoundaryID > _boundaries_exec_printed
Keep track of which boundaries were visited.

◆ printExecutionOrdering() [1/2]

void ThreadedElementLoop< ConstElemRange >::printExecutionOrdering ( const std::vector< std::shared_ptr< T > > &  objs_ptrs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protectedinherited

Definition at line 87 of file ThreadedElementLoop.h.

184{
185 std::vector<T *> regular_ptrs;
186 for (auto shared_ptr : objs_ptrs)
187 regular_ptrs.push_back(shared_ptr.get());
188 printExecutionOrdering<T>(regular_ptrs, print_header, line_prefix);
189}
const Elem & get(const ElemType type_in)

◆ printExecutionOrdering() [2/2]

void ThreadedElementLoop< ConstElemRange >::printExecutionOrdering ( const std::vector< T * > &  objs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protectedinherited

Routine to output the ordering of objects within a vector of pointers to these objects.

These objects must implement the name() routine, and it must return a string or compatible type.

Template Parameters
Tthe object type
Parameters
objsthe vector with all the objects (should be pointers)
objects_typethe name of the type of objects. Defaults to the CPP object name
print_headerwhether to print a header about the timing of execution and the type of objects

Definition at line 83 of file ThreadedElementLoop.h.

158{
159 if (!objs.size())
160 return;
161
162 auto & console = _fe_problem.console();
163 const auto objects_type = MooseUtils::prettyCppType(objs[0]);
164 std::vector<MooseObject *> moose_objs;
165 for (auto obj_ptr : objs)
166 moose_objs.push_back(dynamic_cast<MooseObject *>(obj_ptr));
167 const auto names = ConsoleUtils::mooseObjectVectorToString(moose_objs);
168
169 // Print string with a DBG prefix and with sufficient line breaks
170 std::string message = print_header ? "Executing " + objects_type + " on " +
172 : "";
173 message += (print_header ? "Order of execution:\n" : "") + names;
174 console << ConsoleUtils::formatString(message, line_prefix) << std::endl;
175}
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
const std::string & name() const
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
std::string mooseObjectVectorToString(const std::vector< MooseObject * > &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.
std::string prettyCppType(const std::string &cpp_type)

◆ printGeneralExecutionInformation()

void NonlinearThread::printGeneralExecutionInformation ( ) const
overrideprotectedvirtualinherited

Print information about the loop, mostly order of execution of objects.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 439 of file NonlinearThread.C.

440{
442 {
443 const auto & console = _fe_problem.console();
444 const auto execute_on = _fe_problem.getCurrentExecuteOnFlag();
445 console << "[DBG] Beginning elemental loop to compute " + objectType() + " on " << execute_on
446 << std::endl;
447 mooseDoOnce(
448 console << "[DBG] Execution order on each element:" << std::endl;
449 console << "[DBG] - kernels on element quadrature points" << std::endl;
450 console << "[DBG] - finite volume elemental kernels on element" << std::endl;
451 console << "[DBG] - integrated boundary conditions on element side quadrature points"
452 << std::endl;
453 console << "[DBG] - DG kernels on element side quadrature points" << std::endl;
454 console << "[DBG] - interface kernels on element side quadrature points" << std::endl;);
455 }
456}

◆ resetExecPrintedSets()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::resetExecPrintedSets ( ) const
protectedinherited

Resets the set of blocks and boundaries visited.

Definition at line 454 of file ThreadedElementLoopBase.h.

455{
456 _blocks_exec_printed.clear();
458}

◆ shouldComputeInternalSide()

bool NonlinearThread::shouldComputeInternalSide ( const Elem &  elem,
const Elem &  neighbor 
) const
overridevirtualinherited

Whether to compute the internal side for the provided element-neighbor pair.

Typically this will return true if the element id is less than the neighbor id when the elements are equal level, or when the element is more refined than the neighbor, and then false otherwise. One type of loop where the logic will be different is when projecting stateful material properties

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 557 of file NonlinearThread.C.

558{
559 // ThreadedElementLoop<ConstElemRange>::shouldComputeInternalSide gets expensive on high
560 // h-refinement cases so we avoid it if possible
561 _should_execute_dg = false;
566}
bool _subdomain_has_dg
Whether the subdomain has DGKernels.

◆ subdomainChanged()

void NonlinearThread::subdomainChanged ( )
overridevirtualinherited

Called every time the current subdomain changes (i.e.

the subdomain of this element is not the same as the subdomain of the last element). Beware of over-using this! You might think that you can do some expensive stuff in here and get away with it... but there are applications that have TONS of subdomains....

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 72 of file NonlinearThread.C.

73{
74 // This should come first to setup the residual objects before we do dependency determination of
75 // material properties and variables
77
79
80 // Update variable Dependencies
81 std::set<MooseVariableFEBase *> needed_moose_vars;
86
87 // Update FE variable coupleable vector tags
88 std::set<TagID> needed_fe_var_vector_tags;
90 _subdomain, needed_fe_var_vector_tags, _tid);
92 _subdomain, needed_fe_var_vector_tags, _tid);
94 _subdomain, needed_fe_var_vector_tags, _tid);
95
96 // Update material dependencies
97 std::unordered_set<unsigned int> needed_mat_props;
102
103 if (_fe_problem.haveFV())
104 {
105 // Re-query the finite volume elemental kernels
106 _fv_kernels.clear();
108 .query()
109 .template condition<AttribSysNum>(_nl.number())
110 .template condition<AttribSystem>("FVElementalKernel")
111 .template condition<AttribSubdomains>(_subdomain)
112 .template condition<AttribThread>(_tid)
114 for (const auto fv_kernel : _fv_kernels)
115 {
116 const auto & fv_mv_deps = fv_kernel->getMooseVariableDependencies();
117 needed_moose_vars.insert(fv_mv_deps.begin(), fv_mv_deps.end());
118 const auto & fv_mp_deps = fv_kernel->getMatPropDependencies();
119 needed_mat_props.insert(fv_mp_deps.begin(), fv_mp_deps.end());
120 }
121 }
122
123 // Cache these to avoid computing them on every side
126
128 _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
129 _fe_problem.prepareMaterials(needed_mat_props, _subdomain, _tid);
130}
const MaterialWarehouse & getMaterialWarehouse() const
void prepareMaterials(const std::unordered_set< unsigned int > &consumer_needed_mat_props, const SubdomainID blk_id, const THREAD_ID tid)
Add the MooseVariables and the material properties that the current materials depend on to the depend...
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase * > &moose_vars, const THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
TheWarehouse & theWarehouse() const
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
void updateBlockMatPropDependency(SubdomainID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
void updateBoundaryVariableDependency(std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
void updateBoundaryMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
virtual void determineObjectWarehouses()=0
Determine the objects we will actually compute based on vector/matrix tag information.
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.

Referenced by ComputeJacobianForScalingThread::operator()().

Member Data Documentation

◆ _blocks

std::vector<JacobianBlock *> ComputeJacobianBlocksThread::_blocks
protected

Definition at line 58 of file ComputeJacobianBlocksThread.h.

Referenced by postElement(), and postInternalSide().

◆ _blocks_exec_printed

template<typename RangeType >
std::set<SubdomainID> ThreadedElementLoopBase< RangeType >::_blocks_exec_printed
mutableprotectedinherited

◆ _boundaries_exec_printed

template<typename RangeType >
std::set<BoundaryID> ThreadedElementLoopBase< RangeType >::_boundaries_exec_printed
mutableprotectedinherited

Keep track of which boundaries were visited.

Definition at line 193 of file ThreadedElementLoopBase.h.

Referenced by NonlinearThread::printBoundaryExecutionInformation().

◆ _dg_kernels

MooseObjectTagWarehouse<DGKernelBase>& NonlinearThread::_dg_kernels
protectedinherited

◆ _dg_warehouse

MooseObjectWarehouse<DGKernelBase>* NonlinearThread::_dg_warehouse
protectedinherited

◆ _dof_indices

std::vector<dof_id_type> ComputeJacobianBlocksThread::_dof_indices
private

Definition at line 61 of file ComputeJacobianBlocksThread.h.

Referenced by postElement(), and postInternalSide().

◆ _dof_neighbor_indices

std::vector<dof_id_type> ComputeJacobianBlocksThread::_dof_neighbor_indices
private

Definition at line 63 of file ComputeJacobianBlocksThread.h.

Referenced by postInternalSide().

◆ _elem_side_builder

libMesh::ElemSideBuilder NonlinearThread::_elem_side_builder
privateinherited

Builds (and caches) the side element for elem/side pairs in onInterfaceWithHRefinementMismatch.

Definition at line 209 of file NonlinearThread.h.

Referenced by NonlinearThread::onInterfaceWithHRefinementMismatch().

◆ _fe_problem

FEProblemBase& ThreadedElementLoop< ConstElemRange >::_fe_problem
protectedinherited

Definition at line 69 of file ThreadedElementLoop.h.

◆ _fv_kernels

std::vector<FVElementalKernel *> NonlinearThread::_fv_kernels
protectedinherited

◆ _has_active_objects

const bool NonlinearThread::_has_active_objects
protectedinherited

Whether there are any active residual objects; otherwise we will do an early return.

Definition at line 195 of file NonlinearThread.h.

Referenced by NonlinearThread::operator()().

◆ _hdg_kernels

MooseObjectTagWarehouse<HDGKernel>& NonlinearThread::_hdg_kernels
protectedinherited

◆ _hdg_warehouse

MooseObjectWarehouse<HDGKernel>* NonlinearThread::_hdg_warehouse
protectedinherited

◆ _ibc_warehouse

MooseObjectWarehouse<IntegratedBCBase>* NonlinearThread::_ibc_warehouse
protectedinherited

◆ _ik_warehouse

MooseObjectWarehouse<InterfaceKernelBase>* NonlinearThread::_ik_warehouse
protectedinherited

◆ _integrated_bcs

MooseObjectTagWarehouse<IntegratedBCBase>& NonlinearThread::_integrated_bcs
protectedinherited

◆ _interface_kernels

MooseObjectTagWarehouse<InterfaceKernelBase>& NonlinearThread::_interface_kernels
protectedinherited

◆ _kernels

MooseObjectTagWarehouse<KernelBase>& NonlinearThread::_kernels
protectedinherited

◆ _mesh

template<typename RangeType >
MooseMesh& ThreadedElementLoopBase< RangeType >::_mesh
protectedinherited

◆ _neighbor_subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_neighbor_subdomain
protectedinherited

◆ _nl

NonlinearSystemBase& NonlinearThread::_nl
protectedinherited

◆ _num_cached

unsigned int NonlinearThread::_num_cached
protectedinherited

◆ _old_neighbor_subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_old_neighbor_subdomain
protectedinherited

The subdomain for the last neighbor.

Definition at line 178 of file ThreadedElementLoopBase.h.

◆ _old_subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 172 of file ThreadedElementLoopBase.h.

Referenced by ComputeJacobianForScalingThread::operator()().

◆ _should_execute_dg

bool NonlinearThread::_should_execute_dg
mutableprivateinherited

Whether DG kernels should be executed for a given elem-neighbor pairing.

This is determined by calling down to our parent (ThreadedElementLoop) class's shouldComputeOnInternalSide method which checks things like whether the elem id is less than the neighbor id such that we make sure we do not execute DGKernels twice on the same face

Definition at line 202 of file NonlinearThread.h.

Referenced by NonlinearThread::onInternalSide(), and NonlinearThread::shouldComputeInternalSide().

◆ _subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_subdomain
protectedinherited

The subdomain for the current element.

Definition at line 169 of file ThreadedElementLoopBase.h.

Referenced by ComputeFullJacobianThread::computeOnBoundary(), NonlinearThread::computeOnElement(), ComputeFullJacobianThread::computeOnElement(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::computeOnInternalFace(), ComputeResidualThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), NonlinearThread::computeOnInternalFace(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), ComputeResidualThread::determineObjectWarehouses(), ComputeMaterialsObjectThread::onBoundary(), ComputeDiracThread::onElement(), ComputeIndicatorThread::onElement(), ComputeMarkerThread::onElement(), ComputeMaterialsObjectThread::onElement(), ComputeUserObjectsThread::onElement(), ComputeMaterialsObjectThread::onInterface(), ComputeMaterialsObjectThread::onInternalSide(), ComputeJacobianForScalingThread::operator()(), postInternalSide(), ComputeDiracThread::printBlockExecutionInformation(), ComputeIndicatorThread::printBlockExecutionInformation(), ComputeMarkerThread::printBlockExecutionInformation(), ComputeUserObjectsThread::printBlockExecutionInformation(), NonlinearThread::printBlockExecutionInformation(), ComputeUserObjectsThread::querySubdomain(), ComputeDiracThread::subdomainChanged(), ComputeIndicatorThread::subdomainChanged(), ComputeMarkerThread::subdomainChanged(), ComputeMaterialsObjectThread::subdomainChanged(), ComputeUserObjectsThread::subdomainChanged(), NonlinearThread::subdomainChanged(), and ProjectMaterialProperties::subdomainChanged().

◆ _subdomain_has_dg

bool NonlinearThread::_subdomain_has_dg
privateinherited

Whether the subdomain has DGKernels.

Definition at line 204 of file NonlinearThread.h.

Referenced by NonlinearThread::shouldComputeInternalSide().

◆ _subdomain_has_hdg

bool NonlinearThread::_subdomain_has_hdg
privateinherited

Whether the subdomain has HDGKernels.

Definition at line 206 of file NonlinearThread.h.

Referenced by NonlinearThread::onInternalSide(), and NonlinearThread::shouldComputeInternalSide().

◆ _tag_kernels

MooseObjectWarehouse<KernelBase>* NonlinearThread::_tag_kernels
protectedinherited

◆ _tags

const std::set<TagID>& ComputeJacobianThread::_tags
protectedinherited

◆ _tid

template<typename RangeType >
THREAD_ID ThreadedElementLoopBase< RangeType >::_tid
protectedinherited

Definition at line 166 of file ThreadedElementLoopBase.h.

Referenced by ComputeResidualAndJacobianThread::accumulate(), ComputeResidualThread::accumulate(), ComputeJacobianThread::accumulateLower(), ComputeResidualAndJacobianThread::accumulateLower(), ComputeResidualThread::accumulateLower(), ComputeJacobianThread::accumulateNeighbor(), ComputeResidualAndJacobianThread::accumulateNeighbor(), ComputeResidualThread::accumulateNeighbor(), ComputeJacobianThread::accumulateNeighborLower(), ComputeResidualAndJacobianThread::accumulateNeighborLower(), ComputeResidualThread::accumulateNeighborLower(), NonlinearThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnBoundary(), NonlinearThread::computeOnElement(), ComputeFullJacobianThread::computeOnElement(), NonlinearThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::computeOnInternalFace(), ComputeResidualThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), NonlinearThread::computeOnInternalFace(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeJacobianThread::determineObjectWarehouses(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), ComputeResidualThread::determineObjectWarehouses(), ComputeUserObjectsThread::getInterfaceMaterialReinitCache(), ComputeUserObjectsThread::getInternalSideMaterialReinitCache(), ComputeMaterialsObjectThread::onBoundary(), ComputeUserObjectsThread::onBoundary(), NonlinearThread::onBoundary(), ProjectMaterialProperties::onBoundary(), ComputeDiracThread::onElement(), ComputeElemDampingThread::onElement(), ComputeIndicatorThread::onElement(), ComputeMarkerThread::onElement(), ComputeMaterialsObjectThread::onElement(), ComputeUserObjectsThread::onElement(), NonlinearThread::onElement(), ProjectMaterialProperties::onElement(), UpdateErrorVectorsThread::onElement(), NonlinearThread::onExternalSide(), ComputeMaterialsObjectThread::onInterface(), ComputeUserObjectsThread::onInterface(), NonlinearThread::onInterface(), NonlinearThread::onInterfaceWithHRefinementMismatch(), ComputeIndicatorThread::onInternalSide(), ComputeMaterialsObjectThread::onInternalSide(), ComputeUserObjectsThread::onInternalSide(), NonlinearThread::onInternalSide(), ProjectMaterialProperties::onInternalSide(), ComputeJacobianForScalingThread::operator()(), ComputeDiracThread::post(), ComputeIndicatorThread::post(), ComputeMarkerThread::post(), ComputeMaterialsObjectThread::post(), ComputeUserObjectsThread::post(), ComputeDiracThread::postElement(), ComputeJacobianThread::postElement(), postElement(), postInternalSide(), ComputeDiracThread::pre(), NonlinearThread::prepareFace(), ComputeDiracThread::printBlockExecutionInformation(), ComputeIndicatorThread::printBlockExecutionInformation(), ComputeMarkerThread::printBlockExecutionInformation(), ComputeUserObjectsThread::printBlockExecutionInformation(), NonlinearThread::printBlockExecutionInformation(), NonlinearThread::printBoundaryExecutionInformation(), ComputeDiracThread::printGeneralExecutionInformation(), ComputeElemDampingThread::printGeneralExecutionInformation(), ComputeIndicatorThread::printGeneralExecutionInformation(), ComputeMarkerThread::printGeneralExecutionInformation(), ComputeUserObjectsThread::printGeneralExecutionInformation(), NonlinearThread::printGeneralExecutionInformation(), ComputeUserObjectsThread::queryBoundary(), ComputeUserObjectsThread::querySubdomain(), ComputeDiracThread::subdomainChanged(), ComputeIndicatorThread::subdomainChanged(), ComputeMarkerThread::subdomainChanged(), ComputeMaterialsObjectThread::subdomainChanged(), ComputeUserObjectsThread::subdomainChanged(), NonlinearThread::subdomainChanged(), and ProjectMaterialProperties::subdomainChanged().


The documentation for this class was generated from the following files: