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

Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in. More...

#include <AllLocalDofIndicesThread.h>

Inheritance diagram for AllLocalDofIndicesThread:
[legend]

Public Member Functions

 AllLocalDofIndicesThread (SubProblem &problem, std::vector< std::string > vars, bool include_semilocal=false)
 
 AllLocalDofIndicesThread (AllLocalDofIndicesThread &x, Threads::split split)
 
void operator() (const ConstElemRange &range)
 
void join (const AllLocalDofIndicesThread &y)
 
const std::set< dof_id_type > & getDofIndices () const
 
void dofIndicesSetUnion ()
 

Protected Attributes

SubProblem_problem
 
System * _sys
 
std::vector< unsigned int_var_numbers
 
const bool _include_semilocal
 Whether to include semilocal dof indices. More...
 
THREAD_ID _tid
 
std::set< dof_id_type_all_dof_indices
 

Detailed Description

Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in.

Definition at line 30 of file AllLocalDofIndicesThread.h.

Constructor & Destructor Documentation

◆ AllLocalDofIndicesThread() [1/2]

LIBMESH_DEFINE_HASH_POINTERS AllLocalDofIndicesThread::AllLocalDofIndicesThread ( SubProblem problem,
std::vector< std::string >  vars,
bool  include_semilocal = false 
)

Definition at line 26 of file AllLocalDofIndicesThread.C.

29  : ParallelObject(problem.comm()),
30  _problem(problem),
31  _sys(nullptr),
32  _include_semilocal(include_semilocal)
33 {
34  for (unsigned int i = 0; i < vars.size(); i++)
35  {
36  auto & var = _problem.getVariable(0, vars[i]);
37  if (_sys)
38  {
39  if (_sys != &var.sys().system())
40  mooseError("Variables passed in AllLocalDofIndicesThread must be all in the same system.");
41  }
42  else
43  _sys = &var.sys().system();
44 
45  if (var.isArray())
46  {
47  const auto & array_var = _problem.getArrayVariable(0, vars[i]);
48  for (unsigned int p = 0; p < var.count(); ++p)
49  _var_numbers.push_back(_sys->variable_number(array_var.componentName(p)));
50  }
51  else
52  _var_numbers.push_back(_sys->variable_number(vars[i]));
53  }
54 }
std::vector< unsigned int > _var_numbers
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
const Parallel::Communicator & comm() const
virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested ArrayMooseVariable which may be in any system...
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
const bool _include_semilocal
Whether to include semilocal dof indices.

◆ AllLocalDofIndicesThread() [2/2]

AllLocalDofIndicesThread::AllLocalDofIndicesThread ( AllLocalDofIndicesThread x,
Threads::split  split 
)

Definition at line 57 of file AllLocalDofIndicesThread.C.

59  : ParallelObject(x._problem.comm()),
60  _problem(x._problem),
61  _sys(x._sys),
64 {
65 }
std::vector< unsigned int > _var_numbers
const Parallel::Communicator & comm() const
const bool _include_semilocal
Whether to include semilocal dof indices.

Member Function Documentation

◆ dofIndicesSetUnion()

void AllLocalDofIndicesThread::dofIndicesSetUnion ( )

Definition at line 105 of file AllLocalDofIndicesThread.C.

106 {
107  _communicator.set_union(_all_dof_indices);
108 }
std::set< dof_id_type > _all_dof_indices

◆ getDofIndices()

const std::set<dof_id_type>& AllLocalDofIndicesThread::getDofIndices ( ) const
inline

◆ join()

void AllLocalDofIndicesThread::join ( const AllLocalDofIndicesThread y)

Definition at line 99 of file AllLocalDofIndicesThread.C.

100 {
101  _all_dof_indices.insert(y._all_dof_indices.begin(), y._all_dof_indices.end());
102 }
std::set< dof_id_type > _all_dof_indices

◆ operator()()

void AllLocalDofIndicesThread::operator() ( const ConstElemRange range)

Definition at line 68 of file AllLocalDofIndicesThread.C.

69 {
70  ParallelUniqueId puid;
71  _tid = puid.id;
72 
73  mooseAssert(_sys, "We should have a system, did you forget to specify any variable in vars?");
74  auto & dof_map = _sys->get_dof_map();
75 
76  for (const auto & elem : range)
77  {
78  std::vector<dof_id_type> dof_indices;
79 
80  dof_id_type local_dof_begin = dof_map.first_dof();
81  dof_id_type local_dof_end = dof_map.end_dof();
82 
83  // prepare variables
84  for (unsigned int i = 0; i < _var_numbers.size(); i++)
85  {
86  dof_map.dof_indices(elem, dof_indices, _var_numbers[i]);
87  for (unsigned int j = 0; j < dof_indices.size(); j++)
88  {
89  dof_id_type dof = dof_indices[j];
90 
91  if (_include_semilocal || (dof >= local_dof_begin && dof < local_dof_end))
92  _all_dof_indices.insert(dof);
93  }
94  }
95  }
96 }
std::vector< unsigned int > _var_numbers
std::set< dof_id_type > _all_dof_indices
const bool _include_semilocal
Whether to include semilocal dof indices.
uint8_t dof_id_type

Member Data Documentation

◆ _all_dof_indices

std::set<dof_id_type> AllLocalDofIndicesThread::_all_dof_indices
protected

Definition at line 57 of file AllLocalDofIndicesThread.h.

Referenced by dofIndicesSetUnion(), getDofIndices(), join(), and operator()().

◆ _include_semilocal

const bool AllLocalDofIndicesThread::_include_semilocal
protected

Whether to include semilocal dof indices.

Definition at line 53 of file AllLocalDofIndicesThread.h.

Referenced by operator()().

◆ _problem

SubProblem& AllLocalDofIndicesThread::_problem
protected

Definition at line 48 of file AllLocalDofIndicesThread.h.

Referenced by AllLocalDofIndicesThread().

◆ _sys

System* AllLocalDofIndicesThread::_sys
protected

Definition at line 49 of file AllLocalDofIndicesThread.h.

Referenced by AllLocalDofIndicesThread(), and operator()().

◆ _tid

THREAD_ID AllLocalDofIndicesThread::_tid
protected

Definition at line 55 of file AllLocalDofIndicesThread.h.

Referenced by operator()().

◆ _var_numbers

std::vector<unsigned int> AllLocalDofIndicesThread::_var_numbers
protected

Definition at line 50 of file AllLocalDofIndicesThread.h.

Referenced by AllLocalDofIndicesThread(), and operator()().


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