www.mooseframework.org
ComputeJacobianBlocksThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
12 // MOOSE includes
13 #include "DGKernel.h"
14 #include "FEProblem.h"
15 #include "KernelBase.h"
16 #include "IntegratedBC.h"
17 
18 #include "libmesh/threads.h"
19 #include "libmesh/dof_map.h"
20 
22  std::vector<JacobianBlock *> & blocks,
23  const std::set<TagID> & tags)
24  : ComputeFullJacobianThread(fe_problem, tags), _blocks(blocks)
25 {
26 }
27 
28 // Splitting Constructor
30  Threads::split split)
31  : ComputeFullJacobianThread(x, split), _blocks(x._blocks)
32 {
33 }
34 
36 
37 void
39 {
40  _dof_indices.clear();
41 
42  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
43 
44  for (const auto & block : _blocks)
45  {
46  const auto & dof_map = block->_precond_system.get_dof_map();
47  dof_map.dof_indices(elem, _dof_indices);
48 
50  block->_jacobian, block->_ivar, block->_jvar, dof_map, _dof_indices, _tags, _tid);
51  }
52 }
53 
54 void
55 ComputeJacobianBlocksThread::postInternalSide(const Elem * elem, unsigned int side)
56 {
58  {
59  _dof_indices.clear();
60  _dof_neighbor_indices.clear();
61 
62  // Pointer to the neighbor we are currently working on.
63  const Elem * neighbor = elem->neighbor_ptr(side);
64 
65  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
66  // Get the global id of the element and the neighbor
67  const auto elem_id = elem->id(), neighbor_id = neighbor->id();
68 
69  if ((neighbor->active() && (neighbor->level() == elem->level()) && (elem_id < neighbor_id)) ||
70  (neighbor->level() < elem->level()))
71  for (const auto & block : _blocks)
72  {
73  const auto & dof_map = block->_precond_system.get_dof_map();
74  dof_map.dof_indices(elem, _dof_indices);
75  dof_map.dof_indices(neighbor, _dof_neighbor_indices);
76 
77  _fe_problem.addJacobianNeighbor(block->_jacobian,
78  block->_ivar,
79  block->_jvar,
80  dof_map,
83  _tags,
84  _tid);
85  }
86  }
87 }
virtual void postElement(const Elem *elem) override
Called after the element assembly is done (including surface assembling)
virtual void addJacobianBlockTags(SparseMatrix< 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)
bool hasActiveBlockObjects(THREAD_ID tid=0) const
ComputeJacobianBlocksThread(FEProblemBase &fe_problem, std::vector< JacobianBlock *> &blocks, const std::set< TagID > &tags)
virtual void postInternalSide(const Elem *elem, unsigned int side) override
Called after evaluations on an element internal side.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Specialization for filling multiple "small" preconditioning matrices simulatenously.
const std::set< TagID > & _tags
virtual void addJacobianNeighbor(const THREAD_ID tid) override
std::vector< dof_id_type > _dof_indices
std::vector< JacobianBlock * > _blocks
tbb::split split
SubdomainID _subdomain
The subdomain for the current element.
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse
std::vector< dof_id_type > _dof_neighbor_indices