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("componentName(): Component index is not less than the number of components");
31  if (isArray())
32  return this->arrayVariableComponent(comp);
33  else
34  return name();
35 }
36 
37 const std::set<SubdomainID> &
39 {
40  return this->_sys.system().variable(_var_num).active_subdomains();
41 }
42 
43 bool
45 {
46  return this->_sys.system().variable(_var_num).active_on_subdomain(subdomain);
47 }
48 
49 bool
50 MooseVariableFieldBase::activeOnSubdomains(const std::set<SubdomainID> & subdomains) const
51 {
52  const auto & active_subs = activeSubdomains();
53  return std::includes(
54  active_subs.begin(), active_subs.end(), subdomains.begin(), subdomains.end());
55 }
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...
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:99
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 and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
bool activeOnSubdomain(SubdomainID subdomain) const
Is the variable active on the subdomain?
Base variable class.