https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static 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)
 
 ComputeNodalAuxVarsThread (ComputeNodalAuxVarsThread &x, Threads::split split)
 
void onNode (ConstNodeRange::const_iterator &nd) override
 
void join (const ComputeNodalAuxVarsThread &)
 
void subdomainChanged ()
 
void post () override
 Called after the node range loop.
 
void operator() (const ConstNodeRange &range)
 
virtual void pre ()
 Called before the node range loop.
 
virtual void onNode (ConstNodeRange::const_iterator &node_it)
 Called for each node.
 
virtual void postNode (ConstNodeRange::const_iterator &node_it)
 Called after the node assembly is done (including surface assembling)
 
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.
 

Protected Member Functions

void printGeneralExecutionInformation () const override
 Print information about the loop, mostly order of execution of objects.
 

Protected Attributes

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

Static Protected Attributes

static Threads::spin_mutex writable_variable_mutex
 

Detailed Description

template<typename AuxKernelType>
class ComputeNodalAuxVarsThread< AuxKernelType >

Definition at line 24 of file ComputeNodalAuxVarsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalAuxVarsThread() [1/2]

template<typename AuxKernelType >
ComputeNodalAuxVarsThread< AuxKernelType >::ComputeNodalAuxVarsThread ( FEProblemBase fe_problem,
const MooseObjectWarehouse< AuxKernelType > &  storage 
)

Definition at line 24 of file ComputeNodalAuxVarsThread.C.

27 _aux_sys(fe_problem.getAuxiliarySystem()),
28 _storage(storage)
29{
30}
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 
)

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 56 of file ThreadedNodeLoop.h.

57 {
58 Threads::spin_mutex::scoped_lock lock(threaded_node_mutex);
59
60 std::string what(e.what());
62 };
static Threads::spin_mutex threaded_node_mutex
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.

◆ join()

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

Definition at line 130 of file ComputeNodalAuxVarsThread.C.

131{
132}

◆ 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 69 of file ThreadedNodeLoop.h.

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

◆ onNode() [1/2]

template<typename AuxKernelType >
void ComputeNodalAuxVarsThread< AuxKernelType >::onNode ( ConstNodeRange::const_iterator &  nd)
override

Definition at line 71 of file ComputeNodalAuxVarsThread.C.

72{
73 const Node * node = *node_it;
74
75 const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
76
77 if (_block_ids != block_ids)
78 {
79 _block_ids.clear();
80 _block_ids.insert(block_ids.begin(), block_ids.end());
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 {
98 aux->compute();
99 // This is the same conditional check that the aux kernel performs internally before calling
100 // computeValue and _var.setNodalValue. We don't want to attempt to insert into the solution
101 // if we don't actually have any dofs on this node
102 if (aux->variable().isNodalDefined())
103 aux->variable().insert(_aux_sys.solution());
104
105 // update the aux solution vector if writable coupled variables are used
106 if (aux->hasWritableCoupledVariables())
107 {
108 for (auto * var : aux->getWritableCoupledVariables())
109 if (var->isNodalDefined())
110 // insert into the global solution vector
111 var->insert(_aux_sys.solution());
112
113 // make solution values available for dependent AuxKernels
115 }
116 }
117 }
118}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::set< SubdomainID > _block_ids
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition MooseMesh.C:1489
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
MooseMesh & mesh()
Definition SystemBase.h:100
NumericVector< Number > & solution()
Definition SystemBase.h:203

◆ onNode() [2/2]

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

Called for each node.

Definition at line 43 of file ThreadedNodeLoop.h.

137{
138}

◆ operator()()

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

Definition at line 28 of file ThreadedNodeLoop.h.

95{
96 try
97 {
99 _tid = puid.id;
100
101 pre();
103
104 for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
105 {
106 if (!keepGoing())
107 break;
108
109 onNode(nd);
110
111 postNode(nd);
112 }
113
114 post();
115 }
116 catch (MooseException & e)
117 {
119 }
120}
Provides a way for users to bail out of the current solve.
virtual void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
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.
virtual bool keepGoing()
Whether or not the loop should continue.
virtual void pre()
Called before the node range loop.
virtual void post()
Called after the node range loop.
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.

◆ 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 122 of file ComputeNodalAuxVarsThread.C.

123{
126}
virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) override
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) override

◆ 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 50 of file ThreadedNodeLoop.h.

143{
144}

◆ pre()

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

Called before the node range loop.

Reimplemented in ComputeNodalKernelJacobiansThread, and ComputeNodalKernelsThread.

Definition at line 33 of file ThreadedNodeLoop.h.

125{
126}

◆ printGeneralExecutionInformation()

template<typename AuxKernelType >
void ComputeNodalAuxVarsThread< AuxKernelType >::printGeneralExecutionInformation ( ) const
overrideprotectedvirtual

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

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

Definition at line 136 of file ComputeNodalAuxVarsThread.C.

137{
139 return;
140
141 const auto & console = _fe_problem.console();
142 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
143 console << "[DBG] Beginning nodal loop of nodal " << MooseUtils::prettyCppType<AuxKernelType>()
144 << " on " << execute_on << std::endl;
145 console << "[DBG] Ordering of the kernels on each block they are defined on:" << std::endl;
146 // TODO Check that all objects are active at this point
147 console << _storage.activeObjectsToFormattedString() << std::endl;
148}
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
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.
bool hasActiveObjects(THREAD_ID tid=0) const
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48

◆ subdomainChanged()

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

Definition at line 44 of file ComputeNodalAuxVarsThread.C.

45{
46 std::set<TagID> needed_vector_tags;
47 std::set<TagID> needed_matrix_tags;
48
49 const auto & block_kernels = _storage.getActiveBlockObjects(_tid);
50
51 for (const auto & block : _block_ids)
52 {
53 const auto iter = block_kernels.find(block);
54
55 if (iter != block_kernels.end())
56 for (const auto & aux : iter->second)
57 {
58 auto & matrix_tags = aux->getFEVariableCoupleableMatrixTags();
59 needed_matrix_tags.insert(matrix_tags.begin(), matrix_tags.end());
60 auto & vector_tags = aux->getFEVariableCoupleableVectorTags();
61 needed_vector_tags.insert(vector_tags.begin(), vector_tags.end());
62 }
63 }
64
67}
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid) override
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override

Member Data Documentation

◆ _aux_sys

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

Definition at line 46 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

Definition at line 72 of file ThreadedNodeLoop.h.

◆ _storage

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

Storage object containing active AuxKernel objects.

Definition at line 49 of file ComputeNodalAuxVarsThread.h.

◆ _tid

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

Definition at line 73 of file ThreadedNodeLoop.h.

◆ writable_variable_mutex

template<typename AuxKernelType >
Threads::spin_mutex ComputeNodalAuxVarsThread< AuxKernelType >::writable_variable_mutex
staticprotected

Definition at line 53 of file ComputeNodalAuxVarsThread.h.


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