22 #include "libmesh/quadrature.h" 24 template <
typename T,
typename Base>
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");
55 template <
typename T,
typename Base>
65 _var(*this->mooseVariable()),
66 _current_node(_var.node()),
67 _u(_var.adNodalValue()),
69 {std::is_same<T, RealVectorValue>::value ? this->
template getParam<bool>(
"set_x_comp")
71 std::is_same<T, RealVectorValue>::value ? this->
template getParam<bool>(
"set_y_comp")
73 std::is_same<T, RealVectorValue>::value ? this->
template getParam<bool>(
"set_z_comp")
75 _undisplaced_assembly(_fe_problem.assembly(_tid, _sys.number()))
77 _subproblem.haveADObjects(
true);
79 addMooseVariableDependency(this->mooseVariable());
85 conversionHelper(
const ADReal & value,
const unsigned int)
97 template <
typename T,
typename Base>
98 template <
typename ADRes
idual>
101 const std::vector<dof_id_type> & dof_indices)
103 mooseAssert(dof_indices.size() <= _set_components.size(),
104 "The number of dof indices must be less than the number of settable components");
107 if (_set_components[i])
108 setResidual(_sys,
raw_value(conversionHelper(residual, i)), dof_indices[i]);
111 template <
typename T,
typename Base>
112 template <
typename ADRes
idual>
115 const std::vector<dof_id_type> & dof_indices)
117 mooseAssert(dof_indices.size() <= _set_components.size(),
118 "The number of dof indices must be less than the number of settable components");
121 if (_set_components[i])
124 addJacobian(_undisplaced_assembly,
125 std::array<ADReal, 1>{{conversionHelper(residual, i)}},
126 std::array<dof_id_type, 1>{{dof_indices[i]}},
130 template <
typename T,
typename Base>
134 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
135 if (dof_indices.empty())
138 const auto residual = computeQpResidual();
140 addResidual(residual, dof_indices);
143 template <
typename T,
typename Base>
147 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
148 if (dof_indices.empty())
151 const auto residual = computeQpResidual();
153 addJacobian(residual, dof_indices);
156 template <
typename T,
typename Base>
160 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
161 if (dof_indices.empty())
164 const auto residual = computeQpResidual();
166 addResidual(residual, dof_indices);
167 addJacobian(residual, dof_indices);
170 template <
typename T,
typename Base>
175 if (jvar_num == _var.number())
179 template <
typename T,
typename Base>
void addJacobian(const ADResidual &residual, const std::vector< dof_id_type > &dof_indices)
process the Jacobian into the global data structures
void computeResidualAndJacobian() override
Base class for deriving any automatic differentiation boundary condition of a integrated type...
void computeJacobian() override final
ADNodalBCTempl(const InputParameters ¶meters)
DualNumber< Real, DNDerivativeType, true > ADReal
InputParameters validParams()
An interface for accessing Moose::Functors for systems that care about automatic differentiation, e.g.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
VarKindType
Framework-wide stuff.
void computeOffDiagJacobian(unsigned int jvar) override final
static InputParameters validParams()
static InputParameters validParams()
void computeResidual() override final
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void computeOffDiagJacobianScalar(unsigned int jvar) override final
Interface for objects that need to get values of MooseVariables.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
void addResidual(const ADResidual &residual, const std::vector< dof_id_type > &dof_indices)
process the residual into the global data structures
auto index_range(const T &sizable)
static InputParameters validParams()