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

#include <ComputeNodalAuxVarsThread.h>

Inheritance diagram for ComputeNodalAuxVarsThread:
[legend]

Public Member Functions

 ComputeNodalAuxVarsThread (FEProblemBase &fe_problem, const MooseObjectWarehouse< AuxKernel > &storage)
 
 ComputeNodalAuxVarsThread (ComputeNodalAuxVarsThread &x, Threads::split split)
 
void onNode (ConstNodeRange::const_iterator &nd) override
 Called for each node. More...
 
void join (const ComputeNodalAuxVarsThread &)
 
void subdomainChanged ()
 
void post () override
 Called after the node range loop. More...
 
void operator() (const ConstNodeRange &range)
 
virtual void pre ()
 Called before the node range loop. More...
 
virtual void postNode (ConstNodeRange::const_iterator &node_it)
 Called after the node assembly is done (including surface assembling) More...
 
virtual void caughtMooseException (MooseException &e)
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing ()
 Whether or not the loop should continue. More...
 

Protected Attributes

AuxiliarySystem_aux_sys
 
const MooseObjectWarehouse< AuxKernel > & _storage
 Storage object containing active AuxKernel objects. More...
 
std::set< SubdomainID_block_ids
 
FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Detailed Description

Definition at line 25 of file ComputeNodalAuxVarsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalAuxVarsThread() [1/2]

ComputeNodalAuxVarsThread::ComputeNodalAuxVarsThread ( FEProblemBase fe_problem,
const MooseObjectWarehouse< AuxKernel > &  storage 
)

Definition at line 20 of file ComputeNodalAuxVarsThread.C.

23  _aux_sys(fe_problem.getAuxiliarySystem()),
24  _storage(storage)
25 {
26 }
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.
AuxiliarySystem & getAuxiliarySystem()

◆ ComputeNodalAuxVarsThread() [2/2]

ComputeNodalAuxVarsThread::ComputeNodalAuxVarsThread ( ComputeNodalAuxVarsThread x,
Threads::split  split 
)

Definition at line 29 of file ComputeNodalAuxVarsThread.C.

32  _aux_sys(x._aux_sys),
33  _storage(x._storage)
34 {
35 }
static PetscErrorCode Vec x
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.

Member Function Documentation

◆ caughtMooseException()

virtual void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::caughtMooseException ( MooseException e)
inlinevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Definition at line 55 of file ThreadedNodeLoop.h.

