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 res0 = RealVectorX::Zero(ndofs),
89 res = RealVectorX::Zero(ndofs);
92 jac_x = RealMatrixX::Zero(ndofs, ndofs),
93 jac_x_fd = RealMatrixX::Zero(ndofs, ndofs),
106 e->internal_residual(
true, res0, jac_x);
109 for (
unsigned int i=0; i<ndofs; i++) {
120 e->internal_residual(
false, res, dummy);
123 jac_x_fd.col(i) = (res-res0)/delta;
136 this->init(
false,
false);
140 check_internal_force_jacobian<MAST::BuildStructural1DElem>(*
this, v);
146 this->init(
false,
true);
150 check_internal_force_jacobian<MAST::BuildStructural1DElem>(*
this, v);
156 this->init(
false,
false);
161 (*_hy_off)() = 0.5*(*_thy)();
163 check_internal_force_jacobian<MAST::BuildStructural1DElem>(*
this, v);
169 this->init(
false,
true);
174 (*_hy_off)() = 0.5*(*_thy)();
176 check_internal_force_jacobian<MAST::BuildStructural1DElem>(*
this, v);
183 this->init(
true,
false);
187 check_internal_force_jacobian<MAST::BuildStructural1DElem>(*
this, v);
194 this->init(
true,
true);
198 check_internal_force_jacobian<MAST::BuildStructural1DElem>(*
this, v);
204 BOOST_AUTO_TEST_SUITE_END()
209 MAST::BuildStructural2DElem)
213 this->init(
false,
false, libMesh::QUAD4);
217 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
223 this->init(
false,
true, libMesh::QUAD4);
227 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
233 this->init(
false,
false, libMesh::QUAD4);
236 (*_hzoff)() = 0.5*(*_thz)();
240 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
246 this->init(
false,
true, libMesh::QUAD4);
249 (*_hzoff)() = 0.5*(*_thz)();
253 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
259 this->init(
true,
false, libMesh::QUAD4);
263 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
269 this->init(
true,
true, libMesh::QUAD4);
273 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
280 this->init(
false,
false, libMesh::TRI3);
284 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
290 this->init(
false,
true, libMesh::TRI3);
294 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
300 this->init(
false,
false, libMesh::TRI3);
303 (*_hzoff)() = 0.5*(*_thz)();
307 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
313 this->init(
false,
true, libMesh::TRI3);
316 (*_hzoff)() = 0.5*(*_thz)();
320 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
326 this->init(
true,
false, libMesh::TRI3);
330 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
336 this->init(
true,
true, libMesh::TRI3);
340 check_internal_force_jacobian<MAST::BuildStructural2DElem>(*
this, v);
345 BOOST_AUTO_TEST_SUITE_END()
void check_internal_force_jacobian(ValType &v, const RealVectorX &sol)
bool compare_matrix(const RealMatrixX &m0, const RealMatrixX &m, const Real tol)
BOOST_FIXTURE_TEST_SUITE(Structural2DJacobianEvaluation, MAST::BuildStructural2DElem) BOOST_AUTO_TEST_CASE(InternalForceJacobianLinear2DIndependentOffsetQUAD4)
void set_deformation(const unsigned int dim, const unsigned int case_num, const libMesh::ElemType e, RealVectorX &vec)
BOOST_AUTO_TEST_CASE(InternalForceJacobianLinear1DIndependentOffset)
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