20#include "libmesh/system.h"
21#include "libmesh/dof_map.h"
26std::unordered_map<dof_id_type, Real>
33 "This must be a nonlinear system base object");
39 elem = assembly.
elem();
54 std::unordered_map<dof_id_type, Real> ret_val;
56 const System & libmesh_sys = sys.
system();
59 const unsigned int num_vars = libmesh_sys.
n_vars();
63 for (
unsigned int var_num = 0; var_num < num_vars; ++var_num)
65 std::vector<dof_id_type> global_indices;
68 dof_map.dof_indices(elem, global_indices, var_num);
71 const auto ad_offset =
adOffset(var_num, max_dofs_per_elem, elem_type, num_vars);
74 for (MooseIndex(global_indices) local_index = 0; local_index < global_indices.size();
76 ret_val[global_indices[local_index]] = ad_real.derivatives()[ad_offset + local_index];
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Keeps track of stuff related to assembling.
const Elem *const & elem() const
Return the current element.
const Elem *const & neighbor() const
Return the neighbor element.
const Elem *const & lowerDElem() const
Return the lower dimensional element.
Nonlinear system to be solved.
Generic class for solving transient nonlinear problems.
virtual unsigned int currentNlSysNum() const =0
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
Base class for a system (of equations)
unsigned int number() const
Gets the number of this system.
SubProblem & subproblem()
std::size_t getMaxVarNDofsPerElem() const
Gets the maximum number of dofs used by any one variable on any one element.
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
unsigned int n_vars() const
const DofMap & get_dof_map() const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
std::size_t adOffset(unsigned int var_num, std::size_t max_dofs_per_elem, ElementType element_type=ElementType::Element, unsigned int num_vars_in_system=0)
Helper function for computing automatic differentiation offset.
bool doDerivatives(const SubProblem &subproblem, const SystemBase &sys)
std::unordered_map< dof_id_type, Real > globalDofIndexToDerivative(const ADReal &ad_real, const SystemBase &sys, ElementType elem_type=ElementType::Element, THREAD_ID tid=0)
Generate a map from global dof index to derivative value.