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

#include <AllNodesSendListThread.h>

Inheritance diagram for AllNodesSendListThread:
[legend]

Public Member Functions

 AllNodesSendListThread (FEProblemBase &fe_problem, const MooseMesh &mesh, const std::vector< unsigned int > &var_nums, const System &system)
 
 AllNodesSendListThread (AllNodesSendListThread &x, Threads::split split)
 
virtual void onNode (ConstNodeRange::const_iterator &nd) override
 Called for each node. More...
 
void join (const AllNodesSendListThread &y)
 
void unique ()
 
const std::vector< dof_id_type > & send_list () const
 
void operator() (const ConstNodeRange &range)
 
virtual void pre ()
 Called before the node range loop. More...
 
virtual void post ()
 Called after 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 Member Functions

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

Protected Attributes

const MooseMesh_ref_mesh
 
FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Private Attributes

std::vector< unsigned int_var_nums
 
const System & _system
 
const unsigned int _system_number
 
const dof_id_type _first_dof
 
const dof_id_type _end_dof
 
std::vector< dof_id_type_send_list
 

Detailed Description

Definition at line 23 of file AllNodesSendListThread.h.

Constructor & Destructor Documentation

◆ AllNodesSendListThread() [1/2]

AllNodesSendListThread::AllNodesSendListThread ( FEProblemBase fe_problem,
const MooseMesh mesh,
const std::vector< unsigned int > &  var_nums,
const System &  system 
)

Definition at line 15 of file AllNodesSendListThread.C.

20  _ref_mesh(mesh),
21  _var_nums(var_nums),
22  _system(system),
23  _system_number(_system.number()),
24  _first_dof(_system.get_dof_map().first_dof()),
25  _end_dof(_system.get_dof_map().end_dof()),
26  _send_list()
27 {
28  // We may use the same _var_num multiple times, but it's inefficient
29  // to examine it multiple times.
30  std::sort(this->_var_nums.begin(), this->_var_nums.end());
31 
32  std::vector<unsigned int>::iterator new_end =
33  std::unique(this->_var_nums.begin(), this->_var_nums.end());
34 
35  std::vector<unsigned int>(this->_var_nums.begin(), new_end).swap(this->_var_nums);
36 }
void swap(std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator &comm)
Swap function for serial or distributed vector of data.
Definition: Shuffle.h:494
std::vector< unsigned int > _var_nums
const unsigned int _system_number
std::vector< dof_id_type > _send_list

◆ AllNodesSendListThread() [2/2]

AllNodesSendListThread::AllNodesSendListThread ( AllNodesSendListThread x,
Threads::split  split 
)

Definition at line 38 of file AllNodesSendListThread.C.

40  _ref_mesh(x._ref_mesh),
41  _var_nums(x._var_nums),
42  _system(x._system),
43  _system_number(_system.number()),
44  _first_dof(_system.get_dof_map().first_dof()),
45  _end_dof(_system.get_dof_map().end_dof()),
46  _send_list()
47 {
48 }
std::vector< unsigned int > _var_nums
tbb::split split
const unsigned int _system_number
std::vector< dof_id_type > _send_list

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  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
static Threads::spin_mutex threaded_node_mutex

◆ join()

void AllNodesSendListThread::join ( const AllNodesSendListThread y)

Definition at line 67 of file AllNodesSendListThread.C.

68 {
69  // Joining simply requires I add the dof indices from the other object
70  this->_send_list.insert(this->_send_list.end(), y._send_list.begin(), y._send_list.end());
71 }
std::vector< dof_id_type > _send_list

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

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

Called for each node.

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

Definition at line 51 of file AllNodesSendListThread.C.

52 {
53  const Node & node = *(*nd);
54 
55  for (unsigned int i = 0; i < _var_nums.size(); i++)
56  {
57  if (node.n_dofs(_system_number, _var_nums[i]) > 0)
58  {
59  const dof_id_type id = node.dof_number(_system_number, _var_nums[i], 0);
60  if (id < _first_dof || id >= _end_dof)
61  this->_send_list.push_back(id);
62  }
63  }
64 }
std::vector< unsigned int > _var_nums
const unsigned int _system_number
std::vector< dof_id_type > _send_list
uint8_t dof_id_type

◆ operator()()

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

Definition at line 94 of file ThreadedNodeLoop.h.

95 {
96  try
97  {
98  ParallelUniqueId puid;
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 }
virtual void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
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 ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::post ( )
virtualinherited

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread< AuxKernelType >.

Definition at line 130 of file ThreadedNodeLoop.h.

131 {
132 }

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

125 {
126 }

◆ printGeneralExecutionInformation()

virtual void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::printGeneralExecutionInformation ( ) const
inlineprotectedvirtualinherited

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

Reimplemented in ComputeNodalKernelJacobiansThread, ComputeNodalAuxVarsThread< AuxKernelType >, ComputeNodalDampingThread, ComputeNodalKernelsThread, and ComputeNodalUserObjectsThread.

Definition at line 76 of file ThreadedNodeLoop.h.

76 {}

◆ send_list()

const std::vector< dof_id_type > & AllNodesSendListThread::send_list ( ) const

Definition at line 95 of file AllNodesSendListThread.C.

Referenced by UpdateDisplacedMeshThread::init().

96 {
97  return this->_send_list;
98 }
std::vector< dof_id_type > _send_list

◆ unique()

void AllNodesSendListThread::unique ( )

Definition at line 74 of file AllNodesSendListThread.C.

Referenced by UpdateDisplacedMeshThread::init().

75 {
76  // Sort the send list. After this duplicated
77  // elements will be adjacent in the vector
78  std::sort(this->_send_list.begin(), this->_send_list.end());
79 
80  // Now use std::unique to remove any duplicate entries. There
81  // actually shouldn't be any, since we're hitting each node exactly
82  // once and we pre-uniqued _var_nums.
83  // std::vector<dof_id_type>::iterator new_end =
84  // std::unique (this->_send_list.begin(),
85  // this->_send_list.end());
86 
87  // If we *do* need to remove duplicate entries, then afterward we should
88  // remove the end of the send_list, using the "swap trick" from Effective
89  // STL.
90  // std::vector<dof_id_type>
91  // (this->_send_list.begin(), new_end).swap (this->_send_list);
92 }
std::vector< dof_id_type > _send_list

Member Data Documentation

◆ _end_dof

const dof_id_type AllNodesSendListThread::_end_dof
private

Definition at line 54 of file AllNodesSendListThread.h.

Referenced by onNode().

◆ _fe_problem

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

◆ _first_dof

const dof_id_type AllNodesSendListThread::_first_dof
private

Definition at line 54 of file AllNodesSendListThread.h.

◆ _ref_mesh

const MooseMesh& AllNodesSendListThread::_ref_mesh
protected

Definition at line 45 of file AllNodesSendListThread.h.

◆ _send_list

std::vector<dof_id_type> AllNodesSendListThread::_send_list
private

Definition at line 56 of file AllNodesSendListThread.h.

Referenced by join(), onNode(), send_list(), and unique().

◆ _system

const System& AllNodesSendListThread::_system
private

Definition at line 50 of file AllNodesSendListThread.h.

◆ _system_number

const unsigned int AllNodesSendListThread::_system_number
private

Definition at line 52 of file AllNodesSendListThread.h.

Referenced by onNode().

◆ _tid

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

◆ _var_nums

std::vector<unsigned int> AllNodesSendListThread::_var_nums
private

Definition at line 48 of file AllNodesSendListThread.h.

Referenced by AllNodesSendListThread(), and onNode().


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