20 #ifndef __mast_libmesh_residual_sensitivity_h__ 21 #define __mast_libmesh_residual_sensitivity_h__ 31 #include <libmesh/nonlinear_implicit_system.h> 32 #include <libmesh/dof_map.h> 38 namespace libMeshWrapper {
40 template <
typename ScalarType,
47 "Scalar type of assembly and element operations must be same");
57 template <
typename VecType,
typename MatType,
typename ContextType,
typename ScalarFieldType>
59 const ScalarFieldType& f,
64 Assert0( R || J,
"Atleast one assembled quantity should be specified.");
72 sol_accessor(*c.sys, X);
74 using elem_vector_t =
typename ElemOpsType::vector_t;
75 using elem_matrix_t =
typename ElemOpsType::matrix_t;
81 libMesh::MeshBase::const_element_iterator
82 el = c.mesh->active_local_elements_begin(),
83 end_el = c.mesh->active_local_elements_end();
85 for ( ; el != end_el; ++el) {
90 sol_accessor.
init(*c.elem);
92 res_e.setZero(sol_accessor.
n_dofs());
93 if (J) jac_e.setZero(sol_accessor.
n_dofs(), sol_accessor.
n_dofs());
96 _e_ops->derivative(c, f, sol_accessor, res_e, J?&jac_e:
nullptr);
102 <ScalarType, VecType, MatType, elem_vector_t, elem_matrix_t>
103 (*R, *J, c.sys->get_dof_map(), sol_accessor.
dof_indices(), res_e, jac_e);
106 <ScalarType, VecType, elem_vector_t>
107 (*R, c.sys->get_dof_map(), sol_accessor.
dof_indices(), res_e);
110 <ScalarType, MatType, elem_matrix_t>
111 (*J, c.sys->get_dof_map(), sol_accessor.
dof_indices(), jac_e);
130 #endif // __mast_libmesh_residual_sensitivity_h__
void init(const libMesh::Elem &e)
void assemble(ContextType &c, const ScalarFieldType &f, const VecType &X, VecType *R, MatType *J)
void finalize(ValType &m)
const std::vector< libMesh::dof_id_type > & dof_indices() const
std::enable_if< Dim< 3, ScalarType >::typesource_load_multiplier(const SourceLoadFieldType *f, const SectionAreaType *s, ContextType &c) { Assert0(f, "Invalid pointer");Assert0(s, "Invalid pointer");return f-> value(c) *s -> value(c)
std::enable_if< std::is_same< ScalarType, real_t >::value, void >::type constrain_and_add_matrix_and_vector(VecType &v, MatType &m, const libMesh::DofMap &dof_map, std::vector< libMesh::dof_id_type > &dof_indices, SubVecType &v_sub, SubMatType &m_sub)
std::enable_if< std::is_same< ScalarType, real_t >::value, void >::type constrain_and_add_vector(VecType &v, const libMesh::DofMap &dof_map, std::vector< libMesh::dof_id_type > &dof_indices, SubVecType &v_sub)
virtual ~ResidualSensitivity()
void set_elem_ops(ElemOpsType &e_ops)
#define Assert0(cond, msg)
std::enable_if< std::is_same< ScalarType, real_t >::value, void >::type constrain_and_add_matrix(MatType &m, const libMesh::DofMap &dof_map, std::vector< libMesh::dof_id_type > &dof_indices, SubMatType &m_sub)