22 #define protected public 25 #include "libmesh/libmesh.h" 26 #include "libmesh/elem.h" 27 #include "libmesh/dof_map.h" 50 TEST_CASE(
"edge2_linear_structural_thermal_jacobian",
51 "[1D],[thermoelastic],[edge],[edge2],[linear],[protected]")
54 coords << -1.0, 1.0, 0.0,
66 temperature_load.
add(temperature_f);
67 temperature_load.
add(ref_temperature_f);
75 double val_margin = (test_elem.
jacobian0.array().abs()).mean() * 1.490116119384766e-08;
77 libMesh::out <<
"R=\n" << test_elem.
residual << std::endl;
78 libMesh::out <<
"J =\n" << test_elem.
jacobian0 << std::endl;
80 SECTION(
"thermal_jacobian_is_zero_matrix")
88 REQUIRE_THAT( test, Catch::Approx<double>(truth).margin(0.0) );
92 SECTION(
"Thermoelastic Jacobian finite difference check")
105 SECTION(
"Thermoelastic Jacobian should be symmetric")
112 SECTION(
"Determinant of undeformed thermoelastic Jacobian should be zero")
114 REQUIRE(test_elem.
jacobian0.determinant() == Approx(0.0).margin(1e-06));
118 SECTION(
"Thermoelastic Jacobian eigenvalue check")
124 SelfAdjointEigenSolver<RealMatrixX> eigensolver(test_elem.
jacobian0,
false);
125 RealVectorX eigenvalues = eigensolver.eigenvalues();
126 libMesh::out <<
"Eigenvalues are:\n" << eigenvalues << std::endl;
128 for (uint i=0; i<eigenvalues.size(); i++)
130 if (std::abs(eigenvalues(i))<0.0001220703125)
139 SECTION(
"Thermoelastic Jacobian is invariant to section orientation")
143 orientation(2) = 1.0;
153 SECTION(
"Thermoelastic Jacobian is invariant to displacement solution")
156 elem_sol << 0.05727841, 0.08896581, 0.09541619, -0.03774913,
157 0.07510557, -0.07122266, -0.00979117, -0.08300009,
158 -0.03453369, -0.05487761, -0.01407677, -0.09268421;
168 SECTION(
"Thermoelastic Jacobian is invariant to element x-location")
171 1.0, 1.0, 0.0, 0.0, 0.0);
180 SECTION(
"Thermoelastic Jacobian is invariant to element y-location")
183 1.0, 1.0, 0.0, 0.0, 0.0);
192 SECTION(
"Thermoelastic Jacobian is invariant to element z-location")
195 1.0, 1.0, 0.0, 0.0, 0.0);
204 SECTION(
"Thermoelastic Jacobian checks for element aligned along y-axis")
212 new_coordinates << 0.0, 0.0, -1.0, 1.0, 0.0, 0.0;
228 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
231 SECTION(
"Thermoelastic Jacobian checks for element aligned along z-axis")
239 new_coordinates << 0.0, 0.0, 0.0, 0.0, -1.0, 1.0;
255 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
257 SECTION(
"Thermoelastic Jacobian checks for element rotated about z-axis")
261 1.0, 1.0, 0.0, 0.0, 63.4);
276 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
280 SECTION(
"Thermoelastic Jacobian checks for element rotated about y-axis")
284 1.0, 1.0, 0.0, 35.8, 0.0);
299 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
301 SECTION(
"Thermoelastic Jacobian checks for element stretched in x-direction")
304 3.2, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0);
319 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
323 SECTION(
"Thermoelastic Jacobian checks for element arbitrarily scaled, stretched, and rotated")
327 2.7, 6.4, 20.0, 47.8, -70.1);
342 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
346 SECTION(
"Thermoelastic Jacobian checks for element arbitrarily scaled, stretched, rotated, and displaced")
350 4.2, 1.5, -18.0, -24.8, 30.1);
354 elem_sol << 0.08158724, 0.07991906, -0.00719128, 0.02025461,
355 -0.04602193, 0.05280159, 0.03700081, 0.04636344,
356 0.05559377, 0.06448206, 0.08919238, -0.03079122;
373 REQUIRE(test_elem.
jacobian.determinant() == Approx(0.0).margin(1e-06));
RealMatrixX jacobian
Matrix storage for Jacobian of the element in a perturbed/modified state.
void add_volume_load(libMesh::subdomain_id_type bid, MAST::BoundaryConditionBase &load)
adds the specified volume loads for the elements with subdomain tag s_id
virtual void init()
Only used by 1D sections.
libMesh::LibMeshInit * p_global_init
RealVectorX elem_solution
libMesh::Elem * reference_elem
Pointer to the actual libMesh element object.
MAST::PhysicsDisciplineBase discipline
RealVectorX & y_vector()
returns value of the property val.
MAST::StructuralElement1D * elem
MAST::Solid1DSectionElementPropertyCard section
This is a scalar function whose value can be changed and one that can be used as a design variable in...
int n_nodes
Number of nodes per element in the test mesh.
void transform_element(libMesh::MeshBase &mesh, const RealMatrixX X0, Real shift_x, Real shift_y, Real shift_z, Real scale_x, Real scale_y, Real rotation_x, Real rotation_y, Real rotation_z, Real shear_x=0, Real shear_y=0)
Transform an element by applying any combination of: shifts, scales, rotations, and shears...
void add(MAST::FunctionBase &f)
adds the function to this card and returns a reference to it.
std::vector< double > eigen_matrix_to_std_vector(RealMatrixX M)
Converts an Eigen Matrix object to a std::vector.
RealMatrixX jacobian0
Matrix storage for Jacobian of baseline/undeformed element.
Matrix< Real, Dynamic, Dynamic > RealMatrixX
RealMatrixX jacobian_fd
Matrix storage for element Jacobian approximated by finite difference.
TEST_CASE("edge2_linear_structural_thermal_jacobian", "[1D],[thermoelastic],[edge],[edge2],[linear],[protected]")
RealVectorX residual
Vector storage for element's residual vector.
virtual void set_solution(const RealVectorX &vec, bool if_sens=false)
stores vec as solution for element level calculations, or its sensitivity if if_sens is true...
Matrix< Real, Dynamic, 1 > RealVectorX
void approximate_thermal_jacobian_with_finite_difference(MAST::StructuralElementBase &elem, const RealVectorX &initial_elem_solution, RealMatrixX &jacobian, MAST::BoundaryConditionBase &thermal_bc)
Approximates the thermal jacobian using a 6th order accurate central finite difference scheme...
virtual bool thermal_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, MAST::BoundaryConditionBase &bc)
Calculates the force vector and Jacobian due to thermal stresses.
void update_coordinates(RealMatrixX &new_coordinates)
Update the nodal coordinates in the mesh.
libMesh::ReplicatedMesh mesh
The actual libMesh mesh object.