20 #ifndef __mast_optimization_topology_simp_libmesh_residual_and_jacobian_h__ 21 #define __mast_optimization_topology_simp_libmesh_residual_and_jacobian_h__ 31 #include <libmesh/nonlinear_implicit_system.h> 32 #include <libmesh/dof_map.h> 35 namespace Optimization {
38 namespace libMeshWrapper {
40 template <
typename ScalarType,
47 "Scalar type of assembly and element operations must be same");
60 template <
typename Vec1Type,
66 const Vec2Type &density,
70 Assert0( R || J,
"Atleast one assembled quantity should be specified.");
78 sol_accessor (*c.sys, X),
79 density_accessor (*c.rho_sys, density);
81 using elem_vector_t =
typename ElemOpsType::vector_t;
82 using elem_matrix_t =
typename ElemOpsType::matrix_t;
84 elem_vector_t res_e, density_e;
88 libMesh::MeshBase::const_element_iterator
89 el = c.mesh->active_local_elements_begin(),
90 end_el = c.mesh->active_local_elements_end();
92 for ( ; el != end_el; ++el) {
97 sol_accessor.init(*c.elem);
98 density_accessor.
init(*c.elem);
100 res_e.setZero(sol_accessor.n_dofs());
101 if (J) jac_e.setZero(sol_accessor.n_dofs(), sol_accessor.n_dofs());
114 <ScalarType, Vec1Type, MatType, elem_vector_t, elem_matrix_t>
115 (*R, *J, c.sys->get_dof_map(), sol_accessor.dof_indices(), res_e, jac_e);
118 <ScalarType, Vec1Type, elem_vector_t>
119 (*R, c.sys->get_dof_map(), sol_accessor.dof_indices(), res_e);
122 <ScalarType, MatType, elem_matrix_t>
123 (*J, c.sys->get_dof_map(), sol_accessor.dof_indices(), jac_e);
143 #endif // __mast_optimization_topology_simp_libmesh_residual_and_jacobian_h__
void init(const libMesh::Elem &e)
void set_elem_ops(ElemOpsType &e_ops)
virtual ~ResidualAndJacobian()
void finalize(ValType &m)
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)
#define Assert0(cond, msg)
void set_finalize_jac(bool f)
void assemble(ContextType &c, const Vec1Type &X, const Vec2Type &density, Vec1Type *R, MatType *J)
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)