www.mooseframework.org
AllNodesSendListThread.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "AllNodesSendListThread.h"
16 #include "MooseMesh.h"
17 
18 #include "libmesh/dof_map.h"
19 
21  const MooseMesh & mesh,
22  const std::vector<unsigned int> & var_nums,
23  const System & system)
24  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
25  _ref_mesh(mesh),
26  _var_nums(var_nums),
27  _system(system),
28  _system_number(_system.number()),
29  _first_dof(_system.get_dof_map().first_dof()),
30  _end_dof(_system.get_dof_map().end_dof()),
31  _send_list()
32 {
33  // We may use the same _var_num multiple times, but it's inefficient
34  // to examine it multiple times.
35  std::sort(this->_var_nums.begin(), this->_var_nums.end());
36 
37  std::vector<unsigned int>::iterator new_end =
38  std::unique(this->_var_nums.begin(), this->_var_nums.end());
39 
40  std::vector<unsigned int>(this->_var_nums.begin(), new_end).swap(this->_var_nums);
41 }
42 
44  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
47  _system(x._system),
48  _system_number(_system.number()),
49  _first_dof(_system.get_dof_map().first_dof()),
50  _end_dof(_system.get_dof_map().end_dof()),
51  _send_list()
52 {
53 }
54 
55 void
56 AllNodesSendListThread::onNode(ConstNodeRange::const_iterator & nd)
57 {
58  const Node & node = *(*nd);
59 
60  for (unsigned int i = 0; i < _var_nums.size(); i++)
61  {
62  if (node.n_dofs(_system_number, _var_nums[i]) > 0)
63  {
64  const dof_id_type id = node.dof_number(_system_number, _var_nums[i], 0);
65  if (id < _first_dof || id >= _end_dof)
66  this->_send_list.push_back(id);
67  }
68  }
69 }
70 
71 void
73 {
74  // Joining simply requires I add the dof indices from the other object
75  this->_send_list.insert(this->_send_list.end(), y._send_list.begin(), y._send_list.end());
76 }
77 
78 void
80 {
81  // Sort the send list. After this duplicated
82  // elements will be adjacent in the vector
83  std::sort(this->_send_list.begin(), this->_send_list.end());
84 
85  // Now use std::unique to remove any duplicate entries. There
86  // actually shouldn't be any, since we're hitting each node exactly
87  // once and we pre-uniqued _var_nums.
88  // std::vector<dof_id_type>::iterator new_end =
89  // std::unique (this->_send_list.begin(),
90  // this->_send_list.end());
91 
92  // If we *do* need to remove duplicate entries, then afterward we should
93  // remove the end of the send_list, using the "swap trick" from Effective
94  // STL.
95  // std::vector<dof_id_type>
96  // (this->_send_list.begin(), new_end).swap (this->_send_list);
97 }
98 
99 const std::vector<dof_id_type> &
101 {
102  return this->_send_list;
103 }
AllNodesSendListThread(FEProblemBase &fe_problem, const MooseMesh &mesh, const std::vector< unsigned int > &var_nums, const System &system)
static PetscErrorCode Vec x
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void onNode(ConstNodeRange::const_iterator &nd) override
Called for each node.
nl system()
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
X_global swap(X_sys)
std::vector< unsigned int > _var_nums
const unsigned int _system_number
void join(const AllNodesSendListThread &y)
std::vector< dof_id_type > _send_list
const std::vector< dof_id_type > & send_list() const