22#include "libmesh/quadrature.h"
24template <
typename T,
typename Base>
28 return Base::validParams();
37 params.
addParam<
bool>(
"set_x_comp",
true,
"Whether to set the x-component of the variable");
38 params.
addParam<
bool>(
"set_y_comp",
true,
"Whether to set the y-component of the variable");
39 params.
addParam<
bool>(
"set_z_comp",
true,
"Whether to set the z-component of the variable");
49 params.
addParam<
bool>(
"set_x_comp",
true,
"Whether to set the x-component of the variable");
50 params.
addParam<
bool>(
"set_y_comp",
true,
"Whether to set the y-component of the variable");
51 params.
addParam<
bool>(
"set_z_comp",
true,
"Whether to set the z-component of the variable");
55template <
typename T,
typename Base>
62 std::is_same_v<T, Real> ?
Moose::VarFieldType::VAR_FIELD_STANDARD
63 :
std::is_same_v<T, RealVectorValue>
64 ?
Moose::VarFieldType::VAR_FIELD_VECTOR
65 :
Moose::VarFieldType::VAR_FIELD_ARRAY),
67 _var(*this->mooseVariable()),
68 _current_node(_var.node()),
69 _u(_var.adNodalValue()),
70 _undisplaced_assembly(_fe_problem.assembly(_tid, _sys.number()))
72 if constexpr (std::is_same_v<T, RealVectorValue>)
75 _set_components[0] = this->
template getParam<bool>(
"set_x_comp");
76 _set_components[1] = this->
template getParam<bool>(
"set_y_comp");
77 _set_components[2] = this->
template getParam<bool>(
"set_z_comp");
80 _set_components.resize(_var.count(),
true);
82 _subproblem.haveADObjects(
true);
84 addMooseVariableDependency(this->mooseVariable());
91conversionHelper(
const T & value,
const unsigned int)
98conversionHelper(
const VectorValue<T> & value,
const unsigned int i)
105conversionHelper(
const Eigen::Matrix<T, Eigen::Dynamic, 1> & value,
const unsigned int i)
111template <
typename T,
typename Base>
114 const std::vector<dof_id_type> & dof_indices)
116 mooseAssert(dof_indices.size() <= _set_components.size(),
117 "The number of dof indices must be less than the number of settable components");
119 for (
const auto i : index_range(dof_indices))
120 if (_set_components[i])
121 setResidual(_sys, conversionHelper(residual, i), dof_indices[i]);
124template <
typename T,
typename Base>
125template <
typename ADRes
idual>
128 const std::vector<dof_id_type> & dof_indices)
130 mooseAssert(dof_indices.size() <= _set_components.size(),
131 "The number of dof indices must be less than the number of settable components");
132 if (!std::is_same_v<T, RealVectorValue>)
133 mooseAssert(dof_indices.size() == _var.count(),
134 "The number of dof indices should match the variable count");
136 for (
const auto i : index_range(dof_indices))
137 if (_set_components[i])
141 this->addJacobianWithoutConstraints(_undisplaced_assembly,
147template <
typename T,
typename Base>
151 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
152 if (dof_indices.empty())
157 addResidual(residual, dof_indices);
160template <
typename T,
typename Base>
164 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
165 if (dof_indices.empty())
168 const auto residual = computeQpResidual();
170 addJacobian(residual, dof_indices);
173template <
typename T,
typename Base>
177 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
178 if (dof_indices.empty())
181 const auto residual = computeQpResidual();
184 addJacobian(residual, dof_indices);
187template <
typename T,
typename Base>
192 if (jvar_num == _var.number())
196template <
typename T,
typename Base>
static InputParameters validParams()
An interface for accessing Moose::Functors for systems that care about automatic differentiation,...
Base class for deriving any automatic differentiation boundary condition of a integrated type.
static InputParameters validParams()
void computeJacobian() override final
void computeResidual() override final
void computeOffDiagJacobian(unsigned int jvar) override final
void computeOffDiagJacobianScalar(unsigned int jvar) override final
void addResidual(const T &residual, const std::vector< dof_id_type > &dof_indices)
process the residual into the global data structures
ADNodalBCTempl(const InputParameters ¶meters)
void addJacobian(const ADResidual &residual, const std::vector< dof_id_type > &dof_indices)
process the Jacobian into the global data structures
void computeResidualAndJacobian() override
Interface for objects that need to get values of MooseVariables.
Replacement for std::span which we only get in c++20.
static InputParameters validParams()
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)