22 #define protected public 26 #include "libmesh/point.h" 27 #include "libmesh/face_quad4.h" 30 #define pi 3.14159265358979323846 35 std::vector<double> vec(M.data(), M.data()+M.rows()*M.cols());
41 Real true_volume = 0.0;
42 uint n_nodes = X.cols();
43 for (uint i=0; i<n_nodes-1; i++)
45 true_volume += X(0,i)*X(1,i+1) - X(0,i+1)*X(1,i);
47 true_volume += X(0,n_nodes-1)*X(1,0) - X(0,0)*X(1,n_nodes-1);
48 true_volume = std::abs(true_volume);
58 Real delta = 3.4526698e-04;
62 int n = jacobian.cols();
67 for (uint i=0; i<elem_solution.size(); i++)
69 elem_solution(i) = initial_elem_solution(i) + delta;
74 elem_solution(i) = initial_elem_solution(i) + 2.0*delta;
79 elem_solution(i) = initial_elem_solution(i) + 3.0*delta;
84 elem_solution(i) = initial_elem_solution(i) - delta;
89 elem_solution(i) = initial_elem_solution(i) - 2.0*delta;
94 elem_solution(i) = initial_elem_solution(i) - 3.0*delta;
99 elem_solution(i) = initial_elem_solution(i);
103 jacobian.col(i) = (-residual_3n + 9.0*residual_2n - 45.0*residual_n + 45.0*residual_h - 9.0*residual_2h + residual_3h)/(60.0 * delta);
114 Real delta = 3.4526698e-04;
116 int n = jacobian.cols();
121 for (uint i=0; i<elem_solution.size(); i++)
123 elem_solution(i) = initial_elem_solution(i) + delta;
128 elem_solution(i) = initial_elem_solution(i) + 2.0*delta;
133 elem_solution(i) = initial_elem_solution(i) - delta;
138 elem_solution(i) = initial_elem_solution(i) - 2.0*delta;
143 elem_solution(i) = initial_elem_solution(i);
145 jacobian.col(i) = (residual_2n - 8.0*residual_n + 8.0*residual_h - residual_2h)/(12.0 * delta);
156 Real delta = 3.4526698e-04;
158 int n = jacobian.cols();
163 for (uint i=0; i<elem_solution.size(); i++)
165 elem_solution(i) = initial_elem_solution(i) + delta;
170 elem_solution(i) = initial_elem_solution(i) + 2.0*delta;
175 elem_solution(i) = initial_elem_solution(i) - delta;
180 elem_solution(i) = initial_elem_solution(i) - 2.0*delta;
185 elem_solution(i) = initial_elem_solution(i);
187 jacobian.col(i) = (residual_2n - 8.0*residual_n + 8.0*residual_h - residual_2h)/(12.0 * delta);
197 Real delta = 3.4526698e-04;
201 int n = jacobian.cols();
206 for (uint i=0; i<elem_accel.size(); i++)
208 elem_accel(i) = initial_elem_accel(i) + delta;
213 elem_accel(i) = initial_elem_accel(i) + 2.0*delta;
218 elem_accel(i) = initial_elem_accel(i) + 3.0*delta;
223 elem_accel(i) = initial_elem_accel(i) - delta;
228 elem_accel(i) = initial_elem_accel(i) - 2.0*delta;
233 elem_accel(i) = initial_elem_accel(i) - 3.0*delta;
238 elem_accel(i) = initial_elem_accel(i);
242 jacobian.col(i) = (-residual_3n + 9.0*residual_2n - 45.0*residual_n + 45.0*residual_h - 9.0*residual_2h + residual_3h)/(60.0 * delta);
253 Real delta = 3.4526698e-04;
257 int n = jacobian.cols();
262 for (uint i=0; i<elem_solution.size(); i++)
264 elem_solution(i) = initial_elem_solution(i) + delta;
269 elem_solution(i) = initial_elem_solution(i) + 2.0*delta;
274 elem_solution(i) = initial_elem_solution(i) + 3.0*delta;
279 elem_solution(i) = initial_elem_solution(i) - delta;
284 elem_solution(i) = initial_elem_solution(i) - 2.0*delta;
289 elem_solution(i) = initial_elem_solution(i) - 3.0*delta;
294 elem_solution(i) = initial_elem_solution(i);
298 jacobian.col(i) = (-residual_3n + 9.0*residual_2n - 45.0*residual_n + 45.0*residual_h - 9.0*residual_2h + residual_3h)/(60.0 * delta);
309 const uint n_nodes = X0.cols();
317 Vc.row(0) = X0.row(0) - X0.row(0).mean()*Vi;
318 Vc.row(1) = X0.row(1) - X0.row(1).mean()*Vi;
319 Vc.row(2) = X0.row(2) - X0.row(2).mean()*Vi;
346 Real theta = rotation_z*
pi/180.0;
347 Rz << cos(theta), -sin(theta), 0.0,
348 sin(theta), cos(theta), 0.0,
353 theta = rotation_y*
pi/180.0;
354 Ry << cos(theta), 0.0, -sin(theta),
356 sin(theta), 0.0, cos(theta);
360 theta = rotation_x*
pi/180.0;
362 0.0, cos(theta), -sin(theta),
363 0.0, sin(theta), cos(theta);
379 X.row(0) = X0.row(0).mean()*Vi + V.row(0);
380 X.row(1) = X0.row(1).mean()*Vi + V.row(1);
381 X.row(2) = X0.row(2).mean()*Vi + V.row(2);
384 X.row(0) += shift_x*RealMatrixX::Ones(1,n_nodes);
385 X.row(1) += shift_y*RealMatrixX::Ones(1,n_nodes);
386 X.row(2) += shift_z*RealMatrixX::Ones(1,n_nodes);
392 for (
int i=0; i<n_nodes; i++)
394 (*mesh.node_ptr(i)) = libMesh::Point(X(0,i), X(1,i), X(2,i));
void approximate_inertial_jacobian_with_finite_difference(MAST::StructuralElementBase &elem, const RealVectorX &initial_elem_solution, RealMatrixX &jacobian)
Approximates the inertial jacobian using a 6th order accurate central finite difference scheme...
virtual bool thermal_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, MAST::BoundaryConditionBase &bc)=0
Calculates the force vector and Jacobian due to thermal stresses.
virtual void set_acceleration(const RealVectorX &vec, bool if_sens=false)
stores vec as acceleration for element level calculations, or its sensitivity if if_sens is true...
Real get_shoelace_area(RealMatrixX X)
Calcualtes the area of a 2D polygon using the shoelace formula.
virtual bool inertial_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac_xddot, RealMatrixX &jac_xdot, RealMatrixX &jac)
inertial force contribution to system residual
void approximate_volume_external_jacobian_with_finite_difference(MAST::StructuralElementBase &elem, MAST::PhysicsDisciplineBase &discipline, const RealVectorX &initial_elem_solution, RealMatrixX &jacobian)
Approximates the volume external jacobian using a 4th order accurate central finite difference scheme...
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...
std::vector< double > eigen_matrix_to_std_vector(RealMatrixX M)
Converts an Eigen Matrix object to a std::vector.
void approximate_internal_jacobian_with_finite_difference(MAST::StructuralElementBase &elem, const RealVectorX &initial_elem_solution, RealMatrixX &jacobian)
Approximates the internal Jacobian of an element using a 6th order accurate central finite difference...
const MAST::SideBCMapType & side_loads() const
Matrix< Real, Dynamic, Dynamic > RealMatrixX
void approximate_side_external_jacobian_with_finite_difference(MAST::StructuralElementBase &elem, MAST::PhysicsDisciplineBase &discipline, const RealVectorX &initial_elem_solution, RealMatrixX &jacobian)
Approximates the side external jacobian using a 4th order accurate central finite difference scheme...
bool side_external_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac_xdot, RealMatrixX &jac, std::multimap< libMesh::boundary_id_type, MAST::BoundaryConditionBase *> &bc)
side external force contribution to system residual.
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
bool volume_external_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac_xdot, RealMatrixX &jac, std::multimap< libMesh::subdomain_id_type, MAST::BoundaryConditionBase *> &bc)
volume external force contribution to system residual.
Matrix< Real, 3, 3 > RealMatrix3
const MAST::VolumeBCMapType & volume_loads() const
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 internal_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)=0
internal force contribution to system residual