www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
ComputeDiracThread Class Reference

#include <ComputeDiracThread.h>

Inheritance diagram for ComputeDiracThread:
[legend]

Public Member Functions

 ComputeDiracThread (FEProblemBase &feproblem, SparseMatrix< Number > *jacobian=NULL)
 
 ComputeDiracThread (ComputeDiracThread &x, Threads::split)
 
virtual ~ComputeDiracThread ()
 
virtual void subdomainChanged () override
 Called every time the current subdomain changes (i.e. More...
 
virtual void pre () override
 Called before the element range loop. More...
 
virtual void onElement (const Elem *elem) override
 Assembly of the element (not including surface assembly) More...
 
virtual void postElement (const Elem *) override
 Called after the element assembly is done (including surface assembling) More...
 
virtual void post () override
 Called after the element range loop. More...
 
void join (const ComputeDiracThread &)
 
virtual void caughtMooseException (MooseException &e) override
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing () override
 Whether or not the loop should continue. More...
 
virtual void preElement (const Elem *elem) override
 Called before the element assembly. More...
 
virtual void preInternalSide (const Elem *elem, unsigned int side) override
 Called before evaluations on an element internal side. More...
 
virtual void neighborSubdomainChanged () override
 Called every time the neighbor subdomain changes (i.e. More...
 
void operator() (const DistElemRange &range, bool bypass_threading=false)
 
virtual void onBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 Called when doing boundary assembling. More...
 
virtual void postInternalSide (const Elem *elem, unsigned int side)
 Called after evaluations on an element internal side. More...
 
virtual void onInternalSide (const Elem *elem, unsigned int side)
 Called when doing internal edge assembling. More...
 
virtual void onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 Called when doing interface assembling. More...
 

Protected Attributes

SparseMatrix< Number > * _jacobian
 
NonlinearSystemBase_nl
 
const MooseObjectWarehouse< DiracKernel > & _dirac_kernels
 Storage for DiracKernel objects. More...
 
FEProblemBase_fe_problem
 
MooseMesh_mesh
 
THREAD_ID _tid
 
SubdomainID _subdomain
 The subdomain for the current element. More...
 
SubdomainID _old_subdomain
 The subdomain for the last element. More...
 
SubdomainID _neighbor_subdomain
 The subdomain for the current neighbor. More...
 
SubdomainID _old_neighbor_subdomain
 The subdomain for the last neighbor. More...
 

Detailed Description

Definition at line 31 of file ComputeDiracThread.h.

Constructor & Destructor Documentation

ComputeDiracThread::ComputeDiracThread ( FEProblemBase feproblem,
SparseMatrix< Number > *  jacobian = NULL 
)

Definition at line 28 of file ComputeDiracThread.C.

30  _jacobian(jacobian),
31  _nl(feproblem.getNonlinearSystemBase()),
33 {
34 }
const MooseObjectWarehouse< DiracKernel > & getDiracKernelWarehouse()
NonlinearSystemBase & getNonlinearSystemBase()
const MooseObjectWarehouse< DiracKernel > & _dirac_kernels
Storage for DiracKernel objects.
SparseMatrix< Number > * _jacobian
NonlinearSystemBase & _nl
ComputeDiracThread::ComputeDiracThread ( ComputeDiracThread x,
Threads::split  split 
)

Definition at line 37 of file ComputeDiracThread.C.

39  _jacobian(x._jacobian),
40  _nl(x._nl),
41  _dirac_kernels(x._dirac_kernels)
42 {
43 }
const MooseObjectWarehouse< DiracKernel > & _dirac_kernels
Storage for DiracKernel objects.
static PetscErrorCode Vec x
SparseMatrix< Number > * _jacobian
NonlinearSystemBase & _nl
ComputeDiracThread::~ComputeDiracThread ( )
virtual

Definition at line 45 of file ComputeDiracThread.C.

45 {}

Member Function Documentation

virtual void ThreadedElementLoop< DistElemRange >::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< DistElemRange >.

void ComputeDiracThread::join ( const ComputeDiracThread )

Definition at line 154 of file ComputeDiracThread.C.

155 {
156 }
virtual bool ThreadedElementLoop< DistElemRange >::keepGoing ( )
inlineoverridevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Reimplemented from ThreadedElementLoopBase< DistElemRange >.

Definition at line 50 of file ThreadedElementLoop.h.

50 { return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.
virtual void ThreadedElementLoop< DistElemRange >::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< DistElemRange >.

virtual void ThreadedElementLoopBase< DistElemRange >::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtualinherited

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
void ComputeDiracThread::onElement ( const Elem *  elem)
overridevirtual

Assembly of the element (not including surface assembly)

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< DistElemRange >.

Definition at line 72 of file ComputeDiracThread.C.

73 {
74  const bool has_dirac_kernels_on_elem = _fe_problem.reinitDirac(elem, _tid);
75  if (!has_dirac_kernels_on_elem)
76  return;
77 
78  std::set<MooseVariable *> needed_moose_vars;
79  const std::vector<std::shared_ptr<DiracKernel>> & dkernels =
81 
82  // Only call reinitMaterials() if one or more DiracKernels has
83  // actually called getMaterialProperty(). Loop over all the
84  // DiracKernels and check whether this is the case.
85  for (const auto & dirac_kernel : dkernels)
86  {
87  // If any of the DiracKernels have had getMaterialProperty()
88  // called, we need to reinit Materials.
89  if (dirac_kernel->getMaterialPropertyCalled())
90  {
91  _fe_problem.reinitMaterials(_subdomain, _tid, /*swap_stateful=*/false);
92  break;
93  }
94  }
95 
96  for (const auto & dirac_kernel : dkernels)
97  {
98  if (!dirac_kernel->hasPointsOnElem(elem))
99  continue;
100  else if (_jacobian == NULL)
101  {
102  dirac_kernel->computeResidual();
103  continue;
104  }
105 
106  // Get a list of coupled variables from the SubProblem
107  std::vector<std::pair<MooseVariable *, MooseVariable *>> & coupling_entries =
108  dirac_kernel->subProblem().assembly(_tid).couplingEntries();
109 
110  // Loop over the list of coupled variable pairs
111  for (auto & it : coupling_entries)
112  {
113  MooseVariable * ivariable = it.first;
114  MooseVariable * jvariable = it.second;
115 
116  // A variant of the check that is in
117  // ComputeFullJacobianThread::computeJacobian(). We
118  // only want to call computeOffDiagJacobian() if both
119  // variables are active on this subdomain, and the
120  // off-diagonal variable actually has dofs.
121  if (dirac_kernel->variable().number() == ivariable->number() &&
122  ivariable->activeOnSubdomain(_subdomain) && jvariable->activeOnSubdomain(_subdomain) &&
123  (jvariable->numberOfDofs() > 0))
124  {
125  dirac_kernel->subProblem().prepareShapes(jvariable->number(), _tid);
126  dirac_kernel->computeOffDiagJacobian(jvariable->number());
127  }
128  }
129  }
130 
131  // Note that we do not call swapBackMaterials() here as they were
132  // never swapped in the first place. This avoids messing up
133  // stored values of stateful material properties.
134 }
Class for stuff related to variables.
Definition: MooseVariable.h:43
virtual bool reinitDirac(const Elem *elem, THREAD_ID tid) override
Returns true if the Problem has Dirac kernels it needs to compute on elem.
unsigned int numberOfDofs()
const MooseObjectWarehouse< DiracKernel > & _dirac_kernels
Storage for DiracKernel objects.
virtual void reinitMaterials(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
bool activeOnSubdomain(SubdomainID subdomain) const
Is the variable active on the subdomain?
SparseMatrix< Number > * _jacobian
unsigned int number() const
Get variable number coming from libMesh.
SubdomainID _subdomain
The subdomain for the current element.
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
virtual void ThreadedElementLoopBase< DistElemRange >::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtualinherited

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
virtual void ThreadedElementLoopBase< DistElemRange >::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Called when doing internal edge assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'
void ThreadedElementLoopBase< DistElemRange >::operator() ( const DistElemRange range,
bool  bypass_threading = false 
)
inherited
void ComputeDiracThread::post ( )
overridevirtual

Called after the element range loop.

Reimplemented from ThreadedElementLoopBase< DistElemRange >.

Definition at line 147 of file ComputeDiracThread.C.

148 {
151 }
virtual void clearActiveMaterialProperties(THREAD_ID tid) override
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override
Clear the active elemental MooseVariable.
void ComputeDiracThread::postElement ( const Elem *  elem)
overridevirtual

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

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< DistElemRange >.

Definition at line 137 of file ComputeDiracThread.C.

138 {
139  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
140  if (_jacobian == NULL)
142  else
144 }
virtual void addResidual(THREAD_ID tid) override
SparseMatrix< Number > * _jacobian
virtual void addJacobian(SparseMatrix< Number > &jacobian, THREAD_ID tid) override
virtual void ThreadedElementLoopBase< DistElemRange >::postInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Called after evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'
void ComputeDiracThread::pre ( )
overridevirtual

Called before the element range loop.

Reimplemented from ThreadedElementLoopBase< DistElemRange >.

Definition at line 48 of file ComputeDiracThread.C.

49 {
50  // Force TID=0 because we run this object _NON THREADED_
51  // Take this out if we ever get Dirac's working with threads!
52  _tid = 0;
53 }
virtual void ThreadedElementLoop< DistElemRange >::preElement ( const Elem *  elem)
overridevirtualinherited

Called before the element assembly.

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< DistElemRange >.

virtual void ThreadedElementLoop< DistElemRange >::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< DistElemRange >.

void ComputeDiracThread::subdomainChanged ( )
overridevirtual

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< DistElemRange >.

Definition at line 56 of file ComputeDiracThread.C.

57 {
59 
60  std::set<MooseVariable *> needed_moose_vars;
61  _dirac_kernels.updateVariableDependency(needed_moose_vars, _tid);
62 
63  // Update material dependencies
64  std::set<unsigned int> needed_mat_props;
65  _dirac_kernels.updateMatPropDependency(needed_mat_props, _tid);
66 
68  _fe_problem.setActiveMaterialProperties(needed_mat_props, _tid);
69 }
virtual void setActiveElementalMooseVariables(const std::set< MooseVariable * > &moose_vars, THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
const MooseObjectWarehouse< DiracKernel > & _dirac_kernels
Storage for DiracKernel objects.
virtual void setActiveMaterialProperties(const std::set< unsigned int > &mat_prop_ids, THREAD_ID tid) override
Record and set the material properties required by the current computing thread.
virtual void subdomainSetup(SubdomainID subdomain, THREAD_ID tid)
void updateVariableDependency(std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
void updateMatPropDependency(std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
Update material property dependency vector.
SubdomainID _subdomain
The subdomain for the current element.

Member Data Documentation

const MooseObjectWarehouse<DiracKernel>& ComputeDiracThread::_dirac_kernels
protected

Storage for DiracKernel objects.

Definition at line 54 of file ComputeDiracThread.h.

Referenced by onElement(), and subdomainChanged().

FEProblemBase& ThreadedElementLoop< DistElemRange >::_fe_problem
protectedinherited

Definition at line 59 of file ThreadedElementLoop.h.

Referenced by onElement(), post(), postElement(), and subdomainChanged().

SparseMatrix<Number>* ComputeDiracThread::_jacobian
protected

Definition at line 50 of file ComputeDiracThread.h.

Referenced by onElement(), and postElement().

MooseMesh& ThreadedElementLoopBase< DistElemRange >::_mesh
protectedinherited

Definition at line 141 of file ThreadedElementLoopBase.h.

SubdomainID ThreadedElementLoopBase< DistElemRange >::_neighbor_subdomain
protectedinherited

The subdomain for the current neighbor.

Definition at line 151 of file ThreadedElementLoopBase.h.

NonlinearSystemBase& ComputeDiracThread::_nl
protected

Definition at line 51 of file ComputeDiracThread.h.

SubdomainID ThreadedElementLoopBase< DistElemRange >::_old_neighbor_subdomain
protectedinherited

The subdomain for the last neighbor.

Definition at line 154 of file ThreadedElementLoopBase.h.

SubdomainID ThreadedElementLoopBase< DistElemRange >::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 148 of file ThreadedElementLoopBase.h.

SubdomainID ThreadedElementLoopBase< DistElemRange >::_subdomain
protectedinherited

The subdomain for the current element.

Definition at line 145 of file ThreadedElementLoopBase.h.

Referenced by onElement(), and subdomainChanged().

THREAD_ID ThreadedElementLoopBase< DistElemRange >::_tid
protectedinherited

Definition at line 142 of file ThreadedElementLoopBase.h.

Referenced by onElement(), post(), postElement(), pre(), and subdomainChanged().


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