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])
140 addJacobian(_undisplaced_assembly,
146template <
typename T,
typename Base>
150 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
151 if (dof_indices.empty())
156 addResidual(residual, dof_indices);
159template <
typename T,
typename Base>
163 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
164 if (dof_indices.empty())
167 const auto residual = computeQpResidual();
169 addJacobian(residual, dof_indices);
172template <
typename T,
typename Base>
176 const std::vector<dof_id_type> & dof_indices = _var.dofIndices();
177 if (dof_indices.empty())
180 const auto residual = computeQpResidual();
183 addJacobian(residual, dof_indices);
186template <
typename T,
typename Base>
191 if (jvar_num == _var.number())
195template <
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)