56  {
57  std::string what(e.what());
59  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception.

◆ join()

void ComputeNodalAuxVarsThread::join ( const ComputeNodalAuxVarsThread )

Definition at line 119 of file ComputeNodalAuxVarsThread.C.

120 {
121 }

◆ keepGoing()

virtual bool ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::keepGoing ( )
inlinevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Definition at line 66 of file ThreadedNodeLoop.h.

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

◆ onNode()

void ComputeNodalAuxVarsThread::onNode ( ConstNodeRange::const_iterator &  node_it)
overridevirtual

Called for each node.

Reimplemented from ThreadedNodeLoop< ConstNodeRange, ConstNodeRange::const_iterator >.

Definition at line 64 of file ComputeNodalAuxVarsThread.C.

65 {
66  const Node * node = *node_it;
67 
68  const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
69 
70  if (_block_ids != block_ids)
71  {
72  _block_ids.clear();
73  _block_ids.insert(block_ids.begin(), block_ids.end());
75  }
76 
77  // prepare variables
78  for (const auto & it : _aux_sys._nodal_vars[_tid])
79  {
80  MooseVariable * var = it.second;
81  var->prepareAux();
82  }
83 
85 
86  // Get a map of all active block restricted AuxKernel objects
87  const auto & block_kernels = _storage.getActiveBlockObjects(_tid);
88 
89  // Loop over all SubdomainIDs for the current node, if an AuxKernel is active on this block then
90  // compute it.
91  for (const auto & block : block_ids)
92  {
93  const auto iter = block_kernels.find(block);
94 
95  if (iter != block_kernels.end())
96  for (const auto & aux : iter->second)
97  aux->compute();
98  }
99 
100  // We are done, so update the solution vector
101  {
102  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
103  for (const auto & it : _aux_sys._nodal_vars[_tid])
104  {
105  MooseVariable * var = it.second;
106  var->insert(_aux_sys.solution());
107  }
108  }
109 }
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:883
std::set< SubdomainID > _block_ids
void insert(NumericVector< Number > &residual) override
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.
virtual NumericVector< Number > & solution() override
virtual MooseMesh & mesh()
Definition: SystemBase.h:102
virtual void reinitNode(const Node *node, THREAD_ID tid) override
void prepareAux() override

◆ operator()()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::operator() ( const ConstNodeRange &  range)
inherited

Definition at line 88 of file ThreadedNodeLoop.h.

89 {
90  try
91  {
92  ParallelUniqueId puid;
93  _tid = puid.id;
94 
95  pre();
96 
97  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
98  {
99  if (!keepGoing())
100  break;
101 
102  onNode(nd);
103 
104  postNode(nd);
105  }
106 
107  post();
108  }
109  catch (MooseException & e)
110  {
112  }
113 }
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
virtual bool keepGoing()
Whether or not the loop should continue.
Provides a way for users to bail out of the current solve.
virtual void pre()
Called before the node range loop.
virtual void post()
Called after the node range loop.
virtual void postNode(ConstNodeRange::const_iterator &node_it)
Called after the node assembly is done (including surface assembling)
virtual void onNode(ConstNodeRange::const_iterator &node_it)
Called for each node.

◆ post()

void ComputeNodalAuxVarsThread::post ( )
overridevirtual

Called after the node range loop.

Reimplemented from ThreadedNodeLoop< ConstNodeRange, ConstNodeRange::const_iterator >.

Definition at line 112 of file ComputeNodalAuxVarsThread.C.

◆ postNode()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::postNode ( ConstNodeRange::const_iterator &  node_it)
virtualinherited

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

Parameters
node- active node

Definition at line 135 of file ThreadedNodeLoop.h.

136 {
137 }

◆ pre()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::pre ( )
virtualinherited

Called before the node range loop.

Reimplemented in ComputeNodalKernelJacobiansThread, and ComputeNodalKernelsThread.

Definition at line 117 of file ThreadedNodeLoop.h.

118 {
119 }

◆ subdomainChanged()

void ComputeNodalAuxVarsThread::subdomainChanged ( )

Definition at line 38 of file ComputeNodalAuxVarsThread.C.

Referenced by onNode().

39 {
40  std::set<TagID> needed_vector_tags;
41  std::set<TagID> needed_matrix_tags;
42 
43  const auto & block_kernels = _storage.getActiveBlockObjects(_tid);
44 
45  for (const auto & block : _block_ids)
46  {
47  const auto iter = block_kernels.find(block);
48 
49  if (iter != block_kernels.end())
50  for (const auto & aux : iter->second)
51  {
52  auto & matrix_tags = aux->getFEVariableCoupleableMatrixTags();
53  needed_matrix_tags.insert(matrix_tags.begin(), matrix_tags.end());
54  auto & vector_tags = aux->getFEVariableCoupleableVectorTags();
55  needed_vector_tags.insert(vector_tags.begin(), vector_tags.end());
56  }
57  }
58 
61 }
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, THREAD_ID tid) override
std::set< SubdomainID > _block_ids
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, THREAD_ID tid) override
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.

Member Data Documentation

◆ _aux_sys

AuxiliarySystem& ComputeNodalAuxVarsThread::_aux_sys
protected

Definition at line 43 of file ComputeNodalAuxVarsThread.h.

Referenced by onNode().

◆ _block_ids

std::set<SubdomainID> ComputeNodalAuxVarsThread::_block_ids
protected

Definition at line 48 of file ComputeNodalAuxVarsThread.h.

Referenced by onNode(), and subdomainChanged().

◆ _fe_problem

FEProblemBase& ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::_fe_problem
protectedinherited

◆ _storage

const MooseObjectWarehouse<AuxKernel>& ComputeNodalAuxVarsThread::_storage
protected

Storage object containing active AuxKernel objects.

Definition at line 46 of file ComputeNodalAuxVarsThread.h.

Referenced by onNode(), and subdomainChanged().

◆ _tid

THREAD_ID ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::_tid
protectedinherited

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