https://mooseframework.inl.gov
MooseVariableFieldBase.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 
10 #include "MooseVariableFieldBase.h"
11 #include "SubProblem.h"
12 #include "SystemBase.h"
13 #include "libmesh/system.h"
14 
17 {
19 }
20 
22  : MooseVariableBase(parameters)
23 {
24 }
25 
26 const std::string &
27 MooseVariableFieldBase::componentName(const unsigned int comp) const
28 {
29  if (comp >= _count)
30  mooseError("Component index must be less than the number of components of variable ",
31  _var_name);
32  if (isArray())
33  return this->arrayVariableComponent(comp);
34  else
35  return _var_name;
36 }
37 
38 const std::set<SubdomainID> &
40 {
41  return this->_sys.system().variable(_var_num).active_subdomains();
42 }
43 
44 bool
46 {
47  return this->_sys.system().variable(_var_num).active_on_subdomain(subdomain);
48 }
49 
50 bool
51 MooseVariableFieldBase::activeOnSubdomains(const std::set<SubdomainID> & subdomains) const
52 {
53  const auto & active_subs = activeSubdomains();
54  return std::includes(
55  active_subs.begin(), active_subs.end(), subdomains.begin(), subdomains.end());
56 }
static InputParameters validParams()
static InputParameters validParams()
const Variable & variable(unsigned int var) const
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string _var_name
Variable name.
const std::set< subdomain_id_type > & active_subdomains() const
bool activeOnSubdomains(const std::set< SubdomainID > &subdomains) const
Is the variable active on the subdomains?
SystemBase & _sys
System this variable is part of.
virtual bool isArray() const
const unsigned int _count
Number of variables in the array.
bool active_on_subdomain(subdomain_id_type sid) const
MooseVariableFieldBase(const InputParameters &parameters)
const std::string & componentName(const unsigned int comp) const
Get the variable name of a component in libMesh.
const std::set< SubdomainID > & activeSubdomains() const
The subdomains the variable is active on.
unsigned int _var_num
variable number (from libMesh)
const std::string & arrayVariableComponent(const unsigned int i) const
Returns the variable name of a component of an array variable.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
bool activeOnSubdomain(SubdomainID subdomain) const
Is the variable active on the subdomain?