https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AllNodesSendListThread.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11#include "MooseMesh.h"
12
13#include "libmesh/dof_map.h"
14
16 const MooseMesh & mesh,
17 const std::vector<unsigned int> & var_nums,
18 const libMesh::System & system)
19 : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
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}
37
39 : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
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}
49
50void
51AllNodesSendListThread::onNode(ConstNodeRange::const_iterator & nd)
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}
65
66void
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}
72
73void
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}
93
94const std::vector<dof_id_type> &
96{
97 return this->_send_list;
98}
virtual void onNode(ConstNodeRange::const_iterator &nd) override
AllNodesSendListThread(FEProblemBase &fe_problem, const MooseMesh &mesh, const std::vector< unsigned int > &var_nums, const libMesh::System &system)
std::vector< unsigned int > _var_nums
const unsigned int _system_number
std::vector< dof_id_type > _send_list
const std::vector< dof_id_type > & send_list() const
void join(const AllNodesSendListThread &y)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
MeshBase & mesh