www.mooseframework.org
MooseVariableDependencyInterface.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
68 protected:
74  {
75  _moose_variable_dependencies.insert(var);
76  }
77  void addMooseVariableDependency(const std::vector<MooseVariableFieldBase *> & vars)
78  {
79  _moose_variable_dependencies.insert(vars.begin(), vars.end());
80  }
81 
82 private:
83  std::set<MooseVariableFieldBase *> _moose_variable_dependencies;
84 
86  std::vector<libMesh::dof_id_type> _dof_indices;
87 };
88 
89 template <typename DofObjectType>
90 std::set<MooseVariableFieldBase *>
92  const DofObjectType & dof_object, const std::set<MooseVariableFieldBase *> & vars_to_omit)
93 {
94  if (vars_to_omit.empty())
95  return checkVariables(dof_object, _moose_variable_dependencies);
96 
97  std::set<MooseVariableFieldBase *> vars_to_check;
98  std::set_difference(_moose_variable_dependencies.begin(),
100  vars_to_omit.begin(),
101  vars_to_omit.end(),
102  std::inserter(vars_to_check, vars_to_check.begin()));
103  return checkVariables(dof_object, vars_to_check);
104 }
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
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:33
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.