22 #include <boost/test/unit_test.hpp> 26 #include "tests/structural/build_structural_elem_1D.h" 27 #include "tests/structural/build_structural_elem_2D.h" 28 #include "tests/base/test_comparisons.h" 30 #include "elasticity/structural_discipline.h" 42 #include "libmesh/dof_map.h" 48 const unsigned int case_num,
49 const libMesh::ElemType e,
54 template <
typename ValType>
63 const libMesh::Elem& elem = **(v._mesh->local_elements_begin());
66 std::unique_ptr<MAST::StructuralElementBase>
69 *v._p_card).release());
73 const libMesh::DofMap& dofmap = v._sys->get_dof_map();
74 std::vector<unsigned int> dof_ids;
75 dofmap.dof_indices(&elem, dof_ids);
77 const unsigned int ndofs = (
unsigned int)dof_ids.size();
81 libmesh_assert_equal_to(sol.size(), ndofs);
86 x0 = RealVectorX::Zero(ndofs),
87 x = RealVectorX::Zero(ndofs),
88 x_sens = RealVectorX::Zero(ndofs),
89 res0 = RealVectorX::Zero(ndofs),
90 res = RealVectorX::Zero(ndofs);
93 jac_sens = RealMatrixX::Zero(ndofs, ndofs),
94 jac0 = RealMatrixX::Zero(ndofs, ndofs),
95 jac_sens_fd = RealMatrixX::Zero(ndofs, ndofs),
107 e->internal_residual(
true, res, jac0);
110 for (
unsigned int i=0; i<ndofs; i++) {
114 x_sens = RealVectorX::Zero(ndofs);
119 e->set_solution(x_sens,
true);
123 e->internal_residual_jac_dot_state_sensitivity(jac_sens);
126 x(i) += x_sens(i) * delta;
130 jac_sens_fd.setZero();
131 e->internal_residual(
true, res, jac_sens_fd);
135 jac_sens_fd /= delta;
138 BOOST_TEST_MESSAGE(
" ** dJac/dXi . dXi/dp for i: " << i <<
" **");
152 this->init(
false,
true);
156 check_internal_force_jacobian_sensitivity<MAST::BuildStructural1DElem>(*
this, v);
163 this->init(
false,
true);
168 (*_hy_off)() = 0.5*(*_thy)();
170 check_internal_force_jacobian_sensitivity<MAST::BuildStructural1DElem>(*
this, v);
178 this->init(
true,
true);
182 check_internal_force_jacobian_sensitivity<MAST::BuildStructural1DElem>(*
this, v);
188 BOOST_AUTO_TEST_SUITE_END()
193 MAST::BuildStructural2DElem)
198 this->init(
false,
true, libMesh::QUAD4);
202 check_internal_force_jacobian_sensitivity<MAST::BuildStructural2DElem>(*
this, v);
209 this->init(
false,
true, libMesh::QUAD4);
212 (*_hzoff)() = 0.5*(*_thz)();
216 check_internal_force_jacobian_sensitivity<MAST::BuildStructural2DElem>(*
this, v);
223 this->init(
true,
true, libMesh::QUAD4);
227 check_internal_force_jacobian_sensitivity<MAST::BuildStructural2DElem>(*
this, v);
234 this->init(
false,
true, libMesh::TRI3);
238 check_internal_force_jacobian_sensitivity<MAST::BuildStructural2DElem>(*
this, v);
245 this->init(
false,
true, libMesh::TRI3);
248 (*_hzoff)() = 0.5*(*_thz)();
252 check_internal_force_jacobian_sensitivity<MAST::BuildStructural2DElem>(*
this, v);
259 this->init(
true,
true, libMesh::TRI3);
263 check_internal_force_jacobian_sensitivity<MAST::BuildStructural2DElem>(*
this, v);
268 BOOST_AUTO_TEST_SUITE_END()
void set_deformation(const unsigned int dim, const unsigned int case_num, const libMesh::ElemType e, RealVectorX &vec)
bool compare_matrix(const RealMatrixX &m0, const RealMatrixX &m, const Real tol)
void check_internal_force_jacobian_sensitivity(ValType &v, const RealVectorX &sol)
Matrix< Real, Dynamic, Dynamic > RealMatrixX
Matrix< Real, Dynamic, 1 > RealVectorX
std::unique_ptr< MAST::StructuralElementBase > build_structural_element(MAST::SystemInitialization &sys, const MAST::GeomElem &elem, const MAST::ElementPropertyCardBase &p)
builds the structural element for the specified element type
BOOST_AUTO_TEST_CASE(InternalForceJacobianNonlinear1DWithConstantOffset)
BOOST_FIXTURE_TEST_SUITE(Structural1DJacobianDerivativeTimesStateSensEvaluation, MAST::BuildStructural1DElem) BOOST_AUTO_TEST_CASE(InternalForceJacobianNonlinear1DIndependentOffset)