20 #include "libmesh/system.h" 21 #include "libmesh/dof_map.h" 26 std::unordered_map<dof_id_type, Real>
32 mooseAssert(dynamic_cast<const NonlinearSystemBase *>(&sys),
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];
const Elem *const & elem() const
Return the current element.
Keeps track of stuff related to assembling.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
virtual unsigned int currentNlSysNum() const =0
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
Base class for a system (of equations)
DualNumber< Real, DNDerivativeType, true > ADReal
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)
SubProblem & subproblem()
unsigned int number() const
Gets the number of this system.
std::size_t getMaxVarNDofsPerElem() const
Gets the maximum number of dofs used by any one variable on any one element.
Generic class for solving transient nonlinear problems.
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
const Elem *const & neighbor() const
Return the neighbor element.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
const Elem *const & lowerDElem() const
Return the lower dimensional element.
const DofMap & get_dof_map() const
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.