https://mooseframework.inl.gov
MooseVariableDependencyInterface.h
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 
10 #pragma once
11 
12 #include "libmesh/id_types.h"
13 
14 #include <set>
15 #include <vector>
16 #include <algorithm>
17 
18 class MooseObject;
20 namespace libMesh
21 {
22 class DofObject;
23 }
24 
26 {
27 public:
28  // Must be a pointer in order to disambiguate with default copy constructor
30 
35  const std::set<MooseVariableFieldBase *> & getMooseVariableDependencies() const
36  {
38  }
39 
49  template <typename DofObjectType>
50  std::set<MooseVariableFieldBase *>
51  checkAllVariables(const DofObjectType & dof_object,
52  const std::set<MooseVariableFieldBase *> & vars_to_omit = {});
53 
63  template <typename DofObjectType>
64  std::set<MooseVariableFieldBase *>
65  checkVariables(const DofObjectType & dof_object,
66  const std::set<MooseVariableFieldBase *> & vars_to_check);
67 
73  {
74  _moose_variable_dependencies.insert(var);
75  }
76  void addMooseVariableDependency(const std::vector<MooseVariableFieldBase *> & vars)
77  {
78  _moose_variable_dependencies.insert(vars.begin(), vars.end());
79  }
80 
81 private:
82  std::set<MooseVariableFieldBase *> _moose_variable_dependencies;
83 
85  std::vector<libMesh::dof_id_type> _dof_indices;
86 };
87 
88 template <typename DofObjectType>
89 std::set<MooseVariableFieldBase *>
91  const DofObjectType & dof_object, const std::set<MooseVariableFieldBase *> & vars_to_omit)
92 {
93  if (vars_to_omit.empty())
94  return checkVariables(dof_object, _moose_variable_dependencies);
95 
96  std::set<MooseVariableFieldBase *> vars_to_check;
97  std::set_difference(_moose_variable_dependencies.begin(),
99  vars_to_omit.begin(),
100  vars_to_omit.end(),
101  std::inserter(vars_to_check, vars_to_check.begin()));
102  return checkVariables(dof_object, vars_to_check);
103 }
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
char ** vars
This class provides an interface for common operations on field variables of both FE and FV types wit...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::set< MooseVariableFieldBase * > checkVariables(const DofObjectType &dof_object, const std::set< MooseVariableFieldBase *> &vars_to_check)
Check whether all of the supplied variables have degree of freedom indices on the supplied degree of ...
std::set< MooseVariableFieldBase * > _moose_variable_dependencies
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
void addMooseVariableDependency(const std::vector< MooseVariableFieldBase *> &vars)
std::set< MooseVariableFieldBase * > checkAllVariables(const DofObjectType &dof_object, const std::set< MooseVariableFieldBase *> &vars_to_omit={})
Check whether all of the variable dependencies have degree of freedom indices on the supplied degree ...
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
std::vector< libMesh::dof_id_type > _dof_indices
A container for holding dof indices in order to avoid constant memory reallocation.