www.mooseframework.org
AllLocalDofIndicesThread.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 
16 
17 #include "FEProblem.h"
18 #include "ParallelUniqueId.h"
19 
20 #include "libmesh/dof_map.h"
21 #include "libmesh/threads.h"
22 #include "libmesh/system.h"
23 #include LIBMESH_INCLUDE_UNORDERED_SET
24 LIBMESH_DEFINE_HASH_POINTERS
25 
26 AllLocalDofIndicesThread::AllLocalDofIndicesThread(System & sys, std::vector<std::string> vars)
27  : _sys(sys), _dof_map(sys.get_dof_map()), _vars(vars)
28 {
29  _var_numbers.resize(_vars.size());
30  for (unsigned int i = 0; i < _vars.size(); i++)
31  _var_numbers[i] = _sys.variable_number(_vars[i]);
32 }
33 
34 // Splitting Constructor
36  Threads::split /*split*/)
38 {
39 }
40 
41 void
42 AllLocalDofIndicesThread::operator()(const ConstElemRange & range)
43 {
44  ParallelUniqueId puid;
45  _tid = puid.id;
46 
47  for (const auto & elem : range)
48  {
49  std::vector<dof_id_type> dof_indices;
50 
51  dof_id_type local_dof_begin = _dof_map.first_dof();
52  dof_id_type local_dof_end = _dof_map.end_dof();
53 
54  // prepare variables
55  for (unsigned int i = 0; i < _var_numbers.size(); i++)
56  {
57  _dof_map.dof_indices(elem, dof_indices, _var_numbers[i]);
58  for (unsigned int j = 0; j < dof_indices.size(); j++)
59  {
60  dof_id_type dof = dof_indices[j];
61 
62  if (dof >= local_dof_begin && dof < local_dof_end)
63  _all_dof_indices.insert(dof_indices[j]);
64  }
65  }
66  }
67 }
68 
69 void
71 {
72  _all_dof_indices.insert(y._all_dof_indices.begin(), y._all_dof_indices.end());
73 }
void operator()(const ConstElemRange &range)
std::vector< unsigned int > _var_numbers
AllLocalDofIndicesThread(System &sys, std::vector< std::string > vars)
void join(const AllLocalDofIndicesThread &y)
static PetscErrorCode Vec x
Grab all the local dof indices for the variables passed in, in the system passed in.
std::set< dof_id_type > _all_dof_indices
std::vector< std::string > _vars