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

#include <ComputeNodalAuxVarsThread.h>

Inheritance diagram for ComputeNodalAuxVarsThread< AuxKernelType >:
[legend]

Public Member Functions

 ComputeNodalAuxVarsThread (FEProblemBase &fe_problem, const MooseObjectWarehouse< AuxKernelType > &storage, const std::vector< std::vector< MooseVariableFEBase *>> &vars)
 
 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< AuxKernelType > & _storage
 Storage object containing active AuxKernel objects. More...
 
const std::vector< std::vector< MooseVariableFEBase * > > _aux_vars
 
std::set< SubdomainID_block_ids
 
FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Detailed Description

template<typename AuxKernelType>
class ComputeNodalAuxVarsThread< AuxKernelType >

Definition at line 25 of file ComputeNodalAuxVarsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalAuxVarsThread() [1/2]

template<typename AuxKernelType >
ComputeNodalAuxVarsThread< AuxKernelType >::ComputeNodalAuxVarsThread ( FEProblemBase fe_problem,
const MooseObjectWarehouse< AuxKernelType > &  storage,
const std::vector< std::vector< MooseVariableFEBase *>> &  vars 
)

Definition at line 21 of file ComputeNodalAuxVarsThread.C.

26  _aux_sys(fe_problem.getAuxiliarySystem()),
27  _storage(storage),
28  _aux_vars(vars)
29 {
30 }
const std::vector< std::vector< MooseVariableFEBase * > > _aux_vars
const MooseObjectWarehouse< AuxKernelType > & _storage
Storage object containing active AuxKernel objects.
AuxiliarySystem & getAuxiliarySystem()

◆ ComputeNodalAuxVarsThread() [2/2]

template<typename AuxKernelType >
ComputeNodalAuxVarsThread< AuxKernelType >::ComputeNodalAuxVarsThread ( ComputeNodalAuxVarsThread< AuxKernelType > &  x,
Threads::split  split 
)

Definition at line 34 of file ComputeNodalAuxVarsThread.C.

37  _aux_sys(x._aux_sys),
38  _storage(x._storage),
39  _aux_vars(x._aux_vars)
40 {
41 }
const std::vector< std::vector< MooseVariableFEBase * > > _aux_vars
const MooseObjectWarehouse< AuxKernelType > & _storage
Storage object containing active AuxKernel objects.
static PetscErrorCode Vec x
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:784

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()

template<typename AuxKernelType >
void ComputeNodalAuxVarsThread< AuxKernelType >::join ( const ComputeNodalAuxVarsThread< AuxKernelType > &  )

Definition at line 123 of file ComputeNodalAuxVarsThread.C.

124 {
125 }

◆ 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()

template<typename AuxKernelType >
void ComputeNodalAuxVarsThread< AuxKernelType >::onNode ( ConstNodeRange::const_iterator &  node_it)
overridevirtual

Called for each node.

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

Definition at line 72 of file ComputeNodalAuxVarsThread.C.

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

template<typename AuxKernelType >
void ComputeNodalAuxVarsThread< AuxKernelType >::post ( )
overridevirtual

Called after the node range loop.

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

Definition at line 115 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()

template<typename AuxKernelType >
void ComputeNodalAuxVarsThread< AuxKernelType >::subdomainChanged ( )

Definition at line 45 of file ComputeNodalAuxVarsThread.C.

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

Member Data Documentation

◆ _aux_sys

template<typename AuxKernelType>
AuxiliarySystem& ComputeNodalAuxVarsThread< AuxKernelType >::_aux_sys
protected

Definition at line 44 of file ComputeNodalAuxVarsThread.h.

◆ _aux_vars

template<typename AuxKernelType>
const std::vector<std::vector<MooseVariableFEBase *> > ComputeNodalAuxVarsThread< AuxKernelType >::_aux_vars
protected

Definition at line 49 of file ComputeNodalAuxVarsThread.h.

◆ _block_ids

template<typename AuxKernelType>
std::set<SubdomainID> ComputeNodalAuxVarsThread< AuxKernelType >::_block_ids
protected

Definition at line 51 of file ComputeNodalAuxVarsThread.h.

◆ _fe_problem

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

◆ _storage

template<typename AuxKernelType>
const MooseObjectWarehouse<AuxKernelType>& ComputeNodalAuxVarsThread< AuxKernelType >::_storage
protected

Storage object containing active AuxKernel objects.

Definition at line 47 of file ComputeNodalAuxVarsThread.h.

◆ _tid

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

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