www.mooseframework.org
Public 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 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 24 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 }
nl system()
X_global swap(X_sys)
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 }
static PetscErrorCode Vec x
std::vector< unsigned int > _var_nums
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 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 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 66 of file ThreadedNodeLoop.h.

66 { 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

◆ 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 ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::post ( )
virtualinherited

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread.

Definition at line 123 of file ThreadedNodeLoop.h.

124 {
125 }

◆ 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 }

◆ send_list()

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

Definition at line 95 of file AllNodesSendListThread.C.

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.

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 55 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 55 of file AllNodesSendListThread.h.

◆ _ref_mesh

const MooseMesh& AllNodesSendListThread::_ref_mesh
protected

Definition at line 46 of file AllNodesSendListThread.h.

◆ _send_list

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

Definition at line 57 of file AllNodesSendListThread.h.

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

◆ _system

const System& AllNodesSendListThread::_system
private

Definition at line 51 of file AllNodesSendListThread.h.

◆ _system_number

const unsigned int AllNodesSendListThread::_system_number
private

Definition at line 53 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 49 of file AllNodesSendListThread.h.

Referenced by AllNodesSendListThread(), and onNode().


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