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" 30 #include "tests/base/test_comparisons.h" 32 #include "elasticity/structural_discipline.h" 42 #include "libmesh/dof_map.h" 46 template <
typename ValType>
56 v._discipline->add_volume_load(0, *v._p_theory);
60 const libMesh::Elem& elem = **(v._mesh->local_elements_begin());
63 std::unique_ptr<MAST::StructuralElementBase>
66 *v._p_card).release());
70 const libMesh::DofMap& dofmap = v._sys->get_dof_map();
71 std::vector<unsigned int> dof_ids;
72 dofmap.dof_indices(&elem, dof_ids);
74 const unsigned int ndofs = (
unsigned int)dof_ids.size();
78 x0 = RealVectorX::Zero(ndofs),
79 xdot0 = RealVectorX::Zero(ndofs),
80 x = RealVectorX::Zero(ndofs),
81 xdot = RealVectorX::Zero(ndofs),
82 res0 = RealVectorX::Zero(ndofs),
83 res = RealVectorX::Zero(ndofs);
86 jac_x = RealMatrixX::Zero(ndofs, ndofs),
87 jac_xdot = RealMatrixX::Zero(ndofs, ndofs),
88 jac_x_fd = RealMatrixX::Zero(ndofs, ndofs),
89 jac_xdot_fd = RealMatrixX::Zero(ndofs, ndofs),
95 e->set_velocity(xdot);
99 e->volume_external_residual(
true,
103 v._discipline->volume_loads());
105 for (
unsigned int i=0; i<ndofs; i++) {
113 e->set_velocity(xdot);
117 e->volume_external_residual(
false,
121 v._discipline->volume_loads());
124 jac_x_fd.col(i) = (res-res0)/delta;
134 e->set_velocity(xdot);
138 e->volume_external_residual(
false,
142 v._discipline->volume_loads());
145 jac_xdot_fd.col(i) = (res-res0)/delta;
159 std::vector<MAST::Parameter*>& params) {
178 for (
unsigned int i=0; i<params.size(); i++) {
191 (fabs(v0) > 0)? dv=delta*v0 : dv=delta;
203 BOOST_TEST_MESSAGE(
" ** dfunc/dp (total) wrt : " << f.
name() <<
" **");
214 this->init(
false,
false);
218 std::unique_ptr<MAST::FieldFunction<Real> >
219 pressure (_p_theory->get_pressure_function(*_dwdx_f, *_dwdt_f).release()),
220 dpressure_dx (_p_theory->get_dpdx_function (*_dwdx_f, *_dwdt_f).release()),
221 dpressure_dxdot(_p_theory->get_dpdxdot_function (*_dwdx_f, *_dwdt_f).release());
235 pressure->derivative(*_dwdx, pt, 0., dpdx1);
236 pressure->derivative(*_dwdt, pt, 0., dpdxdot1);
239 (*dpressure_dx) (pt, 0., dpdx2);
240 (*dpressure_dxdot)(pt, 0., dpdxdot2);
242 BOOST_TEST_MESSAGE(
" ***** dpress/dx (total) **");
245 BOOST_TEST_MESSAGE(
" ***** dpress/dxdot (total) **");
250 std::vector<MAST::Parameter*> params(4);
251 params[0] = _velocity;
253 params[2] = _rho_air;
254 params[3] = _gamma_air;
257 BOOST_TEST_MESSAGE(
" ***** dpress_dx/dp (total) **");
260 BOOST_TEST_MESSAGE(
" ***** dpress_dxdot/dp (total) **");
265 params.push_back(_dwdx);
266 params.push_back(_dwdt);
268 BOOST_TEST_MESSAGE(
" ***** dpress/dp (total) **");
277 this->init(
false,
false);
278 check_piston_theory_jacobian<MAST::BuildStructural1DElem>(*this);
282 BOOST_AUTO_TEST_SUITE_END()
290 this->init(
false,
false, libMesh::QUAD4);
291 check_piston_theory_jacobian<MAST::BuildStructural2DElem>(*this);
297 this->init(
false,
false, libMesh::TRI3);
298 check_piston_theory_jacobian<MAST::BuildStructural2DElem>(*this);
302 BOOST_AUTO_TEST_SUITE_END()
const std::string & name() const
returns the name of this function
This is a scalar function whose value can be changed and one that can be used as a design variable in...
BOOST_FIXTURE_TEST_SUITE(PanelSmallDisturbanceFrequencyDomain2D, MAST::PanelInviscidSmallDisturbanceFrequencyDomain2DAnalysis) BOOST_AUTO_TEST_CASE(FreqDomainSensitivityWrtOmega)
bool compare_matrix(const RealMatrixX &m0, const RealMatrixX &m, const Real tol)
virtual void derivative(const MAST::FunctionBase &f, ValType &v) const
calculates the value of the function derivative and returns it in v.
void check_piston_theory_jacobian(ValType &v)
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
bool compare_value(const Real v0, const Real v, const Real tol)
BOOST_AUTO_TEST_CASE(PistonTheoryPressure)
void check_value_sensitivity(MAST::FieldFunction< Real > &func, std::vector< MAST::Parameter *> ¶ms)