20 #include "libmesh/variable.h" 21 #include "libmesh/dof_map.h" 22 #include "libmesh/system.h" 23 #include "libmesh/fe_type.h" 24 #include "libmesh/string_to_enum.h" 37 "CONSTANT FIRST SECOND THIRD FOURTH FIFTH SIXTH SEVENTH EIGHTH NINTH TENTH ELEVENTH TWELFTH " 38 "THIRTEENTH FOURTEENTH FIFTEENTH SIXTEENTH SEVENTEENTH EIGHTTEENTH NINETEENTH TWENTIETH " 39 "TWENTYFIRST TWENTYSECOND TWENTYTHIRD TWENTYFOURTH TWENTYFIFTH TWENTYSIXTH TWENTYSEVENTH " 40 "TWENTYEIGHTH TWENTYNINTH THIRTIETH THIRTYFIRST THIRTYSECOND THIRTYTHIRD THIRTYFOURTH " 41 "THIRTYFIFTH THIRTYSIXTH THIRTYSEVENTH THIRTYEIGHTH THIRTYNINTH FORTIETH FORTYFIRST " 42 "FORTYSECOND FORTYTHIRD",
47 "Order of the FE shape function to use for this variable (additional " 48 "orders not listed here are allowed, depending on the family).");
53 "family", family,
"Specifies the family of FE shape functions to use for this variable.");
57 "components", 1,
"components>0",
"Number of components for an array variable");
60 params.
addParam<std::vector<Real>>(
"scaling",
61 "Specifies a scaling factor to apply to this variable");
62 params.
addParam<
bool>(
"eigen",
false,
"True to make this variable an eigen variable");
63 params.
addParam<
bool>(
"fv",
false,
"True to make this variable a finite volume variable");
66 "True to make this variable a array variable regardless of number of " 67 "components. If 'components' > 1, this will automatically be set to true.");
68 params.
addParam<NonlinearSystemName>(
"nl_sys",
70 "If this variable is a nonlinear variable, this is the " 71 "nonlinear system to which it should be added.");
74 params.
addParam<
bool>(
"use_dual",
false,
"True to use dual basis for Lagrange multipliers");
84 "Base class for Moose variables. This should never be the terminal object type");
96 _var_num(getParam<unsigned
int>(
"_var_num")),
97 _is_eigen(getParam<bool>(
"eigen")),
99 _subproblem(_sys.subproblem()),
100 _variable(_sys.system().variable(_var_num)),
101 _assembly(_subproblem.assembly(getParam<
THREAD_ID>(
"_tid"),
103 _dof_map(_sys.dofMap()),
104 _mesh(_subproblem.
mesh()),
106 _count(getParam<unsigned
int>(
"components")),
107 _scaling_factor(_count, 1.0),
108 _use_dual(getParam<bool>(
"use_dual")),
109 _is_array(getParam<bool>(
"array"))
112 : std::vector<Real>(
_count, 1.));
113 if (getParam<bool>(
"fv") && getParam<bool>(
"eigen"))
114 paramError(
"eigen",
"finite volume (fv=true) variables do not have eigen support");
116 paramError(
"family",
"finite volume (fv=true) variables must be have MONOMIAL family");
117 if (getParam<bool>(
"fv") &&
_fe_type.order != 0)
118 paramError(
"order",
"finite volume (fv=true) variables currently support CONST order only");
120 mooseAssert(
_is_array,
"Must be true with component > 1");
124 std::size_t found = name0.find_last_of(
"_");
125 if (found == std::string::npos)
126 mooseError(
"Error creating ArrayMooseVariable name with base name ", name0);
131 mooseAssert(
_count == 1,
"component size of normal variable (_count) must be one");
140 mooseAssert(!blk_ids.empty(),
"Every variable should have at least one subdomain");
144 for (
auto it = ++blk_ids.begin(); it != blk_ids.end(); ++it)
146 "A user should not specify a mix of lower-dimensional and higher-dimensional " 147 "blocks for a variable");
152 const std::vector<dof_id_type> &
159 mooseError(
"VariableAllDoFMap not prepared for ",
161 " . Check nonlocal coupling requirement for the variable.");
170 std::vector<dof_id_type>
172 unsigned int component)
const 174 std::vector<dof_id_type> new_dof_indices(dof_indices);
178 for (
auto &
id : new_dof_indices)
182 unsigned int n = dof_indices.size();
183 for (
auto &
id : new_dof_indices)
187 return new_dof_indices;
193 mooseAssert(factor.size() ==
_count,
"Inconsistent scaling factor size");
205 [](
const Real element) {
static InputParameters validParams()
virtual bool isNodal() const
Is this variable nodal.
std::vector< dof_id_type > componentDofIndices(const std::vector< dof_id_type > &dof_indices, unsigned int component) const
Obtain DoF indices of a component with the indices of the 0th component.
FEType _fe_type
The FEType associated with this variable.
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
static InputParameters validParams()
bool _is_lower_d
Whether this variable lives on lower dimensional blocks.
A class to provide an common interface to objects requiring "outputs" option.
const std::string & name() const override
Get the variable name.
std::string _var_name
Variable name.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
void addScalingVector()
Add the scaling factor vector to the system.
Base class for a system (of equations)
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
static MooseEnum getNonlinearVariableFamilies()
Get the possible variable families.
bool isLowerD(const SubdomainID subdomain_id) const
static InputParameters validParams()
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
registerMooseObject("MooseApp", MooseVariableBase)
SubProblem & _subproblem
Problem this variable is part of.
Every object that can be built by the factory should be derived from this class.
SystemBase & _sys
System this variable is part of.
T string_to_enum(const std::string &s)
VarKindType
Framework-wide stuff.
std::vector< Real > _scaling_factor
scaling factor for this variable
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Moose::VarKindType _var_kind
Variable type (see MooseTypes.h)
Real scalingFactor() const
Get the scaling factor for this variable.
virtual void automaticScaling(bool automatic_scaling)
Automatic scaling setter.
virtual SubProblem & subproblem()
const unsigned int _count
Number of variables in the array.
virtual System & system()=0
Get the reference to the libMesh system.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
MooseMesh & _mesh
mesh the variable is active in
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< dof_id_type > & allDofIndices() const
Get all global dofindices for the variable.
unsigned int _var_num
variable number (from libMesh)
An interface that restricts an object to subdomains via the 'blocks' input parameter.
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
static InputParameters validParams()
const bool _is_array
Whether this is an array variable.
void ErrorVector unsigned int
MooseVariableBase(const InputParameters ¶meters)